2
0
forked from Wavyzz/dolibarr

New: Ajout d'un champ note sur les produits non destin etre visible sur les factures ou propales.

This commit is contained in:
Laurent Destailleur
2005-08-20 18:25:39 +00:00
parent 1267e3dbd9
commit d0e245c030
5 changed files with 29 additions and 20 deletions

View File

@@ -59,4 +59,5 @@ NoPhotoYet=No pictures available yet
PriceRemoved=Price removed PriceRemoved=Price removed
BarCode=Barcode BarCode=Barcode
Pack=Pack Pack=Pack
Packs=Packs Packs=Packs
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)

View File

@@ -74,4 +74,5 @@ DeleteFromCat=Supprimer de la cat
PriceRemoved=Prix supprim<69> PriceRemoved=Prix supprim<69>
BarCode=Code barre BarCode=Code barre
Pack=Lot Pack=Lot
Packs=Lots Packs=Lots
NoteNotVisibleOnBill=Note (non visible sur les factures, propals...)

View File

@@ -104,9 +104,13 @@ class Product
function create($user) function create($user)
{ {
$this->ref = ereg_replace("'","",stripslashes($this->ref)); $this->ref = ereg_replace("'","",$this->ref);
$this->ref = ereg_replace("\"","",stripslashes($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); dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid);
$this->db->begin(); $this->db->begin();
@@ -120,12 +124,6 @@ class Product
$row = $this->db->fetch_array($result); $row = $this->db->fetch_array($result);
if ($row[0] == 0) 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 = "INSERT INTO ".MAIN_DB_PREFIX."product ";
$sql .= " (datec, fk_user_author, fk_product_type, price)"; $sql .= " (datec, fk_user_author, fk_product_type, price)";
$sql .= " VALUES (now(),".$user->id.",$this->type, '" . $this->price . "')"; $sql .= " VALUES (now(),".$user->id.",$this->type, '" . $this->price . "')";
@@ -191,12 +189,14 @@ class Product
$langs->load("products"); $langs->load("products");
if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT'; 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 = trim($this->ref);
$this->ref = ereg_replace("\"","",$this->ref);
$this->ref = ereg_replace("'","",$this->ref);
$this->libelle = trim($this->libelle); $this->libelle = trim($this->libelle);
$this->description = trim($this->description); $this->description = trim($this->description);
$this->note = trim($this->note);
$sql = "UPDATE ".MAIN_DB_PREFIX."product "; $sql = "UPDATE ".MAIN_DB_PREFIX."product ";
$sql .= " SET label = '" . addslashes($this->libelle) ."'"; $sql .= " SET label = '" . addslashes($this->libelle) ."'";
@@ -205,6 +205,7 @@ class Product
$sql .= ",envente = " . $this->envente ; $sql .= ",envente = " . $this->envente ;
$sql .= ",seuil_stock_alerte = " . $this->seuil_stock_alerte ; $sql .= ",seuil_stock_alerte = " . $this->seuil_stock_alerte ;
$sql .= ",description = '" . addslashes($this->description) ."'"; $sql .= ",description = '" . addslashes($this->description) ."'";
$sql .= ",note = '" . addslashes($this->note) ."'";
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'"; $sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
$sql .= " WHERE rowid = " . $id; $sql .= " WHERE rowid = " . $id;
@@ -214,11 +215,13 @@ class Product
} }
else 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); $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
return -1; return -1;
} }
else { else
{
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2; return -2;
} }
@@ -397,8 +400,9 @@ class Product
*/ */
function fetch ($id) function fetch ($id)
{ {
$sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration, seuil_stock_alerte"; $sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,";
$sql .= " FROM ".MAIN_DB_PREFIX."product WHERE rowid = $id"; $sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte";
$sql.= " FROM ".MAIN_DB_PREFIX."product WHERE rowid = $id";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
@@ -410,6 +414,7 @@ class Product
$this->ref = $result["ref"]; $this->ref = $result["ref"];
$this->libelle = stripslashes($result["label"]); $this->libelle = stripslashes($result["label"]);
$this->description = stripslashes($result["description"]); $this->description = stripslashes($result["description"]);
$this->note = stripslashes($result["note"]);
$this->price = $result["price"]; $this->price = $result["price"];
$this->tva_tx = $result["tva_tx"]; $this->tva_tx = $result["tva_tx"];
$this->type = $result["fk_product_type"]; $this->type = $result["fk_product_type"];

View File

@@ -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; alter table llx_product add seuil_stock_alerte integer default 0;
update llx_product set ref=substr(label,0,15) where ref is null; 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 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 ; alter table llx_groupart add description text after groupart ;

View File

@@ -26,10 +26,11 @@ create table llx_product
datec datetime, datec datetime,
tms timestamp, tms timestamp,
ref varchar(15) UNIQUE NOT NULL, ref varchar(15) UNIQUE NOT NULL,
label varchar(255), label varchar(128),
description text, description varchar(255),
note text,
price double, price double,
tva_tx double DEFAULT 19.6, tva_tx double,
fk_user_author integer, fk_user_author integer,
envente tinyint DEFAULT 1, envente tinyint DEFAULT 1,
nbvente integer DEFAULT 0, nbvente integer DEFAULT 0,