FIX #16240
This commit is contained in:
parent
060e64fe02
commit
c875ad9a1c
@ -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é)"
|
||||||
|
|||||||
@ -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");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,18 +240,18 @@ 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(
|
||||||
'update' => array('qty'=>'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
|
'update' => array('qty'=>'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key
|
||||||
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
|
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
|
||||||
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
|
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
|
||||||
);
|
);
|
||||||
$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;
|
||||||
}
|
}
|
||||||
@ -531,47 +532,47 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
/* TODO This does not work for number with thousand separator that is , */
|
/* TODO This does not work for number with thousand separator that is , */
|
||||||
function checkFreeLine(e, npRate)
|
function checkFreeLine(e, npRate)
|
||||||
{
|
{
|
||||||
var buying_price = $("input[name='buying_price']:first");
|
var buying_price = $("input[name='buying_price']:first");
|
||||||
var remise = $("input[name='remise_percent']:first");
|
var remise = $("input[name='remise_percent']:first");
|
||||||
|
|
||||||
var rate = $("input[name='"+npRate+"']:first");
|
var rate = $("input[name='"+npRate+"']:first");
|
||||||
if (rate.val() == '')
|
if (rate.val() == '')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||||
{
|
{
|
||||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setTimeout(function () { rate.focus() }, 50);
|
setTimeout(function () { rate.focus() }, 50);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||||
{
|
{
|
||||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setTimeout(function () { rate.focus() }, 50);
|
setTimeout(function () { rate.focus() }, 50);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var price = 0;
|
var price = 0;
|
||||||
remisejs=price2numjs(remise.val());
|
remisejs=price2numjs(remise.val());
|
||||||
|
|
||||||
if (remisejs != 100) // If a discount not 100 or no discount
|
if (remisejs != 100) // If a discount not 100 or no discount
|
||||||
{
|
{
|
||||||
if (remisejs == '') remisejs=0;
|
if (remisejs == '') remisejs=0;
|
||||||
|
|
||||||
bpjs=price2numjs(buying_price.val());
|
bpjs=price2numjs(buying_price.val());
|
||||||
ratejs=price2numjs(rate.val());
|
ratejs=price2numjs(rate.val());
|
||||||
|
|
||||||
if (npRate == "np_marginRate")
|
if (npRate == "np_marginRate")
|
||||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||||
else if (npRate == "np_markRate")
|
else if (npRate == "np_markRate")
|
||||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -603,39 +604,39 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#prod_entry_mode_free").on( "click", function() {
|
$("#prod_entry_mode_free").on( "click", function() {
|
||||||
setforfree();
|
setforfree();
|
||||||
});
|
});
|
||||||
$("#select_type").change(function()
|
$("#select_type").change(function()
|
||||||
{
|
{
|
||||||
setforfree();
|
setforfree();
|
||||||
if (jQuery('#select_type').val() >= 0)
|
if (jQuery('#select_type').val() >= 0)
|
||||||
{
|
{
|
||||||
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
|
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
|
||||||
jQuery('#dp_desc').focus();
|
jQuery('#dp_desc').focus();
|
||||||
/* focus if CKEDITOR */
|
/* focus if CKEDITOR */
|
||||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||||
{
|
{
|
||||||
var editor = CKEDITOR.instances['dp_desc'];
|
var editor = CKEDITOR.instances['dp_desc'];
|
||||||
if (editor) { editor.focus(); }
|
if (editor) { editor.focus(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Hide/show date according to product type");
|
console.log("Hide/show date according to product type");
|
||||||
if (jQuery('#select_type').val() == '0')
|
if (jQuery('#select_type').val() == '0')
|
||||||
{
|
{
|
||||||
jQuery('#trlinefordates').hide();
|
jQuery('#trlinefordates').hide();
|
||||||
jQuery('.divlinefordates').hide();
|
jQuery('.divlinefordates').hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jQuery('#trlinefordates').show();
|
jQuery('#trlinefordates').show();
|
||||||
jQuery('.divlinefordates').show();
|
jQuery('.divlinefordates').show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#prod_entry_mode_predef").on( "click", function() {
|
$("#prod_entry_mode_predef").on( "click", function() {
|
||||||
console.log("click prod_entry_mode_predef");
|
console.log("click prod_entry_mode_predef");
|
||||||
setforpredef();
|
setforpredef();
|
||||||
jQuery('#trlinefordates').show();
|
jQuery('#trlinefordates').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user