From 1fe1256f2474504dfd3f47b682dc5eb6f85d77c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2004 16:02:47 +0000 Subject: [PATCH] Fix: La fonction filtre des produits s'accorde bien avec la fonction tri. --- htdocs/product/liste.php | 72 ++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index d55ed0cedaa..1088914709d 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -23,30 +23,29 @@ /*! \file htdocs/product/liste.php - \ingroup product + \ingroup produit \brief Page liste des produits ou services \version $Revision$ */ require("./pre.inc.php"); -$user->getrights('produit'); $langs->load("products"); +$user->getrights('produit'); + if (!$user->rights->produit->lire) accessforbidden(); -/* - * - * - */ +$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; +$snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"]; -$type=$_GET["type"]; +$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"]; +$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; +$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; $page = $_GET["page"]; -$sortfield = $_GET["sortfield"]; -$sortorder = $_GET["sortorder"]; if ($page < 0) { $page = 0 ; } @@ -60,14 +59,19 @@ if ($sortorder == "") { $sortorder="DESC"; } - + +if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) { + $sref=""; + $snom=""; +} + /* * Mode Liste * */ -$title=$langs->trans("Products and Services"); +$title=$langs->trans("ProductsAndServices"); $sql = "SELECT p.rowid, p.label, p.price, p.ref"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; @@ -89,15 +93,14 @@ else { $type = 0; } - - $sql .= " WHERE p.fk_product_type = $type"; - if ($_POST["sref"]) + $sql .= " WHERE p.fk_product_type = ".$type; + if ($sref) { - $sql .= " AND p.ref like '%".$_POST["sref"]."%'"; + $sql .= " AND p.ref like '%".$sref."%'"; } - if ($_POST["snom"]) + if ($snom) { - $sql .= " AND p.label like '%".$_POST["snom"]."%'"; + $sql .= " AND p.label like '%".$snom."%'"; } if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0) { @@ -124,7 +127,7 @@ if ($result) $i = 0; - if ($num == 1 && (isset($_POST["sall"]) or isset($_POST["snom"]) or isset($_POST["sref"]))) + if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref)) { $objp = $db->fetch_object($i); Header("Location: fiche.php?id=$objp->rowid"); @@ -152,9 +155,9 @@ if ($result) llxHeader("","",$texte); - if ($_POST["sref"] || $_POST["snom"] || $_POST["sall"] || $_POST["search"]) + if ($sref || $snom || $_POST["sall"] || $_POST["search"]) { - print_barre_liste($texte, $page, "liste.php", "&sref=".$_POST["sref"]."&snom=".$_POST["snom"]."&envente=".$_POST["envente"], $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&envente=".$_POST["envente"], $sortfield, $sortorder,'',$num); } else { @@ -163,18 +166,31 @@ if ($result) print ''; + // Lignes des titres print ""; - print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente&type=$type&fourn_id=$fourn_id"); - print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&type=$type&fourn_id=$fourn_id"); - print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&type=$type&fourn_id=$fourn_id","",'align=\"right\"'); + print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente&type=$type&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); + print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&type=$type&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield); + print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&type=$type&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield); print "\n"; + // Lignes des champs de filtre + print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $var=True;
 
  
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '  '; + print '