2005-04-11 18:00:06 +02:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2012-01-19 09:53:27 +01:00
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2005-04-11 18:00:06 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-04-11 18:00:06 +02:00
|
|
|
* (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
|
2011-08-01 01:45:11 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-11 18:00:06 +02:00
|
|
|
*/
|
|
|
|
|
|
2009-10-19 21:54:27 +02:00
|
|
|
/**
|
2011-08-27 17:14:31 +02:00
|
|
|
* \file htdocs/product/index.php
|
|
|
|
|
* \ingroup product
|
|
|
|
|
* \brief Page accueil des produits et services
|
|
|
|
|
*/
|
2005-04-11 18:00:06 +02:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../../main.inc.php';
|
2005-04-11 18:00:06 +02:00
|
|
|
|
2010-03-27 16:06:19 +01:00
|
|
|
// Security check
|
2009-06-08 20:14:37 +02:00
|
|
|
if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden();
|
|
|
|
|
|
2005-04-11 18:00:06 +02:00
|
|
|
|
|
|
|
|
/*
|
2009-06-08 20:14:37 +02:00
|
|
|
* View
|
2005-04-11 18:00:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
llxHeader("","",$langs->trans("ProductsAndServices"));
|
|
|
|
|
|
2009-03-02 20:07:12 +01:00
|
|
|
print_fiche_titre($langs->trans("ProductsAndServicesArea"));
|
2005-04-11 18:00:06 +02:00
|
|
|
|
|
|
|
|
print '<table border="0" width="100%">';
|
|
|
|
|
|
|
|
|
|
print '<tr><td valign="top" width="30%">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Zone recherche produit/service
|
|
|
|
|
*/
|
|
|
|
|
print '<form method="post" action="liste.php">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2012-09-09 13:13:24 +02:00
|
|
|
print '<table class="noborder nohover" width="100%">';
|
2005-04-11 18:00:06 +02:00
|
|
|
print "<tr class=\"liste_titre\">\n";
|
|
|
|
|
print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
2012-09-09 13:13:24 +02:00
|
|
|
print "<tr ".$bc[false]."><td>";
|
2005-04-11 18:00:06 +02:00
|
|
|
print $langs->trans("Ref").' :</td><td><input class="flat" type="text" size="20" name="sf_ref"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
2012-09-09 13:13:24 +02:00
|
|
|
print "<tr ".$bc[false]."><td>";
|
2005-04-11 18:00:06 +02:00
|
|
|
print $langs->trans("Label").' :</td><td><input class="flat" type="text" size="20" name="snom"></td><td><input class="button" type="submit" value="'.$langs->trans("Search").'"></td></tr>';
|
|
|
|
|
print "</table></form><br>\n";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Nombre de produits et/ou services
|
|
|
|
|
*/
|
|
|
|
|
$prodser = array();
|
2012-02-11 10:18:09 +01:00
|
|
|
$sql = "SELECT count(*), p.fk_product_type";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
|
|
|
|
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
|
|
|
|
$sql.= " GROUP BY p.fk_product_type";
|
2010-08-14 04:44:07 +02:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-04-11 18:00:06 +02:00
|
|
|
{
|
2010-08-14 04:44:07 +02:00
|
|
|
$num = $db->num_rows($resql);
|
2005-04-11 18:00:06 +02:00
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
2010-08-14 04:44:07 +02:00
|
|
|
$row = $db->fetch_row($resql);
|
2005-04-11 18:00:06 +02:00
|
|
|
$prodser[$row[1]] = $row[0];
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
2010-08-14 04:44:07 +02:00
|
|
|
$db->free($resql);
|
2005-04-11 18:00:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
|
2012-09-15 10:01:35 +02:00
|
|
|
if (! empty($conf->product->enabled))
|
2005-04-11 18:00:06 +02:00
|
|
|
{
|
|
|
|
|
print "<tr $bc[0]>";
|
2005-04-11 18:01:44 +02:00
|
|
|
print '<td><a href="liste.php?type=0">'.$langs->trans("Products").'</a></td><td>'.round($prodser[0]).'</td>';
|
2005-04-11 18:00:06 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
}
|
2012-09-15 10:01:35 +02:00
|
|
|
if (! empty($conf->service->enabled))
|
2005-04-11 18:00:06 +02:00
|
|
|
{
|
|
|
|
|
print "<tr $bc[1]>";
|
2005-04-11 18:01:44 +02:00
|
|
|
print '<td><a href="liste.php?type=1">'.$langs->trans("Services").'</a></td><td>'.round($prodser[1]).'</td>';
|
2005-04-11 18:00:06 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
}
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
print '</td><td valign="top" width="70%">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-01-30 02:20:16 +01:00
|
|
|
* Derniers produits en vente
|
2005-04-11 18:00:06 +02:00
|
|
|
*/
|
2007-01-30 02:20:16 +01:00
|
|
|
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.type";
|
2012-02-11 10:18:09 +01:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
|
|
|
|
|
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
|
|
|
|
$sql.= " AND p.fk_product_type <> 1";
|
|
|
|
|
$sql.= " ORDER BY p.datec DESC ";
|
|
|
|
|
$sql.= $db->plimit(15, 0);
|
2005-04-11 18:00:06 +02:00
|
|
|
|
2011-09-20 15:32:16 +02:00
|
|
|
$resql = $db->query($sql);
|
2005-04-11 18:00:06 +02:00
|
|
|
|
|
|
|
|
if ($resql)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
if ($num > 0)
|
|
|
|
|
{
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("LastProducts").'</td></tr>';
|
2009-03-02 20:07:12 +01:00
|
|
|
|
2005-04-11 18:00:06 +02:00
|
|
|
$var=True;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object($resql);
|
|
|
|
|
$var=!$var;
|
2013-06-20 09:18:12 +02:00
|
|
|
print "<tr ".$bc[$var].">";
|
2005-04-11 18:00:06 +02:00
|
|
|
print "<td><a href=\"fiche.php?id=$objp->rowid\">";
|
2007-01-27 15:36:20 +01:00
|
|
|
if ($objp->fk_product_type==1) print img_object($langs->trans("ShowService"),"service");
|
2005-04-11 18:00:06 +02:00
|
|
|
else print img_object($langs->trans("ShowProduct"),"product");
|
|
|
|
|
print "</a> <a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n";
|
|
|
|
|
print "<td>$objp->label</td>";
|
2007-01-30 02:20:16 +01:00
|
|
|
print "<td>";
|
|
|
|
|
if ($objp->fk_product_type==1) print $langs->trans('ShowService');
|
|
|
|
|
else print $langs->trans('ShowProduct');
|
|
|
|
|
print "</td></tr>\n";
|
2005-04-11 18:00:06 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free($resql);
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_print_error();
|
2005-04-11 18:00:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</td></tr></table>';
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2005-04-11 18:00:06 +02:00
|
|
|
?>
|