102 require_once DOL_DOCUMENT_ROOT.
'/includes/mike42/escpos-php/autoload.php';
103 use Mike42\Escpos\PrintConnectors\FilePrintConnector;
104 use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
105 use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
106 use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
107 use Mike42\Escpos\PrintConnectors\DummyPrintConnector;
108 use Mike42\Escpos\CapabilityProfile;
109 use Mike42\Escpos\Printer;
110 use Mike42\Escpos\EscposImage;
118 const CONNECTOR_DUMMY = 1;
119 const CONNECTOR_FILE_PRINT = 2;
120 const CONNECTOR_NETWORK_PRINT = 3;
121 const CONNECTOR_WINDOWS_PRINT = 4;
122 const CONNECTOR_CUPS_PRINT = 5;
140 public $orderprinter;
150 public $errors = array();
161 'dol_line_feed' =>
'DOL_LINE_FEED',
162 'dol_line_feed_reverse' =>
'DOL_LINE_FEED_REVERSE',
163 'dol_align_left' =>
'DOL_ALIGN_LEFT',
164 'dol_align_center' =>
'DOL_ALIGN_CENTER',
165 'dol_align_right' =>
'DOL_ALIGN_RIGHT',
166 'dol_use_font_a' =>
'DOL_USE_FONT_A',
167 'dol_use_font_b' =>
'DOL_USE_FONT_B',
168 'dol_use_font_c' =>
'DOL_USE_FONT_C',
169 'dol_bold' =>
'DOL_BOLD',
170 'dol_bold_disabled' =>
'DOL_BOLD_DISABLED',
171 'dol_double_height' =>
'DOL_DOUBLE_HEIGHT',
172 'dol_double_width' =>
'DOL_DOUBLE_WIDTH',
173 'dol_default_height_width' =>
'DOL_DEFAULT_HEIGHT_WIDTH',
174 'dol_underline' =>
'DOL_UNDERLINE',
175 'dol_underline_disabled' =>
'DOL_UNDERLINE_DISABLED',
176 'dol_cut_paper_full' =>
'DOL_CUT_PAPER_FULL',
177 'dol_cut_paper_partial' =>
'DOL_CUT_PAPER_PARTIAL',
178 'dol_open_drawer' =>
'DOL_OPEN_DRAWER',
179 'dol_beep' =>
'DOL_BEEP',
180 'dol_print_text' =>
'DOL_PRINT_TEXT',
181 'dol_print_barcode' =>
'DOL_PRINT_BARCODE',
182 'dol_value_date' =>
'DateInvoice',
183 'dol_value_date_time' =>
'DateInvoiceWithTime',
184 'dol_value_year' =>
'YearInvoice',
185 'dol_value_month_letters' =>
'DOL_VALUE_MONTH_LETTERS',
186 'dol_value_month' =>
'DOL_VALUE_MONTH',
187 'dol_value_day' =>
'DOL_VALUE_DAY',
188 'dol_value_day_letters' =>
'DOL_VALUE_DAY',
189 'dol_print_payment' =>
'DOL_PRINT_PAYMENT',
190 'dol_print_logo' =>
'DOL_PRINT_LOGO',
191 'dol_print_logo_old' =>
'DOL_PRINT_LOGO_OLD',
192 'dol_value_object_id' =>
'InvoiceID',
193 'dol_value_object_ref' =>
'InvoiceRef',
194 'dol_print_object_lines' =>
'DOL_PRINT_OBJECT_LINES',
195 'dol_print_object_tax' =>
'TotalVAT',
196 'dol_print_object_local_tax1' =>
'TotalLT1',
197 'dol_print_object_local_tax2' =>
'TotalLT2',
198 'dol_print_object_total' =>
'Total',
199 'dol_print_object_number' =>
'DOL_PRINT_OBJECT_NUMBER',
201 'dol_print_order_lines' =>
'DOL_PRINT_ORDER_LINES',
202 'dol_value_customer_firstname' =>
'DOL_VALUE_CUSTOMER_FIRSTNAME',
203 'dol_value_customer_lastname' =>
'DOL_VALUE_CUSTOMER_LASTNAME',
204 'dol_value_customer_mail' =>
'DOL_VALUE_CUSTOMER_MAIL',
205 'dol_value_customer_phone' =>
'DOL_VALUE_CUSTOMER_PHONE',
206 'dol_value_customer_skype' =>
'DOL_VALUE_CUSTOMER_SKYPE',
207 'dol_value_customer_tax_number' =>
'DOL_VALUE_CUSTOMER_TAX_NUMBER',
210 'dol_value_mysoc_name' =>
'DOL_VALUE_MYSOC_NAME',
211 'dol_value_mysoc_address' =>
'Address',
212 'dol_value_mysoc_zip' =>
'Zip',
213 'dol_value_mysoc_town' =>
'Town',
214 'dol_value_mysoc_country' =>
'Country',
215 'dol_value_mysoc_idprof1' =>
'ProfId1',
216 'dol_value_mysoc_idprof2' =>
'ProfId2',
217 'dol_value_mysoc_idprof3' =>
'ProfId3',
218 'dol_value_mysoc_idprof4' =>
'ProfId4',
219 'dol_value_mysoc_idprof5' =>
'ProfId5',
220 'dol_value_mysoc_idprof6' =>
'ProfId6',
221 'dol_value_mysoc_tva_intra' =>
'VATIntra',
222 'dol_value_mysoc_capital' =>
'Capital',
223 'dol_value_vendor_lastname' =>
'VendorLastname',
224 'dol_value_vendor_firstname' =>
'VendorFirstname',
225 'dol_value_vendor_mail' =>
'VendorEmail',
240 $sql =
'SELECT rowid, name, fk_type, fk_profile, parameter';
241 $sql .=
' FROM '.MAIN_DB_PREFIX.
'printer_receipt';
242 $sql .=
' WHERE entity = '.$conf->entity;
246 while ($line < $num) {
247 $row = $this->
db->fetch_array(
$resql);
248 switch ($row[
'fk_type']) {
250 $row[
'fk_type_name'] =
'CONNECTOR_DUMMY';
253 $row[
'fk_type_name'] =
'CONNECTOR_FILE_PRINT';
256 $row[
'fk_type_name'] =
'CONNECTOR_NETWORK_PRINT';
259 $row[
'fk_type_name'] =
'CONNECTOR_WINDOWS_PRINT';
262 $row[
'fk_type_name'] =
'CONNECTOR_CUPS_PRINT';
265 $row[
'fk_type_name'] =
'CONNECTOR_UNKNOWN';
268 switch ($row[
'fk_profile']) {
270 $row[
'fk_profile_name'] =
'PROFILE_DEFAULT';
273 $row[
'fk_profile_name'] =
'PROFILE_SIMPLE';
276 $row[
'fk_profile_name'] =
'PROFILE_EPOSTEP';
279 $row[
'fk_profile_name'] =
'PROFILE_P822D';
282 $row[
'fk_profile_name'] =
'PROFILE_STAR';
290 $this->errors[] = $this->
db->lasterror;
292 $this->listprinters = $obj;
308 $sql =
'SELECT rowid, name, template';
309 $sql .=
' FROM '.MAIN_DB_PREFIX.
'printer_receipt_template';
310 $sql .=
' WHERE entity = '.$conf->entity;
314 while ($line < $num) {
315 $obj[] = $this->
db->fetch_array(
$resql);
320 $this->errors[] = $this->
db->lasterror;
322 $this->listprinterstemplates = $obj;
339 1 => $langs->trans(
'CONNECTOR_DUMMY'),
340 2 => $langs->trans(
'CONNECTOR_FILE_PRINT'),
341 3 => $langs->trans(
'CONNECTOR_NETWORK_PRINT'),
342 4 => $langs->trans(
'CONNECTOR_WINDOWS_PRINT'),
343 5 => $langs->trans(
'CONNECTOR_CUPS_PRINT'),
364 0 => $langs->trans(
'PROFILE_DEFAULT'),
365 1 => $langs->trans(
'PROFILE_SIMPLE'),
366 2 => $langs->trans(
'PROFILE_EPOSTEP'),
367 3 => $langs->trans(
'PROFILE_P822D'),
368 4 => $langs->trans(
'PROFILE_STAR'),
385 public function addPrinter($name, $type, $profile, $parameter)
389 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'printer_receipt';
390 $sql .=
' (name, fk_type, fk_profile, parameter, entity)';
391 $sql .=
' VALUES ("'.$this->db->escape($name).
'", '.$type.
', '.$profile.
', "'.$this->
db->escape($parameter).
'", '.$conf->entity.
')';
395 $this->errors[] = $this->
db->lasterror;
410 public function updatePrinter($name, $type, $profile, $parameter, $printerid)
414 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'printer_receipt';
415 $sql .=
' SET name="'.$this->db->escape($name).
'"';
416 $sql .=
', fk_type='.$type;
417 $sql .=
', fk_profile='.$profile;
418 $sql .=
', parameter="'.$this->db->escape($parameter).
'"';
419 $sql .=
' WHERE rowid='.$printerid;
423 $this->errors[] = $this->
db->lasterror;
438 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'printer_receipt';
439 $sql .=
' WHERE rowid='.$printerid;
443 $this->errors[] = $this->
db->lasterror;
459 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'printer_receipt_template';
460 $sql .=
' (name, template, entity) VALUES ("'.$this->db->escape($name).
'"';
461 $sql .=
', "'.$this->db->escape($template).
'", '.$conf->entity.
')';
465 $this->errors[] = $this->
db->lasterror;
480 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'printer_receipt_template';
481 $sql .=
" WHERE rowid = ".((int) $this->
db->escape($templateid));
482 $sql .=
" AND entity = ".$conf->entity;
486 $this->errors[] = $this->
db->lasterror;
503 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'printer_receipt_template';
504 $sql .=
' SET name="'.$this->db->escape($name).
'"';
505 $sql .=
', template="'.$this->db->escape($template).
'"';
506 $sql .=
' WHERE rowid='.$templateid;
510 $this->errors[] = $this->
db->lasterror;
526 $img = EscposImage::load(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo_bw.png');
533 $this->printer->bitImage($img);
534 $this->printer->text(
"Hello World!\n");
535 $testStr =
"1234567890";
536 $this->printer->barcode($testStr);
538 $this->printer->text(
"Most simple example\n");
539 $this->printer->feed();
540 $this->printer->cut();
543 if ($this->printer->connector instanceof DummyPrintConnector)
545 $data = $this->printer->connector-> getData();
548 $this->printer->close();
550 $this->errors[] = $e->getMessage();
567 global $conf, $mysoc, $langs, $user;
572 $this->
template = str_replace(
'{dol_value_object_id}', $object->id, $this->template);
573 $this->
template = str_replace(
'{dol_value_object_ref}', $object->ref, $this->template);
575 $this->
template = str_replace(
'{dol_value_date}',
dol_print_date($object->date,
'day'), $this->template);
576 $this->
template = str_replace(
'{dol_value_date_time}',
dol_print_date($object->date,
'dayhour'), $this->template);
577 $this->
template = str_replace(
'{dol_value_year}',
dol_print_date($object->date,
'%Y'), $this->template);
578 $this->
template = str_replace(
'{dol_value_month_letters}', $langs->trans(
"Month".dol_print_date($object->date,
'%m')), $this->
template);
579 $this->
template = str_replace(
'{dol_value_month}',
dol_print_date($object->date,
'%m'), $this->template);
580 $this->
template = str_replace(
'{dol_value_day}',
dol_print_date($object->date,
'%d'), $this->template);
581 $this->
template = str_replace(
'{dol_value_day_letters}', $langs->trans(
"Day".dol_print_date($object->date,
'%m')[1]), $this->
template);
583 $this->
template = str_replace(
'{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template);
584 $this->
template = str_replace(
'{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template);
585 $this->
template = str_replace(
'{dol_value_customer_mail}', $object->thirdparty->email, $this->template);
586 $this->
template = str_replace(
'{dol_value_customer_phone}', $object->thirdparty->phone, $this->template);
588 $this->
template = str_replace(
'{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template);
592 $this->
template = str_replace(
'{dol_value_mysoc_name}', $mysoc->name, $this->template);
593 $this->
template = str_replace(
'{dol_value_mysoc_address}', $mysoc->address, $this->template);
594 $this->
template = str_replace(
'{dol_value_mysoc_zip}', $mysoc->zip, $this->template);
595 $this->
template = str_replace(
'{dol_value_mysoc_town}', $mysoc->town, $this->template);
596 $this->
template = str_replace(
'{dol_value_mysoc_country}', $mysoc->country, $this->template);
597 $this->
template = str_replace(
'{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template);
598 $this->
template = str_replace(
'{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template);
599 $this->
template = str_replace(
'{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template);
600 $this->
template = str_replace(
'{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template);
601 $this->
template = str_replace(
'{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template);
602 $this->
template = str_replace(
'{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template);
603 $this->
template = str_replace(
'{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template);
604 $this->
template = str_replace(
'{dol_value_mysoc_capital}', $mysoc->capital, $this->template);
606 $this->
template = str_replace(
'{dol_value_vendor_firstname}', $user->firstname, $this->template);
607 $this->
template = str_replace(
'{dol_value_vendor_lastname}', $user->lastname, $this->template);
608 $this->
template = str_replace(
'{dol_value_vendor_mail}', $user->email, $this->template);
611 $this->
template = str_replace(
"{",
"<", $this->
template);
612 $this->
template = str_replace(
"}",
">", $this->
template);
613 $p = xml_parser_create();
614 xml_parse_into_struct($p, $this->
template, $vals, $index);
620 $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48);
625 $nboflines = count($vals);
626 for ($tplline = 0; $tplline < $nboflines; $tplline++) {
628 switch ($vals[$tplline][
'tag']) {
629 case 'DOL_PRINT_TEXT':
630 $this->printer->text($vals[$tplline][
'value']);
632 case 'DOL_PRINT_OBJECT_LINES':
633 foreach ($object->lines as $line) {
634 if ($line->fk_product)
636 $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
637 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
638 $this->printer->text($line->ref.$spaces.$line->qty.
' '.str_pad(
price($line->total_ttc), 10,
' ', STR_PAD_LEFT).
"\n");
639 $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label)).
"\n");
642 $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1;
643 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
644 $this->printer->text($line->description.$spaces.$line->qty.
' '.str_pad(
price($line->total_ttc), 10,
' ', STR_PAD_LEFT).
"\n");
648 case 'DOL_PRINT_OBJECT_TAX':
651 foreach ($object->lines as $line) {
652 $vatarray[$line->tva_tx] += $line->total_tva;
654 foreach ($vatarray as $vatkey => $vatvalue) {
655 $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12;
656 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
657 $this->printer->text($spaces.$vatkey.
'% '.str_pad(
price($vatvalue), 10,
' ', STR_PAD_LEFT).
"\n");
660 case 'DOL_PRINT_OBJECT_TAX1':
662 $total_localtax1 = 0;
663 foreach ($object->lines as $line) {
664 $total_localtax1 += $line->total_localtax1;
666 foreach ($vatarray as $vatkey => $vatvalue) {
667 $this->printer->text(str_pad(
price($total_localtax1), 10,
' ', STR_PAD_LEFT).
"\n");
670 case 'DOL_PRINT_OBJECT_TAX2':
672 $total_localtax2 = 0;
673 foreach ($object->lines as $line) {
674 $total_localtax2 += $line->total_localtax2;
676 foreach ($vatarray as $vatkey => $vatvalue) {
677 $this->printer->text(str_pad(
price($total_localtax2), 10,
' ', STR_PAD_LEFT).
"\n");
680 case 'DOL_PRINT_OBJECT_TOTAL':
681 $title = $langs->trans(
'TotalHT');
682 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
683 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
684 $this->printer->text($title.$spaces.str_pad(
price($object->total_ht), 10,
' ', STR_PAD_LEFT).
"\n");
685 $title = $langs->trans(
'TotalVAT');
686 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
687 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
688 $this->printer->text($title.$spaces.str_pad(
price($object->total_tva), 10,
' ', STR_PAD_LEFT).
"\n");
689 $title = $langs->trans(
'TotalTTC');
690 $spacestoadd = $nbcharactbyline - strlen($title) - 10;
691 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
692 $this->printer->text($title.$spaces.str_pad(
price($object->total_ttc), 10,
' ', STR_PAD_LEFT).
"\n");
694 case 'DOL_LINE_FEED':
695 $this->printer->feed();
697 case 'DOL_LINE_FEED_REVERSE':
698 $this->printer->feedReverse();
700 case 'DOL_ALIGN_CENTER':
701 $this->printer->setJustification(Printer::JUSTIFY_CENTER);
703 case 'DOL_ALIGN_RIGHT':
704 $this->printer->setJustification(Printer::JUSTIFY_RIGHT);
706 case 'DOL_ALIGN_LEFT':
707 $this->printer->setJustification(Printer::JUSTIFY_LEFT);
709 case 'DOL_OPEN_DRAWER':
710 $this->printer->pulse();
712 case 'DOL_ACTIVATE_BUZZER':
715 case 'DOL_PRINT_BARCODE':
719 $this->printer->barcode($vals[$tplline][
'value']);
721 $this->errors[] =
'Invalid Barcode value: '.$vals[$tplline][
'value'];
725 case 'DOL_PRINT_LOGO':
726 $img = EscposImage::load(DOL_DATA_ROOT.
'/mycompany/logos/'.$mysoc->logo);
727 $this->printer->graphics($img);
729 case 'DOL_PRINT_LOGO_OLD':
730 $img = EscposImage::load(DOL_DATA_ROOT.
'/mycompany/logos/'.$mysoc->logo);
731 $this->printer->bitImage($img);
733 case 'DOL_PRINT_QRCODE':
735 $this->printer->qrcode($vals[$tplline][
'value']);
737 case 'DOL_CUT_PAPER_FULL':
738 $this->printer->cut(Printer::CUT_FULL);
740 case 'DOL_CUT_PAPER_PARTIAL':
741 $this->printer->cut(Printer::CUT_PARTIAL);
743 case 'DOL_USE_FONT_A':
744 $this->printer->setFont(Printer::FONT_A);
746 case 'DOL_USE_FONT_B':
747 $this->printer->setFont(Printer::FONT_B);
749 case 'DOL_USE_FONT_C':
750 $this->printer->setFont(Printer::FONT_C);
753 $this->printer->setEmphasis(
true);
755 case 'DOL_BOLD_DISABLED':
756 $this->printer->setEmphasis(
false);
758 case 'DOL_DOUBLE_HEIGHT':
759 $this->printer->setTextSize(1, 2);
761 case 'DOL_DOUBLE_WIDTH':
762 $this->printer->setTextSize(2, 1);
764 case 'DOL_DEFAULT_HEIGHT_WIDTH':
765 $this->printer->setTextSize(1, 1);
767 case 'DOL_UNDERLINE':
768 $this->printer->setUnderline(
true);
770 case 'DOL_UNDERLINE_DISABLED':
771 $this->printer->setUnderline(
false);
774 $this->printer->getPrintConnector() -> write(
"\x1e");
776 case 'DOL_PRINT_ORDER_LINES':
777 foreach ($object->lines as $line) {
778 if ($line->special_code == $this->orderprinter)
780 $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
781 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
782 $this->printer->text($line->ref.$spaces.$line->qty.
' '.str_pad(
price($line->total_ttc), 10,
' ', STR_PAD_LEFT).
"\n");
783 $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc)).
"\n");
787 case 'DOL_PRINT_PAYMENT':
788 $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,";
790 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
791 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
792 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
793 $sql .=
" ORDER BY p.datep";
800 $row = $this->
db->fetch_object(
$resql);
801 $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code)) - 12;
802 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
803 $amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
804 if ($row->code ==
"LIQ") $amount_payment = $amount_payment + $row->pos_change;
805 $this->printer->text($spaces.$langs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code).
' '.str_pad(
price($amount_payment), 10,
' ', STR_PAD_LEFT).
"\n");
806 if ($row->code ==
"LIQ" && $row->pos_change > 0)
808 $spacestoadd = $nbcharactbyline - strlen($langs->trans(
"Change")) - 12;
809 $spaces = str_repeat(
' ', $spacestoadd > 0 ? $spacestoadd : 0);
810 $this->printer->text($spaces.$langs->trans(
"Change").
' '.str_pad(
price($row->pos_change), 10,
' ', STR_PAD_LEFT).
"\n");
817 $this->printer->text($vals[$tplline][
'tag']);
818 $this->printer->text($vals[$tplline][
'value']);
819 $this->errors[] =
'UnknowTag: <'.strtolower($vals[$tplline][
'tag']).
'>';
825 if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector")
827 $data = $this->printer->connector->getData();
828 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") echo base64_encode($data);
832 $this->printer->close();
847 $sql =
'SELECT template';
848 $sql .=
' FROM '.MAIN_DB_PREFIX.
'printer_receipt_template';
849 $sql .=
' WHERE rowid='.$templateid;
850 $sql .=
' AND entity = '.$conf->entity;
853 $obj = $this->
db->fetch_array(
$resql);
856 $this->errors[] = $this->
db->lasterror;
860 $this->errors[] =
'TemplateDontExist';
862 $this->
template = $obj[
'0'];
878 if ($conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") {
879 $this->connector =
new DummyPrintConnector();
880 $this->printer =
new Printer($this->connector, $this->profile);
884 $sql =
'SELECT rowid, name, fk_type, fk_profile, parameter';
885 $sql .=
' FROM '.MAIN_DB_PREFIX.
'printer_receipt';
886 $sql .=
' WHERE rowid = '.$printerid;
887 $sql .=
' AND entity = '.$conf->entity;
890 $obj = $this->
db->fetch_array(
$resql);
893 $this->errors[] = $this->
db->lasterror;
897 $this->errors[] =
'PrinterDontExist';
900 $parameter = $obj[
'parameter'];
902 switch ($obj[
'fk_type']) {
904 $this->connector =
new DummyPrintConnector();
907 $this->connector =
new FilePrintConnector($parameter);
910 $parameters = explode(
':', $parameter);
911 $this->connector =
new NetworkPrintConnector($parameters[0], $parameters[1]);
914 $this->connector =
new WindowsPrintConnector($parameter);
917 $this->connector =
new CupsPrintConnector($parameter);
920 $this->connector =
'CONNECTOR_UNKNOWN';
923 $this->printer =
new Printer($this->connector, $this->profile);
925 $this->errors[] = $e->getMessage();
deletePrinter($printerid)
Function to Delete a printer from db.
listPrintersTemplates()
List printers templates.
addTemplate($name, $template)
Function to add a printer template in db.
selectTypePrinter($selected= '', $htmlname= 'printertypeid')
Form to Select type printer.
updatePrinter($name, $type, $profile, $parameter, $printerid)
Function to Update a printer in db.
initPrinter($printerid)
Function Init Printer.
listPrinters()
list printers
$conf db
API class for accounts.
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...
loadTemplate($templateid)
Function to load Template.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
deleteTemplate($templateid)
Function to delete a printer template in db.
Class to manage Receipt Printers.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
__construct($db)
Constructor.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
addPrinter($name, $type, $profile, $parameter)
Function to Add a printer in db.
selectProfilePrinter($selected= '', $htmlname= 'printerprofileid')
Form to Select Profile printer.
sendTestToPrinter($printerid)
Function to Send Test page to Printer.
sendToPrinter($object, $templateid, $printerid)
Function to Print Receipt Ticket.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
updateTemplate($name, $template, $templateid)
Function to Update a printer template in db.