Gestion des services
This commit is contained in:
parent
b860e86f0c
commit
43869a2437
@ -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;
|
||||
}
|
||||
/*
|
||||
|
||||
@ -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 "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||||
print "<form action=\"$PHP_SELF?type=$type\" method=\"post\">\n";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">\n";
|
||||
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
|
||||
print '<div class="titre">Nouveau '.$types[$type].'</div><br>'."\n";
|
||||
@ -119,6 +118,16 @@ if ($action == 'create')
|
||||
print "<tr><td valign=\"top\">Description</td><td>";
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print "</textarea></td></tr>";
|
||||
if ($type == 1)
|
||||
{
|
||||
print '<tr><td>Durée</td><TD><input name="duration_value" size="6" value="'.$product->duree.'">';
|
||||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||||
print '<input name="duration_unit" type="radio" value="y">année';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
@ -134,14 +143,14 @@ else
|
||||
{
|
||||
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="index.php3" method="post">';
|
||||
print '<form action="index.php3?type='.$product->type.'" method="post">';
|
||||
print '<td valign="center">Réf : <input class="flat" type="text" size="10" name="sref"> <input class="flat" type="submit" value="go"></td>';
|
||||
print '</form><form action="index.php3" method="post">';
|
||||
print '<td>Libellé : <input class="flat" type="text" size="20" name="snom"> <input class="flat" type="submit" value="go"></td>';
|
||||
print '</form><td> </td></tr></table>';
|
||||
|
||||
|
||||
print_fiche_titre('Fiche produit : '.$product->ref, $mesg);
|
||||
print_fiche_titre('Fiche '.$types[$product->type].' : '.$product->ref, $mesg);
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
@ -170,7 +179,27 @@ else
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>Durée</td><TD>'.$product->tva_tx.' %</td></tr>';
|
||||
print '<tr><td>Durée</td><TD>'.$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 '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
@ -178,7 +207,7 @@ else
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<hr><div class="titre">Edition de la fiche produit : '.$product->ref.'</div><br>';
|
||||
print '<hr><div class="titre">Edition de la fiche '.$types[$product->type].' : '.$product->ref.'</div><br>';
|
||||
|
||||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
@ -211,7 +240,12 @@ else
|
||||
|
||||
if ($product->type == 1)
|
||||
{
|
||||
print '<tr><td>Durée</td><TD><input name="duree" size="6" value="'.$product->duree.'"></td></tr>';
|
||||
print '<tr><td>Durée</td><TD><input name="duration_value" size="6" value="'.$product->duration_value.'">';
|
||||
print '<input name="duration_unit" type="radio" value="d" selected>jour ';
|
||||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||||
print '<input name="duration_unit" type="radio" value="y">année';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td> </td><td><input type="submit" value="Enregistrer"> ';
|
||||
|
||||
@ -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 '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
@ -88,7 +88,7 @@ if ( $db->query($sql) )
|
||||
print "</TR>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="index.php3" method="post">';
|
||||
print '<form action="index.php3?type='.$type.'" method="post">';
|
||||
print '<td><input class="flat" type="text" size="10" name="sref"> <input class="flat" type="submit" value="go"></td>';
|
||||
print '</form><form action="index.php3" method="post">';
|
||||
print '<td><input class="flat" type="text" size="20" name="snom"> <input class="flat" type="submit" value="go"></td>';
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user