Ajout filtre sur le canevas utilise

This commit is contained in:
Rodolphe Quiedeville 2006-12-04 17:54:07 +00:00
parent 874632f772
commit 8392dc44fc

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
* *
@ -22,10 +22,10 @@
*/ */
/** /**
\file htdocs/product/liste.php \file htdocs/product/liste.php
\ingroup produit \ingroup produit
\brief Page liste des produits ou services \brief Page liste des produits ou services
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -59,13 +59,13 @@ $offset = $limit * $page ;
if (isset($_POST["button_removefilter_x"])) if (isset($_POST["button_removefilter_x"]))
{ {
$sref=""; $sref="";
$snom=""; $snom="";
} }
if (isset($_REQUEST['catid'])) if (isset($_REQUEST['catid']))
{ {
$catid = $_REQUEST['catid']; $catid = $_REQUEST['catid'];
} }
@ -81,47 +81,51 @@ $sql.= ' p.duration, p.envente as statut';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // '.MAIN_DB_PREFIX.'product_det as d'; //en attendant le debugage $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // '.MAIN_DB_PREFIX.'product_det as d'; //en attendant le debugage
if ($catid || ($conf->categorie->enabled && !$user->rights->categorie->voir)) if ($catid || ($conf->categorie->enabled && !$user->rights->categorie->voir))
{ {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
} }
if ($_GET["fourn_id"] > 0) if ($_GET["fourn_id"] > 0)
{ {
$fourn_id = $_GET["fourn_id"]; $fourn_id = $_GET["fourn_id"];
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
} }
$sql .= " WHERE 1=1"; $sql .= " WHERE 1=1";
if ($sall) if ($sall)
{ {
$sql .= " AND (p.ref like '%".$sall."%' OR p.label like '%".$sall."%' OR p.description like '%".$sall."%' OR p.note like '%".$sall."%')"; $sql .= " AND (p.ref like '%".$sall."%' OR p.label like '%".$sall."%' OR p.description like '%".$sall."%' OR p.note like '%".$sall."%')";
} }
if (strlen($_GET["type"]) || strlen($_POST["type"])) if (strlen($_GET["type"]) || strlen($_POST["type"]))
{ {
$sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]); $sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]);
} }
if ($sref) if ($sref)
{ {
$sql .= " AND p.ref like '%".$sref."%'"; $sql .= " AND p.ref like '%".$sref."%'";
} }
if ($snom) if ($snom)
{ {
$sql .= " AND p.label like '%".$snom."%'"; $sql .= " AND p.label like '%".$snom."%'";
} }
if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0) if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0)
{ {
$sql .= " AND p.envente = ".$_GET["envente"]; $sql .= " AND p.envente = ".$_GET["envente"];
}
if (isset($_GET["canvas"]) && strlen($_GET["canvas"]) > 0)
{
$sql .= " AND p.canvas = '".mysql_escape_string($_GET["canvas"])."'";
} }
if($catid) if($catid)
{ {
$sql .= " AND cp.fk_categorie = ".$catid; $sql .= " AND cp.fk_categorie = ".$catid;
} }
if ($conf->categorie->enabled && !$user->rights->categorie->voir) if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{ {
$sql.= ' AND IFNULL(c.visible,1)=1'; $sql.= ' AND IFNULL(c.visible,1)=1';
} }
if ($fourn_id > 0) if ($fourn_id > 0)
{ {
$sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
} }
$sql .= " ORDER BY $sortfield $sortorder "; $sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit($limit + 1 ,$offset); $sql .= $db->plimit($limit + 1 ,$offset);
@ -129,50 +133,50 @@ $resql = $db->query($sql) ;
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num == 1 && ($sall or $snom or $sref)) if ($num == 1 && ($sall or $snom or $sref))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
Header("Location: fiche.php?id=$objp->rowid"); Header("Location: fiche.php?id=$objp->rowid");
exit; exit;
} }
if (isset($_GET["envente"]) || isset($_POST["envente"])) if (isset($_GET["envente"]) || isset($_POST["envente"]))
{ {
$envente = (isset($_GET["envente"])?$_GET["envente"]:$_POST["envente"]); $envente = (isset($_GET["envente"])?$_GET["envente"]:$_POST["envente"]);
} }
if (isset($_GET["type"]) || isset($_POST["type"])) if (isset($_GET["type"]) || isset($_POST["type"]))
{ {
$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"]; $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
if ($type) { $texte = $langs->trans("Services"); } if ($type) { $texte = $langs->trans("Services"); }
else { $texte = $langs->trans("Products"); } else { $texte = $langs->trans("Products"); }
} else { } else {
$texte = $langs->trans("ProductsAndServices"); $texte = $langs->trans("ProductsAndServices");
} }
llxHeader("","",$texte); llxHeader("","",$texte);
if ($sref || $snom || $sall || $_POST["search"]) if ($sref || $snom || $sall || $_POST["search"])
{ {
print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;envente=".$_POST["envente"], $sortfield, $sortorder,'',$num); print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;envente=".$_POST["envente"], $sortfield, $sortorder,'',$num);
} }
else else
{ {
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num); print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
} }
if (isset($catid)) if (isset($catid))
{ {
print "<div id='ways'>"; print "<div id='ways'>";
$c = new Categorie ($db, $catid); $c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' &gt; ','product/liste.php'); $ways = $c->print_all_ways(' &gt; ','product/liste.php');
print " &gt; ".$ways[0]."<br />\n"; print " &gt; ".$ways[0]."<br />\n";
print "</div><br />"; print "</div><br />";
} }
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
@ -201,9 +205,9 @@ if ($resql)
print '</td>'; print '</td>';
if ($conf->service->enabled && $type != 0) if ($conf->service->enabled && $type != 0)
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '&nbsp;'; print '&nbsp;';
print '</td>'; print '</td>';
} }
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '&nbsp;'; print '&nbsp;';
@ -222,22 +226,22 @@ if ($resql)
$var=True; $var=True;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
// Multilangs // Multilangs
if ($conf->global->MAIN_MULTILANGS) // si l'option est active if ($conf->global->MAIN_MULTILANGS) // si l'option est active
{ {
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det";
$sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'";
$sql.= " LIMIT 1"; $sql.= " LIMIT 1";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$objtp = $db->fetch_object($result); $objtp = $db->fetch_object($result);
if ($objtp->label != '') $objp->label = $objtp->label; if ($objtp->label != '') $objp->label = $objtp->label;
} }
} }
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td nowrap="nowrap">'; print '<tr '.$bc[$var].'><td nowrap="nowrap">';
@ -265,15 +269,15 @@ if ($resql)
if ($num > $conf->liste_limit) if ($num > $conf->liste_limit)
{ {
if ($sref || $snom || $sall || $_POST["search"]) if ($sref || $snom || $sall || $_POST["search"])
{ {
print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;envente=".$_POST["envente"], $sortfield, $sortorder,'',$num); print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;envente=".$_POST["envente"], $sortfield, $sortorder,'',$num);
}
else
{
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
}
} }
else
{
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
}
}
$db->free($resql); $db->free($resql);
@ -282,7 +286,7 @@ if ($resql)
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }