From 6dfeaabad5f77d77b83c6d34b6747b2c71e76ce2 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Thu, 1 Dec 2016 22:28:29 +0100 Subject: [PATCH 1/9] FIX: #6062 --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 88eceda8aa9..e93687fb65d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1267,7 +1267,7 @@ else print ''.$langs->trans("Description").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); $doleditor->Create(); print ""; From c2bee0f9375035cd96645f3e9bebe968342d667a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Dec 2016 12:44:56 +0100 Subject: [PATCH 2/9] FIX #6088 --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 52c3b2f5cb9..420f6529758 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -729,7 +729,7 @@ class ExtraFields } elseif ($type == 'price') { - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { From 79d6fa334b811edbdfa637895d6d3270b044b005 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Thu, 8 Dec 2016 13:12:10 +0100 Subject: [PATCH 3/9] FIX: Consistent description for add or edit product --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e93687fb65d..359ba7416d5 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -963,7 +963,7 @@ else // Description (used in invoice, propal...) print ''.$langs->trans("Description").''; - $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, '80%'); + $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, '80%'); $doleditor->Create(); print ""; @@ -1267,7 +1267,7 @@ else print ''.$langs->trans("Description").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); $doleditor->Create(); print ""; From a45915e4a006bcd8eea7dec175d67650fa72dcdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Dec 2016 12:04:13 +0100 Subject: [PATCH 4/9] Better message after report on #5933 --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 85e3b313ccc..c602d3a2a3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,7 +115,7 @@ NEW: Add hidden option to hide column qty ordered on shipments. NEW: Add view of virtual stock into product list (when appropriate) NEW: Add warning on tasks when they are late (add also the warning tolerance parameter) NEW: Add weight/volume for one product into shipment export -NEW: Add width and height on product card +NEW: Add width and height on product table NEW: allow a document to be linked to project from another customer on config NEW: allow project to be shared across entities (for multicompany module) NEW: All variant of ckeditor config can be tested into the setup page of module. From 829ff2299e7a6e3ae01abf8fef953e14d0750190 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 10 Dec 2016 12:46:26 +0100 Subject: [PATCH 5/9] Fix: Delete surplus migration file --- .../install/mysql/migration/3.8.0-3.9.0.sql | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 htdocs/install/mysql/migration/3.8.0-3.9.0.sql diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql deleted file mode 100644 index c3e6b5b091e..00000000000 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ /dev/null @@ -1,30 +0,0 @@ --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 3.9.0 or higher. --- --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To restrict request to Mysql version x.y use -- VMYSQLx.y --- To restrict request to Pgsql version x.y use -- VPGSQLx.y --- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE --- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); --- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); - --- Fix bad data -update llx_opensurvey_sondage set format = 'D' where format = 'D+'; -update llx_opensurvey_sondage set format = 'A' where format = 'A+'; - -INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); - -ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); -ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); - - From 97e21cb7758d9ad24534f4c639eaa0e01da40b48 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 10 Dec 2016 13:05:46 +0100 Subject: [PATCH 6/9] Fix : delete product was not possible if batch stock --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 78ea0cb39c7..6b53fea0347 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -879,7 +879,7 @@ class Product extends CommonObject // Delete all child tables if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price'); + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_batch'); foreach($elements as $table) { if (! $error) From 5a2b8ff53cce86971b56299c7b6592819df1bb75 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 10 Dec 2016 22:41:53 +0100 Subject: [PATCH 7/9] FIX #5853 $conf->global->$calc==0 || $conf->global->$calc==1 --- htdocs/compta/localtax/clients.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index b4cea5b4982..5c21b67a891 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -106,7 +106,7 @@ $fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport -if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services +if ($calc==0 || $calc==1) // Calculate on invoice for goods and services { $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); @@ -124,7 +124,7 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice $productsup=$langs->trans("Description"); $amountsup=$langs->trans("AmountHT"); } -if ($conf->global->$calc==2) // Invoice for goods, payment for services +if ($calc==2) // Invoice for goods, payment for services { $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$langs->trans("CalcModeLT2Debt"); @@ -149,7 +149,7 @@ $vatcust=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code); $vatsup=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code); // IRPF that the customer has retained me -if($conf->global->$calc ==0 || $conf->global->$calc == 2) +if($calc ==0 || $calc == 2) { print ""; print ""; @@ -232,7 +232,7 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 2) } // IRPF I retained my supplier -if($conf->global->$calc ==0 || $conf->global->$calc == 1){ +if($calc ==0 || $calc == 1){ print "
"; print ""; print '"; @@ -309,7 +309,7 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 1){ } } -if($conf->global->$calc ==0){ +if($calc ==0){ // Total to pay print '

'; print '
'.$langs->trans("Num")."
'; From 7fd75c793aea3b0b003f40c4d97be86c4f29dc43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Dec 2016 10:39:48 +0100 Subject: [PATCH 8/9] FIX Regression when deleting product --- htdocs/product/class/product.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9bf8bcbd3f0..1d8d17d6c8f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -908,10 +908,26 @@ class Product extends CommonObject // End call triggers } + // Delete from product_batch on product delete + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; + $sql.= " WHERE fk_product_stock IN ("; + $sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; + $sql.= " WHERE fk_product = ".$id.")"; + dol_syslog(get_class($this).'::delete', LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete all child tables if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_batch'); + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price'); foreach($elements as $table) { if (! $error) From 43d18cd70cb19b2e552fa3179ccf7b3564b1a6f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Dec 2016 13:22:24 +0100 Subject: [PATCH 9/9] FIX if a supplier price reference is changed after creating an order, we can't clone order. --- .../class/fournisseur.commande.class.php | 52 +++++++++++-------- .../fourn/class/fournisseur.facture.class.php | 10 ++-- htdocs/product/class/product.class.php | 8 +-- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index df3b5efa75a..b2f2d3dc3c3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -324,10 +324,10 @@ class CommandeFournisseur extends CommonOrder $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; - $line->ref = $objp->product_ref; - $line->product_ref = $objp->product_ref; - $line->ref_fourn = $objp->ref_supplier; - $line->ref_supplier = $objp->ref_supplier; + $line->ref = $objp->product_ref; // Ref of product + $line->product_ref = $objp->product_ref; // Ref of product + $line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since + $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); @@ -1139,7 +1139,7 @@ class CommandeFournisseur extends CommonOrder $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, 0, - $this->lines[$i]->ref_fourn, + $this->lines[$i]->ref_fourn, // $this->lines[$i]->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product $this->lines[$i]->remise_percent, 'HT', 0, @@ -1295,7 +1295,7 @@ class CommandeFournisseur extends CommonOrder * @param float $txlocaltax2 Localtax2 tax * @param int $fk_product Id product * @param int $fk_prod_fourn_price Id supplier price - * @param string $fourn_ref Supplier reference + * @param string $fourn_ref Supplier reference price * @param float $remise_percent Remise * @param string $price_base_type HT or TTC * @param float $pu_ttc Unit price TTC @@ -1341,7 +1341,8 @@ class CommandeFournisseur extends CommonOrder $pu=$pu_ttc; } $desc=trim($desc); - + $ref=''; // Ref of supplier price when we add line + // Check parameters if ($qty < 1 && ! $fk_product) { @@ -1363,15 +1364,28 @@ class CommandeFournisseur extends CommonOrder $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, $fourn_ref); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref + $product_type = $prod->type; + $label = $prod->libelle; + + // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc if ($result > 0) { - $label = $prod->libelle; - $pu = $prod->fourn_pu; - $ref = $prod->ref_fourn; - $product_type = $prod->type; + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref = $prod->ref_fourn; // Ref supplier price set by get_buyprice } - if ($result == 0 || $result == -1) + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) { $langs->load("errors"); $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); @@ -1424,7 +1438,7 @@ class CommandeFournisseur extends CommonOrder $subprice = price2num($pu,'MU'); - // TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work loke other object (proposal, order, invoice) + // TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work like other object (proposal, order, invoice) $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " (fk_commande, label, description, date_start, date_end,"; $sql.= " fk_product, product_type,"; @@ -2708,15 +2722,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // From llx_product_fournisseur_price /** - * Supplier ref - * @var string - * @deprecated Use ref_supplier - * @see ref_supplier - */ - public $ref_fourn; - - /** - * Supplier reference + * Supplier reference of price when we added the line. May have been changed after line was added. * @var string */ public $ref_supplier; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8c1a86b03a5..bc7f5bfdca6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1219,11 +1219,11 @@ class FactureFournisseur extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - + $ref=''; // Ref of supplier price when we add line + // Check parameters if ($type < 0) return -1; - $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; @@ -1954,12 +1954,14 @@ class SupplierInvoiceLine extends CommonObjectLine * @var string */ public $product_ref; + /** - * Reference product supplier - * TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline + * Supplier reference of price when we added the line. May have been changed after line was added. + * TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields into updateline * @var string */ public $ref_supplier; + /** * @deprecated * @see label diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2d222829812..fe432b5dc5e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1334,10 +1334,11 @@ class Product extends CommonObject * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param double $qty Quantity asked or -1 to get first entry found * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search. + * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. + * @param int $fk_soc If of supplier * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ - function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='') + function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) { global $conf; $result = 0; @@ -1383,12 +1384,13 @@ class Product extends CommonObject } else // If not found { - // We do a second search by doing a select again but searching with qty and id product + // 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.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.fk_product = ".$product_id; if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; + if ($fk_soc > 0) $sql.= " AND pfp.fk_soc = ".$fk_soc; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; $sql.= " LIMIT 1";