From a680d1e34d51a7068d8c2ae4b43de2cefb736fae Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 18 Nov 2023 00:42:15 +0100 Subject: [PATCH 1/3] Fix strpos inversion for expedition and receipt in files.lib (#26701) --- htdocs/core/lib/files.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 8e7446a456e..2b21acd43e6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2762,14 +2762,14 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } - $original_file = $conf->expedition->dir_output."/".(strpos('sending/', $original_file) === 0 ? '' : 'sending/').$original_file; + $original_file = $conf->expedition->dir_output."/".(strpos($original_file, 'sending/') === 0 ? '' : 'sending/').$original_file; //$original_file = $conf->expedition->dir_output."/".$original_file; } elseif (($modulepart == 'livraison' || $modulepart == 'delivery') && !empty($conf->expedition->dir_output)) { // Delivery Note Wrapping if ($fuser->rights->expedition->delivery->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } - $original_file = $conf->expedition->dir_output."/".(strpos('receipt/', $original_file) === 0 ? '' : 'receipt/').$original_file; + $original_file = $conf->expedition->dir_output."/".(strpos($original_file, 'receipt/') === 0 ? '' : 'receipt/').$original_file; } elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { // Wrapping pour les actions if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i', $original_file)) { From 5ae8da372abd662f5726c49a61aeaaa30f92746a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 18 Nov 2023 00:42:52 +0100 Subject: [PATCH 2/3] fix phpcs (#26697) --- htdocs/core/class/commonobject.class.php | 70 ++++++++++++------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dfc3603983a..8244cb4d609 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3405,7 +3405,7 @@ abstract class CommonObject * * @param string $note New value for note * @param string $suffix '', '_public' or '_private' - * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ public function update_note($note, $suffix = '', $notrigger = 0) @@ -3452,32 +3452,34 @@ abstract class CommonObject $this->note = $note; // deprecated $this->note_private = $note; } - if(empty($notrigger)) { - switch($this->element) { - case 'societe': - $trigger_name = 'COMPANY_MODIFY'; - break; - case 'commande': - $trigger_name = 'ORDER_MODIFY'; - break; - case 'facture': - $trigger_name = 'BILL_MODIFY'; - break; - case 'invoice_supplier': - $trigger_name = 'BILL_SUPPLIER_MODIFY'; - break; - case 'facturerec': - $trigger_name = 'BILLREC_MODIFIY'; - break; - case 'expensereport': - $trigger_name = 'EXPENSE_REPORT_MODIFY'; - break; - default: - $trigger_name = strtoupper($this->element) . '_MODIFY'; - } - $ret = $this->call_trigger($trigger_name, $user); - if($ret < 0 ) { return -1; } - } + if (empty($notrigger)) { + switch ($this->element) { + case 'societe': + $trigger_name = 'COMPANY_MODIFY'; + break; + case 'commande': + $trigger_name = 'ORDER_MODIFY'; + break; + case 'facture': + $trigger_name = 'BILL_MODIFY'; + break; + case 'invoice_supplier': + $trigger_name = 'BILL_SUPPLIER_MODIFY'; + break; + case 'facturerec': + $trigger_name = 'BILLREC_MODIFIY'; + break; + case 'expensereport': + $trigger_name = 'EXPENSE_REPORT_MODIFY'; + break; + default: + $trigger_name = strtoupper($this->element) . '_MODIFY'; + } + $ret = $this->call_trigger($trigger_name, $user); + if($ret < 0 ) { + return -1; + } + } return 1; } else { $this->error = $this->db->lasterror(); @@ -8451,8 +8453,8 @@ abstract class CommonObject var val = $("select[name=\""+parent_list+"\"]").val(); var parentVal = parent_list + ":" + val; if(typeof val == "string"){ - if(val != "") { - var options = orig_select.find("option[parent=\""+parentVal+"\"]").clone(); + if(val != "") { + var options = orig_select.find("option[parent=\""+parentVal+"\"]").clone(); $("select[name=\""+child_list+"\"] option[parent]").remove(); $("select[name=\""+child_list+"\"]").append(options); } else { @@ -8460,7 +8462,7 @@ abstract class CommonObject $("select[name=\""+child_list+"\"] option[parent]").remove(); $("select[name=\""+child_list+"\"]").append(options); } - } else if(val > 0) { + } else if(val > 0) { var options = orig_select.find("option[parent=\""+parentVal+"\"]").clone(); $("select[name=\""+child_list+"\"] option[parent]").remove(); $("select[name=\""+child_list+"\"]").append(options); @@ -8481,15 +8483,15 @@ abstract class CommonObject //Hide daughters lists if ($("#"+child_list).val() == 0 && $("#"+parent_list).val() == 0){ - $("#"+child_list).hide(); + $("#"+child_list).hide(); //Show mother lists } else if ($("#"+parent_list).val() != 0){ - $("#"+parent_list).show(); + $("#"+parent_list).show(); } //Show the child list if the parent list value is selected $("select[name=\""+parent_list+"\"]").click(function() { - if ($(this).val() != 0){ - $("#"+child_list).show() + if ($(this).val() != 0){ + $("#"+child_list).show() } }); From 29e3386e6f5e1e9c64a48a934d2906eb8b25b33b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Nov 2023 01:21:17 +0100 Subject: [PATCH 3/3] Fix #26584 Fix #26673 --- htdocs/core/class/html.form.class.php | 1 + htdocs/core/tpl/objectline_create.tpl.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bf3f9e378c1..9e7ab1a9947 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3690,6 +3690,7 @@ class Form $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; $optstart .= ' data-default-vat-code="' . dol_escape_htmltag($objp->default_vat_code) . '"'; + $optstart .= ' data-supplier-ref="' . dol_escape_htmltag($objp->ref_fourn) . '"'; } $optstart .= ' data-description="' . dol_escape_htmltag($objp->description, 0, 1) . '"'; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 382dcb93b7e..42377634ff9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1007,7 +1007,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { // Deal with supplier ref price (idprodfournprice = int) if (jQuery('#idprodfournprice').val() > 0) { - console.log("objectline_create.tpl #idprodfournprice is is an ID > 0, so we set some properties into page"); + console.log("objectline_create.tpl #idprodfournprice is an ID > 0, so we set some properties into page"); var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with ajax autocomplete @@ -1032,7 +1032,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } - console.log("objectline_create.tpl We find supplier price : up = "+up+", up_locale = "+up_locale+", qty = "+qty+", tva_tx = "+tva_tx+", default_vat_code = "+default_vat_code+", stringforvatrateselection="+stringforvatrateselection+", discount = "+discount+" for product supplier ref id = "+jQuery('#idprodfournprice').val()); + var supplier_ref = $('option:selected', this).attr('data-supplier-ref'); // When select is done from HTML select + if (typeof supplier_ref === 'undefined') { supplier_ref = jQuery('#idprodfournprice').attr('data-supplier-ref');} // When select is done from HTML input with ajax autocomplete + + console.log("objectline_create.tpl We find supplier price : up = "+up+", up_locale = "+up_locale+", supplier_ref = "+supplier_ref+" qty = "+qty+", tva_tx = "+tva_tx+", default_vat_code = "+default_vat_code+", stringforvatrateselection="+stringforvatrateselection+", discount = "+discount+" for product supplier ref id = "+jQuery('#idprodfournprice').val()); if (typeof up_locale === 'undefined') { jQuery("#price_ht").val(up); @@ -1040,6 +1043,8 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#price_ht").val(up_locale); } + // Set supplier_ref + $('#fourn_ref').val(supplier_ref); // Set vat rate if field is an input box $('#tva_tx').val(tva_tx); // Set vat rate by selecting the combo