forked from Wavyzz/dolibarr
FIX Debug setup of module TakePOS
This commit is contained in:
@@ -460,7 +460,6 @@ class dolReceiptPrinter extends Printer
|
||||
*/
|
||||
public function updatePrinter($name, $type, $profile, $parameter, $printerid)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix()."printer_receipt";
|
||||
@@ -625,6 +624,7 @@ class dolReceiptPrinter extends Printer
|
||||
|
||||
$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);
|
||||
@@ -706,6 +706,7 @@ class dolReceiptPrinter extends Printer
|
||||
// print ticket
|
||||
$nbcharactbyline = getDolGlobalInt('RECEIPT_PRINTER_NB_CHARACT_BY_LINE', 48);
|
||||
$ret = $this->initPrinter($printerid);
|
||||
|
||||
if ($ret > 0) {
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
} else {
|
||||
@@ -961,22 +962,23 @@ class dolReceiptPrinter extends Printer
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to load Template
|
||||
* Function to load Template into $this->template
|
||||
*
|
||||
* @param int $templateid Template id
|
||||
* @return int 0 if OK; >0 if KO
|
||||
*/
|
||||
public function loadTemplate($templateid)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT template";
|
||||
$sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
|
||||
$sql .= " WHERE rowid = ".((int) $templateid);
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$sql .= " AND entity IN (".getEntity('printer_receipt_template').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_array($resql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror;
|
||||
@@ -985,7 +987,7 @@ class dolReceiptPrinter extends Printer
|
||||
$error++;
|
||||
$this->errors[] = 'TemplateDontExist';
|
||||
} else {
|
||||
$this->template = $obj['0'];
|
||||
$this->template = $obj->template;
|
||||
}
|
||||
|
||||
return $error;
|
||||
@@ -993,24 +995,25 @@ class dolReceiptPrinter extends Printer
|
||||
|
||||
|
||||
/**
|
||||
* Function Init Printer
|
||||
* Function Init Printer into $this->printer
|
||||
*
|
||||
* @param int $printerid Printer id
|
||||
* @return void|int 0 if OK; >0 if KO
|
||||
*/
|
||||
public function initPrinter($printerid)
|
||||
{
|
||||
global $conf;
|
||||
if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
|
||||
$this->connector = new DummyPrintConnector();
|
||||
$this->printer = new Printer($this->connector, $this->profile);
|
||||
return;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
$sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
|
||||
$sql .= " FROM ".$this->db->prefix()."printer_receipt";
|
||||
$sql .= " WHERE rowid = ".((int) $printerid);
|
||||
$sql .= " AND entity = ".((int) $conf->entity);
|
||||
$sql .= " AND entity IN (".getEntity('printer_receipt').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_array($resql);
|
||||
|
||||
@@ -131,11 +131,17 @@ class modReceiptPrinter extends DolibarrModules
|
||||
*/
|
||||
public function init($options = '')
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
$result = $this->_load_tables('/install/mysql/', 'receiptprinter');
|
||||
if ($result < 0) {
|
||||
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
||||
}
|
||||
|
||||
// Clean before activation
|
||||
$this->remove($options);
|
||||
|
||||
// @TODO Move create/delete into sql file and insert into data file
|
||||
$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;",
|
||||
@@ -143,6 +149,7 @@ class modReceiptPrinter extends DolibarrModules
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$this->db->escape($langs->trans('Example'))."';",
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$this->db->escape($langs->trans('Example'))."', '".$this->db->escape($templateexample)."', 1);",
|
||||
);
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,10 @@ ControlCashOpening=Open the "Control cash box" popup when opening the POS
|
||||
CloseCashFence=Close cash box control
|
||||
CashReport=Cash report
|
||||
MainPrinterToUse=Main printer to use
|
||||
MainPrinterToUseMore=empty means the browser printer system
|
||||
OrderPrinterToUse=Order printer to use
|
||||
MainTemplateToUse=Main template to use
|
||||
MainTemplateToUseMore=when not using browser printing system
|
||||
OrderTemplateToUse=Order template to use
|
||||
BarRestaurant=Bar Restaurant
|
||||
AutoOrder=Order by the customer himself
|
||||
|
||||
@@ -126,7 +126,7 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
|
||||
print '<td>'.$langs->trans("Parameters").'</td><td class="">'.$langs->trans("Value").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if (getDolGlobalString('TAKEPOS_PRINT_METHOD') != "browser") { // Why this ?
|
||||
//if (getDolGlobalString('TAKEPOS_PRINT_METHOD') != "browser") { // Why this ?
|
||||
print '<tr class="oddeven value"><td>';
|
||||
print $langs->trans("OrderPrinters").' (<a href="'.DOL_URL_ROOT.'/takepos/admin/orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>)';
|
||||
print '</td>';
|
||||
@@ -135,6 +135,7 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
|
||||
//print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
|
||||
print '<tr class="oddeven value"><td>';
|
||||
print $langs->trans("OrderNotes");
|
||||
print '</td>';
|
||||
@@ -142,7 +143,8 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
|
||||
print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0);
|
||||
//print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1);
|
||||
print '</td></tr>';
|
||||
} else {
|
||||
}
|
||||
/*else {
|
||||
print '<tr class="oddeven value"><td>';
|
||||
print $langs->trans("OrderPrinters");
|
||||
print '</td>';
|
||||
@@ -156,7 +158,7 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
|
||||
print '<td class="">';
|
||||
print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
}*/
|
||||
|
||||
print '<tr class="oddeven value"><td>';
|
||||
print $langs->trans("BasicPhoneLayout");
|
||||
|
||||
@@ -302,21 +302,23 @@ if (isModEnabled('stock')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
|
||||
if (isModEnabled('receiptprinter')) {
|
||||
// Select printer to use with terminal
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
|
||||
$printer = new dolReceiptPrinter($db);
|
||||
if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
|
||||
|
||||
$printer->listprinters();
|
||||
$printers = array();
|
||||
foreach ($printer->listprinters as $key => $value) {
|
||||
$printers[$value['rowid']] = $value['name'];
|
||||
}
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse").'</td>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse");
|
||||
print ' <span class="opacitymedium">('.$langs->trans("MainPrinterToUseMore").')</span>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
|
||||
print '</td></tr>';
|
||||
if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
|
||||
if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1</td>';
|
||||
print '<td>';
|
||||
print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
|
||||
@@ -331,12 +333,19 @@ if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlob
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if (isModEnabled('receiptprinter') || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
|
||||
// Select printer to use with terminal
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
|
||||
$printer = new dolReceiptPrinter($db);
|
||||
$printer->listPrintersTemplates();
|
||||
$templates = array();
|
||||
foreach ($printer->listprinterstemplates as $key => $value) {
|
||||
$templates[$value['rowid']] = $value['name'];
|
||||
}
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse").' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse");
|
||||
print ' <span class="opacitymedium">('.$langs->trans("MainTemplateToUseMore").')</span>';
|
||||
print ' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
|
||||
print '<td>';
|
||||
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal), 1);
|
||||
print '</td></tr>';
|
||||
|
||||
Reference in New Issue
Block a user