Gestion des categories

This commit is contained in:
Rodolphe Quiedeville 2005-04-14 10:37:39 +00:00
parent ba6818c5a6
commit a07a906649
3 changed files with 67 additions and 31 deletions

View File

@ -83,6 +83,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
$product->ref = $_POST["ref"]; $product->ref = $_POST["ref"];
$product->libelle = $_POST["libelle"]; $product->libelle = $_POST["libelle"];
$product->price = $_POST["price"]; $product->price = $_POST["price"];
$product->catid = $_POST["catid"];
$product->tva_tx = $_POST["tva_tx"]; $product->tva_tx = $_POST["tva_tx"];
$product->type = $_POST["type"]; $product->type = $_POST["type"];
$product->envente = $_POST["statut"]; $product->envente = $_POST["statut"];
@ -238,14 +239,29 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
print '<form action="fiche.php" method="post">'; print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n"; print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
print '<input type="hidden" name="catid" value="'.$_REQUEST["catid"].'">'."\n";
print '<div class="titre">'; print '<div class="titre">';
if ($_GET["type"]==0) { print $langs->trans("NewProduct"); } if ($_GET["type"]==0) { print $langs->trans("NewProduct"); }
if ($_GET["type"]==1) { print $langs->trans("NewService"); } if ($_GET["type"]==1) { print $langs->trans("NewService"); }
print '</div><br>'."\n"; print '</div><br>'."\n";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>';
print '<td>'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$product->ref.'">'; if ($conf->categorie->enabled)
{
print '<tr><td>'.$langs->trans("Categorie");
print '</td><td>';
if (isset($_REQUEST["catid"]))
{
$c = new Categorie ($db, $_REQUEST["catid"]);
$ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php');
print $ways[0]."<br />\n";
}
print '</td></tr>';
}
print '<tr><td>'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$product->ref.'">';
if ($_error == 1) if ($_error == 1)
{ {
print $langs->trans("RefAlreadyExists"); print $langs->trans("RefAlreadyExists");
@ -321,7 +337,7 @@ else
if ($conf->fournisseur->enabled) if ($conf->fournisseur->enabled)
{ {
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; $head[$h][0] = DOL_URL_ROOT."/fourn/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers"); $head[$h][1] = $langs->trans("Suppliers");
$h++; $h++;
} }
@ -348,7 +364,6 @@ else
if ($conf->categorie->enabled) if ($conf->categorie->enabled)
{ {
print '<tr id="ways">'; print '<tr id="ways">';
print '<td colspan="3">'; print '<td colspan="3">';
$cat = new Categorie ($db); $cat = new Categorie ($db);

View File

@ -70,7 +70,10 @@ if (isset($_REQUEST['catid']))
$title=$langs->trans("ProductsAndServices"); $title=$langs->trans("ProductsAndServices");
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type"; $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type";
$sql .= ", pf.fk_soc";
$sql .= ", ppf.price";
$sql .= ", s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if ($_GET["fourn_id"] > 0) if ($_GET["fourn_id"] > 0)
@ -84,6 +87,11 @@ if ($catid)
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
} }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = pf.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_soc = pf.fk_soc AND ppf.fk_product = p.rowid AND ppf.quantity = 1";
if ($_POST["mode"] == 'search') if ($_POST["mode"] == 'search')
{ {
$sql .= " WHERE p.ref like '%".$_POST["sall"]."%'"; $sql .= " WHERE p.ref like '%".$_POST["sall"]."%'";
@ -118,22 +126,24 @@ if ($fourn_id > 0)
} }
$sql .= " ORDER BY $sortfield $sortorder "; $sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit($limit + 1 ,$offset); $sql .= $db->plimit($limit + 1 ,$offset);
$result = $db->query($sql) ;
if ($result) $resql = $db->query($sql) ;
if ($resql)
{ {
$num = $db->num_rows(); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref)) if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref))
{ {
$objp = $db->fetch_object($i); $objp = $db->fetch_object($resql);
Header("Location: fiche.php?id=$objp->rowid"); Header("Location: fiche.php?id=$objp->rowid");
} }
$texte = $langs->trans("List"); $texte = $langs->trans("List");
llxHeader("","",$texte); llxHeader("","",$texte);
@ -158,7 +168,6 @@ if ($result)
{ {
$c = new Categorie ($db, $catid); $c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php'); $ways = $c->print_all_ways(' &gt; ','fourn/product/liste.php');
print " &gt; ".$ways[0]."<br />\n"; print " &gt; ".$ways[0]."<br />\n";
} }
print "</div><br />"; print "</div><br />";
@ -169,7 +178,8 @@ if ($result)
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield); print_liste_field_titre($langs->trans("Supplier"),"liste.php", "p.price","","","",$sortfield);
print_liste_field_titre($langs->trans("BuiingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield);
print "</tr>\n"; print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre
@ -184,31 +194,42 @@ if ($result)
print '<td valign="right">'; print '<td valign="right">';
print '<input class="fat" type="text" name="snom" value="'.$snom.'">'; print '<input class="fat" type="text" name="snom" value="'.$snom.'">';
print '</td>'; print '</td>';
print '<td align="center">'; print '<td colspan="2" align="center">';
print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">'; print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">';
print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">'; print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
$oldid = '';
$var=True; $var=True;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$objp = $db->fetch_object( $i); $objp = $db->fetch_object( $i);
$var=!$var; $var=!$var;
print "<tr $bc[$var]><td>"; print "<tr $bc[$var]>";
print "<a href=\"../../product/fiche.php?id=$objp->rowid\">";
if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); if ($oldid <> $objp->rowid)
else print img_object($langs->trans("ShowProduct"),"product"); {
print "</a> "; $oldid = $objp->rowid;
print "<a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n"; print "<td><a href=\"../../product/fiche.php?id=$objp->rowid\">";
print "<td>$objp->label</td>\n"; if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
else print img_object($langs->trans("ShowProduct"),"product");
print "</a> ";
print "<a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n";
print "<td>$objp->label</td>\n";
}
else
{
print '<td colspan="2">&nbsp;</td>';
}
print '<td>'.$objp->nom.'</td>';
print '<td align="right">'.price($objp->price).'</td>'; print '<td align="right">'.price($objp->price).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
$db->free(); $db->free($resql);
print "</table>"; print "</table>";

View File

@ -59,7 +59,7 @@ function llxHeader($head = "", $title="", $help_url='',$addons='')
if ($user->societe_id == 0 && $user->rights->produit->creer) if ($user->societe_id == 0 && $user->rights->produit->creer)
{ {
$menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&amp;type=0", $langs->trans("NewProduct")); $menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&amp;type=0&amp;catid=".$_REQUEST['catid'], $langs->trans("NewProduct"));
} }
} }