From ebd1b49d2a0bee8b5f963ebf47343893a02f350c Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Sun, 29 Aug 2021 22:41:22 +0800 Subject: [PATCH 1/6] Fix undef 4-1 PHP8 warnings --- htdocs/takepos/invoice.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 96b06d09271..d94fdb9e181 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -152,19 +152,19 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); + $ret = $invoice->fetch('', '(PROV-POS'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' .'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; } -$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $soc = new Societe($db); if ($invoice->socid > 0) { $soc->fetch($invoice->socid); } else { - $soc->fetch($conf->global->$constforcompanyid); + $soc->fetch(getDolGlobalString("$constforcompanyid")); } @@ -477,10 +477,10 @@ if ($action == 'history' || $action == 'creditnote') { } if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = $conf->global->$constforcompanyid; + $invoice->socid = getDolGlobalString("$constforcompanyid"); $invoice->date = dol_now(); $invoice->module_source = 'takepos'; - $invoice->pos_source = $_SESSION["takeposterminal"]; + $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; if ($invoice->socid <= 0) { @@ -549,7 +549,7 @@ if ($action == "addline") { } if ($idoflineadded <= 0) { $invoice->fetch_thirdparty(); - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, '', '', 0, 100, '', null, 0); + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { $CUSTOMER_DISPLAY_line1 = $prod->label; $CUSTOMER_DISPLAY_line2 = price($price_ttc); @@ -930,7 +930,7 @@ $(document).ready(function() { } global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -951,7 +951,7 @@ if ($action == "order" and $order_receipt_printer1 != "") { } } -if ($action == "order" and $order_receipt_printer2 != "") { +if ($action == "order" and !empty($order_receipt_printer2)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -972,7 +972,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { } } -if ($action == "order" and $order_receipt_printer3 != "") { +if ($action == "order" and !empty($order_receipt_printer3)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -992,7 +992,7 @@ if ($action == "search" || $action == "valid") { } -if ($action == "temp" and $ticket_printer1 != "") { +if ($action == "temp" and !empty($ticket_printer1)) { ?> $.ajax({ type: "POST", @@ -1039,7 +1039,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: '/printer/index.php', @@ -1053,7 +1053,7 @@ function DolibarrTakeposPrinting(id) { $.ajax({ type: "GET", data: { token: '' }, - url: "" + id, + url: "" + id, }); } @@ -1086,7 +1086,7 @@ $( document ).ready(function() { $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture"; if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { // By default, only invoices with a ref not already defined can in list of open invoice we can edit. - $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION["takeposterminal"])."-0%' AND entity IN (".getEntity('invoice').")"; + $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape( isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; } else { // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; @@ -1127,12 +1127,12 @@ $( document ).ready(function() { $s = ''; - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; + if (!empty($conf->stock->enabled) && getDolGlobalString("$constantforkey") != "1") { $s = ''; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; $warehouse = new Entrepot($db); - $warehouse->fetch($conf->global->$constantforkey); + $warehouse->fetch(getDolGlobalString("$constantforkey")); $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; $s .= '
'; } From b242387c4353f9634786a995157608cb27ae4b67 Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Sun, 29 Aug 2021 22:46:39 +0800 Subject: [PATCH 2/6] Fix undef4-2 PHP8 warnings --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a54797323a3..cf7aa02f0f5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -253,7 +253,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { +if (getDolGlobalString("INVOICE_USE_SITUATION") && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } // Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields) From 6417d3ddf73d9b256da32c7dd5c074e8aa5f1406 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Aug 2021 14:48:25 +0000 Subject: [PATCH 3/6] Fixing style errors. --- 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 d94fdb9e181..45c266b5816 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1039,7 +1039,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: '/printer/index.php', @@ -1053,7 +1053,7 @@ function DolibarrTakeposPrinting(id) { $.ajax({ type: "GET", data: { token: '' }, - url: "" + id, + url: "" + id, }); } @@ -1086,7 +1086,7 @@ $( document ).ready(function() { $sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture"; if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { // By default, only invoices with a ref not already defined can in list of open invoice we can edit. - $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape( isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; + $sql .= " WHERE ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; } else { // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; From 1061a9f9fe6b5e65cc2f448d25e43875ccb20ee6 Mon Sep 17 00:00:00 2001 From: Gurvan Kervern Date: Fri, 3 Sep 2021 01:27:43 +0800 Subject: [PATCH 4/6] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 45c266b5816..a3e86a64ebd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -152,7 +152,7 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' .'-'.$place.')'); + $ret = $invoice->fetch('', '(PROV-POS'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '') .'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; From 7ca855d192ce26012feb2a4b76406452ae66bb52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Sep 2021 21:14:01 +0200 Subject: [PATCH 5/6] Update invoice.php --- htdocs/takepos/invoice.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a3e86a64ebd..5a95128c090 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -930,7 +930,7 @@ $(document).ready(function() { } global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -951,7 +951,7 @@ if ($action == "order" and !empty($order_receipt_printer1)) { } } -if ($action == "order" and !empty($order_receipt_printer2)) { +if ($action == "order" && !empty($order_receipt_printer2)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -972,7 +972,7 @@ if ($action == "order" and !empty($order_receipt_printer2)) { } } -if ($action == "order" and !empty($order_receipt_printer3)) { +if ($action == "order" && !empty($order_receipt_printer3)) { if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ @@ -992,7 +992,7 @@ if ($action == "search" || $action == "valid") { } -if ($action == "temp" and !empty($ticket_printer1)) { +if ($action == "temp" && !empty($ticket_printer1)) { ?> $.ajax({ type: "POST", @@ -1127,10 +1127,10 @@ $( document ).ready(function() { $s = ''; - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); if (!empty($conf->stock->enabled) && getDolGlobalString("$constantforkey") != "1") { $s = ''; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); $warehouse = new Entrepot($db); $warehouse->fetch(getDolGlobalString("$constantforkey")); $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; From f79b883a4ad07756f7ac17a2751f9da100bd15eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Sep 2021 01:57:05 +0200 Subject: [PATCH 6/6] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 5a95128c090..520fe8dccdb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1132,7 +1132,7 @@ $( document ).ready(function() { $s = ''; $constantforkey = 'CASHDESK_ID_WAREHOUSE'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); $warehouse = new Entrepot($db); - $warehouse->fetch(getDolGlobalString("$constantforkey")); + $warehouse->fetch(getDolGlobalString($constantforkey)); $s .= $langs->trans("Warehouse").'
'.$warehouse->ref; $s .= '
'; }