From 094fd7f0d74ed7dc5376a310949d845c46901705 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 21 Feb 2010 10:03:06 +0000 Subject: [PATCH] Fix: view popularity by type --- htdocs/langs/en_US/products.lang | 4 +++- htdocs/langs/fr_FR/products.lang | 4 +++- htdocs/product/popuprop.php | 25 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index f794c4577d3..ca1e61ddfa3 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -144,7 +144,9 @@ RecordedProductsAndServices=Products/services recorded GenerateThumb=Generate thumb ProductCanvasAbility=Use special "canvas" addons ServiceNb=Service #%s -ListProductByPopularity=List of products/services by popularity +ListProductServiceByPopularity=List of products/services by popularity +ListProductByPopularity=List of products by popularity +ListServiceByPopularity=List of services by popularity Finished=Manufactured product RowMaterial=First material CloneProduct=Clone product or service diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 90b1dc9e7da..3edf363debe 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -144,7 +144,9 @@ RecordedProductsAndServices=Produits/services en vente GenerateThumb=Générer la vignette ProductCanvasAbility=Utiliser les extensions speciales "canvas" ServiceNb=Service no %s -ListProductByPopularity=Liste des produits/services par popularité +ListProductServiceByPopularity=Liste des produits/services par popularité +ListProductByPopularity=Liste des produits par popularité +ListServiceByPopularity=Liste des services par popularité Finished=Produit manufacturé RowMaterial=Matière première CloneProduct=Cloner produit/service diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index f329e2b4632..805bd0b11f1 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * * 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 @@ -21,7 +21,7 @@ /** \file htdocs/product/popuprop.php \ingroup propal, produit - \brief Liste des produits/services par popularit� + \brief Liste des produits/services par popularite \version $Id$ */ @@ -57,6 +57,7 @@ llxHeader(); $sql = "SELECT count(*) as c"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity = ".$conf->entity; +if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; $result=$db->query($sql); if ($result) @@ -65,7 +66,16 @@ if ($result) $num = $obj->c; } -print_barre_liste($langs->trans("ListProductByPopularity"), $page, "popuprop.php","","","","",$num); +$param = ''; +$title = $langs->trans("ListProductServiceByPopularity"); +if (isset($_GET['type'])) +{ + $param = '&type='.$_GET['type']; + $title = $langs->trans("ListProductByPopularity"); + if ($_GET['type'] == 1) $title = $langs->trans("ListServiceByPopularity"); +} + +print_barre_liste($title, $page, "popuprop.php",$param,"","","",$num); print ''; @@ -77,21 +87,22 @@ print_liste_field_titre($langs->trans("Label"),"popuprop.php", "p.label","",""," print_liste_field_titre("Nb. de proposition","popuprop.php", "c","","",'align="right"',$sortfield,$sortorder); print "\n"; -$sql = "SELECT p.rowid, p.label, p.ref, fk_product_type, count(*) as c"; +$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, count(*) as c"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; if ($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.= " WHERE p.rowid = pd.fk_product"; $sql.= " AND p.entity = ".$conf->entity; +if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { $sql.= ' AND COALESCE(c.visible,1)=1'; } -$sql.= " group by (p.rowid)"; +$sql.= " GROUP BY (p.rowid)"; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit( $limit ,$offset); @@ -126,7 +137,7 @@ if ($result) $var=!$var; print ""; print '';
'; - if ($objp->fk_product_type==1) print img_object($langs->trans("ShowService"),"service"); + if ($objp->type==1) print img_object($langs->trans("ShowService"),"service"); else print img_object($langs->trans("ShowProduct"),"product"); print " "; print $objp->ref.'