Merge pull request #9214 from atm-greg/Add_supplier_product_description
NEW Can record the supplier product description
This commit is contained in:
commit
1b20d6feab
@ -50,6 +50,7 @@ class ProductFournisseur extends Product
|
||||
var $fourn_ref;
|
||||
var $delivery_time_days;
|
||||
var $ref_supplier; // ref supplier (can be set by get_buyprice)
|
||||
var $desc_supplier;
|
||||
var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
|
||||
|
||||
var $fourn_id; //supplier id
|
||||
@ -196,9 +197,10 @@ class ProductFournisseur extends Product
|
||||
* @param string $multicurrency_price_base_type HT or TTC in currency
|
||||
* @param float $multicurrency_tx Rate currency
|
||||
* @param string $multicurrency_code Currency code
|
||||
* @param string $desc_fourn Custom description for product_fourn_price
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
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='')
|
||||
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='')
|
||||
{
|
||||
global $conf, $langs;
|
||||
//global $mysoc;
|
||||
@ -270,6 +272,7 @@ class ProductFournisseur extends Product
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql.= " SET fk_user = " . $user->id." ,";
|
||||
$sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',";
|
||||
$sql.= " desc_fourn = '" . $this->db->escape($desc_fourn) . "',";
|
||||
$sql.= " price = ".price2num($buyprice).",";
|
||||
$sql.= " quantity = ".$qty.",";
|
||||
$sql.= " remise_percent = ".$remise_percent.",";
|
||||
@ -336,7 +339,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, 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)";
|
||||
$sql .= " values(";
|
||||
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
|
||||
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
|
||||
@ -347,6 +350,7 @@ class ProductFournisseur extends Product
|
||||
$sql .= " " . $this->id . ",";
|
||||
$sql .= " " . $fourn->id . ",";
|
||||
$sql .= " '" . $this->db->escape($ref_fourn) . "',";
|
||||
$sql .= " '" . $this->db->escape($desc_fourn) . "',";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . $buyprice . ",";
|
||||
$sql .= " " . $qty . ",";
|
||||
@ -436,7 +440,7 @@ class ProductFournisseur extends Product
|
||||
global $conf;
|
||||
|
||||
$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.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
|
||||
$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";
|
||||
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
@ -456,6 +460,7 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_id = $obj->fk_soc;
|
||||
$this->fourn_ref = $obj->ref_fourn; // deprecated
|
||||
$this->ref_supplier = $obj->ref_fourn;
|
||||
$this->desc_supplier = $obj->desc_fourn;
|
||||
$this->fourn_price = $obj->price;
|
||||
$this->fourn_charges = $obj->charges; // deprecated
|
||||
$this->fourn_qty = $obj->quantity;
|
||||
@ -525,7 +530,7 @@ class ProductFournisseur extends Product
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$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";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
@ -553,6 +558,7 @@ class ProductFournisseur extends Product
|
||||
$prodfourn->product_fourn_id = $record["product_fourn_id"];
|
||||
$prodfourn->fourn_ref = $record["ref_fourn"];
|
||||
$prodfourn->ref_supplier = $record["ref_fourn"];
|
||||
$prodfourn->desc_supplier = $record["desc_fourn"];
|
||||
$prodfourn->fourn_price = $record["price"];
|
||||
$prodfourn->fourn_qty = $record["quantity"];
|
||||
$prodfourn->fourn_remise_percent = $record["remise_percent"];
|
||||
|
||||
@ -401,7 +401,11 @@ if (empty($reshook))
|
||||
{
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
// if we use supplier description of the products
|
||||
if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||
$desc = $productsupplier->desc_supplier;
|
||||
} else $desc = $productsupplier->description;
|
||||
|
||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
||||
|
||||
$type = $productsupplier->type;
|
||||
|
||||
@ -1209,7 +1209,11 @@ if (empty($reshook))
|
||||
{
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
// if we use supplier description of the products
|
||||
if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||
$desc = $productsupplier->desc_supplier;
|
||||
} else $desc = $productsupplier->description;
|
||||
|
||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
||||
|
||||
$type = $productsupplier->type;
|
||||
|
||||
@ -38,6 +38,7 @@ ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent varchar(32) DEFA
|
||||
|
||||
ALTER TABLE llx_extrafields ADD COLUMN help text NULL;
|
||||
ALTER TABLE llx_extrafields ADD COLUMN totalizable boolean DEFAULT FALSE after list;
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN desc_fourn text after ref_fourn;
|
||||
|
||||
|
||||
ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment;
|
||||
|
||||
@ -28,6 +28,7 @@ create table llx_product_fournisseur_price
|
||||
fk_product integer,
|
||||
fk_soc integer,
|
||||
ref_fourn varchar(30),
|
||||
desc_fourn text,
|
||||
fk_availability integer,
|
||||
price double(24,8) DEFAULT 0, -- price without tax for quantity
|
||||
quantity double,
|
||||
|
||||
@ -293,7 +293,8 @@ ProductSheet=Product sheet
|
||||
ServiceSheet=Service sheet
|
||||
PossibleValues=Possible values
|
||||
GoOnMenuToCreateVairants=Go on menu %s - %s to prepare attribute variants (like colors, size, ...)
|
||||
|
||||
UseProductFournDesc=Use supplier descriptions of products in supplier documents
|
||||
ProductSupplierDescription=Supplier description for the product
|
||||
#Attributes
|
||||
VariantAttributes=Variant attributes
|
||||
ProductAttributes=Variant attributes for products
|
||||
|
||||
@ -144,6 +144,18 @@ if ($action == 'other')
|
||||
|
||||
$value = GETPOST('activate_usesearchtoselectproduct','alpha');
|
||||
$res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $value,'chaine',0,'',$conf->entity);
|
||||
|
||||
$value = GETPOST('activate_useProdFournDesc', 'alpha');
|
||||
$res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value,'chaine',0,'',$conf->entity);
|
||||
if ($value) {
|
||||
$sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1";
|
||||
$resql = $db->query($sql_test);
|
||||
if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it
|
||||
{
|
||||
$sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN desc_fourn text";
|
||||
$resql_new = $db->query($sql_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'specimen') // For products
|
||||
@ -541,6 +553,7 @@ $rowspan = 4;
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++;
|
||||
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) $rowspan++;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) $rowspan++;
|
||||
if (! empty($conf->fournisseur->enabled)) $rowspan++;
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
@ -653,6 +666,15 @@ if (! empty($conf->global->MAIN_MULTILANGS))
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("UseProductFournDesc").'</td>';
|
||||
print '<td width="60" align="right">';
|
||||
print $form->selectyesno("activate_useProdFournDesc", (! empty($conf->global->PRODUIT_FOURN_TEXTS)?$conf->global->PRODUIT_FOURN_TEXTS:0), 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (! empty($conf->global->PRODUCT_CANVAS_ABILITY))
|
||||
{
|
||||
|
||||
@ -1523,7 +1523,7 @@ class Product extends CommonObject
|
||||
|
||||
// We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref)
|
||||
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,";
|
||||
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression";
|
||||
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression";
|
||||
$sql.= " ,pfp.default_vat_code";
|
||||
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
@ -1560,6 +1560,7 @@ class Product extends CommonObject
|
||||
$this->fourn_socid = $obj->fk_soc; // Company that offer this price
|
||||
$this->ref_fourn = $obj->ref_fourn; // deprecated
|
||||
$this->ref_supplier = $obj->ref_fourn; // Ref supplier
|
||||
$this->desc_supplier = $obj->desc_fourn; // desc supplier
|
||||
$this->remise_percent = $obj->remise_percent; // remise percent if present and not typed
|
||||
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
||||
$this->default_vat_code = $obj->default_vat_code; // Vat code supplier
|
||||
@ -1575,7 +1576,7 @@ class Product extends CommonObject
|
||||
{
|
||||
// We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc.
|
||||
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
|
||||
$sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression";
|
||||
$sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression";
|
||||
$sql.= " ,pfp.default_vat_code";
|
||||
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
@ -1616,6 +1617,7 @@ class Product extends CommonObject
|
||||
$this->fourn_socid = $obj->fk_soc; // Company that offer this price
|
||||
$this->ref_fourn = $obj->ref_supplier; // deprecated
|
||||
$this->ref_supplier = $obj->ref_supplier; // Ref supplier
|
||||
$this->desc_supplier = $obj->desc_supplier; // desc supplier
|
||||
$this->remise_percent = $obj->remise_percent; // remise percent if present and not typed
|
||||
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
||||
$this->default_vat_code = $obj->default_vat_code; // Vat code supplier
|
||||
|
||||
@ -156,6 +156,7 @@ if (empty($reshook))
|
||||
$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') : '';
|
||||
$supplier_reputation = GETPOST('supplier_reputation');
|
||||
$supplier_description = GETPOST('supplier_description', 'alpha');
|
||||
|
||||
if ($tva_tx == '')
|
||||
{
|
||||
@ -249,9 +250,9 @@ if (empty($reshook))
|
||||
$object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']);
|
||||
|
||||
if ($conf->multicurrency->enabled) {
|
||||
$ret = $object->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $_POST["multicurrency_price"], $_POST["multicurrency_price_base_type"], $_POST["multicurrency_tx"], $_POST["multicurrency_code"]);
|
||||
$ret = $object->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $_POST["multicurrency_price"], $_POST["multicurrency_price_base_type"], $_POST["multicurrency_tx"], $_POST["multicurrency_code"], $supplier_description);
|
||||
} else {
|
||||
$ret = $object->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation);
|
||||
$ret = $object->update_buyprice($quantity, $_POST["price"], $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);
|
||||
}
|
||||
if ($ret < 0)
|
||||
{
|
||||
@ -672,6 +673,23 @@ SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
// Product description of the supplier
|
||||
if (! empty($conf->global->PRODUIT_FOURN_TEXTS))
|
||||
{
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('ProductSupplierDescription').'</td>';
|
||||
print '<td>';
|
||||
|
||||
$doleditor = new DolEditor('supplier_description', $object->desc_supplier, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id);
|
||||
|
||||
@ -624,7 +624,11 @@ if (empty($reshook))
|
||||
{
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
// if we use supplier description of the products
|
||||
if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||
$desc = $productsupplier->desc_supplier;
|
||||
} else $desc = $productsupplier->description;
|
||||
|
||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
||||
|
||||
$pu_ht = $productsupplier->fourn_pu;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user