diff --git a/htdocs/product/stock/liste.php b/htdocs/product/stock/liste.php new file mode 100644 index 00000000000..53a0c2b4b76 --- /dev/null +++ b/htdocs/product/stock/liste.php @@ -0,0 +1,162 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); +$user->getrights('produit'); + +if (!$user->rights->produit->lire) + accessforbidden(); + +if ($action == 'update') +{ + $sql = "UPDATE llx_product SET description='$desc' where rowid = $rowid"; + $db->query($sql); +} + +/* + * + * + */ + +if ($page < 0) { + $page = 0 ; } + +$limit = $conf->liste_limit; +$offset = $limit * $page ; + +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 ($_POST["sall"]) +{ + $sql .= " WHERE lower(p.ref) like '%".strtolower($sall)."%'"; + $sql .= " OR lower(p.label) like '%".strtolower($sall)."%'"; +} +else +{ + if (strlen($type) == 0) + { + $type = 0; + } + + $sql .= " WHERE p.fk_product_type = $type"; + if ($sref) + { + $sql .= " AND lower(p.ref) like '%".strtolower($sref)."%'"; + } + if ($snom) + { + $sql .= " AND lower(p.label) like '%".strtolower($snom)."%'"; + } + if (isset($envente) && strlen($envente) > 0) + { + $sql .= " AND p.envente = $envente"; + } + else + { + $sql .= " AND p.envente = 1"; + } +} + +$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit($limit + 1 ,$offset); +$result = $db->query($sql) ; + +if ($result) +{ + $num = $db->num_rows(); + + $i = 0; + + if ($num == 1 && (isset($sall) or isset($snom) or isset($sref))) + { + $objp = $db->fetch_object($i); + Header("Location: fiche.php?id=$objp->rowid"); + } + + if ($ref || $snom || $sall) + { + llxHeader("","","Recherche Produit/Service"); + + print_barre_liste("Recherche d'un produit ou service", $page, "liste.php", "&sref=$sref&snom=$snom&envente=$envente", $sortfield, $sortorder,'',$num); + } + else + { + $texte = "Liste des ".$types[$type]."s"; + llxHeader("","",$texte); + if (isset($envente) && $envente == 0) + { + $texte .= " hors vente"; + } + print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); + } + + print ''; + + print ""; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + + $var=True; + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print ''; + print "\n"; + $i++; + } + $db->free(); + + print "
"; + print_liste_field_titre("Réf","liste.php", "p.ref","&envente=$envente&type=$type"); + print ""; + print_liste_field_titre("Libellé","liste.php", "p.label","&envente=$envente&type=$type"); + print "Prix de vente
 
  
rowid\">$objp->ref$objp->label'.price($objp->price).'
"; + +} +else +{ + print $db->error() . "
" .$sql; +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>