Merge pull request #10703 from atm-quentin/NEW_develop_supplier_buyprice_barcode
NEW Support barcode on supplier price references
This commit is contained in:
commit
88f9f33c2a
@ -2636,6 +2636,7 @@ 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.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
|
||||
$sql.= " pfp.supplier_reputation";
|
||||
if (! empty($conf->barcode->enabled)) $sql.= " ,pfp.barcode";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
|
||||
if ($socid) $sql.= " AND pfp.fk_soc = ".$socid;
|
||||
@ -2660,7 +2661,10 @@ class Form
|
||||
$i++;
|
||||
}
|
||||
if (count($scrit) > 1) $sql.=")";
|
||||
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
|
||||
if (! empty($conf->barcode->enabled)){
|
||||
$sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
|
||||
$sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
|
||||
}
|
||||
$sql.=')';
|
||||
}
|
||||
$sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
|
||||
@ -2780,6 +2784,11 @@ class Form
|
||||
$opt .= " - ".dol_trunc($objp->name, 8);
|
||||
$outval.=" - ".dol_trunc($objp->name, 8);
|
||||
}
|
||||
if (! empty($conf->barcode->enabled) && !empty($objp->barcode))
|
||||
{
|
||||
$opt .= " - ".$objp->barcode;
|
||||
$outval.=" - ".$objp->barcode;
|
||||
}
|
||||
if ($objp->supplier_reputation)
|
||||
{
|
||||
//TODO dictionary
|
||||
|
||||
@ -278,6 +278,21 @@ else {
|
||||
}
|
||||
|
||||
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300');
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$(document).on('keypress',function(e) {
|
||||
if ($('input:focus').length == 0) {
|
||||
$('#idprodfournprice').select2('open');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
echo '<input type="hidden" name="pbq" id="pbq" value="">';
|
||||
echo '</span>';
|
||||
|
||||
@ -227,9 +227,11 @@ class ProductFournisseur extends Product
|
||||
* @param float $multicurrency_tx Rate currency
|
||||
* @param string $multicurrency_code Currency code
|
||||
* @param string $desc_fourn Custom description for product_fourn_price
|
||||
* @param string $barcode Barcode
|
||||
* @param int $fk_barcode_type Barcode type
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '')
|
||||
public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode='', $fk_barcode_type='')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
@ -350,7 +352,9 @@ class ProductFournisseur extends Product
|
||||
$sql.= " info_bits = ".$newnpr.",";
|
||||
$sql.= " charges = ".$charges.","; // deprecated
|
||||
$sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').",";
|
||||
$sql.= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'");
|
||||
$sql.= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
|
||||
$sql.= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
|
||||
$sql.= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
|
||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
// TODO Add price_base_type and price_ttc
|
||||
|
||||
@ -400,7 +404,7 @@ class ProductFournisseur extends Product
|
||||
// Add price for this quantity to supplier
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
|
||||
$sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
|
||||
$sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)";
|
||||
$sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
|
||||
$sql .= " values(";
|
||||
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
|
||||
@ -426,6 +430,8 @@ class ProductFournisseur extends Product
|
||||
$sql .= $conf->entity . ",";
|
||||
$sql .= $delivery_time_days . ",";
|
||||
$sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'");
|
||||
$sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'");
|
||||
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'");
|
||||
$sql .= ")";
|
||||
|
||||
$idinserted = 0;
|
||||
@ -488,8 +494,9 @@ class ProductFournisseur extends Product
|
||||
|
||||
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
|
||||
$sql.= " pfp.supplier_reputation, pfp.fk_user, pfp.datec";
|
||||
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql.= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
|
||||
$sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
|
||||
$sql.=" pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE pfp.rowid = ".$rowid;
|
||||
|
||||
@ -529,7 +536,10 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_multicurrency_tx = $obj->multicurrency_tx;
|
||||
$this->fourn_multicurrency_id = $obj->fk_multicurrency;
|
||||
$this->fourn_multicurrency_code = $obj->multicurrency_code;
|
||||
|
||||
if($conf->barcode->enabled) {
|
||||
$this->fourn_barcode = $obj->barcode;
|
||||
$this->fourn_fk_barcode_type = $obj->fk_barcode_type;
|
||||
}
|
||||
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
|
||||
{
|
||||
$priceparser = new PriceParser($this->db);
|
||||
@ -582,7 +592,8 @@ class ProductFournisseur extends Product
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
|
||||
$sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms";
|
||||
$sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
|
||||
$sql.= " pfp.barcode, pfp.fk_barcode_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
|
||||
$sql.= " AND pfp.fk_soc = s.rowid";
|
||||
@ -632,6 +643,11 @@ class ProductFournisseur extends Product
|
||||
$prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
|
||||
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
|
||||
|
||||
if($conf->barcode->enabled){
|
||||
$prodfourn->barcode = $record["barcode"];
|
||||
$prodfourn->fk_barcode_type = $record["fk_barcode_type"];
|
||||
}
|
||||
|
||||
if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
|
||||
$priceparser = new PriceParser($this->db);
|
||||
$price_result = $priceparser->parseProductSupplier($prodfourn);
|
||||
|
||||
@ -2769,6 +2769,8 @@ elseif (! empty($object->id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -3235,6 +3235,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -282,4 +282,3 @@ ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account;
|
||||
ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -235,6 +235,13 @@ ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid);
|
||||
ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product);
|
||||
ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom);
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL;
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL;
|
||||
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid);
|
||||
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN buy_price_ht double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN fk_product_fournisseur_price integer DEFAULT NULL;
|
||||
|
||||
|
||||
@ -31,3 +31,8 @@ ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_p
|
||||
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity);
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fk_barcode_type (fk_barcode_type);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity);
|
||||
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid);
|
||||
|
||||
@ -37,6 +37,8 @@ create table llx_product_fournisseur_price
|
||||
unitprice double(24,8) DEFAULT 0, -- unit price without tax
|
||||
charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it.
|
||||
default_vat_code varchar(10),
|
||||
barcode varchar(180) DEFAULT NULL, -- barcode
|
||||
fk_barcode_type integer DEFAULT NULL, -- barcode type
|
||||
tva_tx double(6,3) NOT NULL,
|
||||
localtax1_tx double(6,3) DEFAULT 0,
|
||||
localtax1_type varchar(10) NOT NULL DEFAULT '0',
|
||||
|
||||
@ -103,6 +103,7 @@ WrongSupplierCode=Code fournisseur incorrect
|
||||
CustomerCodeModel=Modèle de code client
|
||||
SupplierCodeModel=Modèle de code fournisseur
|
||||
Gencod=Code-barres
|
||||
GencodBuyPrice=Code-barres lié au prix d'achat
|
||||
##### Professional ID #####
|
||||
ProfId1Short=Id. prof. 1
|
||||
ProfId2Short=Id. prof. 2
|
||||
|
||||
@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
|
||||
|
||||
if(!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php');
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('products', 'suppliers', 'bills', 'margins'));
|
||||
|
||||
@ -158,6 +158,8 @@ if (empty($reshook))
|
||||
$delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
|
||||
$supplier_reputation = GETPOST('supplier_reputation');
|
||||
$supplier_description = GETPOST('supplier_description', 'alpha');
|
||||
$barcode=GETPOST('barcode', 'alpha');
|
||||
$fk_barcode_type=GETPOST('fk_barcode_type', 'int');
|
||||
|
||||
if ($tva_tx == '')
|
||||
{
|
||||
@ -258,9 +260,9 @@ if (empty($reshook))
|
||||
$multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha'));
|
||||
$multicurrency_code = GETPOST("multicurrency_code", 'alpha');
|
||||
|
||||
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description);
|
||||
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type);
|
||||
} else {
|
||||
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description);
|
||||
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type);
|
||||
}
|
||||
if ($ret < 0)
|
||||
{
|
||||
@ -666,8 +668,24 @@ SCRIPT;
|
||||
print '<tr><td>'.$langs->trans("SupplierReputation").'</td><td>';
|
||||
echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation?$supplier_reputation:$object->supplier_reputation);
|
||||
print '</td></tr>';
|
||||
if(!empty($conf->barcode->enabled)) {
|
||||
|
||||
// Option to define a transport cost on supplier price
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans('BarcodeValue') . '</td>';
|
||||
print '<td><input class="flat" name="barcode" value="'.($rowid ? $object->fourn_barcode : '').'"></td>';
|
||||
print '</tr>';
|
||||
$formbarcode = new FormBarCode($db);
|
||||
|
||||
// Barcode type
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans('BarcodeType') . '</td>';
|
||||
print '<td>';
|
||||
print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : ''), 'fk_barcode_type', 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Option to define a transport cost on supplier price
|
||||
if ($conf->global->PRODUCT_CHARGES)
|
||||
{
|
||||
if (! empty($conf->margin->enabled))
|
||||
@ -780,6 +798,10 @@ SCRIPT;
|
||||
print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if($conf->barcode->enabled) {
|
||||
print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -871,6 +893,23 @@ SCRIPT;
|
||||
}
|
||||
print'</td>';
|
||||
|
||||
if($conf->barcode->enabled) {
|
||||
// Barcode
|
||||
print '<td align="right">';
|
||||
print $productfourn->barcode;
|
||||
print '</td>';
|
||||
|
||||
|
||||
|
||||
// Barcode type
|
||||
print '<td align="center">';
|
||||
|
||||
$productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type:0;
|
||||
$productfourn->fetch_barcode();
|
||||
print $productfourn->barcode_type_label?$productfourn->barcode_type_label:($productfourn->barcode?'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>':'');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id);
|
||||
|
||||
@ -142,6 +142,7 @@ if (! empty($conf->global->MAIN_MULTILANGS))
|
||||
}
|
||||
if (! empty($conf->barcode->enabled)) {
|
||||
$fieldstosearchall['p.barcode']='Gencod';
|
||||
$fieldstosearchall['pfp.barcode']='GencodBuyPrice';
|
||||
}
|
||||
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user