2004-10-20 22:06:49 +02:00
|
|
|
<?php
|
2004-02-13 14:20:07 +01:00
|
|
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2005-01-08 23:20:19 +01:00
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2002-04-30 12:57:25 +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
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2002-06-29 00:46:44 +02:00
|
|
|
* $Id$
|
|
|
|
|
* $Source$
|
|
|
|
|
*
|
2002-04-30 12:57:25 +02:00
|
|
|
*/
|
2004-10-23 01:34:25 +02:00
|
|
|
|
2005-01-08 23:20:19 +01:00
|
|
|
/** \file htdocs/product/index.php
|
2004-10-23 01:34:25 +02:00
|
|
|
\ingroup product
|
|
|
|
|
\brief Page accueil des produits et services
|
|
|
|
|
\version $Revision$
|
|
|
|
|
*/
|
|
|
|
|
|
2003-09-11 22:18:51 +02:00
|
|
|
require("./pre.inc.php");
|
2003-08-06 14:07:24 +02:00
|
|
|
$user->getrights('produit');
|
2002-04-30 12:57:25 +02:00
|
|
|
|
2004-10-23 01:34:25 +02:00
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
$langs->load("products");
|
|
|
|
|
|
|
|
|
|
|
2003-08-06 14:28:02 +02:00
|
|
|
if (!$user->rights->produit->lire)
|
|
|
|
|
accessforbidden();
|
|
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
|
2004-10-23 01:34:25 +02:00
|
|
|
|
|
|
|
|
if ($_POST["action"] == 'update')
|
2003-06-21 16:35:43 +02:00
|
|
|
{
|
2004-10-23 01:34:25 +02:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product SET description='".$_POST["desc"]."' where rowid = ".$_POST["rowid"];
|
2002-04-30 12:57:25 +02:00
|
|
|
$db->query($sql);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
|
2003-08-06 14:07:24 +02:00
|
|
|
/*
|
2004-10-23 01:34:25 +02:00
|
|
|
* Affichage page accueil
|
2003-08-06 14:07:24 +02:00
|
|
|
*
|
|
|
|
|
*/
|
2002-04-30 12:57:25 +02:00
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
llxHeader("","",$langs->trans("ProductsAndServices"));
|
2002-04-30 12:57:25 +02:00
|
|
|
|
2004-08-20 11:04:51 +02:00
|
|
|
print '<div class="formsearch"><form action="liste.php" method="post">';
|
|
|
|
|
print '<input type="hidden" name="type" value="'.$product->type.'">';
|
2005-01-08 23:20:19 +01:00
|
|
|
print $langs->trans("Ref").': <input class="flat" type="text" size="10" name="sref"> <input class="button" type="submit" value="'.$langs->trans("Go").'">';
|
2004-09-04 13:49:37 +02:00
|
|
|
print ' ';
|
2005-01-08 23:20:19 +01:00
|
|
|
print $langs->trans("Label").': <input class="flat" type="text" size="20" name="snom"> <input class="button" type="submit" value="'.$langs->trans("Go").'">';
|
2004-08-20 11:04:51 +02:00
|
|
|
print '</form></div>';
|
|
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
print_titre($langs->trans("ProductsAndServices"));
|
2003-08-12 15:56:44 +02:00
|
|
|
|
2004-10-23 01:34:25 +02:00
|
|
|
print '<table border="0" width="100%">';
|
2003-08-12 15:56:44 +02:00
|
|
|
|
2003-10-10 15:55:12 +02:00
|
|
|
print '<tr><td valign="top" width="30%">';
|
2003-08-06 14:07:24 +02:00
|
|
|
|
2004-05-08 16:31:02 +02:00
|
|
|
|
2003-10-14 17:30:39 +02:00
|
|
|
/*
|
2004-05-08 16:31:02 +02:00
|
|
|
* Nombre de produits et/ou services
|
2003-10-14 17:30:39 +02:00
|
|
|
*/
|
2004-05-08 16:31:02 +02:00
|
|
|
$prodser = array();
|
2004-08-10 16:55:25 +02:00
|
|
|
$sql = "SELECT count(*), fk_product_type, envente FROM ".MAIN_DB_PREFIX."product as p GROUP BY fk_product_type, envente";
|
2003-11-18 10:40:26 +01:00
|
|
|
if ($db->query($sql))
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$row = $db->fetch_row($i);
|
2004-05-08 16:31:02 +02:00
|
|
|
$prodser[$row[1]][$row[2]] = $row[0];
|
2003-11-18 10:40:26 +01:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free();
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-22 23:23:49 +01:00
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Number").'</td></tr>';
|
2004-08-13 00:16:46 +02:00
|
|
|
if ($conf->produit->enabled)
|
2004-05-08 16:31:02 +02:00
|
|
|
{
|
|
|
|
|
print "<tr $bc[0]>";
|
2004-08-13 00:16:46 +02:00
|
|
|
print '<td><a href="liste.php?type=0&envente=0">'.$langs->trans("ProductsNotOnSell").'</a></td><td>'.round($prodser[0][0]).'</td>';
|
2004-05-08 16:31:02 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
print "<tr $bc[1]>";
|
2004-08-13 00:16:46 +02:00
|
|
|
print '<td><a href="liste.php?type=0&envente=1">'.$langs->trans("ProductsOnSell").'</a></td><td>'.round($prodser[0][1]).'</td>';
|
2004-05-08 16:31:02 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
}
|
2004-08-13 00:16:46 +02:00
|
|
|
if ($conf->service->enabled)
|
2003-11-17 17:37:14 +01:00
|
|
|
{
|
2004-05-08 16:31:02 +02:00
|
|
|
print "<tr $bc[0]>";
|
2004-08-13 00:16:46 +02:00
|
|
|
print '<td><a href="liste.php?type=1&envente=0">'.$langs->trans("ServicesNotOnSell").'</a></td><td>'.round($prodser[1][0]).'</td>';
|
2004-05-08 16:31:02 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
print "<tr $bc[1]>";
|
2004-08-13 00:16:46 +02:00
|
|
|
print '<td><a href="liste.php?type=1&envente=1">'.$langs->trans("ServicesOnSell").'</a></td><td>'.round($prodser[1][1]).'</td>';
|
2004-05-08 16:31:02 +02:00
|
|
|
print "</tr>";
|
2003-11-17 17:37:14 +01:00
|
|
|
}
|
|
|
|
|
print '</table>';
|
2004-05-08 16:31:02 +02:00
|
|
|
|
2003-10-10 15:55:12 +02:00
|
|
|
print '</td><td valign="top" width="70%">';
|
2004-05-08 16:31:02 +02:00
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
|
2003-10-14 17:30:39 +02:00
|
|
|
/*
|
2004-05-08 16:31:02 +02:00
|
|
|
* Derniers produits/services en vente
|
2003-10-14 17:30:39 +02:00
|
|
|
*/
|
2004-05-08 16:31:02 +02:00
|
|
|
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type FROM ".MAIN_DB_PREFIX."product as p WHERE envente=1";
|
2003-09-04 12:03:06 +02:00
|
|
|
$sql .= " ORDER BY p.datec DESC ";
|
|
|
|
|
$sql .= $db->plimit(15 ,0);
|
2003-08-12 15:27:55 +02:00
|
|
|
$result = $db->query($sql) ;
|
2003-08-06 14:07:24 +02:00
|
|
|
|
|
|
|
|
if ($result)
|
2003-06-21 16:35:43 +02:00
|
|
|
{
|
2002-06-29 00:46:44 +02:00
|
|
|
$num = $db->num_rows();
|
2003-06-21 16:35:43 +02:00
|
|
|
|
2003-08-06 14:07:24 +02:00
|
|
|
$i = 0;
|
2004-05-08 16:31:02 +02:00
|
|
|
|
2004-08-13 00:16:46 +02:00
|
|
|
$typeprodser[0]=$langs->trans("Product");
|
|
|
|
|
$typeprodser[1]=$langs->trans("Service");
|
2004-05-08 16:31:02 +02:00
|
|
|
|
2003-09-04 12:03:06 +02:00
|
|
|
if ($num > 0)
|
2003-07-12 12:32:11 +02:00
|
|
|
{
|
2004-12-22 23:23:49 +01:00
|
|
|
print '<table class="noborder" width="100%">';
|
2003-09-04 12:03:06 +02:00
|
|
|
|
2004-12-22 23:23:49 +01:00
|
|
|
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("LastRecorded").'</td></tr>';
|
2003-09-04 12:03:06 +02:00
|
|
|
|
|
|
|
|
$var=True;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object( $i);
|
|
|
|
|
$var=!$var;
|
2003-10-14 17:30:39 +02:00
|
|
|
print "<tr $bc[$var]>";
|
2004-03-09 15:23:31 +01:00
|
|
|
print "<td><a href=\"fiche.php?id=$objp->rowid\">";
|
|
|
|
|
print img_file();
|
2004-05-08 16:31:02 +02:00
|
|
|
print "</a> <a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n";
|
|
|
|
|
print "<td>$objp->label</td>";
|
|
|
|
|
print "<td>".$typeprodser[$objp->fk_product_type]."</td>";
|
|
|
|
|
print "</tr>\n";
|
2003-09-04 12:03:06 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free();
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
2003-07-12 12:32:11 +02:00
|
|
|
}
|
2002-06-29 00:46:44 +02:00
|
|
|
}
|
2003-07-12 12:32:11 +02:00
|
|
|
else
|
|
|
|
|
{
|
2004-08-13 00:16:46 +02:00
|
|
|
dolibarr_print_error();
|
2003-07-12 12:32:11 +02:00
|
|
|
}
|
|
|
|
|
|
2003-10-14 17:30:39 +02:00
|
|
|
print '</td></tr></table>';
|
2002-05-04 23:28:42 +02:00
|
|
|
|
2002-04-30 12:57:25 +02:00
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
|
|
|
?>
|