New fields desc_supplier on product_fourn_prices

This commit is contained in:
atm-greg 2018-08-06 16:26:25 +02:00
parent 6010d9de4b
commit a8b33a1710
8 changed files with 62 additions and 11 deletions

View File

@ -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
@ -191,7 +192,7 @@ class ProductFournisseur extends Product
* @param string $newdefaultvatcode Default vat code
* @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='')
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='', $desc_fourn='')
{
global $conf, $langs;
//global $mysoc;
@ -245,6 +246,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.",";
@ -393,7 +395,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.unitcharges, 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.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
$sql.= " pfp.supplier_reputation";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$rowid;
@ -412,6 +414,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;
@ -476,7 +479,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.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
@ -503,6 +506,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"];

View File

@ -389,7 +389,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;

View File

@ -987,7 +987,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);
$tva_tx=get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']);

View File

@ -291,7 +291,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

View File

@ -143,6 +143,9 @@ 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 ($action == 'specimen') // For products
@ -544,6 +547,7 @@ $rowspan = 4;
if (! empty($conf->global->PRODUIT_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">';
@ -660,6 +664,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))
{

View File

@ -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.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$prodfournprice;
@ -1558,6 +1558,7 @@ class Product extends CommonObject
$this->fourn_price_base_type = 'HT'; // Price base type
$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
@ -1568,7 +1569,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.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.fk_product = ".$product_id;
@ -1607,6 +1608,7 @@ class Product extends CommonObject
$this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier
$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

View File

@ -157,6 +157,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 == '')
{
@ -232,7 +233,7 @@ if (empty($reshook))
if (isset($_POST['ref_fourn_price_id']))
$object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']);
$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, '', '', $supplier_description);
if ($ret < 0)
{
@ -562,7 +563,24 @@ if ($id > 0 || $ref)
print '</tr>';
}
}
// 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);

View File

@ -613,7 +613,12 @@ if (empty($reshook))
$price_base_type = $productsupplier->fourn_price_base_type;
$type = $productsupplier->type;
$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);
$ref_supplier = $productsupplier->ref_supplier;