'."\n";
print '';
print '| '.$langs->trans("Name").' | ';
print ''.$langs->trans("Type").' | ';
print ''.$langs->trans("Profile").' | ';
print ''.$langs->trans("Parameters").' | ';
print ' | ';
- print ' | ';
- print ' | ';
print "
\n";
$ret = $printer->listprinters();
$nbofprinters = count($printer->listprinters);
@@ -290,8 +288,6 @@ if ($mode == 'config' && $user->admin) {
print ''.$printer->profileresprint.' | ';
print ' | ';
print ' | ';
- print ' | ';
- print ' | ';
print '';
} else {
print ''.$printer->listprinters[$line]['name'].' | ';
@@ -301,13 +297,13 @@ if ($mode == 'config' && $user->admin) {
// edit icon
print '';
print img_picto($langs->trans("Edit"), 'edit');
- print ' | ';
+ print '';
// delete icon
- print '';
+ print '';
print img_picto($langs->trans("Delete"), 'delete');
- print ' | ';
+ print '';
// test icon
- print '';
+ print '';
print img_picto($langs->trans("TestPrinter"), 'printer');
print ' | ';
print '';
@@ -323,8 +319,6 @@ if ($mode == 'config' && $user->admin) {
print ''.$langs->trans("Profile").' | ';
print ''.$langs->trans("Parameters").' | ';
print ' | ';
- print ' | ';
- print ' | ';
print "\n";
}
@@ -413,21 +407,19 @@ if ($mode == 'template' && $user->admin) {
print '';
print ' | ';
print ' | ';
- print ' | ';
- print ' | ';
} else {
print ''.$printer->listprinterstemplates[$line]['name'].' | ';
print ''.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).' | ';
// edit icon
print '';
print img_picto($langs->trans("Edit"), 'edit');
- print ' | ';
+ print '';
// delete icon
- print '';
+ print '';
print img_picto($langs->trans("Delete"), 'delete');
- print ' | ';
+ print '';
// test icon
- print '';
+ print '';
print img_picto($langs->trans("TestPrinterTemplate"), 'printer');
print ' | ';
}
@@ -442,8 +434,6 @@ if ($mode == 'template' && $user->admin) {
print '';
print ' | ';
print ' | ';
- print ' | ';
- print ' | ';
print '';
} else {
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index c18c6e0be9b..309f8fcc061 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -37,55 +37,65 @@
* Underline with double line
* Emphasized text
* Print in white on black
- * Print barcode
- * Print barcode customer id
* Ticket print width of 57mm
* Cut ticket completely
* Cut ticket partially
* Open cash drawer
* Activate buzzer
- *
- * Code which can be placed everywhere
+ * Print barcode
* Print QR Code
- * Print date AAAA-MM-DD
- * Print date and time AAAA-MM-DD HH:MM:SS
- * Print Year
- * Print month in letters (example : november)
- * Print month number
- * Print day number
- * Print day number
- * Print table number (for restaurant, bar...)
- * Print number of cutlery (for restaurant)
- * Print payment method
* 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 object number
- * Print object number after validation
- * Print customer firstname
- * Print customer name
- * Print customer mail
- * Print customer phone
- * Print customer mobile
- * Print customer skype
- * Print customer VAT number
- * Print customer account balance
- * Print vendor name
- * Print vendor firstname
- * Print vendor mail
- * Print customer points
- * Print number of points for this object
+ * Print object lines
+ * Print object total tax
+ * Print object local tax
+ * Print object total
+ * Print payment method
*
- * Conditional code at line start (if�then Print)
+ * Code which can be placed everywhere
+ * Replaced by date AAAA-MM-DD
+ * Replaced by date and time AAAA-MM-DD HH:MM:SS
+ * Replaced by Year
+ * Replaced by month in letters (example : november)
+ * Replaced by month number
+ * Replaced by day number
+ * Replaced by day number
+ * Replaced by table number (for restaurant, bar...)
+ * Replaced by number of cutlery (for restaurant)
+ * Replaced by object id
+ * Replaced by object ref
+ * Replaced by customer firstname
+ * Replaced by customer name
+ * Replaced by customer mail
+ * Replaced by customer phone
+ * Replaced by customer mobile
+ * Replaced by customer skype
+ * Replaced by customer VAT number
+ * Replaced by customer account balance
+ * Replaced by mysoc name
+ * Replaced by mysoc address
+ * Replaced by mysoc zip
+ * Replaced by mysoc town
+ * Replaced by mysoc country
+ * Replaced by mysoc idprof1
+ * Replaced by mysoc idprof2
+ * Replaced by mysoc idprof3
+ * Replaced by mysoc idprof4
+ * Replaced by mysoc idprof5
+ * Replaced by mysoc idprof6
+ * Replaced by vendor name
+ * Replaced by vendor firstname
+ * Replaced by vendor mail
+ * Replaced by customer points
+ * Replaced by number of points for this object
+ *
+ * Conditional code at line start (if then Print)
* Print the line IF a customer is affected to the object
* Print the line IF a vendor is affected to the object
* Print the line IF Happy Hour
- * Print the line IF object is validated
+ * Print the line IF object is validated
* Print the line IF customer points > 0
- * Print the line IF points of the object > 0
+ * Print the line IF points of the object > 0
* Print the line IF customer has vat number
* Print the line IF customer balance > 0
*
@@ -116,6 +126,9 @@ class dolReceiptPrinter extends Printer
*/
public $db;
+ /*
+ * @var string[] array of tags
+ */
public $tags;
public $printer;
public $template;
@@ -130,8 +143,6 @@ class dolReceiptPrinter extends Printer
*/
public $errors = array();
-
-
/**
* Constructor
*
@@ -142,6 +153,7 @@ class dolReceiptPrinter extends Printer
$this->db=$db;
$this->tags = array(
'dol_line_feed',
+ 'dol_line_feed_reverse',
'dol_align_left',
'dol_align_center',
'dol_align_right',
@@ -162,8 +174,6 @@ class dolReceiptPrinter extends Printer
'/dol_emphasized',
'dol_switch_colors',
'/dol_switch_colors',
- 'dol_print_barcode',
- 'dol_print_barcode_customer_id',
'dol_set_print_width_57',
'dol_cut_paper_full',
'dol_cut_paper_partial',
@@ -171,39 +181,52 @@ class dolReceiptPrinter extends Printer
//'dol_activate_buzzer',
'dol_print_text',
'dol_print_qrcode',
- 'dol_print_date',
- 'dol_print_date_time',
- 'dol_print_year',
- 'dol_print_month_letters',
- 'dol_print_month',
- 'dol_print_day',
- 'dol_print_day_letters',
- 'dol_print_table',
- 'dol_print_cutlery',
+ 'dol_print_barcode',
+ 'dol_value_date',
+ 'dol_value_date_time',
+ 'dol_value_year',
+ 'dol_value_month_letters',
+ 'dol_value_month',
+ 'dol_value_day',
+ 'dol_value_day_letters',
+ 'dol_value_table',
+ 'dol_value_cutlery',
'dol_print_payment',
'dol_print_logo',
'dol_print_logo_old',
- 'dol_print_object_id',
- 'dol_print_object_ref',
+ 'dol_value_object_id',
+ 'dol_value_object_ref',
'dol_print_object_lines',
'dol_print_object_tax',
'dol_print_object_local_tax',
'dol_print_object_total',
'dol_print_object_number',
- 'dol_print_object_number_unique',
- 'dol_print_customer_firstname',
- 'dol_print_customer_lastname',
- 'dol_print_customer_mail',
- 'dol_print_customer_phone',
- 'dol_print_customer_mobile',
- 'dol_print_customer_skype',
- 'dol_print_customer_tax_number',
- 'dol_print_customer_account_balance',
- 'dol_print_vendor_lastname',
- 'dol_print_vendor_firstname',
- 'dol_print_vendor_mail',
- 'dol_print_customer_points',
- 'dol_print_object_points',
+ 'dol_value_customer_firstname',
+ 'dol_value_customer_lastname',
+ 'dol_value_customer_mail',
+ 'dol_value_customer_phone',
+ 'dol_value_customer_mobile',
+ 'dol_value_customer_skype',
+ 'dol_value_customer_tax_number',
+ 'dol_value_customer_account_balance',
+ 'dol_value_mysoc_name',
+ 'dol_value_mysoc_address',
+ 'dol_value_mysoc_zip',
+ 'dol_value_mysoc_town',
+ 'dol_value_mysoc_country',
+ 'dol_value_mysoc_idprof1',
+ 'dol_value_mysoc_idprof2',
+ 'dol_value_mysoc_idprof3',
+ 'dol_value_mysoc_idprof4',
+ 'dol_value_mysoc_idprof5',
+ 'dol_value_mysoc_idprof6',
+ 'dol_value_mysoc_tva_intra',
+ 'dol_value_mysoc_capital',
+ 'dol_value_vendor_lastname',
+ 'dol_value_vendor_firstname',
+ 'dol_value_vendor_mail',
+ 'dol_value_customer_points',
+ 'dol_value_object_points',
'dol_print_if_customer',
'dol_print_if_vendor',
'dol_print_if_happy_hour',
@@ -328,7 +351,7 @@ class dolReceiptPrinter extends Printer
1 => $langs->trans('CONNECTOR_DUMMY'),
2 => $langs->trans('CONNECTOR_FILE_PRINT'),
3 => $langs->trans('CONNECTOR_NETWORK_PRINT'),
- 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT')
+ 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'),
);
$this->resprint = Form::selectarray($htmlname, $options, $selected);
@@ -353,7 +376,7 @@ class dolReceiptPrinter extends Printer
1 => $langs->trans('PROFILE_SIMPLE'),
2 => $langs->trans('PROFILE_EPOSTEP'),
3 => $langs->trans('PROFILE_P822D'),
- 4 => $langs->trans('PROFILE_STAR')
+ 4 => $langs->trans('PROFILE_STAR'),
);
$this->profileresprint = Form::selectarray($htmlname, $options, $selected);
@@ -502,6 +525,7 @@ class dolReceiptPrinter extends Printer
$this->printer->text("Hello World!\n");
$testStr = "1234567890";
$this->printer->barcode($testStr);
+ //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1);
$this->printer->text("Most simple example\n");
$this->printer->feed();
$this->printer->cut();
@@ -525,35 +549,48 @@ class dolReceiptPrinter extends Printer
*/
public function sendToPrinter($object, $templateid, $printerid)
{
- global $conf, $mysoc;
+ global $conf, $mysoc, $langs;
$error = 0;
$ret = $this->loadTemplate($templateid);
- // tags a remplacer par leur valeur avant de parser
- $this->template = str_replace('', $object->id, $this->template);
- $this->template = str_replace('', $object->ref, $this->template);
- $this->template = str_replace('', $object->customer_firstname, $this->template);
- $this->template = str_replace('', $object->customer_lastname, $this->template);
- $this->template = str_replace('', $object->customer_mail, $this->template);
- $this->template = str_replace('', $object->customer_phone, $this->template);
- $this->template = str_replace('', $object->customer_mobile, $this->template);
- $this->template = str_replace('', $object->customer_skype, $this->template);
- $this->template = str_replace('', $object->customer_tax_number, $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('', $object->object_points, $this->template);
- $this->template = str_replace('', $object->vendor_firstname, $this->template);
- $this->template = str_replace('', $object->vendor_lastname, $this->template);
- $this->template = str_replace('', $object->vendor_mail, $this->template);
- $this->template = str_replace('', $object->date, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->date_time, $this->template);
- $this->template = str_replace('', $object->table, $this->template);
- $this->template = str_replace('', $object->cutlery, $this->template);
+ // 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('', $object->points, $this->template);
+ $this->template = str_replace('', $object->customer_firstname, $this->template);
+ $this->template = str_replace('', $object->customer_lastname, $this->template);
+ $this->template = str_replace('', $object->customer_mail, $this->template);
+ $this->template = str_replace('', $object->customer_phone, $this->template);
+ $this->template = str_replace('', $object->customer_mobile, $this->template);
+ $this->template = str_replace('', $object->customer_skype, $this->template);
+ $this->template = str_replace('', $object->customer_tax_number, $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('', $object->vendor_firstname, $this->template);
+ $this->template = str_replace('', $object->vendor_lastname, $this->template);
+ $this->template = str_replace('', $object->vendor_mail, $this->template);
+ $this->template = str_replace('', $object->date, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->date_time, $this->template);
+ $this->template = str_replace('', $object->table, $this->template);
+ $this->template = str_replace('', $object->cutlery, $this->template);
// parse template
$p = xml_parser_create();
@@ -563,7 +600,7 @@ class dolReceiptPrinter extends Printer
//print ''.print_r($vals, true).'
';
// print ticket
$level = 0;
- $nbcaractbyline = 47;
+ $nbcharactbyline = 48;
$ret = $this->initPrinter($printerid);
if ($ret>0) {
setEventMessages($this->error, $this->errors, 'errors');
@@ -577,15 +614,45 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_PRINT_OBJECT_LINES':
foreach ($object->lines as $line) {
- $spacestoadd = $nbcaractbyline - strlen($line->ref) - strlen(price($line->total_ttc, 'MT'));
+ //var_dump($line);
+ $spacestoadd = $nbcharactbyline - strlen($line->ref)- strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
- $this->printer->text($line->ref.$spaces.price($line->total_ttc, 'MT')."\n");
- //var_dump($line->ref);
+ $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
+ $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n");
}
break;
+ case 'DOL_PRINT_OBJECT_TAX':
+ //var_dump($object);
+ $vatarray = array();
+ foreach ($object->lines as $line) {
+ $vatarray[$line->tva_tx] += $line->total_tva;
+ }
+ foreach($vatarray as $vatkey => $vatvalue) {
+ $spacestoadd = $nbcharactbyline - strlen($vatkey)- 12;
+ $spaces = str_repeat(' ', $spacestoadd);
+ $this->printer->text($spaces. $vatkey.'% '.str_pad(price($vatvalue, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
+ }
+ break;
+ case 'DOL_PRINT_OBJECT_TOTAL':
+ $title = $langs->trans('TotalHT');
+ $spacestoadd = $nbcharactbyline - strlen($title) - 10;
+ $spaces = str_repeat(' ', $spacestoadd);
+ $this->printer->text($title.$spaces.str_pad(price($object->total_ht, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
+ $title = $langs->trans('TotalVAT');
+ $spacestoadd = $nbcharactbyline - strlen($title) - 10;
+ $spaces = str_repeat(' ', $spacestoadd);
+ $this->printer->text($title.$spaces.str_pad(price($object->total_tva, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
+ $title = $langs->trans('TotalTTC');
+ $spacestoadd = $nbcharactbyline - strlen($title) - 10;
+ $spaces = str_repeat(' ', $spacestoadd);
+ $this->printer->text($title.$spaces.str_pad(price($object->total_ttc, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
+ break;
case 'DOL_LINE_FEED':
$this->printer->feed();
break;
+ case 'DOL_LINE_FEED_REVERSE':
+ $this->printer->feedReverse();
+ break;
case 'DOL_ALIGN_CENTER':
$this->printer->setJustification(Printer::JUSTIFY_CENTER);
break;
@@ -603,22 +670,22 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_PRINT_BARCODE':
// $vals[$tplline]['value'] -> barcode($content, $type)
- $this->printer->barcode($object->barcode);
+ // var_dump($vals[$tplline]['value']);
+ try {
+ $this->printer->barcode($vals[$tplline]['value']);
+ } catch (Exception $e) {
+ $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value'];
+ $error++;
+ }
break;
case 'DOL_PRINT_LOGO':
- // $vals[$tplline]['value'] -> barcode($content, $type)
$img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo);
$this->printer->graphics($img);
break;
case 'DOL_PRINT_LOGO_OLD':
- // $vals[$tplline]['value'] -> barcode($content, $type)
$img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo);
$this->printer->bitImage($img);
break;
- case 'DOL_PRINT_BARCODE_CUSTOMER_ID':
- // $vals[$tplline]['value'] -> barcode($content, $type)
- $this->printer->barcode($object->customer_id);
- break;
case 'DOL_PRINT_QRCODE':
// $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model)
$this->printer->qrcode($vals[$tplline]['value']);
@@ -631,19 +698,16 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_USE_FONT_A':
$this->printer->setFont(Printer::FONT_A);
- $this->printer->text($vals[$tplline]['value']);
break;
case 'DOL_USE_FONT_B':
$this->printer->setFont(Printer::FONT_B);
- $this->printer->text($vals[$tplline]['value']);
break;
case 'DOL_USE_FONT_C':
$this->printer->setFont(Printer::FONT_C);
- $this->printer->text($vals[$tplline]['value']);
break;
default:
+ $this->printer->text($vals[$tplline]['tag']);
$this->printer->text($vals[$tplline]['value']);
- $html.= nl2br($vals[$tplline]['value']);
$this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>';
$error++;
break;
diff --git a/htdocs/includes/mike42/escpos-php/src/Mike42/Escpos/PrintConnectors/ApiPrintConnector.php b/htdocs/includes/mike42/escpos-php/src/Mike42/Escpos/PrintConnectors/ApiPrintConnector.php
index 893a4858c8e..80e8c1302af 100644
--- a/htdocs/includes/mike42/escpos-php/src/Mike42/Escpos/PrintConnectors/ApiPrintConnector.php
+++ b/htdocs/includes/mike42/escpos-php/src/Mike42/Escpos/PrintConnectors/ApiPrintConnector.php
@@ -30,9 +30,9 @@ class ApiPrintConnector implements PrintConnector
/**
* Construct new connector
*
- * @param string $host
- * @param string $printerId
- * @param string $apiToken
+ * @param string $host Host
+ * @param string $printerId Printer Id
+ * @param string $apiToken Api Token
*/
public function __construct($host, $printerId, $apiToken)
{
@@ -57,6 +57,7 @@ class ApiPrintConnector implements PrintConnector
/**
* Finish using this print connector (close file, socket, send
* accumulated output, etc).
+ * @return void
*/
public function finalize()
{
@@ -94,6 +95,7 @@ class ApiPrintConnector implements PrintConnector
* Write data to the print connector.
*
* @param string $data The data to write
+ * @return void
*/
public function write($data)
{
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index de14a5621a2..4d8afaad9aa 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2093,7 +2093,6 @@ class Product extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
-
unset($this->oldcopy);
if ($this->db->num_rows($resql) > 0) {
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index f0bedbcd7f5..e1940864dd0 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -269,7 +269,6 @@ if (empty($reshook))
$resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $object->product_fourn_price_id);
// Insert a new extrafields row, if none exists
if ($db->num_rows($resql) != 1) {
-
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields (fk_object, ";
foreach ($extrafield_values as $key => $value) {
$sql .= str_replace('options_', '', $key) . ', ';
@@ -291,7 +290,7 @@ if (empty($reshook))
// Execute the sql command from above
$db->query($sql);
-
+
$newprice = price2num(GETPOST("price", "alpha"));
if ($conf->multicurrency->enabled)