From a07a906649e60da9c67c43db02e2de0fdd370660 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 14 Apr 2005 10:37:39 +0000 Subject: [PATCH] Gestion des categories --- htdocs/fourn/product/fiche.php | 25 ++++++++--- htdocs/fourn/product/liste.php | 71 +++++++++++++++++++++----------- htdocs/fourn/product/pre.inc.php | 2 +- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/htdocs/fourn/product/fiche.php b/htdocs/fourn/product/fiche.php index 234d6ae9aa6..cf774ed95fc 100644 --- a/htdocs/fourn/product/fiche.php +++ b/htdocs/fourn/product/fiche.php @@ -83,6 +83,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) $product->ref = $_POST["ref"]; $product->libelle = $_POST["libelle"]; $product->price = $_POST["price"]; + $product->catid = $_POST["catid"]; $product->tva_tx = $_POST["tva_tx"]; $product->type = $_POST["type"]; $product->envente = $_POST["statut"]; @@ -238,14 +239,29 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) print '
'; print ''; print ''."\n"; + print ''."\n"; print '
'; if ($_GET["type"]==0) { print $langs->trans("NewProduct"); } if ($_GET["type"]==1) { print $langs->trans("NewService"); } print '

'."\n"; print ''; - print ''; - print ''; + } + + print '
'.$langs->trans("Ref").''; + + if ($conf->categorie->enabled) + { + print '
'.$langs->trans("Categorie"); + print ''; + + if (isset($_REQUEST["catid"])) + { + $c = new Categorie ($db, $_REQUEST["catid"]); + $ways = $c->print_all_ways(' > ','fourn/product/liste.php'); + print $ways[0]."
\n"; + } + print '
'.$langs->trans("Ref").''; if ($_error == 1) { print $langs->trans("RefAlreadyExists"); @@ -321,7 +337,7 @@ else 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"); $h++; } @@ -347,8 +363,7 @@ else print ''; if ($conf->categorie->enabled) - { - + { print ''; print '"; print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); - print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&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)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield); print "\n"; // Lignes des champs de filtre @@ -184,31 +194,42 @@ if ($result) print ''; - print ''; print ''; print ''; - + $oldid = ''; $var=True; while ($i < min($num,$limit)) { $objp = $db->fetch_object( $i); $var=!$var; - print "\n"; - print "\n"; + print ""; + + if ($oldid <> $objp->rowid) + { + $oldid = $objp->rowid; + print "\n"; + print "\n"; + } + else + { + print ''; + } + + print ''; print ''; print "\n"; $i++; } - $db->free(); + $db->free($resql); print "
'; $cat = new Categorie ($db); diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php index a1a4189b422..530e2aced45 100644 --- a/htdocs/fourn/product/liste.php +++ b/htdocs/fourn/product/liste.php @@ -70,7 +70,10 @@ if (isset($_REQUEST['catid'])) $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"; if ($_GET["fourn_id"] > 0) @@ -84,6 +87,11 @@ if ($catid) $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') { $sql .= " WHERE p.ref like '%".$_POST["sall"]."%'"; @@ -118,23 +126,25 @@ if ($fourn_id > 0) } $sql .= " ORDER BY $sortfield $sortorder "; -$sql .= $db->plimit($limit + 1 ,$offset); -$result = $db->query($sql) ; -if ($result) +$sql .= $db->plimit($limit + 1 ,$offset); + +$resql = $db->query($sql) ; + +if ($resql) { - $num = $db->num_rows(); - - $i = 0; + $num = $db->num_rows($resql); - if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref)) + $i = 0; + + if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref)) { - $objp = $db->fetch_object($i); - Header("Location: fiche.php?id=$objp->rowid"); + $objp = $db->fetch_object($resql); + Header("Location: fiche.php?id=$objp->rowid"); } - $texte = $langs->trans("List"); - + $texte = $langs->trans("List"); + llxHeader("","",$texte); if ($sref || $snom || $_POST["sall"] || $_POST["search"]) @@ -145,7 +155,7 @@ if ($result) { print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); } - + /* * @@ -158,7 +168,6 @@ if ($result) { $c = new Categorie ($db, $catid); $ways = $c->print_all_ways(' > ','fourn/product/liste.php'); - print " > ".$ways[0]."
\n"; } print "
"; @@ -169,7 +178,8 @@ if ($result) print "
'; print ''; print ''; + print ''; print ''; print '  '; print '
"; - print "rowid\">"; - if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " "; - print "rowid\">$objp->ref$objp->label
rowid\">"; + if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); + else print img_object($langs->trans("ShowProduct"),"product"); + print " "; + print "rowid\">$objp->ref$objp->label '.$objp->nom.''.price($objp->price).'
"; diff --git a/htdocs/fourn/product/pre.inc.php b/htdocs/fourn/product/pre.inc.php index db5fa251bb3..c333550dcd3 100644 --- a/htdocs/fourn/product/pre.inc.php +++ b/htdocs/fourn/product/pre.inc.php @@ -59,7 +59,7 @@ function llxHeader($head = "", $title="", $help_url='',$addons='') if ($user->societe_id == 0 && $user->rights->produit->creer) { - $menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); + $menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&type=0&catid=".$_REQUEST['catid'], $langs->trans("NewProduct")); } }