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 "
\n"; + print "\n"; print "\n"; print ''."\n"; print '
Nouveau '.$types[$type].'

'."\n"; @@ -119,6 +118,16 @@ if ($action == 'create') print "Description"; print '"; + if ($type == 1) + { + print 'Durée'; + print 'jour '; + print 'semaine '; + print 'mois '; + print 'année'; + print ''; + } + print ' '; print ''; print '
'; @@ -134,14 +143,14 @@ else { print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print '
Réf :  
Libellé :   
'; - print_fiche_titre('Fiche produit : '.$product->ref, $mesg); + print_fiche_titre('Fiche '.$types[$product->type].' : '.$product->ref, $mesg); print ''; print ""; @@ -170,7 +179,27 @@ else if ($product->type == 1) { - print ''; + print ''; } 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 '
"; @@ -178,7 +207,7 @@ else if ($action == 'edit') { - print '
Edition de la fiche produit : '.$product->ref.'

'; + print '
Edition de la fiche '.$types[$product->type].' : '.$product->ref.'

'; print "
\n"; print ''; @@ -211,7 +240,12 @@ else if ($product->type == 1) { - print 'Durée'; + print 'Durée'; + print 'jour '; + print 'semaine '; + print 'mois '; + print 'année'; + print ''; } print '  '; diff --git a/htdocs/product/index.php3 b/htdocs/product/index.php3 index 0d0f0ca2ff7..fe89b81b0dd 100644 --- a/htdocs/product/index.php3 +++ b/htdocs/product/index.php3 @@ -76,7 +76,7 @@ if ( $db->query($sql) ) llxHeader(); - print_barre_liste("Liste des produits", $page, $PHP_SELF, "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); + print_barre_liste("Liste des ".$types[$type]."s", $page, $PHP_SELF, "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); print ''; @@ -88,7 +88,7 @@ if ( $db->query($sql) ) print "\n"; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/product/pre.inc.php3 b/htdocs/product/pre.inc.php3 index 6a7729e2dbb..e9eb7944a47 100644 --- a/htdocs/product/pre.inc.php3 +++ b/htdocs/product/pre.inc.php3 @@ -21,6 +21,9 @@ */ require("../main.inc.php3"); +$types[0] = "produit"; +$types[1] = "service"; + function llxHeader($head = "", $urlp = "") { global $user, $conf; @@ -35,10 +38,12 @@ function llxHeader($head = "", $urlp = "") $menu->add(DOL_URL_ROOT."/product/index.php3?type=0", "Produits"); - $menu->add_submenu("fiche.php3?&action=create","Nouveau produit"); + $menu->add_submenu("fiche.php3?&action=create&type=0","Nouveau produit"); $menu->add(DOL_URL_ROOT."/product/index.php3?type=1", "Services"); + $menu->add_submenu("fiche.php3?&action=create&type=1","Nouveau service"); + if (defined("MAIN_MODULE_BOUTIQUE") && MAIN_MODULE_BOUTIQUE) {