diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 6bb498e9c01460a0d295d5630843fdf35ccd2919..19ea469b0e15001fc1ea1e6e737f9fe2029dce6a 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -36,6 +36,21 @@ ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10) ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +CREATE TABLE llx_product_lot ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + batch varchar(30) NOT NULL, + eatby datetime DEFAULT NULL, + sellby datetime DEFAULT NULL, + note_public text, + note_private text, + qty double NOT NULL DEFAULT 0, + import_key varchar(14) DEFAULT NULL +) ENGINE=InnoDB; + +ALTER TABLE llx_product ADD COLUMN note_public text; +ALTER TABLE llx_user ADD COLUMN note_public text; + ALTER TABLE llx_c_type_contact ADD COLUMN position integer NOT NULL DEFAULT 0; @@ -362,3 +377,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_RECEIVE','Supplier order request received','Executed when a supplier order is received','order_supplier',12); ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NULL; + +-- Delete old deprecated field +ALTER TABLE llx_product_stock DROP COLUMN pmp; + diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 78620495f61da84f12c2f1271e953c14f19fa547..d9de9da17e962bc68f5ce0d42bb8af1aed9d2013 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -35,6 +35,7 @@ create table llx_product label varchar(255) NOT NULL, description text, + note_public text, note text, customcode varchar(32), -- Optionnal custom code fk_country integer DEFAULT NULL, -- Optionnal id of original country diff --git a/htdocs/install/mysql/tables/llx_product_batch.sql b/htdocs/install/mysql/tables/llx_product_batch.sql index 1cf721513044725924db712db23efc9e02067c0f..f502bb8c23f0801df68b181b7c9a3b08a0652e50 100644 --- a/htdocs/install/mysql/tables/llx_product_batch.sql +++ b/htdocs/install/mysql/tables/llx_product_batch.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr> +-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -14,13 +15,14 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. -- +-- This table is dedicated to store detail (lots/serial) of a stock -- ============================================================================ CREATE TABLE llx_product_batch ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_product_stock integer NOT NULL, - eatby datetime DEFAULT NULL, - sellby datetime DEFAULT NULL, + eatby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot + sellby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot batch varchar(30) NOT NULL, qty double NOT NULL DEFAULT 0, import_key varchar(14) DEFAULT NULL diff --git a/htdocs/install/mysql/tables/llx_product_lot.sql b/htdocs/install/mysql/tables/llx_product_lot.sql new file mode 100644 index 0000000000000000000000000000000000000000..91796823a8ddd8ab3d5b03b00ff9f35db7db6ace --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_lot.sql @@ -0,0 +1,30 @@ +-- ============================================================================ +-- Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr> +-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- This table is dedicated to store lots with detail of each lot +-- ============================================================================ +CREATE TABLE llx_product_lot ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + batch varchar(30) NOT NULL, + eatby datetime DEFAULT NULL, + sellby datetime DEFAULT NULL, + note_public text, + note_private text, + qty double NOT NULL DEFAULT 0, + import_key varchar(14) DEFAULT NULL +) ENGINE=InnoDB; diff --git a/htdocs/install/mysql/tables/llx_product_stock.sql b/htdocs/install/mysql/tables/llx_product_stock.sql index 99d7d27fb77317e7ef68f0be059dcfe2ecff0223..a2696a4bc4e3517184fab6635039e1282d298614 100644 --- a/htdocs/install/mysql/tables/llx_product_stock.sql +++ b/htdocs/install/mysql/tables/llx_product_stock.sql @@ -1,7 +1,7 @@ -- ============================================================================ --- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> --- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> --- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> +-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> +-- Copyright (C) 2009-2016 Laurent Destailleur <eldy@users.sourceforge.net> +-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -24,8 +24,7 @@ create table llx_product_stock tms timestamp, fk_product integer NOT NULL, fk_entrepot integer NOT NULL, - reel real, -- physical stock - pmp double(24,8) default 0 NOT NULL, -- PMP value for product in this warehouse (deprecated. no sens for warehouse) - import_key varchar(14) -- Import key + reel real, -- physical stock + import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index e334ae1f802450993188305a6e2d8c5b095b6861..6b3c5b83f6dbc7d7ad9463af23a47bed3e813b07 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -61,6 +61,7 @@ create table llx_user fk_socpeople integer, fk_member integer, fk_user integer, -- Hierarchic parent + note_public text, note text DEFAULT NULL, datelastlogin datetime, datepreviouslogin datetime, diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ca752c1a1f87e899399e80e7612ff64a9ce515b0..a538e4543ee56e011c8d252b0694efcf7c644e1f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3338,7 +3338,7 @@ class Product extends CommonObject $this->stock_reel = 0; $this->stock_warehouse = array(); - $sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp, ps.rowid"; + $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; $sql.= " WHERE w.entity IN (".getEntity('stock', 1).")"; @@ -3358,7 +3358,6 @@ class Product extends CommonObject $row = $this->db->fetch_object($result); $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; - $this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1); $this->stock_reel+=$row->reel; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 80d8bea62f757a3bc232ae7214e7f3fe89a0237a..430e042c202f43ba81c3145319e3ab517695991c 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -384,7 +384,7 @@ else print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$id,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$id,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$id,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$id,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&id=".$id,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$id,"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&id=".$id,"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&id=".$id,"",'align="right"',$sortfield,$sortorder); @@ -396,7 +396,7 @@ else $totalvalue=$totalvaluesell=0; $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; - $sql.= " ps.pmp, ps.reel as value"; + $sql.= " ps.reel as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_product = p.rowid"; $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index dde89bfb6e52272b243516dc12f45591487e54c3..652c6d9dc363b5fdeb0ab67fe904793fc0ba255c 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -304,15 +304,12 @@ class MouvementStock extends CommonObject { if ($num > 0) { - //$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET pmp = ".$newpmpwarehouse.", reel = reel + ".$qty; $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty; $sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock"; - //$sql.= " (pmp, reel, fk_entrepot, fk_product) VALUES "; - //$sql.= " (".$newpmpwarehouse.", ".$qty.", ".$entrepot_id.", ".$fk_product.")"; $sql.= " (reel, fk_entrepot, fk_product) VALUES "; $sql.= " (".$qty.", ".$entrepot_id.", ".$fk_product.")"; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 42fadf549230fe05da2f6be649480c174e874dd3..de30bc3d0b6008a6bab3f226e296cf2d81477436 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -229,7 +229,6 @@ if ($action == "transfert_stock" && ! $cancel) // Define value of products moved $pricesrc=0; - //if (isset($object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; if (isset($object->pmp)) $pricesrc=$object->pmp; $pricedest=$pricesrc; @@ -677,7 +676,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) print '</tr>'; } -$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.pmp, ps.rowid as product_stock_id"; +$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";