* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 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 * 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. */ /** * \file htdocs/product/index.php * \ingroup product * \brief Page accueil des produits et services * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); $type=isset($_GET["type"])?$_GET["type"]:(isset($_POST["type"])?$_POST["type"]:''); if ($type =='' && !$user->rights->produit->lire) $type='1'; // Force global page on service page only if ($type =='' && !$user->rights->service->lire) $type='0'; // Force global page on prpduct page only // Security check if ($type=='0') $result=restrictedArea($user,'produit',$id,'product','','',$fieldid); else if ($type=='1') $result=restrictedArea($user,'service',$id,'service','','',$fieldid); else $result=restrictedArea($user,'produit|service',$id,'service','','',$fieldid); $product_static = new Product($db); $langs->load("products"); /* * View */ $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl=''; if (! isset($_GET["type"])) { $transAreaType = $langs->trans("ProductsArea"); $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) { $transAreaType = $langs->trans("ProductsArea"); $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) { $transAreaType = $langs->trans("ServicesArea"); $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader("",$helpurl,$langs->trans("ProductsAndServices")); print_fiche_titre($transAreaType); print ''; print '
'; /* * Zone recherche produit/service */ $rowspan=2; if ($conf->barcode->enabled) $rowspan++; print '
'; print ''; print ''; print ""; print ''; print "'; print ''; if ($conf->barcode->enabled) { print "'; //print ''; print ''; } print "'; //print ''; print ''; print "
'.$langs->trans("Search").'
"; print $langs->trans("Ref").':
"; print $langs->trans("BarCode").':
"; print $langs->trans("Other").':

"; /* * Nombre de produits et/ou services */ $prodser = array(); $prodser[0][0]=$prodser[0][1]=$prodser[1][0]=$prodser[1][1]=0; $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.envente"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " GROUP BY p.fk_product_type, p.envente"; $result = $db->query($sql); while ($objp = $db->fetch_object($result)) { $prodser[$objp->fk_product_type][$objp->envente]=$objp->total; } print ''; print ''; if ($conf->product->enabled) { $statProducts = ""; $statProducts.= ''; $statProducts.= ""; $statProducts.= ""; $statProducts.= ''; $statProducts.= ""; } if ($conf->service->enabled) { $statServices = ""; $statServices.= ''; $statServices.= ""; $statServices.= ""; $statServices.= ''; $statServices.= ""; } $total=0; if ($type == '0') { print $statProducts; $total=round($prodser[0][0])+round($prodser[0][1]); } else if ($type == '1') { print $statServices; $total=round($prodser[1][0])+round($prodser[1][1]); } else { print $statProducts.$statServices; $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[0][0])+round($prodser[0][1]); } print ''; print '
'.$langs->trans("Statistics").'
'.$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("Total").''; print $total; print '
'; print '
'; /* * Derniers produits/services en vente */ $max=15; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.envente,"; $sql.= " p.tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $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.= " AND p.entity = ".$conf->entity; if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; if ($type != '') $sql.= " AND p.fk_product_type = ".$type; $sql.= $db->order("p.tms","DESC"); $sql.= $db->plimit($max,0); //print $sql; $result = $db->query($sql) ; if ($result) { $num = $db->num_rows($result); $i = 0; if ($num > 0) { $transRecordedType = $langs->trans("LastModifiedProductsAndServices",$max); if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts",$max); if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices",$max); print ''; print ''; $var=True; while ($i < $num) { $objp = $db->fetch_object($result); //Multilangs if ($conf->global->MAIN_MULTILANGS) { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql.= " WHERE fk_product=".$objp->rowid; $sql.= " AND lang='". $langs->getDefaultLang() ."'"; $resultd = $db->query($sql); if ($resultd) { $objtp = $db->fetch_object($resultd); if ($objtp && $objtp->label != '') $objp->label = $objtp->label; } } $var=!$var; print ""; print '\n"; print ''; print ""; print '"; print "\n"; $i++; } $db->free(); print "
'.$transRecordedType.'
'; $product_static->id=$objp->rowid; $product_static->ref=$objp->ref; $product_static->type=$objp->fk_product_type; print $product_static->getNomUrl(1,'',16); print "'.dol_trunc($objp->label,32).'"; print dol_print_date($objp->datem,'day'); print "'; print $product_static->LibStatut($objp->envente,5); print "
"; } } else { dol_print_error($db); } print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>