This commit is contained in:
Laurent Destailleur 2021-02-10 02:17:01 +01:00
parent 060e64fe02
commit c875ad9a1c
3 changed files with 70 additions and 68 deletions

View File

@ -3047,7 +3047,7 @@ class Form
// "key" value of json key array is used by jQuery automatically as selected value // "key" value of json key array is used by jQuery automatically as selected value
// "label" value of json key array is used by jQuery automatically as text for combo box // "label" value of json key array is used by jQuery automatically as text for combo box
$out .= $opt; $out .= $opt;
array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'up'=>$objp->unitprice, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false))); array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'up'=>price2num($objp->unitprice, 'MT'), 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false)));
// Exemple of var_dump $outarray // Exemple of var_dump $outarray
// array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp" // array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp"
// ["label"]=>string(76) "ppp (<strong>f</strong>ff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)" // ["label"]=>string(76) "ppp (<strong>f</strong>ff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)"

View File

@ -147,7 +147,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("We will trigger change on input '.$htmlname.' because of the select definition of autocomplete code for input#search_'.$htmlname.'"); console.log("We will trigger change on input '.$htmlname.' because of the select definition of autocomplete code for input#search_'.$htmlname.'");
console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective"); console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
console.log("Propagate before some properties"); console.log("Propagate before some properties retrieved into data-xxx properties");
$("#'.$htmlname.'").attr("data-pbq", ui.item.pbq); $("#'.$htmlname.'").attr("data-pbq", ui.item.pbq);
$("#'.$htmlname.'").attr("data-pbqup", ui.item.price_ht); $("#'.$htmlname.'").attr("data-pbqup", ui.item.price_ht);
$("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype); $("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype);
@ -190,6 +190,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("Make action update on each ui.item.update") console.log("Make action update on each ui.item.update")
// loop on each "update" fields // loop on each "update" fields
$.each(ui.item.update, function(key, value) { $.each(ui.item.update, function(key, value) {
console.log("Set value "+value+" into #"+key);
$("#" + key).val(value).trigger("change"); $("#" + key).val(value).trigger("change");
}); });
} }

View File

@ -32,6 +32,7 @@
* $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders) * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders)
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($object) || !is_object($object)) { if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL"; print "Error: this template page cannot be called directly as an URL";
@ -239,7 +240,7 @@ if ($nolinesbefore) {
<?php <?php
} }
} else { } else {
// $senderissupplier=2 is the same as 1 but disables test on minimum qty and disable autofill qty with minimum // $senderissupplier=2 is the same as 1 but disables test on minimum qty, disable autofill qty with minimum and autofill unit price
if ($senderissupplier != 2) if ($senderissupplier != 2)
{ {
$ajaxoptions = array( $ajaxoptions = array(
@ -250,7 +251,7 @@ if ($nolinesbefore) {
$alsoproductwithnosupplierprice = 0; $alsoproductwithnosupplierprice = 0;
} else { } else {
$ajaxoptions = array( $ajaxoptions = array(
'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key 'update' => array('remise_percent' => 'discount', 'price_ht' => 'up') // html id tags that will be edited with each ajax json response key
); );
$alsoproductwithnosupplierprice = 1; $alsoproductwithnosupplierprice = 1;
} }
@ -648,7 +649,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
/* When changing predefined product, we reload list of supplier prices required for margin combo */ /* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function() $("#idprod, #idprodfournprice").change(function()
{ {
console.log("Call method change() after change on #idprod or #idprodfournprice. this.val = "+$(this).val()); console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva