diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index 350d4a3dc15..26bfd1ef1c8 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -43,7 +43,7 @@ $printername = GETPOST('printername', 'alpha');
$printerid = GETPOST('printerid', 'int');
$parameter = GETPOST('parameter', 'alpha');
-$template = GETPOST('template', 'alpha');
+$template = GETPOST('template', 'nohtml');
$templatename = GETPOST('templatename', 'alpha');
$templateid = GETPOST('templateid', 'int');
@@ -473,7 +473,7 @@ if ($mode == 'template' && $user->admin) {
$langs->loadLangs(array("bills", "companies"));
foreach ($printer->tags as $key => $val) {
print '
';
- print '| <'.$key.'> | '.$langs->trans($val).' | ';
+ print '{'.$key.'} | '.$langs->trans($val).' | ';
print '
';
}
print '';
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index f8c33f9403a..6cab6580a5a 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -25,32 +25,32 @@
/*
* Tags for ticket template
*
- * Left align text
- * Center text
- * Right align text
- * Use font A of printer
- * Use font B of printer
- * Use font C of printer
- * Text Bold
- * Disable Text Bold
- * Text double height
- * Text double width
- * Text default height and width
- * Underline text
- * Disable underline text
- * Cut ticket completely
- * Cut ticket partially
- * Open cash drawer
- * Activate buzzer
- * Print barcode
- * Print logo stored on printer. Example : 32|32
- * Print logo stored on printer. Must be followed by logo code. For old printers.
- * Print object lines
- * Print object total tax
- * Print object local tax
- * Print object total
- * Print order lines for Printer
- * Print payment method
+ * {dol_align_left} Left align text
+ * {dol_align_center} Center text
+ * {dol_align_right} Right align text
+ * {dol_use_font_a} Use font A of printer
+ * {dol_use_font_b} Use font B of printer
+ * {dol_use_font_c} Use font C of printer
+ * {dol_bold} Text Bold
+ * {dol_bold_disabled} Disable Text Bold
+ * {dol_double_height} Text double height
+ * {dol_double_width} Text double width
+ * {dol_default_height_width} Text default height and width
+ * {dol_underline} Underline text
+ * {dol_underline_disabled} Disable underline text
+ * {dol_cut_paper_full} Cut ticket completely
+ * {dol_cut_paper_partial} Cut ticket partially
+ * {dol_open_drawer} Open cash drawer
+ * {dol_beep} Activate buzzer
+ * {dol_print_barcode} Print barcode
+ * {dol_print_logo} Print logo stored on printer. Example : 32|32
+ * {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers.
+ * {dol_print_object_lines} Print object lines
+ * {dol_print_object_tax} Print object total tax
+ * {dol_print_object_local_tax} Print object local tax
+ * {dol_print_object_total} Print object total
+ * {dol_print_order_lines} Print order lines for Printer
+ * {dol_print_payment} Print payment method
*
* Code which can be placed everywhere
* Replaced by date AAAA-MM-DD
@@ -569,45 +569,47 @@ class dolReceiptPrinter extends Printer
$ret = $this->loadTemplate($templateid);
// tags a remplacer par leur valeur avant de parser (dol_value_xxx)
- $this->template = str_replace('', $object->id, $this->template);
- $this->template = str_replace('', $object->ref, $this->template);
+ $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template);
+ $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template);
//$this->template = str_replace('', $object->points, $this->template);
- $this->template = str_replace('', dol_print_date($object->date, 'day'), $this->template);
- $this->template = str_replace('', dol_print_date($object->date, 'dayhour'), $this->template);
- $this->template = str_replace('', dol_print_date($object->date, '%Y'), $this->template);
- $this->template = str_replace('', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template);
- $this->template = str_replace('', dol_print_date($object->date, '%m'), $this->template);
- $this->template = str_replace('', dol_print_date($object->date, '%d'), $this->template);
- $this->template = str_replace('', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template);
+ $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template);
+ $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template);
+ $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template);
+ $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template);
+ $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('', $object->thirdparty->firstname, $this->template);
- $this->template = str_replace('', $object->thirdparty->lastname, $this->template);
- $this->template = str_replace('', $object->thirdparty->email, $this->template);
- $this->template = str_replace('', $object->thirdparty->phone, $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);
+ $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template);
+ $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template);
//$this->template = str_replace('', $object->thirdparty->mobile, $this->template);
- $this->template = str_replace('', $object->thirdparty->tva_intra, $this->template);
+ $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template);
//$this->template = str_replace('', $object->customer_account_balance, $this->template);
//$this->template = str_replace('', $object->customer_points, $this->template);
- $this->template = str_replace('', $mysoc->name, $this->template);
- $this->template = str_replace('', $mysoc->address, $this->template);
- $this->template = str_replace('', $mysoc->zip, $this->template);
- $this->template = str_replace('', $mysoc->town, $this->template);
- $this->template = str_replace('', $mysoc->country, $this->template);
- $this->template = str_replace('', $mysoc->idprof1, $this->template);
- $this->template = str_replace('', $mysoc->idprof2, $this->template);
- $this->template = str_replace('', $mysoc->idprof3, $this->template);
- $this->template = str_replace('', $mysoc->idprof4, $this->template);
- $this->template = str_replace('', $mysoc->idprof5, $this->template);
- $this->template = str_replace('', $mysoc->idprof6, $this->template);
- $this->template = str_replace('', $mysoc->tva_intra, $this->template);
- $this->template = str_replace('', $mysoc->capital, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template);
+ $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template);
- $this->template = str_replace('', $user->firstname, $this->template);
- $this->template = str_replace('', $user->lastname, $this->template);
- $this->template = str_replace('', $user->email, $this->template);
+ $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template);
+ $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template);
+ $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template);
// parse template
+ $this->template = str_replace("{", "<", $this->template);
+ $this->template = str_replace("}", ">", $this->template);
$p = xml_parser_create();
xml_parse_into_struct($p, $this->template, $vals, $index);
xml_parser_free($p);
diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php
index 818c090dcc0..32124dc8f5b 100644
--- a/htdocs/core/modules/modReceiptPrinter.class.php
+++ b/htdocs/core/modules/modReceiptPrinter.class.php
@@ -136,7 +136,7 @@ class modReceiptPrinter extends DolibarrModules
// Clean before activation
$this->remove($options);
- $templateexample = '\r\n\r\n\r\n\r\n\r\nFacture \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n';
+ $templateexample = '{dol_align_center}\r\n{dol_print_text}{dol_value_mysoc_name}\r\n{dol_print_text}{dol_value_mysoc_address}\r\n{dol_print_text}{dol_value_mysoc_zip}{dol_value_mysoc_town}\r\n{dol_line_feed}\r\n{dol_print_text}Facture {dol_value_object_ref}\r\n{dol_line_feed}\r\n{dol_align_left}\r\n{dol_print_object_lines}\r\n{dol_line_feed}\r\n{dol_print_object_tax}\r\n{dol_line_feed}\r\n{dol_print_object_total}\r\n{dol_line_feed}\r\n{dol_cut_paper_full}';
$sql = array(
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",