parent
8f5c05f577
commit
409b137ba7
@ -3534,7 +3534,13 @@ class Form
|
|||||||
$opt .= ' disabled';
|
$opt .= ' disabled';
|
||||||
}
|
}
|
||||||
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
|
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
|
||||||
$opt .= ' data-product-id="'.dol_escape_htmltag($objp->rowid).'" data-price-id="'.dol_escape_htmltag($objp->idprodfournprice).'" data-qty="'.dol_escape_htmltag($objp->quantity).'" data-up="'.dol_escape_htmltag($objp->unitprice).'" data-discount="'.dol_escape_htmltag($outdiscount).'" data-tvatx="'.dol_escape_htmltag($objp->tva_tx).'"';
|
$opt .= ' data-product-id="'.dol_escape_htmltag($objp->rowid).'"';
|
||||||
|
$opt .= ' data-price-id="'.dol_escape_htmltag($objp->idprodfournprice).'"';
|
||||||
|
$opt .= ' data-qty="'.dol_escape_htmltag($objp->quantity).'"';
|
||||||
|
$opt .= ' data-up="'.dol_escape_htmltag($objp->unitprice).'"';
|
||||||
|
$opt .= ' data-up-locale="'.dol_escape_htmltag(price($objp->unitprice)).'"';
|
||||||
|
$opt .= ' data-discount="'.dol_escape_htmltag($outdiscount).'"';
|
||||||
|
$opt .= ' data-tvatx="'.dol_escape_htmltag($objp->tva_tx).'"';
|
||||||
}
|
}
|
||||||
$opt .= ' data-description="'.dol_escape_htmltag($objp->description, 0, 1).'"';
|
$opt .= ' data-description="'.dol_escape_htmltag($objp->description, 0, 1).'"';
|
||||||
$opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"';
|
$opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"';
|
||||||
|
|||||||
@ -143,8 +143,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
textarea[key] = item[value];
|
textarea[key] = item[value];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Return value from GET to the rest of code");
|
console.log("Return value from GET to the rest of code");
|
||||||
return { label: label, value: item.value, id: item.key, disabled: item.disabled,
|
return { label: label,
|
||||||
|
value: item.value,
|
||||||
|
id: item.key,
|
||||||
|
disabled: item.disabled,
|
||||||
update: update,
|
update: update,
|
||||||
textarea: textarea,
|
textarea: textarea,
|
||||||
pbq: item.pbq,
|
pbq: item.pbq,
|
||||||
@ -154,6 +158,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
pricebasetype: item.pricebasetype,
|
pricebasetype: item.pricebasetype,
|
||||||
price_ht: item.price_ht,
|
price_ht: item.price_ht,
|
||||||
price_ttc: item.price_ttc,
|
price_ttc: item.price_ttc,
|
||||||
|
price_unit_ht: item.price_unit_ht,
|
||||||
|
price_unit_ht_locale: item.price_unit_ht_locale,
|
||||||
description : item.description,
|
description : item.description,
|
||||||
ref_customer: item.ref_customer,
|
ref_customer: item.ref_customer,
|
||||||
tva_tx: item.tva_tx }
|
tva_tx: item.tva_tx }
|
||||||
@ -173,6 +179,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
|
|
||||||
// For supplier price and customer when price by quantity is off
|
// For supplier price and customer when price by quantity is off
|
||||||
$("#'.$htmlnamejquery.'").attr("data-up", ui.item.price_ht);
|
$("#'.$htmlnamejquery.'").attr("data-up", ui.item.price_ht);
|
||||||
|
$("#'.$htmlnamejquery.'").attr("data-up-locale", ui.item.price_unit_ht_locale);
|
||||||
$("#'.$htmlnamejquery.'").attr("data-base", ui.item.pricebasetype);
|
$("#'.$htmlnamejquery.'").attr("data-base", ui.item.pricebasetype);
|
||||||
$("#'.$htmlnamejquery.'").attr("data-qty", ui.item.qty);
|
$("#'.$htmlnamejquery.'").attr("data-qty", ui.item.qty);
|
||||||
$("#'.$htmlnamejquery.'").attr("data-discount", ui.item.discount);
|
$("#'.$htmlnamejquery.'").attr("data-discount", ui.item.discount);
|
||||||
@ -191,6 +198,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
';
|
';
|
||||||
}
|
}
|
||||||
$script .= '
|
$script .= '
|
||||||
|
// A new value has been selected, we trigger the handlers on #htmlnamejquery
|
||||||
|
console.log("Trigger changes on #'.$htmlnamejquery.'");
|
||||||
$("#'.$htmlnamejquery.'").val(ui.item.id).trigger("change"); // Select new value
|
$("#'.$htmlnamejquery.'").val(ui.item.id).trigger("change"); // Select new value
|
||||||
|
|
||||||
// Disable an element
|
// Disable an element
|
||||||
|
|||||||
@ -291,7 +291,9 @@ if ($nolinesbefore) {
|
|||||||
$alsoproductwithnosupplierprice = 0;
|
$alsoproductwithnosupplierprice = 0;
|
||||||
} else {
|
} else {
|
||||||
$ajaxoptions = array(
|
$ajaxoptions = array(
|
||||||
'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
|
// Disabled: This is useless because setting discount and price_ht after a selection is already managed
|
||||||
|
// by ths page itself with a .change on the combolist '#idprodfournprice'
|
||||||
|
//'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
|
||||||
);
|
);
|
||||||
$alsoproductwithnosupplierprice = 1;
|
$alsoproductwithnosupplierprice = 1;
|
||||||
}
|
}
|
||||||
@ -711,7 +713,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 (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val());
|
console.log("objectline_create.tpl 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
|
||||||
jQuery('#trlinefordates').show();
|
jQuery('#trlinefordates').show();
|
||||||
@ -724,7 +726,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
|
|
||||||
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
|
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
|
||||||
{
|
{
|
||||||
console.log("We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later");
|
console.log("objectline_create.tpl We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later");
|
||||||
} else {
|
} else {
|
||||||
<?php if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?>
|
<?php if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?>
|
||||||
if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); }
|
if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); }
|
||||||
@ -734,7 +736,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
|
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
|
||||||
{ 'id': $(this).val(), 'socid': <?php print $object->socid; ?> },
|
{ 'id': $(this).val(), 'socid': <?php print $object->socid; ?> },
|
||||||
function(data) {
|
function(data) {
|
||||||
console.log("Load unit price end, we got value "+data.price_ht);
|
console.log("objectline_create.tpl Load unit price end, we got value "+data.price_ht);
|
||||||
|
|
||||||
$('#date_start').removeAttr('type');
|
$('#date_start').removeAttr('type');
|
||||||
$('#date_end').removeAttr('type');
|
$('#date_end').removeAttr('type');
|
||||||
@ -755,6 +757,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
jQuery('#date_end').removeClass('inputmandatory');
|
jQuery('#date_end').removeClass('inputmandatory');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("objectline_create.tpl set content of price_ht");
|
||||||
jQuery("#price_ht").val(data.price_ht);
|
jQuery("#price_ht").val(data.price_ht);
|
||||||
<?php
|
<?php
|
||||||
if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
|
if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
|
||||||
@ -765,7 +768,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
var proddesc = data.desc;
|
var proddesc = data.desc;
|
||||||
<?php
|
<?php
|
||||||
} ?>
|
} ?>
|
||||||
console.log("Load desciption into text area : "+proddesc);
|
console.log("objectline_create.tpl Load desciption into text area : "+proddesc);
|
||||||
<?php
|
<?php
|
||||||
if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
|
if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
|
||||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||||
@ -829,7 +832,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
print 'costprice';
|
print 'costprice';
|
||||||
}
|
}
|
||||||
} ?>';
|
} ?>';
|
||||||
console.log("we will set the field for margin. defaultbuyprice="+defaultbuyprice);
|
console.log("objectline_create.tpl we will set the field for margin. defaultbuyprice="+defaultbuyprice);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
$(data).each(function() {
|
$(data).each(function() {
|
||||||
@ -940,11 +943,16 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
//Deal with supplier
|
// Deal with supplier
|
||||||
if (jQuery('#idprodfournprice').val() >0)
|
if (jQuery('#idprodfournprice').val() > 0)
|
||||||
{
|
{
|
||||||
|
console.log("objectline_create.tpl #idprodfournprice is > 0, so we set some properties into page");
|
||||||
|
|
||||||
var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select
|
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 autocomplete
|
if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with ajax autocomplete
|
||||||
|
|
||||||
|
var up_locale = $('option:selected', this).attr('data-up-locale'); // When select is done from HTML select
|
||||||
|
if (typeof up_locale === 'undefined') { up_locale = jQuery('#idprodfournprice').attr('data-up-locale');} // When select is done from HTML input with ajax autocomplete
|
||||||
|
|
||||||
var qty = parseFloat($('option:selected', this).attr('data-qty'));
|
var qty = parseFloat($('option:selected', this).attr('data-qty'));
|
||||||
if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
|
if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
|
||||||
@ -953,11 +961,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
|
if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
|
||||||
|
|
||||||
var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select
|
var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select
|
||||||
if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with autocomplete
|
if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with ajax autocomplete
|
||||||
|
|
||||||
console.log("We find supplier price :"+up+" qty: "+qty+" tva_tx="+tva_tx+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val());
|
console.log("objectline_create.tpl We find supplier price : up = "+up+", up_locale = "+up_locale+", qty = "+qty+", tva_tx = "+tva_tx+", discount = "+discount+" for product "+jQuery('#idprodfournprice').val());
|
||||||
|
|
||||||
jQuery("#price_ht").val(up);
|
if (typeof up_locale === 'undefined') {
|
||||||
|
jQuery("#price_ht").val(up);
|
||||||
|
} else {
|
||||||
|
jQuery("#price_ht").val(up_locale);
|
||||||
|
}
|
||||||
|
|
||||||
/* $('#tva_tx option').removeAttr('selected').filter('[value='+tva_tx+']').prop('selected', true); */
|
/* $('#tva_tx option').removeAttr('selected').filter('[value='+tva_tx+']').prop('selected', true); */
|
||||||
$('#tva_tx option').val(tva_tx);
|
$('#tva_tx option').val(tva_tx);
|
||||||
@ -965,8 +977,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
if (jQuery("#qty").val() < qty) {
|
if (jQuery("#qty").val() < qty) {
|
||||||
jQuery("#qty").val(qty);
|
jQuery("#qty").val(qty);
|
||||||
}
|
}
|
||||||
if (jQuery("#remise_percent").val() < discount)
|
if (jQuery("#remise_percent").val() < discount) {
|
||||||
{
|
|
||||||
jQuery("#remise_percent").val(discount);
|
jQuery("#remise_percent").val(discount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,7 +1044,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
|
|
||||||
/* Function to set fields from choice */
|
/* Function to set fields from choice */
|
||||||
function setforfree() {
|
function setforfree() {
|
||||||
console.log("Call setforfree. We show most fields");
|
console.log("objectline_create.tpl::setforfree. We show most fields");
|
||||||
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
|
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
|
||||||
jQuery("#prod_entry_mode_free").prop('checked',true).change();
|
jQuery("#prod_entry_mode_free").prop('checked',true).change();
|
||||||
jQuery("#prod_entry_mode_predef").prop('checked',false).change();
|
jQuery("#prod_entry_mode_predef").prop('checked',false).change();
|
||||||
@ -1044,7 +1055,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setforpredef() {
|
function setforpredef() {
|
||||||
console.log("Call setforpredef. We hide some fields and show dates");
|
console.log("objectline_create.tpl::setforpredef We hide some fields, show dates");
|
||||||
jQuery("#select_type").val(-1);
|
jQuery("#select_type").val(-1);
|
||||||
jQuery("#prod_entry_mode_free").prop('checked',false).change();
|
jQuery("#prod_entry_mode_free").prop('checked',false).change();
|
||||||
jQuery("#prod_entry_mode_predef").prop('checked',true).change();
|
jQuery("#prod_entry_mode_predef").prop('checked',true).change();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user