diff --git a/htdocs/product.class.php3 b/htdocs/product.class.php3 index b511b59bb34..ad44872e391 100644 --- a/htdocs/product.class.php3 +++ b/htdocs/product.class.php3 @@ -30,6 +30,9 @@ class Product var $description; var $price; var $tva_tx; + var $type; + var $duration_value; + var $duration_unit; Function Product($DB, $id=0) { @@ -45,7 +48,7 @@ class Product Function create($user) { - $sql = "INSERT INTO llx_product (fk_user_author) VALUES (".$user->id.")"; + $sql = "INSERT INTO llx_product (fk_user_author, fk_product_type) VALUES (".$user->id.",$this->type)"; if ($this->db->query($sql) ) { @@ -78,6 +81,7 @@ class Product $sql .= ",tva_tx = " . $this->tva_tx ; $sql .= ",envente = " . $this->envente ; $sql .= ",description = '" . trim($this->description) ."'"; + $sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'"; $sql .= " WHERE rowid = " . $id; @@ -104,7 +108,7 @@ class Product Function fetch ($id) { - $sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente"; + $sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration"; $sql .= " FROM llx_product WHERE rowid = $id"; $result = $this->db->query($sql) ; @@ -119,10 +123,20 @@ class Product $this->description = stripslashes($result["description"]); $this->price = $result["price"]; $this->tva_tx = $result["tva_tx"]; + $this->type = $result["fk_product_type"]; $this->nbvente = $result["nbvente"]; $this->envente = $result["envente"]; + + $this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1); + $this->duration_unit = substr($result["duration"],-1); + + $this->db->free(); } - $this->db->free(); + else + { + print $this->db->error(); + } + return $result; } /* diff --git a/htdocs/product/fiche.php3 b/htdocs/product/fiche.php3 index 27c5a8c00a5..12ed842cf0d 100644 --- a/htdocs/product/fiche.php3 +++ b/htdocs/product/fiche.php3 @@ -20,9 +20,6 @@ * */ -$types[0] = "produit"; -$types[1] = "service"; - require("./pre.inc.php3"); require("../propal.class.php3"); require("../facture.class.php3"); @@ -84,6 +81,8 @@ if ($action == 'update' && $cancel <> 'Annuler') $product->tva_tx = $HTTP_POST_VARS["tva_tx"]; $product->description = $HTTP_POST_VARS["desc"]; $product->envente = $HTTP_POST_VARS["statut"]; + $product->duration_value = $HTTP_POST_VARS["duration_value"]; + $product->duration_unit = $HTTP_POST_VARS["duration_unit"]; if ( $product->update($id, $user)) { @@ -102,7 +101,7 @@ if ($action == 'update' && $cancel <> 'Annuler') */ if ($action == 'create') { - print "
'; @@ -134,14 +143,14 @@ else { print '| Durée | '.$product->tva_tx.' % |
| Durée | '.$product->duration_value.' '; + if ($product->duration_value > 1) + { + $plu = "s"; + } + switch ($product->duration_unit) + { + case "d": + print "jour$plu "; + break; + case "w": + print "semaine$plu "; + break; + case "m": + print 'mois '; + break; + case "y": + print "an$plu "; + break; + } + print ' |