From 5f1c05308a3a7a93164caba8807335cb2532b3b5 Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Thu, 21 Mar 2024 00:54:54 -0600 Subject: [PATCH 1/6] PHP Warning: Undefined array key 1 on line 533 PHP Warning: Undefined array key 1 on line 533 --- htdocs/compta/bank/releve.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index bf0a08f02db..feeefb00425 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -529,8 +529,12 @@ if (empty($numref)) { print ''; $reg = array(); preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) { - print $langs->trans($reg[1]); + if (!empty($reg[1])) { + if ($langs->trans($reg[1]) != $reg[1]) { + print $langs->trans($reg[1]); + } else { + print $objp->label; + } } else { print $objp->label; } From 3b5aa4e03a3d1e0f61f4322b1283a2a906398af7 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Thu, 21 Mar 2024 10:46:45 +0100 Subject: [PATCH 2/6] FIX default workstation on BOM --- htdocs/bom/ajax/ajax.php | 23 ++++++++++++++++++++++- htdocs/bom/class/bom.class.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 17 +++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 9a55c609252..eddb8a40dc5 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -53,7 +53,7 @@ $idproduct = GETPOST('idproduct', 'int'); * View */ -top_httphead(); +top_httphead('application/json'); if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) { $product = new Product($db); @@ -65,3 +65,24 @@ if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) echo json_encode($fk_unit); exit(); } + +if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) { + $product = new Product($db); + $res = $product->fetch($idproduct); + + $result = array(); + + if ($res < 0) { + $error = 'SQL ERROR'; + } elseif ($res == 0) { + $error = 'NOT FOUND'; + } else { + $error = null; + $result['defaultWk']=$product->fk_default_workstation; + } + + $result['error']=$error; + + echo json_encode($result); + exit(); +} diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cfae2ea3e0c..8ea8e3e3edd 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -792,7 +792,7 @@ class BOM extends CommonObject $line->array_options[$key] = $array_options[$key]; } } - if ($fk_default_workstation > 0 && $line->fk_default_workstation != $fk_default_workstation) { + if ($fk_default_workstation >= 0 && $line->fk_default_workstation != $fk_default_workstation) { $line->fk_default_workstation = $fk_default_workstation; } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index db3991eac7d..8beefbc8b01 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -185,7 +185,7 @@ if ($filtertype != 1) { $coldisplay++; print ''; - print ' '; + print $formproduct->selectWorkstations('', 'idworkstations', 1); print ''; $coldisplay++; @@ -235,14 +235,27 @@ jQuery(document).ready(function() { ,type: 'POST' ,data: { 'action': 'getDurationUnitByProduct' + ,'token' : "" ,'idproduct' : idproduct } }).done(function(data) { console.log(data); - var data = JSON.parse(data); $("#fk_unit").val(data).change(); }); + + $.ajax({ + url : "" + ,type: 'POST' + ,data: { + 'action': 'getWorkstationByProduct' + ,'token' : "" + ,'idproduct' : idproduct + } + }).done(function(data) { + $('#idworkstations').val(data.defaultWk).select2(); + + }); }); }); From ab10f29db72ea6e984a295137dc5b05587c31534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= Date: Thu, 21 Mar 2024 13:06:09 +0100 Subject: [PATCH 3/6] add invoice id --- htdocs/takepos/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 97dae7e1a14..33367b95535 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -504,11 +504,12 @@ function ClickProduct(position, qty = 1) { } else{ console.log($('#prodiv4').data('rowid')); + invoiceid = $("#invoiceid").val(); idproduct=$('#prodiv'+position).data('rowid'); console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty); if (idproduct=="") return; // Call page invoice.php to generate the section with product lines - $("#poslines").load("invoice.php?action=addline&token=&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty, function() { + $("#poslines").load("invoice.php?action=addline&token=&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty+"&invoiceid="+invoiceid, function() { global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?> }); } @@ -527,7 +528,8 @@ function ChangeThirdparty(idcustomer) { function deleteline() { console.log("Delete line"); - $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline, function() { + invoiceid = $("#invoiceid").val(); + $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline+"invoiceid="+invoiceid, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); ClearSearch(); From 5ffdc449524a1d63bda824eadb8556c547af5b86 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Mar 2024 13:35:51 +0100 Subject: [PATCH 4/6] FIX missing entity parameter for ajax_constantonoff --- htdocs/core/class/html.formsetup.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index ac6bbc42e0d..03b9695b18f 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -26,6 +26,9 @@ class FormSetup */ public $db; + /** @var int */ + public $entity; + /** @var FormSetupItem[] */ public $items = array(); @@ -86,7 +89,8 @@ class FormSetup */ public function __construct($db, $outputLangs = false) { - global $langs; + global $conf, $langs; + $this->db = $db; $this->form = new Form($this->db); $this->formAttributes['action'] = $_SERVER["PHP_SELF"]; @@ -94,6 +98,7 @@ class FormSetup $this->formHiddenInputs['token'] = newToken(); $this->formHiddenInputs['action'] = 'update'; + $this->entity = (is_null($this->entity) ? $conf->entity : $this->entity); if ($outputLangs) { $this->langs = $outputLangs; @@ -446,6 +451,8 @@ class FormSetup { $item = new FormSetupItem($confKey); + $item->entity = $this->entity; + // set item rank if not defined as last item if (empty($item->rank)) { $item->rank = $this->getCurentItemMaxRank() + 1; @@ -638,7 +645,7 @@ class FormSetupItem /** * Constructor * - * @param string $confKey the conf key used in database + * @param string $confKey the conf key used in database */ public function __construct($confKey) { @@ -652,7 +659,7 @@ class FormSetupItem } $this->langs = $langs; - $this->entity = $conf->entity; + $this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity)); $this->confKey = $confKey; $this->loadValueFromConf(); @@ -1089,7 +1096,7 @@ class FormSetupItem $out.= $this->generateOutputFieldColor(); } elseif ($this->type == 'yesno') { if (!empty($conf->use_javascript_ajax)) { - $out.= ajax_constantonoff($this->confKey); + $out.= ajax_constantonoff($this->confKey, array(), $this->entity); // TODO possibility to add $input parameter } else { if ($this->fieldValue == 1) { $out.= $langs->trans('yes'); From d8b87ff6eb820f32998452e47688574bfd8fddf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= Date: Thu, 21 Mar 2024 14:22:12 +0100 Subject: [PATCH 5/6] fix --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 33367b95535..540fa54f19c 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -529,7 +529,7 @@ function ChangeThirdparty(idcustomer) { function deleteline() { console.log("Delete line"); invoiceid = $("#invoiceid").val(); - $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline+"invoiceid="+invoiceid, function() { + $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline+"&invoiceid="+invoiceid, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); ClearSearch(); From ea1762f0fda2d8faeda8c82d028b8cbc9d47cf1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Mar 2024 14:36:31 +0100 Subject: [PATCH 6/6] Update releve.php --- htdocs/compta/bank/releve.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index feeefb00425..af21117d21c 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -529,14 +529,10 @@ if (empty($numref)) { print ''; $reg = array(); preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction - if (!empty($reg[1])) { - if ($langs->trans($reg[1]) != $reg[1]) { - print $langs->trans($reg[1]); - } else { - print $objp->label; - } + if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) { + print $langs->trans($reg[1]); } else { - print $objp->label; + print dol_escape_htmltag($objp->label); } print '';