From 9e59a9aa8cbf2228d704f13ee9b2823bc6c3c7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Nov 2020 18:39:50 +0100 Subject: [PATCH 1/6] Create index.html --- htdocs/admin/dolistore/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/admin/dolistore/index.html diff --git a/htdocs/admin/dolistore/index.html b/htdocs/admin/dolistore/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/admin/dolistore/index.html @@ -0,0 +1 @@ + From 9c7d698cc729f1792da00a8630e34ae2427092aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Nov 2020 18:40:34 +0100 Subject: [PATCH 2/6] Create index.html --- htdocs/admin/dolistore/class/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/admin/dolistore/class/index.html diff --git a/htdocs/admin/dolistore/class/index.html b/htdocs/admin/dolistore/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/admin/dolistore/class/index.html @@ -0,0 +1 @@ + From caa82a1e2f6e5ba7db9217ee43cf56c8e9ac873d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Nov 2020 18:43:52 +0100 Subject: [PATCH 3/6] Update PSWebServiceLibrary.class.php --- .../dolistore/class/PSWebServiceLibrary.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 00e8672f6d5..abbb3bbc4ed 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -221,7 +221,9 @@ class PrestaShopWebservice * Load XML from string. Can throw exception * * @param string $response String from a CURL response - * @return SimpleXMLElement status_code, response + * @return SimpleXMLElement|boolean status_code, response + * + * @throw PrestaShopWebserviceException */ protected function parseXML($response) { @@ -251,6 +253,8 @@ class PrestaShopWebservice * * @param array $options Options * @return SimpleXMLElement status_code, response + * + * @throw PrestaShopWebserviceException */ public function add($options) { @@ -300,7 +304,9 @@ class PrestaShopWebservice * ?> * * @param array $options Array representing resource to get. - * @return SimpleXMLElement status_code, response + * @return SimpleXMLElement|boolean status_code, response + * + * @throw PrestaShopWebserviceException */ public function get($options) { @@ -336,6 +342,8 @@ class PrestaShopWebservice * * @param array $options Array representing resource for head request. * @return SimpleXMLElement status_code, response + * + * @throw PrestaShopWebserviceException */ public function head($options) { @@ -372,6 +380,8 @@ class PrestaShopWebservice * * @param array $options Array representing resource to edit. * @return SimpleXMLElement status_code, response + * + * @throw PrestaShopWebserviceException */ public function edit($options) { From 64c48a246a8327186a1a1f90051aec11ba00dc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Nov 2020 18:53:26 +0100 Subject: [PATCH 4/6] The method PrestaShopWebservice::... is not static, but was called statically --- .../class/PSWebServiceLibrary.class.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index abbb3bbc4ed..201191d1262 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -272,10 +272,10 @@ class PrestaShopWebservice } else { throw new PrestaShopWebserviceException('Bad parameters given'); } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); + $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); - self::checkStatusCode($request['status_code']); - return self::parseXML($request['response']); + $this->checkStatusCode($request['status_code']); + return $this->parseXML($request['response']); } /** @@ -332,9 +332,9 @@ class PrestaShopWebservice throw new PrestaShopWebserviceException('Bad parameters given '); } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); - self::checkStatusCode($request['status_code']); // check the response validity - return self::parseXML($request['response']); + $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); + $this->checkStatusCode($request['status_code']); // check the response validity + return $this->parseXML($request['response']); } /** @@ -366,8 +366,8 @@ class PrestaShopWebservice } else { throw new PrestaShopWebserviceException('Bad parameters given'); } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true)); - self::checkStatusCode($request['status_code']); // check the response validity + $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true)); + $this->checkStatusCode($request['status_code']); // check the response validity return $request['header']; } /** @@ -400,9 +400,9 @@ class PrestaShopWebservice throw new PrestaShopWebserviceException('Bad parameters given'); } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); - self::checkStatusCode($request['status_code']); // check the response validity - return self::parseXML($request['response']); + $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); + $this->checkStatusCode($request['status_code']); // check the response validity + return $this->parseXML($request['response']); } } From a5ffac1935c3a6cb882b2a9417b89a6f97535024 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Thu, 12 Nov 2020 22:31:32 +0100 Subject: [PATCH 5/6] Compatibility with new TakePOS connector --- htdocs/takepos/admin/terminal.php | 4 +- htdocs/takepos/invoice.php | 81 +++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 8ae37c2b8f7..870feb71778 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -41,7 +41,7 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) // Security check if (!$user->admin) accessforbidden(); -$langs->loadLangs(array("admin", "cashdesk", "printing")); +$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter")); global $db; @@ -255,7 +255,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TA foreach ($printer->listprinterstemplates as $key => $value) { $templates[$value['rowid']] = $value['name']; } - print ''.$langs->trans("MainTemplateToUse").''; + print ''.$langs->trans("MainTemplateToUse").' ('.$langs->trans("SetupReceiptTemplate").')'; print ''; print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1); print ''; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index fc1e690e263..1254a5ecf7c 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -672,7 +672,7 @@ if ($action == "updatereduction") if ($action == "order" and $placeid != 0) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); } @@ -703,10 +703,13 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer1 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 1; + echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); @@ -731,10 +734,13 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer2 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 2; + echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); @@ -759,10 +765,13 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer3 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 3; + echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); @@ -841,25 +850,59 @@ $(document).ready(function() { - $.ajax({ - type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', - data: '' - }); - global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + ?> + $.ajax({ + type: "POST", + url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php', + data: 'invoice='+orderprinter1esc + }); + + $.ajax({ + type: "POST", + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + data: '' + }); + - $.ajax({ - type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', - data: '' - }); + if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + ?> + $.ajax({ + type: "POST", + url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2', + data: 'invoice='+orderprinter2esc + }); + + $.ajax({ + type: "POST", + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', + data: '' + }); global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + ?> + $.ajax({ + type: "POST", + url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3', + data: 'invoice='+orderprinter3esc + }); + Date: Thu, 12 Nov 2020 22:50:46 +0100 Subject: [PATCH 6/6] Fix travis --- htdocs/takepos/invoice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1254a5ecf7c..9c4a5320c58 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -859,7 +859,7 @@ if ($action == "order" and $order_receipt_printer1 != "") { }); $.ajax({ type: "POST", @@ -881,7 +881,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { }); $.ajax({ type: "POST", @@ -889,7 +889,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { data: '' }); -