diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 9e06b327f09..732bd06952d 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -249,15 +249,15 @@ if ($mode == 'config' && $user->admin) print ''.$langs->trans($connector).''; print ''.$printer->listprinters[$line]['parameter'].''; // edit icon - print ''; + print ''; print img_picto($langs->trans("Edit"),'edit'); print ''; // delete icon - print ''; + print ''; print img_picto($langs->trans("Delete"),'delete'); print ''; // test icon - print ''; + print ''; print img_picto($langs->trans("TestPrinter"),'printer'); print ''; print ''; @@ -368,9 +368,13 @@ if ($mode == 'template' && $user->admin) 'dol_print_if_customer_account_balance_positive', ); - print '
'; + print ''; print ''; - print ''; + if ($action!='edittemplate') { + print ''; + } else { + print ''; + } dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic'); @@ -378,11 +382,56 @@ if ($mode == 'template' && $user->admin) print ''."\n"; $var=true; print ''; + print ''; print ''; print ''; + print ''; + print ''; print "\n"; + $ret = $printer->listPrintersTemplates(); + //print '
'.print_r($printer->listprinterstemplates, true).'
'; + if ($ret > 0) { + setEventMessages($printer->error, $printer->errors, 'errors'); + } else { + for ($line=0; $line < count($printer->listprinterstemplates); $line++) { + $var = !$var; + print ''; + if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) { + print ''; + print ''; + // TODO doleditor + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + // edit icon + print ''; + // delete icon + print ''; + // test icon + print ''; + } + print ''; + } + } + print '
'.$langs->trans("Name").''.$langs->trans("Template").'
'.$printer->listprinterstemplates[$line]['name'].''.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).''; + print img_picto($langs->trans("Edit"),'edit'); + print ''; + print img_picto($langs->trans("Delete"),'delete'); + print ''; + print img_picto($langs->trans("TestPrinterTemplate"),'printer'); + print '
'; + if ($action!='edittemplate') { + print '
'; + } else { + print '
'; + } print '
'; + print '

'; print ''."\n"; $var=true; print ''; @@ -396,6 +445,7 @@ if ($mode == 'template' && $user->admin) print ''; } print '
'; + dol_fiche_end(); } diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 3de7be512af..57f8691f6e7 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -122,7 +122,7 @@ class dolReceiptPrinter extends Escpos } /** - * Constructor + * list printers * * @return int 0 if OK; >0 if KO */ @@ -150,6 +150,35 @@ class dolReceiptPrinter extends Escpos } + /** + * List printers templates + * + * @return int 0 if OK; >0 if KO + */ + function listPrintersTemplates() + { + global $conf; + $error = 0; + $line = 0; + $sql = 'SELECT rowid, name, template'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql.= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $obj[] = $this->db->fetch_array($resql); + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinterstemplates = $obj; + return $error; + } + + /** * Form to Select type printer * @@ -243,7 +272,7 @@ class dolReceiptPrinter extends Escpos } /** - * Function to Send Test äge to Printer + * Function to Send Test page to Printer * * @param int $printerid Printer id * @return int 0 if OK; >0 if KO @@ -308,4 +337,25 @@ class dolReceiptPrinter extends Escpos return $error; } + /** + * Function to Print Receipt Ticket + * + * @param object $object order or invoice object + * @param int $template Template id + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + function SendToPrinter($object, $template, $printerid) + { + global $conf; + $error = 0; + + // parse template + + + // print ticket + + return $error; + } + }