From ebd1b49d2a0bee8b5f963ebf47343893a02f350c Mon Sep 17 00:00:00 2001 From: GurvanKervern Date: Sun, 29 Aug 2021 22:41:22 +0800 Subject: [PATCH] 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 .= '
'; }