dolibarr 24.0.0-beta
dolreceiptprinter.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
3 * Copyright (C) 2020 Andreu Bisquerra <jove@bisquerra.com>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Abbes Bahfir <bafbes@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
27/*
28 * Tags for ticket template
29 *
30 * {dol_align_left} Left align text
31 * {dol_align_center} Center text
32 * {dol_align_right} Right align text
33 * {dol_use_font_a} Use font A of printer
34 * {dol_use_font_b} Use font B of printer
35 * {dol_use_font_c} Use font C of printer
36 * {dol_bold} Text Bold
37 * {dol_bold_disabled} Disable Text Bold
38 * {dol_double_height} Text double height
39 * {dol_double_width} Text double width
40 * {dol_default_height_width} Text default height and width
41 * {dol_underline} Underline text
42 * {dol_underline_disabled} Disable underline text
43 * {dol_cut_paper_full} Cut ticket completely
44 * {dol_cut_paper_partial} Cut ticket partially
45 * {dol_open_drawer} Open cash drawer
46 * {dol_beep} Activate buzzer
47 * {dol_beep_alternative} Activate buzzer (alternative mode)
48 * {dol_print_barcode} Print barcode
49 * {dol_print_logo} Print logo stored on printer. Example : <print_logo>32|32
50 * {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers.
51 * {dol_print_logo_old_cf} Print logo stored on printer. Must be followed by logo code. For old printers. May help for centering image.
52 * {dol_print_object_lines} Print object lines
53 * {dol_print_object_tax} Print object total tax
54 * {dol_print_object_local_tax} Print object local tax
55 * {dol_print_object_total} Print object total
56 * {dol_print_order_lines} Print order lines for Printer
57 * {dol_print_object_lines_with_notes} Print object lines with notes
58 * {dol_print_payment} Print payment method
59 * {dol_print_curr_date} Print the current date/time. Must be followed by format string.
60 *
61 * Code which can be placed everywhere
62 * <dol_value_date> Replaced by date AAAA-MM-DD
63 * <dol_value_date_time> Replaced by date and time AAAA-MM-DD HH:MM:SS
64 * <dol_value_year> Replaced by Year
65 * <dol_value_month_letters> Replaced by month in letters (example : november)
66 * <dol_value_month> Replaced by month number
67 * <dol_value_day> Replaced by day number
68 * <dol_value_day_letters> Replaced by day number
69 * <dol_value_currentdate> Replaced by current date and time
70 * <dol_value_currentdate_notime> Replaced by current date without time
71 * <dol_object_id> Replaced by object id
72 * <dol_object_ref> Replaced by object ref
73 * <dol_value_customer_firstname> Replaced by customer firstname
74 * <dol_value_customer_lastname> Replaced by customer name
75 * <dol_value_customer_mail> Replaced by customer mail
76 * <dol_value_customer_phone> Replaced by customer phone
77 * <dol_value_customer_mobile> Replaced by customer mobile
78 * <dol_value_customer_tax_number> Replaced by customer VAT number
79 * <dol_value_customer_account_balance> Replaced by customer account balance
80 * <dol_value_mysoc_name> Replaced by mysoc name
81 * <dol_value_mysoc_address> Replaced by mysoc address
82 * <dol_value_mysoc_zip> Replaced by mysoc zip
83 * <dol_value_mysoc_town> Replaced by mysoc town
84 * <dol_value_mysoc_country> Replaced by mysoc country
85 * <dol_value_mysoc_idprof1> Replaced by mysoc idprof1
86 * <dol_value_mysoc_idprof2> Replaced by mysoc idprof2
87 * <dol_value_mysoc_idprof3> Replaced by mysoc idprof3
88 * <dol_value_mysoc_idprof4> Replaced by mysoc idprof4
89 * <dol_value_mysoc_idprof5> Replaced by mysoc idprof5
90 * <dol_value_mysoc_idprof6> Replaced by mysoc idprof6
91 * <dol_value_vendor_lastname> Replaced by vendor name
92 * <dol_value_vendor_firstname> Replaced by vendor firstname
93 * <dol_value_vendor_mail> Replaced by vendor mail
94 * <dol_value_customer_points> Replaced by customer points
95 * <dol_value_object_points> Replaced by number of points for this object
96 *
97 * Conditional code at line start (if then Print)
98 * <dol_print_if_customer> Print the line IF a customer is affected to the object
99 * <dol_print_if_vendor> Print the line IF a vendor is affected to the object
100 * <dol_print_if_happy_hour> Print the line IF Happy Hour
101 * <dol_print_if_num_object_unique> Print the line IF object is validated
102 * <dol_print_if_customer_points> Print the line IF customer points > 0
103 * <dol_print_if_object_points> Print the line IF points of the object > 0
104 * <dol_print_if_customer_tax_number> Print the line IF customer has vat number
105 * <dol_print_if_customer_account_balance_positive> Print the line IF customer balance > 0
106 *
107 */
108
109require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/autoload.php';
110use Mike42\Escpos\PrintConnectors\FilePrintConnector;
111use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
112use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
113use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
114use Mike42\Escpos\PrintConnectors\DummyPrintConnector;
115use Mike42\Escpos\Printer;
116use Mike42\Escpos\EscposImage;
117
121class dolReceiptPrinter extends Printer
122{
123 const CONNECTOR_DUMMY = 1;
124 const CONNECTOR_FILE_PRINT = 2;
125 const CONNECTOR_NETWORK_PRINT = 3;
126 const CONNECTOR_WINDOWS_PRINT = 4;
127 const CONNECTOR_CUPS_PRINT = 5;
128
132 public $db;
133
137 public $tags;
138
142 public $printer;
146 public $template;
147
152 public $orderprinter;
153
158 public $listprinters;
159
164 public $listprinterstemplates;
165
169 public $profileresprint;
170
174 public $resprint;
175
179 public $error = '';
180
184 public $errors = array();
185
191 public function __construct($db)
192 {
193 $this->db = $db;
194 $this->tags = array(
195 'dol_line_feed' => 'DOL_LINE_FEED',
196 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE',
197 'dol_align_left' => 'DOL_ALIGN_LEFT',
198 'dol_align_center' => 'DOL_ALIGN_CENTER',
199 'dol_align_right' => 'DOL_ALIGN_RIGHT',
200 'dol_use_font_a' => 'DOL_USE_FONT_A',
201 'dol_use_font_b' => 'DOL_USE_FONT_B',
202 'dol_use_font_c' => 'DOL_USE_FONT_C',
203 'dol_bold' => 'DOL_BOLD',
204 'dol_bold_disabled' => 'DOL_BOLD_DISABLED',
205 'dol_double_height' => 'DOL_DOUBLE_HEIGHT',
206 'dol_double_width' => 'DOL_DOUBLE_WIDTH',
207 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH',
208 'dol_underline' => 'DOL_UNDERLINE',
209 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED',
210 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL',
211 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL',
212 'dol_open_drawer' => 'DOL_OPEN_DRAWER',
213 'dol_beep' => 'DOL_BEEP',
214 'dol_beep_alternative' => 'DOL_BEEP_ALTERNATIVE',
215 'dol_print_text' => 'DOL_PRINT_TEXT',
216 'dol_print_barcode' => 'DOL_PRINT_BARCODE',
217 'dol_value_date' => 'DateInvoice',
218 'dol_value_date_time' => 'DateInvoiceWithTime',
219 'dol_value_year' => 'YearInvoice',
220 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS',
221 'dol_value_month' => 'DOL_VALUE_MONTH',
222 'dol_value_day' => 'DOL_VALUE_DAY',
223 'dol_value_day_letters' => 'DOL_VALUE_DAY',
224 'dol_value_currentdate' => 'DOL_VALUE_CURRENTDATE',
225 'dol_value_currentdate_notime' => 'CurrentDateWithTime',
226 'dol_value_currentdate_letters' => 'DOL_VALUE_CURRENTDATE_LETTERS',
227 'dol_value_currentyear' => 'CurrentYear',
228 'dol_value_currentmonth_letters' => 'DOL_VALUE_CURRENT_MONTH_LETTERS',
229 'dol_value_currentmonth' => 'DOL_VALUE_CURRENT_MONTH',
230 'dol_value_currentday' => 'DOL_VALUE_CURRENT_DAY',
231 'dol_value_currentday_letters' => 'DOL_VALUE_CURRENT_DAY',
232 'dol_print_payment' => 'DOL_PRINT_PAYMENT',
233 'dol_print_curr_date' => 'DOL_PRINT_CURR_DATE',
234 'dol_print_logo' => 'DOL_PRINT_LOGO',
235 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD',
236 'dol_print_logo_old_cf' => 'DOL_PRINT_LOGO_OLD_CF',
237 'dol_value_object_id' => 'InvoiceID',
238 'dol_value_object_ref' => 'InvoiceRef',
239 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES',
240 'dol_print_object_lines_with_notes' => 'DOL_PRINT_OBJECT_LINES_WITH_NOTES',
241 'dol_print_object_tax' => 'TotalVAT',
242 'dol_print_object_local_tax1' => 'TotalLT1',
243 'dol_print_object_local_tax2' => 'TotalLT2',
244 'dol_print_object_total' => 'Total',
245 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER',
246 //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS',
247 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES',
248 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME',
249 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME',
250 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL',
251 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE',
252 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER',
253 //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE',
254 //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS',
255 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME',
256 'dol_value_mysoc_address' => 'Address',
257 'dol_value_mysoc_zip' => 'Zip',
258 'dol_value_mysoc_town' => 'Town',
259 'dol_value_mysoc_country' => 'Country',
260 'dol_value_mysoc_idprof1' => 'ProfId1',
261 'dol_value_mysoc_idprof2' => 'ProfId2',
262 'dol_value_mysoc_idprof3' => 'ProfId3',
263 'dol_value_mysoc_idprof4' => 'ProfId4',
264 'dol_value_mysoc_idprof5' => 'ProfId5',
265 'dol_value_mysoc_idprof6' => 'ProfId6',
266 'dol_value_mysoc_tva_intra' => 'VATIntra',
267 'dol_value_mysoc_capital' => 'Capital',
268 'dol_value_mysoc_url' => 'Web',
269 'dol_value_vendor_lastname' => 'VendorLastname',
270 'dol_value_vendor_firstname' => 'VendorFirstname',
271 'dol_value_vendor_mail' => 'VendorEmail',
272 'dol_value_place' => 'DOL_VALUE_PLACE',
273 );
274 }
275
281 public function listPrinters()
282 {
283 global $conf;
284
285 $error = 0;
286 $line = 0;
287 $listofprinters = array();
288
289 $sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
290 $sql .= " FROM ".$this->db->prefix()."printer_receipt";
291 $sql .= " WHERE entity = ".((int) $conf->entity);
292
293 $resql = $this->db->query($sql);
294
295 if ($resql) {
296 $num = $this->db->num_rows($resql);
297 while ($line < $num) {
298 $row = $this->db->fetch_array($resql);
299 if ($row) {
300 switch ($row['fk_type']) {
301 case 1:
302 $row['fk_type_name'] = 'CONNECTOR_DUMMY';
303 break;
304 case 2:
305 $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT';
306 break;
307 case 3:
308 $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT';
309 break;
310 case 4:
311 $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT';
312 break;
313 case 5:
314 $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT';
315 break;
316 default:
317 $row['fk_type_name'] = 'CONNECTOR_UNKNOWN';
318 break;
319 }
320 switch ($row['fk_profile']) {
321 case 0:
322 $row['fk_profile_name'] = 'PROFILE_DEFAULT';
323 break;
324 case 1:
325 $row['fk_profile_name'] = 'PROFILE_SIMPLE';
326 break;
327 case 2:
328 $row['fk_profile_name'] = 'PROFILE_EPOSTEP';
329 break;
330 case 3:
331 $row['fk_profile_name'] = 'PROFILE_P822D';
332 break;
333 default:
334 $row['fk_profile_name'] = 'PROFILE_STAR';
335 break;
336 }
337 $listofprinters[] = $row;
338 }
339 $line++;
340 }
341 } else {
342 $error++;
343 $this->errors[] = $this->db->lasterror;
344 }
345
346 $this->listprinters = $listofprinters;
347
348 return $error;
349 }
350
351
357 public function listPrintersTemplates()
358 {
359 global $conf;
360
361 $error = 0;
362 $line = 0;
363 $listofprinters = array();
364
365 $sql = "SELECT rowid, name, template";
366 $sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
367 $sql .= " WHERE entity = ".$conf->entity;
368
369 $resql = $this->db->query($sql);
370
371 if ($resql) {
372 $num = $this->db->num_rows($resql);
373 while ($line < $num) {
374 $row = $this->db->fetch_array($resql);
375 if ($row) {
376 $listofprinters[] = $row;
377 }
378 $line++;
379 }
380 } else {
381 $error++;
382 $this->errors[] = $this->db->lasterror;
383 }
384
385 $this->listprinterstemplates = $listofprinters;
386
387 return $error;
388 }
389
390
398 public function selectTypePrinter($selected = '', $htmlname = 'printertypeid')
399 {
400 global $langs;
401
402 $options = array(
403 1 => $langs->trans('CONNECTOR_DUMMY'),
404 2 => $langs->trans('CONNECTOR_FILE_PRINT'),
405 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'),
406 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'),
407 5 => $langs->trans('CONNECTOR_CUPS_PRINT'),
408 );
409
410 $this->resprint = Form::selectarray($htmlname, $options, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth150');
411
412 return 0;
413 }
414
415
423 public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid')
424 {
425 global $langs;
426
427 $options = array(
428 0 => $langs->trans('PROFILE_DEFAULT'),
429 1 => $langs->trans('PROFILE_SIMPLE'),
430 2 => $langs->trans('PROFILE_EPOSTEP'),
431 3 => $langs->trans('PROFILE_P822D'),
432 4 => $langs->trans('PROFILE_STAR'),
433 );
434
435 $this->profileresprint = Form::selectarray($htmlname, $options, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth150');
436 return 0;
437 }
438
439
449 public function addPrinter($name, $type, $profile, $parameter)
450 {
451 global $conf;
452 $error = 0;
453 $sql = "INSERT INTO ".$this->db->prefix()."printer_receipt";
454 $sql .= " (name, fk_type, fk_profile, parameter, entity)";
455 $sql .= " VALUES ('".$this->db->escape($name)."', ".((int) $type).", ".((int) $profile).", '".$this->db->escape($parameter)."', ".((int) $conf->entity).")";
456 $resql = $this->db->query($sql);
457 if (!$resql) {
458 $error++;
459 $this->errors[] = $this->db->lasterror;
460 }
461 return $error;
462 }
463
474 public function updatePrinter($name, $type, $profile, $parameter, $printerid)
475 {
476 $error = 0;
477
478 $sql = "UPDATE ".$this->db->prefix()."printer_receipt";
479 $sql .= " SET name='".$this->db->escape($name)."'";
480 $sql .= ", fk_type=".((int) $type);
481 $sql .= ", fk_profile=".((int) $profile);
482 $sql .= ", parameter='".$this->db->escape($parameter)."'";
483 $sql .= " WHERE rowid=".((int) $printerid);
484
485 $resql = $this->db->query($sql);
486 if (!$resql) {
487 $error++;
488 $this->errors[] = $this->db->lasterror;
489 }
490 return $error;
491 }
492
499 public function deletePrinter($printerid)
500 {
501 global $conf;
502 $error = 0;
503 $sql = 'DELETE FROM '.$this->db->prefix().'printer_receipt';
504 $sql .= ' WHERE rowid='.((int) $printerid);
505 $resql = $this->db->query($sql);
506 if (!$resql) {
507 $error++;
508 $this->errors[] = $this->db->lasterror;
509 }
510 return $error;
511 }
512
520 public function addTemplate($name, $template)
521 {
522 global $conf;
523 $error = 0;
524 $sql = "INSERT INTO ".$this->db->prefix()."printer_receipt_template";
525 $sql .= " (name, template, entity) VALUES ('".$this->db->escape($name)."'";
526 $sql .= ", '".$this->db->escape($template)."', ".$conf->entity.")";
527 $resql = $this->db->query($sql);
528 if (!$resql) {
529 $error++;
530 $this->errors[] = $this->db->lasterror;
531 }
532 return $error;
533 }
534
541 public function deleteTemplate($templateid)
542 {
543 global $conf;
544 $error = 0;
545 $sql = 'DELETE FROM '.$this->db->prefix().'printer_receipt_template';
546 $sql .= " WHERE rowid = ".((int) $templateid);
547 $sql .= " AND entity = ".$conf->entity;
548 $resql = $this->db->query($sql);
549 if (!$resql) {
550 $error++;
551 $this->errors[] = $this->db->lasterror;
552 }
553 return $error;
554 }
555
564 public function updateTemplate($name, $template, $templateid)
565 {
566 global $conf;
567 $error = 0;
568
569 $sql = "UPDATE ".$this->db->prefix()."printer_receipt_template";
570 $sql .= " SET name='".$this->db->escape($name)."'";
571 $sql .= ", template='".$this->db->escape($template)."'";
572 $sql .= " WHERE rowid=".((int) $templateid);
573 $resql = $this->db->query($sql);
574 if (!$resql) {
575 $error++;
576 $this->errors[] = $this->db->lasterror;
577 }
578 return $error;
579 }
580
581
589 public function sendTestToPrinter($printerid, $addimgandbarcode = 0)
590 {
591 $error = 0;
592 $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png');
593
594 // TODO Set the profile into $this->profile (used by initPrinter). Profile not used yet.
595
596 // Init printer
597 $ret = $this->initPrinter($printerid);
598 if ($ret > 0) {
599 setEventMessages("initPrinter error: ".$this->error, $this->errors, 'errors');
600 } else {
601 try {
602 if ($addimgandbarcode) {
603 $this->printer->bitImage($img);
604 }
605 $this->printer->text("Hello World!\n");
606 if ($addimgandbarcode) {
607 $testStr = "1234567890";
608 $this->printer->barcode($testStr);
609 //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1);
610 }
611 $this->printer->text("\n");
612 $this->printer->text("Most simple example\n");
613 $this->printer->feed();
614 $this->printer->cut();
615
616 // If is DummyPrintConnector send to log to debugging
617 $connector = $this->printer->connector;
618 if ($connector instanceof DummyPrintConnector) {
619 $data = $connector->getData();
620 dol_syslog($data);
621 }
622 // Close and print
623 $this->printer->close();
624 } catch (Exception $e) {
625 $this->errors[] = $e->getMessage();
626 $error++;
627 }
628 }
629 return $error;
630 }
631
640 public function sendToPrinter($object, $templateid, $printerid)
641 {
642 global $mysoc, $langs, $user;
643 global $hookmanager;
644
645 $langs->load('bills');
646
647 $error = 0;
648
649 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
650 $islneverion = isALNERunningVersion();
651
652 if ($templateid) {
653 // Load the custom template from table printer_receipt_template
654 $ret = $this->loadTemplate($templateid);
655
656 // For the moment, we do not allow custom ticket when used in LNE certified context because
657 if ($islneverion) {
658 // Test that all required tags are present, if not we fallback on the generic template by setting templateid=0
659 // TODO
660
661 $templateid = 0;
662 }
663 }
664
665 if (empty($templateid) || $islneverion) {
666 // The default hard coded template
667 $this->template = "{dol_align_center}\r\n";
668 $this->template .= "{dol_print_text}{dol_value_mysoc_name}\r\n";
669 $this->template .= "{dol_print_text}{dol_value_mysoc_address}\r\n";
670 $this->template .= "{dol_print_text}{dol_value_mysoc_zip}{dol_value_mysoc_town}\r\n";
671 $this->template .= "{dol_print_text}{dol_value_mysoc_idprof1}\r\n";
672 $this->template .= "{dol_print_text}{dol_value_mysoc_vatnumber}\r\n";
673 $this->template .= "{dol_line_feed}\r\n";
674 $this->template .= "{dol_print_text}".$langs->transnoentitiesnoconv("Invoice")." {dol_value_object_ref}\r\n";
675 if ($object->status != 2) {
676 $this->template .= "{dol_print_text}*** ".$langs->transnoentities("TemporaryReceipt")." ***\r\n";
677 }
678 if ($object->pos_print_counter > 1) {
679 $this->template .= "{dol_print_text}*** ".$langs->transnoentities("DUPLICATA");
680 if (getDolGlobalString('TAKEPOS_SHOW_PRINT_COUNTER_ON_RECEIPT')) {
681 $this->template .= ' (no '.($object->pos_print_counter - 1).') ***';
682 }
683 $this->template .= "\r\n";
684 }
685
686 $this->template .= "{dol_value_date}\r\n";
687 $this->template .= "{dol_value_currentdate}\r\n";
688 $this->template .= "{dol_value_signaturehashstart}\r\n";
689 $this->template .= "{dol_line_feed}\r\n";
690 $this->template .= "{dol_align_left}\r\n";
691 $this->template .= "{dol_print_object_lines}\r\n";
692 $this->template .= "{dol_line_feed}\r\n";
693 $this->template .= "{dol_print_object_tax}\r\n";
694 $this->template .= "{dol_line_feed}\r\n";
695 $this->template .= "{dol_print_object_total}\r\n";
696 $this->template .= "{dol_line_feed}\r\n";
697 if ($islneverion) {
698 $this->template .= "{dol_value_lnemention}\r\n";
699 $this->template .= "{dol_line_feed}\r\n";
700 }
701 $this->template .= "{dol_cut_paper_full}";
702 }
703
704 $now = dol_now('tzuser');
705 // Placeholders to replace with the actual value before further parsing (dol_value_xxx)
706 $this->template = str_replace('{dol_value_object_id}', (string) $object->id, $this->template);
707 $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template);
708 //$this->template = str_replace('<dol_value_object_points>', $object->points, $this->template);
709 $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template);
710 $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template);
711 $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template);
712 $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template);
713 $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template);
714 $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template);
715 $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template);
716
717 $this->template = str_replace('{dol_value_currentdate}', dol_print_date($now, 'dayhour'), $this->template);
718 $this->template = str_replace('{dol_value_currentdate_notime}', dol_print_date($now, 'day'), $this->template);
719 $this->template = str_replace('{dol_value_currentdate_letters}', dol_print_date($now, 'dayhourtext'), $this->template);
720 $this->template = str_replace('{dol_value_currentyear}', dol_print_date($now, '%Y'), $this->template);
721 $this->template = str_replace('{dol_value_currentmonth_letters}', $langs->trans("Month".dol_print_date($now, '%m')), $this->template);
722 $this->template = str_replace('{dol_value_currentmonth}', dol_print_date($now, '%m'), $this->template);
723 $this->template = str_replace('{dol_value_currentday}', dol_print_date($now, '%d'), $this->template);
724 $this->template = str_replace('{dol_value_currentday_letters}', $langs->trans("Day".dol_print_date($now, '%m')[1]), $this->template);
725
726 $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template);
727 $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template);
728 $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template);
729 $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template);
730 //$this->template = str_replace('<dol_value_customer_mobile>', $object->thirdparty->mobile, $this->template);
731 $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template);
732 //$this->template = str_replace('<dol_value_customer_account_balance>', $object->customer_account_balance, $this->template);
733 //$this->template = str_replace('<dol_value_customer_points>', $object->customer_points, $this->template);
734
735 $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template);
736 $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template);
737 $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template);
738 $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template);
739 $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template);
740 $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template);
741 $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template);
742 $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template);
743 $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template);
744 $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template);
745 $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template);
746 $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template);
747 $this->template = str_replace('{dol_value_mysoc_capital}', (string) $mysoc->capital, $this->template);
748 $this->template = str_replace('{dol_value_mysoc_url}', $mysoc->url, $this->template);
749
750 $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template);
751 $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template);
752 $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template);
753
754 $parameters = array('object' => $object);
755 $action = '';
756 $reshook = $hookmanager->executeHooks('sendToPrinterBefore', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
757 if ($reshook < 0) {
758 $this->error = "Error in hook dolReceiptPrinter sendToPrinterBefore ".$reshook;
759 dol_syslog("dolReceiptPrinter::sendToPrinter: error=".$this->error, LOG_ERR);
760 return $reshook;
761 }
762
763 // escape special characters for xml_parse_into_struct
764 $this->template = htmlspecialchars($this->template, ENT_QUOTES | ENT_XML1);
765
766 // parse template
767 $this->template = str_replace("{", "<", $this->template);
768 $this->template = str_replace("}", ">", $this->template);
769
770 if (LIBXML_VERSION < 20900) {
771 // Avoid load of external entities (security problem).
772 // Required only if LIBXML_VERSION < 20900
773 // @phan-suppress-next-line PhanDeprecatedFunctionInternal
774 libxml_disable_entity_loader(true);
775 }
776
777 $vals = array();
778 $index = array();
779
780 $p = xml_parser_create();
781 xml_parse_into_struct($p, $this->template, $vals, $index);
782 xml_parser_free($p);
783
784 //print '<pre>'.print_r($index, true).'</pre>';
785 //print '<pre>'.print_r($vals, true).'</pre>';
786 // print ticket
787 $nbcharactbyline = getDolGlobalInt('RECEIPT_PRINTER_NB_CHARACT_BY_LINE', 48);
788
789 // TODO Set the profile into $this->profile (used by initPrinter). Profile not used yet.
790
791 // Init printer
792 $ret = $this->initPrinter($printerid);
793
794 if ($ret > 0) {
795 setEventMessages($this->error, $this->errors, 'errors');
796 } else {
797 $nboflines = count($vals);
798 for ($tplline = 0; $tplline < $nboflines; $tplline++) {
799 //var_dump($vals[$tplline]['value']);
800 switch ($vals[$tplline]['tag']) {
801 case 'DOL_PRINT_TEXT':
802 $this->printer->text($vals[$tplline]['value']);
803 break;
804 case 'DOL_PRINT_OBJECT_LINES':
805 foreach ($object->lines as $line) {
806 if ($line->fk_product) {
807 $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen((string) $line->qty) - strlen(price($line->subprice)) - 10 - 1;
808 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
809 $this->printer->text($line->ref . $spaces . $line->qty . str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT) . ' ' . str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT) . "\n");
810 $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n \n");
811 } else {
812 $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen((string) $line->qty) - strlen(price($line->subprice)) - 10 - 1;
813 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
814 $this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT).' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
815 }
816 }
817 break;
818 case 'DOL_PRINT_OBJECT_LINES_WITH_NOTES':
819 foreach ($object->lines as $line) {
820 if ($line->fk_product) {
821 $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen((string) $line->qty) - 10 - 1;
822 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
823 $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
824 $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
825 $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen((string) $line->qty) - 10 - 1;
826 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
827 $this->printer->text($line->description."\n");
828 } else {
829 $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen((string) $line->qty) - 10 - 1;
830 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
831 $this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
832 }
833 }
834 break;
835 case 'DOL_PRINT_OBJECT_TAX':
836 //var_dump($object);
837 $vatarray = array();
838 foreach ($object->lines as $line) {
839 $vat_rate = $line->tva_tx;
840 if (!array_key_exists($vat_rate, $vatarray)) {
841 $vatarray[$vat_rate] = 0;
842 }
843 $vatarray[$vat_rate] += $line->total_tva;
844 }
845 foreach ($vatarray as $vatkey => $vatvalue) {
846 $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12;
847 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
848 $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n");
849 }
850 break;
851 case 'DOL_PRINT_OBJECT_TAX1':
852 //var_dump($object);
853 $total_localtax1 = 0;
854 foreach ($object->lines as $line) {
855 $total_localtax1 += $line->total_localtax1;
856 }
857 $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n");
858 break;
859 case 'DOL_PRINT_OBJECT_TAX2':
860 //var_dump($object);
861 $total_localtax2 = 0;
862 foreach ($object->lines as $line) {
863 $total_localtax2 += $line->total_localtax2;
864 }
865 $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n");
866 break;
867 case 'DOL_PRINT_OBJECT_TOTAL':
868 $title = $langs->trans('TotalHT');
869 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
870 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
871 $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n");
872 $title = $langs->trans('TotalVAT');
873 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
874 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
875 $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n");
876 $title = $langs->trans('TotalTTC');
877 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
878 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
879 $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
880 break;
881 case 'DOL_PRINT_CURR_DATE':
882 if (strlen($vals[$tplline]['value']) < 2) {
883 $this->printer->text(date('d/m/Y H:i:s')."\n");
884 } else {
885 $this->printer->text(date($vals[$tplline]['value'])."\n");
886 }
887 break;
888 case 'DOL_LINE_FEED':
889 $this->printer->feed();
890 break;
891 case 'DOL_LINE_FEED_REVERSE':
892 $this->printer->feedReverse();
893 break;
894 case 'DOL_ALIGN_CENTER':
895 $this->printer->setJustification(Printer::JUSTIFY_CENTER);
896 break;
897 case 'DOL_ALIGN_RIGHT':
898 $this->printer->setJustification(Printer::JUSTIFY_RIGHT);
899 break;
900 case 'DOL_ALIGN_LEFT':
901 $this->printer->setJustification(Printer::JUSTIFY_LEFT);
902 break;
903 case 'DOL_OPEN_DRAWER':
904 $this->printer->pulse();
905 break;
906 case 'DOL_ACTIVATE_BUZZER':
907 //$this->printer->buzzer();
908 break;
909 case 'DOL_PRINT_BARCODE':
910 // $vals[$tplline]['value'] -> barcode($content, $type)
911 // var_dump($vals[$tplline]['value']);
912 try {
913 $this->printer->barcode($vals[$tplline]['value']);
914 } catch (Exception $e) {
915 $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value'];
916 $error++;
917 }
918 break;
919 case 'DOL_PRINT_LOGO':
920 $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo);
921 $this->printer->graphics($img);
922 break;
923 case 'DOL_PRINT_LOGO_OLD':
924 $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo);
925 $this->printer->bitImage($img);
926 break;
927 case 'DOL_PRINT_LOGO_OLD_CF':
928 $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo);
929 $this->printer->bitImageColumnFormat($img);
930 break;
931 case 'DOL_PRINT_QRCODE':
932 // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model)
933 $this->printer->qrcode($vals[$tplline]['value']);
934 break;
935 case 'DOL_CUT_PAPER_FULL':
936 $this->printer->cut(Printer::CUT_FULL);
937 break;
938 case 'DOL_CUT_PAPER_PARTIAL':
939 $this->printer->cut(Printer::CUT_PARTIAL);
940 break;
941 case 'DOL_USE_FONT_A':
942 $this->printer->setFont(Printer::FONT_A);
943 break;
944 case 'DOL_USE_FONT_B':
945 $this->printer->setFont(Printer::FONT_B);
946 break;
947 case 'DOL_USE_FONT_C':
948 $this->printer->setFont(Printer::FONT_C);
949 break;
950 case 'DOL_BOLD':
951 $this->printer->setEmphasis(true);
952 break;
953 case 'DOL_BOLD_DISABLED':
954 $this->printer->setEmphasis(false);
955 break;
956 case 'DOL_DOUBLE_HEIGHT':
957 $this->printer->setTextSize(1, 2);
958 break;
959 case 'DOL_DOUBLE_WIDTH':
960 $this->printer->setTextSize(2, 1);
961 break;
962 case 'DOL_DEFAULT_HEIGHT_WIDTH':
963 $this->printer->setTextSize(1, 1);
964 break;
965 case 'DOL_UNDERLINE':
966 $this->printer->setUnderline(1);
967 break;
968 case 'DOL_UNDERLINE_DISABLED':
969 $this->printer->setUnderline(0);
970 break;
971 case 'DOL_BEEP':
972 $this->printer->getPrintConnector() -> write("\x1e");
973 break;
974 case 'DOL_BEEP_ALTERNATIVE': //if DOL_BEEP not works
975 $this->printer->getPrintConnector() -> write(Printer::ESC . "B" . chr(4) . chr(1));
976 break;
977 case 'DOL_PRINT_ORDER_LINES':
978 foreach ($object->lines as $line) {
979 if ($line->special_code == $this->orderprinter) {
980 $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen((string) $line->qty) - 10 - 1;
981 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
982 $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
983 $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n");
984 }
985 }
986 break;
987 case 'DOL_PRINT_PAYMENT':
988 $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
989 $sql .= " cp.code";
990 $sql .= " FROM ".$this->db->prefix()."paiement_facture as pf, ".$this->db->prefix()."paiement as p";
991 $sql .= " LEFT JOIN ".$this->db->prefix()."c_paiement as cp ON p.fk_paiement = cp.id";
992 $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
993 $sql .= " ORDER BY p.datep";
994 $resql = $this->db->query($sql);
995 if ($resql) {
996 $num = $this->db->num_rows($resql);
997 $i = 0;
998 while ($i < $num) {
999 $row = $this->db->fetch_object($resql);
1000 $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12;
1001 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
1002 $amount_payment = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
1003 if ($row->code == "LIQ") {
1004 $amount_payment += $row->pos_change; // Show amount with excess received if is cash payment
1005 }
1006 $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n");
1007 if ($row->code == "LIQ" && $row->pos_change > 0) { // Print change only in cash payments
1008 $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12;
1009 $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
1010 $this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->pos_change), 10, ' ', STR_PAD_LEFT)."\n");
1011 }
1012 $i++;
1013 }
1014 }
1015 break;
1016 case 'DOL_VALUE_PLACE':
1017 $sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref)));
1018 $resql = $this->db->query($sql);
1019 $obj = $this->db->fetch_object($resql);
1020 if ($obj) {
1021 $this->printer->text($obj->label);
1022 }
1023 break;
1024 default:
1025 $parameters = array('vals' => $vals[$tplline],'object' => $object,'nbcharactbyline' => $nbcharactbyline);
1026 $action = '';
1027 $reshook = $hookmanager->executeHooks('sendToPrinterAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1028
1029 if (!$reshook || $reshook < 0) {
1030 $this->printer->text($vals[$tplline]['tag']);
1031 $this->printer->text($vals[$tplline]['value']);
1032 $this->errors[] = 'UnknowTag: &lt;'.strtolower($vals[$tplline]['tag']).'&gt;';
1033 $error++;
1034 }
1035 break;
1036 }
1037 }
1038 // If is DummyPrintConnector send to log to debugging
1039 $connector = $this->printer->connector;
1040 if ($connector instanceof DummyPrintConnector || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1041 $data = $connector->getData();
1042 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1043 echo rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
1044 }
1045 dol_syslog($data);
1046 }
1047 // Close and print
1048 $this->printer->close();
1049 }
1050 return $error;
1051 }
1052
1059 public function loadTemplate($templateid)
1060 {
1061 $error = 0;
1062
1063 $sql = "SELECT template";
1064 $sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
1065 $sql .= " WHERE rowid = ".((int) $templateid);
1066 $sql .= " AND entity IN (".getEntity('printer_receipt_template').")";
1067
1068 $resql = $this->db->query($sql);
1069 if ($resql) {
1070 $obj = $this->db->fetch_object($resql);
1071 } else {
1072 $error++;
1073 $this->errors[] = $this->db->lasterror;
1074 }
1075 if (empty($obj)) {
1076 $error++;
1077 $this->errors[] = 'TemplateDontExist';
1078 } else {
1079 $this->template = $obj->template;
1080 }
1081
1082 return $error;
1083 }
1084
1085
1092 public function initPrinter($printerid)
1093 {
1094 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
1095 $this->connector = new DummyPrintConnector();
1096 $this->printer = new Printer($this->connector, $this->profile);
1097 return;
1098 }
1099
1100 $error = 0;
1101 $sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
1102 $sql .= " FROM ".$this->db->prefix()."printer_receipt";
1103 $sql .= " WHERE rowid = ".((int) $printerid);
1104 $sql .= " AND entity IN (".getEntity('printer_receipt').")";
1105
1106 $resql = $this->db->query($sql);
1107 if ($resql) {
1108 $obj = $this->db->fetch_array($resql);
1109 if (empty($obj)) {
1110 $error++;
1111 $this->errors[] = 'PrinterDontExist';
1112 }
1113 if (!$error) {
1114 $parameter = (isset($obj['parameter']) ? $obj['parameter'] : '');
1115
1116 dol_syslog("initPrinter printerid=".$printerid." parameter=".$parameter);
1117
1118 try {
1119 $type = empty($obj['fk_type']) ? 0 : (int) $obj['fk_type'];
1120 $found = true;
1121 switch ($type) {
1122 case 1:
1123 $this->connector = new DummyPrintConnector();
1124 break;
1125 case 2:
1126 $this->connector = new FilePrintConnector($parameter);
1127 break;
1128 case 3:
1129 $parameters = explode(':', $parameter);
1130 if (empty($parameters[1])) {
1131 $this->connector = new NetworkPrintConnector($parameters[0]);
1132 } else {
1133 $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]);
1134 }
1135 break;
1136 case 4: // LPT1, smb://...
1137 $this->connector = new WindowsPrintConnector(dol_sanitizePathName($parameter));
1138 break;
1139 case 5:
1140 $this->connector = new CupsPrintConnector($parameter);
1141 break;
1142 default:
1143 $found = false;
1144 break;
1145 }
1146
1147 // TODO Set the profile into $this->profile by the caller of this method initPrinter. Profile not used yet.
1148 // Note: currently $this->profile is always null, so will load "default".
1149 if ($found) {
1150 $this->printer = new Printer($this->connector, $this->profile);
1151 } else {
1152 $error++;
1153 $this->errors[] = 'CONNECTOR_UNKNOWN';
1154 }
1155 } catch (Exception $e) {
1156 $this->errors[] = $e->getMessage();
1157 $error++;
1158 }
1159 }
1160 } else {
1161 $error++;
1162 $this->errors[] = $this->db->lasterror;
1163 }
1164
1165 return $error;
1166 }
1167}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
static selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='minwidth75', $addjscombo=1, $moreparamonempty='', $disablebademail=0, $nohtmlescape=0)
Return a HTML select string, built from an array of key+value.
Class to manage Receipt Printers.
selectTypePrinter($selected='', $htmlname='printertypeid')
Form to Select type printer.
addPrinter($name, $type, $profile, $parameter)
Function to Add a printer in db.
updatePrinter($name, $type, $profile, $parameter, $printerid)
Function to Update a printer in db.
sendToPrinter($object, $templateid, $printerid)
Function to Print Receipt Ticket using ESCPOS lib.
listPrinters()
List printers into the array ->listprinters.
loadTemplate($templateid)
Function to load Template into $this->template.
updateTemplate($name, $template, $templateid)
Function to Update a printer template in db.
initPrinter($printerid)
Function Init Printer into $this->printer.
deleteTemplate($templateid)
Function to delete a printer template in db.
deletePrinter($printerid)
Function to Delete a printer from db.
selectProfilePrinter($selected='', $htmlname='printerprofileid')
Form to Select Profile printer.
addTemplate($name, $template)
Function to add a printer template in db.
listPrintersTemplates()
List printers templates.
sendTestToPrinter($printerid, $addimgandbarcode=0)
Function to Send Test page to Printer.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:487