clean get price for fourn and labal for supplier coducment
This commit is contained in:
parent
8c935661ee
commit
76824c868b
@ -2737,6 +2737,12 @@ class Form
|
|||||||
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
|
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
|
||||||
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
|
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
|
||||||
$sql .= " pfp.supplier_reputation";
|
$sql .= " pfp.supplier_reputation";
|
||||||
|
// if we use supplier description of the products
|
||||||
|
if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||||
|
$sql .= " ,pfp.desc_fourn as description";
|
||||||
|
} else {
|
||||||
|
$sql .= " ,p.description";
|
||||||
|
}
|
||||||
// Units
|
// Units
|
||||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||||
$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
|
$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
|
||||||
@ -2766,7 +2772,11 @@ class Form
|
|||||||
foreach ($scrit as $crit)
|
foreach ($scrit as $crit)
|
||||||
{
|
{
|
||||||
if ($i > 0) $sql .= " AND ";
|
if ($i > 0) $sql .= " AND ";
|
||||||
$sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')";
|
$sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||||
|
if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||||
|
$sql .= " OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||||
|
}
|
||||||
|
$sql .= ")";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if (count($scrit) > 1) $sql .= ")";
|
if (count($scrit) > 1) $sql .= ")";
|
||||||
@ -2956,8 +2966,9 @@ class Form
|
|||||||
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
|
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
|
||||||
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
|
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
|
||||||
{
|
{
|
||||||
$opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"';
|
$opt .= ' data-qty="'.$objp->quantity.'" data-up="'.$objp->unitprice.'" data-discount="'.$outdiscount.'"';
|
||||||
}
|
}
|
||||||
|
$opt .= ' data-description="'.dol_escape_htmltag($objp->description).'"';
|
||||||
$opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"';
|
$opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"';
|
||||||
$opt .= '>';
|
$opt .= '>';
|
||||||
|
|
||||||
@ -2971,7 +2982,20 @@ 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'=>$objp->unitprice,
|
||||||
|
'discount'=>$outdiscount,
|
||||||
|
'type'=>$outtype,
|
||||||
|
'duration_value'=>$outdurationvalue,
|
||||||
|
'duration_unit'=>$outdurationunit,
|
||||||
|
'disabled'=>(empty($objp->idprodfournprice) ?true:false),
|
||||||
|
'description'=>$objp->description
|
||||||
|
)
|
||||||
|
);
|
||||||
// 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é)"
|
||||||
|
|||||||
@ -134,7 +134,11 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
}
|
}
|
||||||
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, textarea: textarea,
|
update: update, textarea: textarea,
|
||||||
pbq: item.pbq, type: item.type, qty: item.qty, discount: item.discount, pricebasetype: item.pricebasetype, price_ht: item.price_ht, price_ttc: item.price_ttc }
|
pbq: item.pbq,
|
||||||
|
type: item.type, qty: item.qty, discount: item.discount,
|
||||||
|
pricebasetype: item.pricebasetype, price_ht: item.price_ht,
|
||||||
|
price_ttc: item.price_ttc,
|
||||||
|
up: item.up, description : item.description}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array.");
|
else console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array.");
|
||||||
@ -146,13 +150,33 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
|||||||
console.log("Call change on input '.$htmlname.' because of select definition of autocomplete select call on input#search_'.$htmlname.'");
|
console.log("Call change on input '.$htmlname.' because of select definition of autocomplete select call on 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(ui.item);
|
console.log(ui.item);
|
||||||
$("#'.$htmlname.'").attr("data-pbq", ui.item.pbq);
|
//For supplier price
|
||||||
$("#'.$htmlname.'").attr("data-pbqup", ui.item.price_ht);
|
$("#'.$htmlname.'").attr("data-up", ui.item.up);
|
||||||
$("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype);
|
$("#'.$htmlname.'").attr("data-discount", ui.item.discount);
|
||||||
$("#'.$htmlname.'").attr("data-pbqqty", ui.item.qty);
|
$("#'.$htmlname.'").attr("data-qty", ui.item.qty);
|
||||||
$("#'.$htmlname.'").attr("data-pbqpercent", ui.item.discount);
|
$("#'.$htmlname.'").attr("data-description", ui.item.description);
|
||||||
|
|
||||||
|
//For customer price
|
||||||
|
';
|
||||||
|
|
||||||
|
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
|
||||||
|
$script .= '
|
||||||
|
$("#' . $htmlname . '").attr("data-pbq", ui.item.pbq);
|
||||||
|
$("#' . $htmlname . '").attr("data-pbqup", ui.item.price_ht);
|
||||||
|
$("#' . $htmlname . '").attr("data-pbqbase", ui.item.pricebasetype);
|
||||||
|
$("#' . $htmlname . '").attr("data-pbqqty", ui.item.qty);
|
||||||
|
$("#' . $htmlname . '").attr("data-pbqpercent", ui.item.discount);
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
$script .= '
|
||||||
|
$("#' . $htmlname . '").attr("data-up", ui.item.price_ht);
|
||||||
|
$("#' . $htmlname . '").attr("data-base", ui.item.pricebasetype);
|
||||||
|
$("#' . $htmlname . '").attr("data-qty", ui.item.qty);
|
||||||
|
$("#' . $htmlname . '").attr("data-discount", ui.item.discount);
|
||||||
|
';
|
||||||
|
}
|
||||||
|
$script .= '
|
||||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
||||||
// Disable an element
|
// Disable an element
|
||||||
if (options.option_disabled) {
|
if (options.option_disabled) {
|
||||||
|
|||||||
@ -804,7 +804,10 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
/* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */
|
<?php
|
||||||
|
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||||
|
{?>
|
||||||
|
/* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */
|
||||||
var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select
|
var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select
|
||||||
if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } // When select is done from HTML input with autocomplete
|
if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } // When select is done from HTML input with autocomplete
|
||||||
var pbqup = parseFloat($('option:selected', this).attr('data-pbqup'));
|
var pbqup = parseFloat($('option:selected', this).attr('data-pbqup'));
|
||||||
@ -816,7 +819,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent'));
|
var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent'));
|
||||||
if (isNaN(pbqpercent)) { pbqpercent = jQuery('#idprod').attr('data-pbqpercent'); }
|
if (isNaN(pbqpercent)) { pbqpercent = jQuery('#idprod').attr('data-pbqpercent'); }
|
||||||
|
|
||||||
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
|
if ((jQuery('#idprod').val() > 0) && ! isNaN(pbq) && pbq > 0)
|
||||||
{
|
{
|
||||||
var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */
|
var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */
|
||||||
|
|
||||||
@ -832,6 +835,48 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
jQuery("#remise_percent").val(pbqpercent);
|
jQuery("#remise_percent").val(pbqpercent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
//Deal with supplier
|
||||||
|
if (jQuery('#idprodfournprice').val() >0)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
var qty = parseFloat($('option:selected', this).attr('data-qty'));
|
||||||
|
if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
|
||||||
|
|
||||||
|
var discount = parseFloat($('option:selected', this).attr('data-discount'));
|
||||||
|
if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
|
||||||
|
|
||||||
|
var description = $('option:selected', this).attr('data-description');
|
||||||
|
if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); }
|
||||||
|
console.log("We find supplier price :"+up+" qty: "+qty+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val());
|
||||||
|
|
||||||
|
jQuery("#price_ht").val(up);
|
||||||
|
if (jQuery("#qty").val() < qty)
|
||||||
|
{
|
||||||
|
jQuery("#qty").val(qty);
|
||||||
|
}
|
||||||
|
if (jQuery("#remise_percent").val() < discount)
|
||||||
|
{
|
||||||
|
jQuery("#remise_percent").val(discount);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Load desciption into text area : "+description);
|
||||||
|
<?php if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
|
||||||
|
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||||
|
{
|
||||||
|
var editor = CKEDITOR.instances['dp_desc'];
|
||||||
|
if (editor) {
|
||||||
|
editor.setData(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<?php } else { ?>
|
||||||
|
jQuery('#dp_desc').text(description);
|
||||||
|
<?php } ?>
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jQuery("#pbq").val('');
|
jQuery("#pbq").val('');
|
||||||
|
|||||||
@ -356,7 +356,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
||||||
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
||||||
$prod_entry_mode = GETPOST('prod_entry_mode');
|
$prod_entry_mode = GETPOST('prod_entry_mode');
|
||||||
@ -475,7 +475,7 @@ if (empty($reshook))
|
|||||||
$outputlangs = new Translate("", $conf);
|
$outputlangs = new Translate("", $conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$desc = (!empty($productsupplier->multilangs [$outputlangs->defaultlang] ["description"])) ? $productsupplier->multilangs [$outputlangs->defaultlang] ["description"] : $productsupplier->description;
|
$desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang]["description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang]["description"] : $productsupplier->description;
|
||||||
} else {
|
} else {
|
||||||
$desc = $productsupplier->description;
|
$desc = $productsupplier->description;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1180,7 +1180,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef = '';
|
$predef = '';
|
||||||
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
|
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
|
||||||
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
||||||
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ if (empty($reshook))
|
|||||||
$price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
|
$price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
|
||||||
$delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
|
$delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
|
||||||
$supplier_reputation = GETPOST('supplier_reputation');
|
$supplier_reputation = GETPOST('supplier_reputation');
|
||||||
$supplier_description = GETPOST('supplier_description', 'alpha');
|
$supplier_description = GETPOST('supplier_description', 'restricthtml');
|
||||||
$barcode = GETPOST('barcode', 'alpha');
|
$barcode = GETPOST('barcode', 'alpha');
|
||||||
$fk_barcode_type = GETPOST('fk_barcode_type', 'int');
|
$fk_barcode_type = GETPOST('fk_barcode_type', 'int');
|
||||||
$packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS');
|
$packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user