Amlioration de la recherche
This commit is contained in:
parent
a05c50455f
commit
1585d46bdd
@ -19,19 +19,9 @@
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
require("./pre.inc.php3");
|
||||
|
||||
$db = new Db();
|
||||
if ($sortfield == "")
|
||||
{
|
||||
$sortfield="lower(p.label),p.price";
|
||||
}
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortorder="ASC";
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
@ -39,51 +29,69 @@ if ($action == 'update')
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
if ($page == -1) {
|
||||
$page = 0 ;
|
||||
}
|
||||
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_barre_liste("Liste des produits", $page, $PHP_SELF);
|
||||
|
||||
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
print "<TR class=\"liste_titre\"><td>";
|
||||
print_liste_field_titre("Réf",$PHP_SELF, "p.ref");
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Libellé",$PHP_SELF, "p.label");
|
||||
print "</td><TD align=\"right\">Prix de vente</TD>";
|
||||
print "</TR>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="index.php3" 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>';
|
||||
print '</form><td> </td></tr>';
|
||||
if ($sortfield == "")
|
||||
{
|
||||
$sortfield="p.tms";
|
||||
}
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortorder="DESC";
|
||||
}
|
||||
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.ref FROM llx_product as p";
|
||||
|
||||
if ($HTTP_POST_VARS["sref"])
|
||||
if ($sref)
|
||||
{
|
||||
$sql .= " WHERE lower(p.ref) like '%".strtolower($HTTP_POST_VARS["sref"])."%'";
|
||||
$sql .= " WHERE lower(p.ref) like '%".strtolower($sref)."%'";
|
||||
}
|
||||
if ($HTTP_POST_VARS["snom"])
|
||||
if ($snom)
|
||||
{
|
||||
$sql .= " WHERE lower(p.label) like '%".strtolower($HTTP_POST_VARS["snom"])."%'";
|
||||
$sql .= " WHERE lower(p.label) like '%".strtolower($snom)."%'";
|
||||
}
|
||||
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||
$sql .= $db->plimit( $limit ,$offset);
|
||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
if ($num == 1)
|
||||
{
|
||||
$objp = $db->fetch_object($i);
|
||||
Header("Location: fiche.php3?id=$objp->rowid");
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_barre_liste("Liste des produits", $page, $PHP_SELF, "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
|
||||
|
||||
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
print "<TR class=\"liste_titre\"><td>";
|
||||
print_liste_field_titre("Réf",$PHP_SELF, "p.ref");
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Libellé",$PHP_SELF, "p.label");
|
||||
print "</td><TD align=\"right\">Prix de vente</TD>";
|
||||
print "</TR>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="index.php3" 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>';
|
||||
print '</form><td> </td></tr>';
|
||||
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
@ -95,8 +103,15 @@ if ( $db->query($sql) )
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
|
||||
print "</table>";
|
||||
|
||||
}
|
||||
print "</table>";
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user