From 01c9915b7aed7f8d0b01ab4b7734d8b691b56369 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 11 Dec 2006 22:43:40 +0000 Subject: [PATCH] Synchro --- htdocs/product/index.php | 131 ++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 77 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 12e1c1e4e88..f8055a313fc 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * @@ -22,10 +22,10 @@ */ /** - \file htdocs/product/index.php - \ingroup product - \brief Page accueil des produits et services - \version $Revision$ + \file htdocs/product/index.php + \ingroup product + \brief Page accueil des produits et services + \version $Revision$ */ require("./pre.inc.php"); @@ -36,7 +36,6 @@ if (!$user->rights->produit->lire) $staticproduct=new Product($db); - /* * Affichage page accueil * @@ -73,54 +72,30 @@ print "
"; $prodser = array(); $prodser[0][0]=$prodser[0][1]=$prodser[1][0]=$prodser[1][1]=0; -$sql = "SELECT count(*), p.fk_product_type, p.envente"; -$sql .= " FROM ".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 as c ON cp.fk_categorie = c.rowid"; - $sql.= " WHERE IFNULL(c.visible,1)=1"; -} -$sql .= " GROUP BY p.fk_product_type, p.envente"; -$result=$db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($result); - $prodser[$row[1]][$row[2]] = $row[0]; - $i++; - } - $db->free(); -} - print ''; print ''; if ($conf->produit->enabled) { - print ""; - print ''; - print ""; - print ""; - print ''; - print ""; + print ""; + print ''; + print ""; + print ""; + print ''; + print ""; } if ($conf->service->enabled) { - print ""; - print ''; - print ""; - print ""; - print ''; - print ""; + print ""; + print ''; + print ""; + print ""; + print ''; + print ""; } print '
'.$langs->trans("Statistics").'
'.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).'
'.$langs->trans("ProductsOnSell").''.round($prodser[0][1]).'
'.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).'
'.$langs->trans("ProductsOnSell").''.round($prodser[0][1]).'
'.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).'
'.$langs->trans("ServicesOnSell").''.round($prodser[1][1]).'
'.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).'
'.$langs->trans("ServicesOnSell").''.round($prodser[1][1]).'
'; print ''; - /* * Derniers produits/services en vente */ @@ -130,9 +105,11 @@ $sql.= " FROM ".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 as c ON cp.fk_categorie = c.rowid"; - $sql.= " WHERE IFNULL(c.visible,1)=1"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; + $sql.= " WHERE IFNULL(c.visible,1)=1 "; } +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_subproduct as sp ON p.rowid = sp.fk_product_subproduct"; +$sql.= " WHERE sp.fk_product_subproduct IS NULL"; $sql.= " ORDER BY p.datec DESC "; $sql.= $db->plimit($max,0); $result = $db->query($sql) ; @@ -140,9 +117,9 @@ $result = $db->query($sql) ; if ($result) { $num = $db->num_rows($result); - + $i = 0; - + if ($num > 0) { print ''; @@ -151,40 +128,40 @@ if ($result) $var=True; - while ($i < $num) + while ($i < $num) + { + $objp = $db->fetch_object($result); + + //Multilangs + if ($conf->global->MAIN_MULTILANGS) + { + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; + $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; + $resultd = $db->query($sql); + if ($resultd) { - $objp = $db->fetch_object($result); - - //Multilangs - if ($conf->global->MAIN_MULTILANGS) - { - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; - $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; - $resultd = $db->query($sql); - if ($resultd) - { - $objtp = $db->fetch_object($resultd); - if ($objtp->label != '') $objp->label = $objtp->label; - } - } - - $var=!$var; - print ""; - print '\n"; - print ''; - print '"; - print '"; - print "\n"; - $i++; + $objtp = $db->fetch_object($resultd); + if ($objtp->label != '') $objp->label = $objtp->label; } - + } + + $var=!$var; + print ""; + print '\n"; + print ''; + print '"; + print '"; + print "\n"; + $i++; + } + $db->free(); - + print "
'; - if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " rowid\">$objp->ref'.dolibarr_trunc($objp->label,40).''.$staticproduct->typeprodser[$objp->fk_product_type]."'; - print $staticproduct->LibStatut($objp->envente,5); - print "
'; + if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service"); + else print img_object($langs->trans("ShowProduct"),"product"); + print " rowid\">$objp->ref'.dolibarr_trunc($objp->label,40).''.$staticproduct->typeprodser[$objp->fk_product_type]."'; + print $staticproduct->LibStatut($objp->envente,5); + print "
"; } }