diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index 794e7c83664..7e766ee1972 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -76,7 +76,7 @@ if ($action == 'addprinter' && $user->admin)
if (! $error)
{
- $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), $parameter);
+ $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
if ($result > 0) $error++;
if (! $error)
@@ -132,7 +132,7 @@ if ($action == 'updateprinter' && $user->admin)
if (! $error)
{
- $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), $parameter, $printerid);
+ $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
if ($result > 0) $error++;
if (! $error)
@@ -235,6 +235,7 @@ if ($mode == 'config' && $user->admin)
print '
';
print '| '.$langs->trans("Name").' | ';
print ''.$langs->trans("Type").' | ';
+ print ''.$langs->trans("Profile").' | ';
print ''.$langs->trans("Parameters").' | ';
print ' | ';
print ' | ';
@@ -252,6 +253,8 @@ if ($mode == 'config' && $user->admin)
print ' | ';
$ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']);
print ''.$printer->resprint.' | ';
+ $ret = $printer->selectProfilePrinter($printer->listprinters[$line]['fk_profile']);
+ print ''.$printer->profileresprint.' | ';
print ' | ';
print ' | ';
print ' | ';
@@ -259,27 +262,8 @@ if ($mode == 'config' && $user->admin)
print '
';
} else {
print ''.$printer->listprinters[$line]['name'].' | ';
- switch ($printer->listprinters[$line]['fk_type']) {
- case 1:
- $connector = 'CONNECTOR_DUMMY';
- break;
- case 2:
- $connector = 'CONNECTOR_FILE_PRINT';
- break;
- case 3:
- $connector = 'CONNECTOR_NETWORK_PRINT';
- break;
- case 4:
- $connector = 'CONNECTOR_WINDOWS_PRINT';
- break;
- case 5:
- $connector = 'CONNECTOR_JAVA';
- break;
- default:
- $connector = 'CONNECTOR_UNKNOWN';
- break;
- }
- print ''.$langs->trans($connector).' | ';
+ print ''.$langs->trans($printer->listprinters[$line]['fk_type_name']).' | ';
+ print ''.$langs->trans($printer->listprinters[$line]['fk_profile_name']).' | ';
print ''.$printer->listprinters[$line]['parameter'].' | ';
// edit icon
print '';
@@ -311,6 +295,8 @@ if ($mode == 'config' && $user->admin)
print ' | | ';
$ret = $printer->selectTypePrinter();
print ''.$printer->resprint.' | ';
+ $ret = $printer->selectProfilePrinter();
+ print ''.$printer->profileresprint.' | ';
print ' | ';
print ' | ';
print ' | ';
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index 064cf130426..78c3a1a4651 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -74,8 +74,8 @@
* Print customer skype
* Print customer VAT number
* Print customer account balance
- * Print vendor name
- * Print vendor firstname
+ * Print vendor name
+ * Print vendor firstname
* Print vendor mail
* Print customer points
* Print number of points for this order
@@ -204,14 +204,52 @@ class dolReceiptPrinter extends Escpos
global $conf;
$error = 0;
$line = 0;
- $sql = 'SELECT rowid, name, fk_type, parameter';
+ $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE entity = '.$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($line < $num) {
- $obj[] = $this->db->fetch_array($resql);
+ $row = $this->db->fetch_array($resql);
+ switch ($row['fk_type']) {
+ case 1:
+ $row['fk_type_name'] = 'CONNECTOR_DUMMY';
+ break;
+ case 2:
+ $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT';
+ break;
+ case 3:
+ $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT';
+ break;
+ case 4:
+ $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT';
+ break;
+ case 5:
+ $row['fk_type_name'] = 'CONNECTOR_JAVA';
+ break;
+ default:
+ $row['fk_type_name'] = 'CONNECTOR_UNKNOWN';
+ break;
+ }
+ switch ($row['fk_profile']) {
+ case 0:
+ $row['fk_profile_name'] = 'DEFAULT';
+ break;
+ case 1:
+ $row['fk_profile_name'] = 'SIMPLE';
+ break;
+ case 2:
+ $row['fk_profile_name'] = 'EPOSTEP';
+ break;
+ case 3:
+ $row['fk_profile_name'] = 'P822D';
+ break;
+ default:
+ $row['fk_profile_name'] = 'STAR';
+ break;
+ }
+ $obj[] = $row;
$line++;
}
} else {
@@ -275,21 +313,47 @@ class dolReceiptPrinter extends Escpos
return $error;
}
+
+ /**
+ * Form to Select Profile printer
+ *
+ * @param string $selected Id printer profile pre-selected
+ * @param string $htmlname select html name
+ * @return int 0 if OK; >0 if KO
+ */
+ function selectProfilePrinter($selected='', $htmlname='printerprofileid')
+ {
+ global $langs;
+ $error = 0;
+ $html = '';
+
+ $this->profileresprint = $html;
+ return $error;
+ }
+
+
/**
* Function to Add a printer in db
*
* @param string $name Printer name
* @param int $type Printer type
+ * @param int $profile Printer profile
* @param string $parameter Printer parameter
* @return int 0 if OK; >0 if KO
*/
- function AddPrinter($name, $type, $parameter)
+ function AddPrinter($name, $type, $profile, $parameter)
{
global $conf;
$error = 0;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt';
- $sql.= ' (name, fk_type, parameter, entity)';
- $sql.= ' VALUES ("'.$this->db->escape($name).'", '.$type.', "'.$this->db->escape($parameter).'", '.$conf->entity.')';
+ $sql.= ' (name, fk_type, fk_profile, parameter, entity)';
+ $sql.= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')';
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
@@ -303,17 +367,19 @@ class dolReceiptPrinter extends Escpos
*
* @param string $name Printer name
* @param int $type Printer type
+ * @param int $profile Printer profile
* @param string $parameter Printer parameter
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
- function UpdatePrinter($name, $type, $parameter, $printerid)
+ function UpdatePrinter($name, $type, $profile, $parameter, $printerid)
{
global $conf;
$error = 0;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' SET name="'.$this->db->escape($name).'"';
$sql.= ', fk_type='.$type;
+ $sql.= ', fk_profile='.$profile;
$sql.= ', parameter="'.$this->db->escape($parameter).'"';
$sql.= ' WHERE rowid='.$printerid;
$resql = $this->db->query($sql);
@@ -427,9 +493,20 @@ class dolReceiptPrinter extends Escpos
$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->order_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);
// parse template
$p = xml_parser_create();
@@ -463,10 +540,18 @@ class dolReceiptPrinter extends Escpos
$this->printer->pulse();
$html.= ' ϟ'.nl2br($vals[$line]['value']);
break;
+ case 'DOL_ACTIVATE_BUZZER':
+ //$this->printer->buzzer();
+ $html.= ' ♫'.nl2br($vals[$line]['value']);
+ break;
case 'DOL_PRINT_BARCODE':
// $vals[$line]['value'] -> barcode($content, $type)
$this->printer->barcode($object->barcode);
break;
+ case 'DOL_PRINT_BARCODE_CUSTOMER_ID':
+ // $vals[$line]['value'] -> barcode($content, $type)
+ $this->printer->barcode($object->customer_id);
+ break;
case 'DOL_PRINT_QRCODE':
// $vals[$line]['value'] -> qrCode($content, $ec, $size, $model)
$this->printer->qrcode($vals[$line]['value']);
@@ -553,7 +638,7 @@ class dolReceiptPrinter extends Escpos
{
global $conf;
$error=0;
- $sql = 'SELECT rowid, name, fk_type, parameter';
+ $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE rowid = '.$printerid;
$sql.= ' AND entity = '.$conf->entity;
@@ -573,7 +658,7 @@ class dolReceiptPrinter extends Escpos
try {
switch ($obj['fk_type']) {
case 1:
- require_once DOL_DOCUMENT_ROOT .'/includes/escpos/src/DummyPrintConnector.php';
+ require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/src/DummyPrintConnector.php';
$this->connector = new DummyPrintConnector();
break;
case 2:
diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php
index 975226819fb..1cee882f0ec 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);
$sql = array(
- "CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid int(11) NOT NULL AUTO_INCREMENT, name varchar(128), fk_type int(11), parameter varchar(128), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
+ "CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid int(11) NOT NULL AUTO_INCREMENT, name varchar(128), fk_type int(11), fk_profile int(11), parameter varchar(128), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
"CREATE TABLE IF NOT EXISTS llx_printer_receipt_template (rowid int(11) NOT NULL AUTO_INCREMENT, name varchar(128), template text, entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
);
return $this->_init($sql,$options);