From d0e245c0303d5b9f429bba861778700dd643d98c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Aug 2005 18:25:39 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20d'un=20champ=20note=20sur=20les?= =?UTF-8?q?=20produits=20non=20destin=E9=20=E0=20etre=20visible=20sur=20le?= =?UTF-8?q?s=20factures=20ou=20propales.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/langs/en_US/products.lang | 3 ++- htdocs/langs/fr_FR/products.lang | 3 ++- htdocs/product.class.php | 35 ++++++++++++++++++-------------- mysql/migration/1.1.0-2.0.0.sql | 1 + mysql/tables/llx_product.sql | 7 ++++--- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 52688faef48..02377377fea 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -59,4 +59,5 @@ NoPhotoYet=No pictures available yet PriceRemoved=Price removed BarCode=Barcode Pack=Pack -Packs=Packs \ No newline at end of file +Packs=Packs +NoteNotVisibleOnBill=Note (not visible on invoices, proposals...) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index eacbea83682..cae78a591f4 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -74,4 +74,5 @@ DeleteFromCat=Supprimer de la cat PriceRemoved=Prix supprimé BarCode=Code barre Pack=Lot -Packs=Lots \ No newline at end of file +Packs=Lots +NoteNotVisibleOnBill=Note (non visible sur les factures, propals...) \ No newline at end of file diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 5cb7e524964..2cc1fc53fcb 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -104,9 +104,13 @@ class Product function create($user) { - $this->ref = ereg_replace("'","",stripslashes($this->ref)); - $this->ref = ereg_replace("\"","",stripslashes($this->ref)); - + $this->ref = ereg_replace("'","",$this->ref); + $this->ref = ereg_replace("\"","",$this->ref); + if (strlen($this->tva_tx)==0) $this->tva_tx = 0; + if (strlen($this->price)==0) $this->price = 0; + if (strlen($this->envente)==0) $this->envente = 0; + $this->price = ereg_replace(",",".",$this->price); + dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid); $this->db->begin(); @@ -120,12 +124,6 @@ class Product $row = $this->db->fetch_array($result); if ($row[0] == 0) { - if (strlen($this->tva_tx)==0) $this->tva_tx = 0; - if (strlen($this->price)==0) $this->price = 0; - if (strlen($this->envente)==0) $this->envente = 0; - - $this->price = ereg_replace(",",".",$this->price); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product "; $sql .= " (datec, fk_user_author, fk_product_type, price)"; $sql .= " VALUES (now(),".$user->id.",$this->type, '" . $this->price . "')"; @@ -191,12 +189,14 @@ class Product $langs->load("products"); if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT'; - $this->ref = ereg_replace("\"","",stripslashes($this->ref)); - $this->ref = ereg_replace("'","",stripslashes($this->ref)); $this->ref = trim($this->ref); + $this->ref = ereg_replace("\"","",$this->ref); + $this->ref = ereg_replace("'","",$this->ref); + $this->libelle = trim($this->libelle); $this->description = trim($this->description); + $this->note = trim($this->note); $sql = "UPDATE ".MAIN_DB_PREFIX."product "; $sql .= " SET label = '" . addslashes($this->libelle) ."'"; @@ -205,6 +205,7 @@ class Product $sql .= ",envente = " . $this->envente ; $sql .= ",seuil_stock_alerte = " . $this->seuil_stock_alerte ; $sql .= ",description = '" . addslashes($this->description) ."'"; + $sql .= ",note = '" . addslashes($this->note) ."'"; $sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'"; $sql .= " WHERE rowid = " . $id; @@ -214,11 +215,13 @@ class Product } else { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref); return -1; } - else { + else + { $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; } @@ -397,8 +400,9 @@ class Product */ function fetch ($id) { - $sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration, seuil_stock_alerte"; - $sql .= " FROM ".MAIN_DB_PREFIX."product WHERE rowid = $id"; + $sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,"; + $sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte"; + $sql.= " FROM ".MAIN_DB_PREFIX."product WHERE rowid = $id"; $result = $this->db->query($sql) ; @@ -410,6 +414,7 @@ class Product $this->ref = $result["ref"]; $this->libelle = stripslashes($result["label"]); $this->description = stripslashes($result["description"]); + $this->note = stripslashes($result["note"]); $this->price = $result["price"]; $this->tva_tx = $result["tva_tx"]; $this->type = $result["fk_product_type"]; diff --git a/mysql/migration/1.1.0-2.0.0.sql b/mysql/migration/1.1.0-2.0.0.sql index 98dfe5dc30d..e79f4dc3430 100644 --- a/mysql/migration/1.1.0-2.0.0.sql +++ b/mysql/migration/1.1.0-2.0.0.sql @@ -419,6 +419,7 @@ alter table llx_product add stock_commande integer default 0; alter table llx_product add seuil_stock_alerte integer default 0; update llx_product set ref=substr(label,0,15) where ref is null; alter table llx_product modify ref varchar(15) UNIQUE NOT NULL; +alter table llx_product add note text after description; alter table llx_groupart add description text after groupart ; diff --git a/mysql/tables/llx_product.sql b/mysql/tables/llx_product.sql index 4efd3a0f279..41b92a5523f 100644 --- a/mysql/tables/llx_product.sql +++ b/mysql/tables/llx_product.sql @@ -26,10 +26,11 @@ create table llx_product datec datetime, tms timestamp, ref varchar(15) UNIQUE NOT NULL, - label varchar(255), - description text, + label varchar(128), + description varchar(255), + note text, price double, - tva_tx double DEFAULT 19.6, + tva_tx double, fk_user_author integer, envente tinyint DEFAULT 1, nbvente integer DEFAULT 0,