* Copyright (C) 2004 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * * 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$ * */ /** \file htdocs/product/popuprop.php \ingroup propal, produit \brief Liste des produits par popularité \version $Revision$ */ require("./pre.inc.php"); $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; $page = $_GET["page"]; if ($page < 0) { $page = 0 ; } if ($sortfield == "") { $sortfield="c"; } if ($sortorder == "") { $sortorder="DESC"; } if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; llxHeader(); //On n'affiche le lien page suivante que s'il y a une page suivante ... $sql = "select count(*) as c from ".MAIN_DB_PREFIX."product"; if ( $db->query($sql) ) { $d = $db->fetch_object(0); $num = $d->c; if($num < ($offset+$offset)) $afficher_pagesuivante = 0; else $afficher_pagesuivante = -1; } print_barre_liste("Liste des produits par popularité", $page, "popuprop.php","","","","",$afficher_pagesuivante); print ''; print ""; print_liste_field_titre($langs->trans("Ref"),"popuprop.php", "p.ref","","","",$sortfield); print_liste_field_titre($langs->trans("Label"),"popuprop.php", "p.label","","","",$sortfield); print_liste_field_titre("Nb. de proposition","popuprop.php", "c","","",'align="right"',$sortfield); print "\n"; $sql = "select p.rowid, p.label, p.ref, count(*) as c from ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."product as p where p.rowid = pd.fk_product group by (p.rowid)"; $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit( $limit ,$offset); if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print ''; print "\n"; $i++; } $db->free(); } print "
rowid\">$objp->ref$objp->label'.$objp->c.'
"; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>