Merge pull request #22868 from frederic34/receiptprinter

add new tags in receipt printer
This commit is contained in:
Laurent Destailleur
2022-11-17 10:23:45 +01:00
committed by GitHub

View File

@@ -46,6 +46,7 @@
* {dol_print_barcode} Print barcode
* {dol_print_logo} Print logo stored on printer. Example : <print_logo>32|32
* {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers.
* {dol_print_logo_old_cf} Print logo stored on printer. Must be followed by logo code. For old printers. May help for centering image.
* {dol_print_object_lines} Print object lines
* {dol_print_object_tax} Print object total tax
* {dol_print_object_local_tax} Print object local tax
@@ -63,7 +64,8 @@
* <dol_value_month> Replaced by month number
* <dol_value_day> Replaced by day number
* <dol_value_day_letters> Replaced by day number
* <dol_value_currentdate> Replaced by current date
* <dol_value_currentdate> Replaced by current date and time
* <dol_value_currentdate_notime> Replaced by current date without time
* <dol_object_id> Replaced by object id
* <dol_object_ref> Replaced by object ref
* <dol_value_customer_firstname> Replaced by customer firstname
@@ -191,10 +193,18 @@ class dolReceiptPrinter extends Printer
'dol_value_day' => 'DOL_VALUE_DAY',
'dol_value_day_letters' => 'DOL_VALUE_DAY',
'dol_value_currentdate' => 'DOL_VALUE_CURRENTDATE',
'dol_value_currentdate_notime' => 'CurrentDateWithTime',
'dol_value_currentdate_letters' => 'DOL_VALUE_CURRENTDATE_LETTERS',
'dol_value_currentyear' => 'CurrentYear',
'dol_value_currentmonth_letters' => 'DOL_VALUE_CURRENT_MONTH_LETTERS',
'dol_value_currentmonth' => 'DOL_VALUE_CURRENT_MONTH',
'dol_value_currentday' => 'DOL_VALUE_CURRENT_DAY',
'dol_value_currentday_letters' => 'DOL_VALUE_CURRENT_DAY',
'dol_print_payment' => 'DOL_PRINT_PAYMENT',
'dol_print_curr_date' => 'DOL_PRINT_CURR_DATE',
'dol_print_logo' => 'DOL_PRINT_LOGO',
'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD',
'dol_print_logo_old_cf' => 'DOL_PRINT_LOGO_OLD_CF',
'dol_value_object_id' => 'InvoiceID',
'dol_value_object_ref' => 'InvoiceRef',
'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES',
@@ -577,9 +587,12 @@ class dolReceiptPrinter extends Printer
public function sendToPrinter($object, $templateid, $printerid)
{
global $conf, $mysoc, $langs, $user;
$langs->load('bills');
$error = 0;
$ret = $this->loadTemplate($templateid);
$now = dol_now('tzuser');
// tags a remplacer par leur valeur avant de parser (dol_value_xxx)
$this->template = str_replace('{dol_value_object_id}', $object->id, $this->template);
$this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template);
@@ -591,7 +604,15 @@ class dolReceiptPrinter extends Printer
$this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template);
$this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template);
$this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template);
$this->template = str_replace('{dol_value_currentdate}', dol_print_date(dol_now(), 'dayhour'), $this->template);
$this->template = str_replace('{dol_value_currentdate}', dol_print_date($now, 'dayhour'), $this->template);
$this->template = str_replace('{dol_value_currentdate_notime}', dol_print_date($now, 'day'), $this->template);
$this->template = str_replace('{dol_value_currentdate_letters}', dol_print_date($now, 'dayhourtext'), $this->template);
$this->template = str_replace('{dol_value_currentyear}', dol_print_date($now, '%Y'), $this->template);
$this->template = str_replace('{dol_value_currentmonth_letters}', $langs->trans("Month".dol_print_date($now, '%m')), $this->template);
$this->template = str_replace('{dol_value_currentmonth}', dol_print_date($now, '%m'), $this->template);
$this->template = str_replace('{dol_value_currentday}', dol_print_date($now, '%d'), $this->template);
$this->template = str_replace('{dol_value_currentday_letters}', $langs->trans("Day".dol_print_date($now, '%m')[1]), $this->template);
$this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template);
$this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template);
@@ -759,6 +780,10 @@ class dolReceiptPrinter extends Printer
$img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo);
$this->printer->bitImage($img);
break;
case 'DOL_PRINT_LOGO_OLD_CF':
$img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo);
$this->printer->bitImageColumnFormat($img);
break;
case 'DOL_PRINT_QRCODE':
// $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model)
$this->printer->qrcode($vals[$tplline]['value']);
@@ -845,9 +870,9 @@ class dolReceiptPrinter extends Printer
}
break;
case 'DOL_VALUE_PLACE':
$sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref)));
$resql = $this->db->query($sql);
$obj = $this->db->fetch_object($resql);
$sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref)));
$resql = $this->db->query($sql);
$obj = $this->db->fetch_object($resql);
if ($obj) {
$this->printer->text($obj->label);
}