dolibarr/htdocs/product/fiche.php3

152 lines
4.7 KiB
PHP
Raw Normal View History

2002-05-04 23:28:42 +02:00
<?PHP
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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-05-04 23:28:42 +02:00
*/
require("./pre.inc.php3");
llxHeader();
$db = new Db();
2002-06-29 00:46:44 +02:00
if ($action == 'add') {
$product = new Product($db);
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
$product->ref = $ref;
$product->libelle = $libelle;
$product->price = $price;
$product->description = $desc;
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
$id = $product->create($user);
}
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
if ($action == 'update') {
2002-05-04 23:28:42 +02:00
$product = new Product($db);
2002-06-29 00:46:44 +02:00
$product->ref = $ref;
$product->libelle = $libelle;
$product->price = $price;
$product->description = $desc;
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
$product->update($id, $user);
}
/*
*
*
*/
2002-12-14 17:32:49 +01:00
if ($action == 'create')
{
2002-06-29 00:46:44 +02:00
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
2002-12-14 17:32:49 +01:00
print '<div class="titre">Nouveau produit</div><br>';
2002-06-29 00:46:44 +02:00
2002-12-14 17:32:49 +01:00
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
2002-06-29 00:46:44 +02:00
print "<tr>";
print '<td>R<>f<EFBFBD>rence</td><td><input name="ref" size="20" value=""></td></tr>';
print '<td>Libell<6C></td><td><input name="libelle" size="40" value=""></td></tr>';
print '<tr><td>Prix</td><TD><input name="price" size="10" value=""></td></tr>';
print "<tr><td valign=\"top\">Description</td><td>";
print '<textarea name="desc" rows="8" cols="50">';
print "</textarea></td></tr>";
print '<tr><td>&nbsp;</td><td><input type="submit" value="Cr<43>er"></td></tr>';
print '</table>';
print '</form>';
2002-05-04 23:28:42 +02:00
2002-12-14 17:32:49 +01:00
}
else
{
if ($id)
{
2002-06-29 00:46:44 +02:00
2002-12-14 17:32:49 +01:00
$product = new Product($db);
$result = $product->fetch($id);
2002-06-29 00:46:44 +02:00
2002-12-14 17:32:49 +01:00
if ( $result )
{
print '<div class="titre">Fiche produit : '.$product->ref.'</div><br>';
2002-06-29 00:46:44 +02:00
2002-12-14 17:32:49 +01:00
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>";
print "<td>R<>f<EFBFBD>rence</td><td>$product->ref</td></tr>\n";
print "<td>Libell<6C></td><td>$product->label</td></tr>\n";
print '<tr><td>Prix</td><TD>'.price($product->price).'</td></tr>';
print "<tr><td valign=\"top\">Description</td><td>".nl2br($product->description)."</td></tr>";
print "</table>";
}
2002-05-04 23:28:42 +02:00
2002-12-14 17:32:49 +01:00
if ($action == 'edit')
{
print '<hr><div class="titre">Edition de la fiche produit : '.$product->ref.'</div><br>';
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>";
print '<td>R<>f<EFBFBD>rence</td><td><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
print '<td>Libell<6C></td><td><input name="libelle" size="40" value="'.$product->label.'"></td></tr>';
print '<tr><td>Prix</td><TD><input name="price" size="10" value="'.$product->price.'"></td></tr>';
print "<tr><td valign=\"top\">Description</td><td>";
print '<textarea name="desc" rows="8" cols="50">';
print $product->description;
print "</textarea></td></tr>";
print '<tr><td>&nbsp;</td><td><input type="submit" value="Enregistrer"></td></tr>';
print '</table>';
print '</form>';
}
}
else
{
print "Error";
}
2002-06-29 00:46:44 +02:00
}
2002-05-04 23:28:42 +02:00
2002-12-14 17:32:49 +01:00
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
print '<td width="20%" align="center">-</td>';
print '<td width="20%" align="center">-</td>';
print '<td width="20%" align="center">-</td>';
2002-12-14 17:32:49 +01:00
if ($action == 'create')
{
print '<td width="20%" align="center">-</td>';
}
else
{
print '<td width="20%" align="center">[<a href="fiche.php3?action=edit&id='.$id.'">Editer</a>]</td>';
}
2002-06-29 00:46:44 +02:00
print '<td width="20%" align="center">-</td>';
print '</table><br>';
2002-05-04 23:28:42 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>