';
- if ($line->fk_product) {
- $order_receipt_printer1 .= $line->product_label;
+
+ $invoice->fetch($placeid);
+ }
+
+ if ($action == "order" and $placeid != 0) {
+ include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
+ $printer = new dolReceiptPrinter($db);
+ }
+
+ $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
+ $resql = $db->query($sql);
+ $row = $db->fetch_object($resql);
+ $headerorder = ' '.$langs->trans('Place').' '.$row->label.'
| '.$langs->trans("Label").' | '.$langs->trans("Qty").' | ';
+ $footerorder = ' '.dol_print_date(dol_now(), 'dayhour').' ';
+ $order_receipt_printer1 = "";
+ $order_receipt_printer2 = "";
+ $order_receipt_printer3 = "";
+ $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
+ $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
+ $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
+ $linestoprint = 0;
+ foreach ($invoice->lines as $line) {
+ if ($line->special_code == "4") {
+ continue;
+ }
+ $c = new Categorie($db);
+ $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
+ $result = array_intersect($catsprinter1, $existing);
+ $count = count($result);
+ if (!$line->fk_product) {
+ $count++; // Print Free-text item (Unassigned printer) to Printer 1
+ }
+ if ($count > 0) {
+ $linestoprint++;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1
+ $db->query($sql);
+ $order_receipt_printer1 .= '| ';
+ if ($line->fk_product) {
+ $order_receipt_printer1 .= $line->product_label;
+ } else {
+ $order_receipt_printer1 .= $line->description;
+ }
+ $order_receipt_printer1 .= ' | '.$line->qty;
+ if (!empty($line->array_options['options_order_notes'])) {
+ $order_receipt_printer1 .= " (".$line->array_options['options_order_notes'].")";
+ }
+ $order_receipt_printer1 .= ' | ';
+ }
+ }
+ if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
+ $invoice->fetch($placeid); //Reload object before send to printer
+ $printer->orderprinter = 1;
+ echo "";
+ }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed
+ $db->query($sql);
+ $invoice->fetch($placeid); //Reload object after set lines as printed
+ $linestoprint = 0;
+
+ foreach ($invoice->lines as $line) {
+ if ($line->special_code == "4") {
+ continue;
+ }
+ $c = new Categorie($db);
+ $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
+ $result = array_intersect($catsprinter2, $existing);
+ $count = count($result);
+ if ($count > 0) {
+ $linestoprint++;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2
+ $db->query($sql);
+ $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty;
+ if (!empty($line->array_options['options_order_notes'])) {
+ $order_receipt_printer2 .= " (".$line->array_options['options_order_notes'].")";
+ }
+ $order_receipt_printer2 .= ' | ';
+ }
+ }
+ if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
+ $invoice->fetch($placeid); //Reload object before send to printer
+ $printer->orderprinter = 2;
+ echo "";
+ }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed
+ $db->query($sql);
+ $invoice->fetch($placeid); //Reload object after set lines as printed
+ $linestoprint = 0;
+
+ foreach ($invoice->lines as $line) {
+ if ($line->special_code == "4") {
+ continue;
+ }
+ $c = new Categorie($db);
+ $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
+ $result = array_intersect($catsprinter3, $existing);
+ $count = count($result);
+ if ($count > 0) {
+ $linestoprint++;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3
+ $db->query($sql);
+ $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty;
+ if (!empty($line->array_options['options_order_notes'])) {
+ $order_receipt_printer3 .= " (".$line->array_options['options_order_notes'].")";
+ }
+ $order_receipt_printer3 .= ' | ';
+ }
+ }
+ if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
+ $invoice->fetch($placeid); //Reload object before send to printer
+ $printer->orderprinter = 3;
+ echo "";
+ }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed
+ $db->query($sql);
+ $invoice->fetch($placeid); //Reload object after set lines as printed
+ }
+
+ $sectionwithinvoicelink = '';
+ if ($action == "valid" || $action == "history" || $action == 'creditnote') {
+ $sectionwithinvoicelink .= ''."\n";
+ $sectionwithinvoicelink .= '';
+ $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
+ $remaintopay = $invoice->getRemainToPay();
+ if ($remaintopay > 0) {
+ $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'';
+ } else {
+ if ($invoice->paye) {
+ $sectionwithinvoicelink .= ''.$langs->trans("Paid").'';
} else {
- $order_receipt_printer1 .= $line->description;
+ $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated');
}
- $order_receipt_printer1 .= ' | '.$line->qty;
- if (!empty($line->array_options['options_order_notes'])) {
- $order_receipt_printer1 .= " (".$line->array_options['options_order_notes'].")";
+ }
+ $sectionwithinvoicelink .= ' ';
+ if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
+ if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
+ $sectionwithinvoicelink .= ' ';
+ } else {
+ $sectionwithinvoicelink .= ' ';
}
- $order_receipt_printer1 .= ' |
';
- }
- }
- if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
- $invoice->fetch($placeid); //Reload object before send to printer
- $printer->orderprinter = 1;
- echo "";
- }
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed
- $db->query($sql);
- $invoice->fetch($placeid); //Reload object after set lines as printed
- $linestoprint = 0;
-
- foreach ($invoice->lines as $line) {
- if ($line->special_code == "4") {
- continue;
- }
- $c = new Categorie($db);
- $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
- $result = array_intersect($catsprinter2, $existing);
- $count = count($result);
- if ($count > 0) {
- $linestoprint++;
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2
- $db->query($sql);
- $order_receipt_printer2 .= '