forked from Wavyzz/dolibarr
Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -173,6 +173,25 @@ if ($action == 'testprinter' && $user->admin) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == 'testprinter2' && $user->admin) {
|
||||
$error = 0;
|
||||
if (empty($printerid)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// test
|
||||
$ret = $printer->sendTestToPrinter($printerid, 1);
|
||||
if ($ret == 0) {
|
||||
setEventMessages($langs->trans("TestSentToPrinter", $printername), null);
|
||||
} else {
|
||||
setEventMessages($printer->error, $printer->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == 'testtemplate' && $user->admin) {
|
||||
$error = 0;
|
||||
// if (empty($printerid)) {
|
||||
@@ -299,8 +318,11 @@ if ($mode == 'config' && $user->admin) {
|
||||
|
||||
print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("ReceiptPrinterDesc")."</span><br><br>\n";
|
||||
//print info_admin($langs->trans("ThisFeatureIsForESCPOSPrintersOnly"));
|
||||
|
||||
print load_fiche_titre($langs->trans("ReceiptPrinterDesc"), '', '')."\n";
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Name").'</th>';
|
||||
@@ -360,23 +382,30 @@ if ($mode == 'config' && $user->admin) {
|
||||
print '<td>'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'</td>';
|
||||
print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
|
||||
// edit icon
|
||||
print '<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=editprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'">';
|
||||
print img_picto($langs->trans("Edit"), 'edit');
|
||||
print '<td class="center">';
|
||||
print '<a class="editfielda marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=editprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'">';
|
||||
print img_picto($langs->trans("Edit"), 'edit', 'class="paddingright"');
|
||||
print '</a>';
|
||||
// delete icon
|
||||
print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=deleteprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">';
|
||||
print img_picto($langs->trans("Delete"), 'delete');
|
||||
print img_picto($langs->trans("Delete"), 'delete', 'class="paddingright"');
|
||||
print '</a>';
|
||||
// test icon
|
||||
print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">';
|
||||
print img_picto($langs->trans("TestPrinter"), 'printer');
|
||||
print '</a></td>';
|
||||
print img_picto($langs->trans("TestPrinterDesc"), 'printer', 'class="paddingright paddingleft"').'TXT';
|
||||
print '</a>';
|
||||
// test icon
|
||||
print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter2&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">';
|
||||
print img_picto($langs->trans("TestPrinterDesc2"), 'printer', 'class="paddingright paddingleft"').'IMG';
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
@@ -385,15 +414,17 @@ if ($mode == 'config' && $user->admin) {
|
||||
print '<br>';
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("ReceiptPrinterTypeDesc"), '', '')."\n";
|
||||
print '<span class="opacitymedium">'.$langs->trans("ReceiptPrinterTypeDesc").'...</span><br><br>'."\n";
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_DUMMY").':</td><td>'.$langs->trans("CONNECTOR_DUMMY_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT").':</td><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_FILE_PRINT").':</td><td>'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_CUPS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_DUMMY").'</td><td>'.$langs->trans("CONNECTOR_DUMMY_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("CONNECTOR_NETWORK_PRINT"), $langs->trans("FromServerPointOfView")).'</td><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("CONNECTOR_FILE_PRINT"), $langs->trans("FromServerPointOfView")).'</td><td>'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("CONNECTOR_WINDOWS_PRINT"), $langs->trans("FromServerPointOfView")).'</td><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("CONNECTOR_CUPS_PRINT"), $langs->trans("FromServerPointOfView")).'</td><td>'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'</td></tr>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
@@ -402,6 +433,10 @@ if ($mode == 'config' && $user->admin) {
|
||||
if ($mode == 'template' && $user->admin) {
|
||||
print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
|
||||
|
||||
//print info_admin($langs->trans("ThisFeatureIsForESCPOSPrintersOnly"));
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
if ($action != 'edittemplate') {
|
||||
@@ -410,6 +445,7 @@ if ($mode == 'template' && $user->admin) {
|
||||
print '<input type="hidden" name="action" value="updatetemplate">';
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Name").'</th>';
|
||||
@@ -468,6 +504,7 @@ if ($mode == 'template' && $user->admin) {
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
@@ -475,6 +512,7 @@ if ($mode == 'template' && $user->admin) {
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Tag").'</th>';
|
||||
@@ -488,6 +526,7 @@ if ($mode == 'template' && $user->admin) {
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@@ -569,13 +569,12 @@ class dolReceiptPrinter extends Printer
|
||||
/**
|
||||
* Function to Send Test page to Printer
|
||||
*
|
||||
* @param int $printerid Printer id
|
||||
* @return int 0 if OK; >0 if KO
|
||||
* @param int $printerid Printer id
|
||||
* @param int $addimgandbarcode Add image and barcode into the test
|
||||
* @return int 0 if OK; >0 if KO
|
||||
*/
|
||||
public function sendTestToPrinter($printerid)
|
||||
public function sendTestToPrinter($printerid, $addimgandbarcode = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error = 0;
|
||||
$img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png');
|
||||
//$this->profile = CapabilityProfile::load("TM-T88IV");
|
||||
@@ -584,11 +583,16 @@ class dolReceiptPrinter extends Printer
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
} else {
|
||||
try {
|
||||
$this->printer->bitImage($img);
|
||||
if ($addimgandbarcode) {
|
||||
$this->printer->bitImage($img);
|
||||
}
|
||||
$this->printer->text("Hello World!\n");
|
||||
$testStr = "1234567890";
|
||||
$this->printer->barcode($testStr);
|
||||
//$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1);
|
||||
if ($addimgandbarcode) {
|
||||
$testStr = "1234567890";
|
||||
$this->printer->barcode($testStr);
|
||||
//$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1);
|
||||
}
|
||||
$this->printer->text("\n");
|
||||
$this->printer->text("Most simple example\n");
|
||||
$this->printer->feed();
|
||||
$this->printer->cut();
|
||||
@@ -598,6 +602,7 @@ class dolReceiptPrinter extends Printer
|
||||
$data = $this->printer->connector->getData();
|
||||
dol_syslog($data);
|
||||
}
|
||||
// Close and print
|
||||
$this->printer->close();
|
||||
} catch (Exception $e) {
|
||||
$this->errors[] = $e->getMessage();
|
||||
|
||||
@@ -155,3 +155,5 @@ LineDiscount=Line discount
|
||||
LineDiscountShort=Line disc.
|
||||
InvoiceDiscount=Invoice discount
|
||||
InvoiceDiscountShort=Invoice disc.
|
||||
TestPrinterDesc=The server will send a simple test page to a ESC/POS printer
|
||||
TestPrinterDesc2=The server will send an enhanced test page with image and barcode to a ESC/POS printer
|
||||
@@ -9,6 +9,8 @@ ReceiptPrinterDesc=Réglage des imprimantes de tickets
|
||||
ReceiptPrinterTemplateDesc=Réglage des modèles
|
||||
ReceiptPrinterTypeDesc=Exemple de valeurs possibles pour le champ "Paramètres" selon le type de driver
|
||||
ReceiptPrinterProfileDesc=Description des imprimantes de tickets
|
||||
ThisFeatureIsForESCPOSPrintersOnly=This feature is for ESC/POS printers only
|
||||
FromServerPointOfView=From the web server point of view. This method must be reachable from the web server hosting.
|
||||
ListPrinters=Liste des imprimantes
|
||||
SetupReceiptTemplate=Réglage des modèles
|
||||
CONNECTOR_DUMMY=Imprimante Test
|
||||
|
||||
Reference in New Issue
Block a user