diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index bd73699dd9c..3d7d892586e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -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"]; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a6629b9bd25..f063d792937 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -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; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cc9164b753f..e85e8b06236 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -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']); diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 1ff1fb0e427..197940745c0 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -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 diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 43afe4f74e7..685c8780e8b 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -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 ''; @@ -660,6 +664,15 @@ if (! empty($conf->global->MAIN_MULTILANGS)) print ''; } +if (! empty($conf->fournisseur->enabled)) +{ + print ''; + print ''.$langs->trans("UseProductFournDesc").''; + print ''; + print $form->selectyesno("activate_useProdFournDesc", (! empty($conf->global->PRODUIT_FOURN_TEXTS)?$conf->global->PRODUIT_FOURN_TEXTS:0), 1); + print ''; + print ''; +} if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e293ba94bbe..4f7fe91f5ec 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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 diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5219291e8af..ecbb477b696 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -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 ''; } } - + + // 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 ''; + print ''.$langs->trans('ProductSupplierDescription').''; + print ''; + + $doleditor = new DolEditor('supplier_description', $object->desc_supplier, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); + $doleditor->Create(); + + print ''; + print ''; + } + if (is_object($hookmanager)) { $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8c2bfb8090a..723babdc885 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -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;