diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fa6bc0f1daf..db3df0ecd5b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3468,7 +3468,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) @@ -3515,32 +3515,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(); @@ -8690,8 +8692,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 { @@ -8699,7 +8701,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); @@ -8720,15 +8722,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() } }); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 84c7562268b..8644b88da7f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3799,6 +3799,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 6cc34a713ae..b68c9b2a4fa 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1061,7 +1061,7 @@ if (!empty($usemargins) && $user->hasRight('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 @@ -1086,7 +1086,10 @@ if (!empty($usemargins) && $user->hasRight('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); @@ -1094,6 +1097,8 @@ if (!empty($usemargins) && $user->hasRight('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