* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2011 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, see . */ /** * \file htdocs/product/index.php * \ingroup product * \brief Page accueil des produits et services */ 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'); else if ($type=='1') $result=restrictedArea($user,'service'); else $result=restrictedArea($user,'produit|service'); $langs->load("products"); $product_static = new Product($db); /* * View */ $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl=''; if (! isset($_GET["type"])) { $transAreaType = $langs->trans("ProductsAndServicesArea"); $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("",$langs->trans("ProductsAndServices"),$helpurl); 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.tosell, p.tobuy"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; $result = $db->query($sql); while ($objp = $db->fetch_object($result)) { $status=1; if (! $objp->tosell && ! $objp->tobuy) $status=0; $prodser[$objp->fk_product_type][$status]=$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 '
'; /* * Last modified products */ $max=15; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy,"; $sql.= " p.tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.entity IN (".getEntity($product_static->element, 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 ''; $colnb=5; if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; 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 ""; // Sell price if (empty($conf->global->PRODUIT_MULTIPRICES)) { 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($db->jdate($objp->datem),'day'); print "'; if ($objp->price_base_type == 'TTC') print price($objp->price_ttc).' '.$langs->trans("TTC"); else print price($objp->price).' '.$langs->trans("HT"); print ''; print $product_static->LibStatut($objp->tosell,5,0); print "'; print $product_static->LibStatut($objp->tobuy,5,1); print "
"; } } else { dol_print_error($db); } print '
'; llxFooter(); $db->close(); ?>