mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
.
This commit is contained in:
parent
d928df9775
commit
89ea444f63
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,24 +15,70 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
class Product {
|
||||
var $db ;
|
||||
|
||||
|
||||
var $id ;
|
||||
var $ref;
|
||||
var $label;
|
||||
var $libelle;
|
||||
var $description;
|
||||
var $price ;
|
||||
|
||||
Function Product($DB, $id=0) {
|
||||
$this->db = $DB;
|
||||
$this->id = $id ;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function create($user) {
|
||||
|
||||
$sql = "INSERT INTO llx_product (fk_user_author) VALUES (".$user->id.")";
|
||||
|
||||
if ($this->db->query($sql) ) {
|
||||
$id = $this->db->last_insert_id();
|
||||
|
||||
if ( $this->update($id, $user) ) {
|
||||
return $id;
|
||||
}
|
||||
} else {
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function update($id, $user) {
|
||||
|
||||
$sql = "UPDATE llx_product ";
|
||||
$sql .= " SET label = '" . trim($this->libelle) ."'";
|
||||
$sql .= ",ref = '" . trim($this->ref) ."'";
|
||||
$sql .= ",price = " . $this->price ;
|
||||
$sql .= ",description = '" . trim($this->description) ."'";
|
||||
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
if ( $this->db->query($sql) ) {
|
||||
return 1;
|
||||
} else {
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function fetch ($id) {
|
||||
|
||||
$sql = "SELECT rowid, ref, label, description, price FROM llx_product WHERE rowid = $id";
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,6 +15,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
require("./pre.inc.php3");
|
||||
|
|
@ -26,55 +26,101 @@ llxHeader();
|
|||
|
||||
$db = new Db();
|
||||
|
||||
if ($action == 'update') {
|
||||
if ($action == 'add') {
|
||||
$product = new Product($db);
|
||||
|
||||
$sql = "UPDATE llx_product SET description='$desc' where rowid = $rowid";
|
||||
$db->query($sql);
|
||||
$product->ref = $ref;
|
||||
$product->libelle = $libelle;
|
||||
$product->price = $price;
|
||||
$product->description = $desc;
|
||||
|
||||
$id = $product->create($user);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
|
||||
if ($action == 'update') {
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($id);
|
||||
|
||||
if ( $result ) {
|
||||
|
||||
print '<div class="titre">Fiche produit : '.$product->ref.'</div>';
|
||||
$product->ref = $ref;
|
||||
$product->libelle = $libelle;
|
||||
$product->price = $price;
|
||||
$product->description = $desc;
|
||||
|
||||
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
|
||||
print "<TR>";
|
||||
print "<TD>Référence</td><td>$product->ref</a></tr>\n";
|
||||
print "<TD>Libellé</td><td>$product->label</TD></tr>\n";
|
||||
|
||||
print "<tr><td>Prix</td><TD>$product->price</td></tr>\n";
|
||||
|
||||
print "<tr><td valign=\"top\">Description</td><td>".nl2br($product->description)."</td></tr>";
|
||||
|
||||
}
|
||||
print "</TABLE>";
|
||||
|
||||
if ($action == 'edit') {
|
||||
|
||||
|
||||
print "<hr><form action=\"$PHP_SELF?rowid=$rowid\" method=\"post\">\n";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
||||
print "<textarea name=\"desc\" rows=\"12\" cols=\"40\">";
|
||||
print nl2br($product->description);
|
||||
print "</textarea><br>";
|
||||
print "<input type=\"submit\">";
|
||||
print "</form>";
|
||||
|
||||
|
||||
|
||||
}
|
||||
$product->update($id, $user);
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($action == 'create') {
|
||||
|
||||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print 'Nouveau produit<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td>Référence</td><td><input name="ref" size="20" value=""></td></tr>';
|
||||
print '<td>Libellé</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> </td><td><input type="submit" value="Créer"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
|
||||
} else {
|
||||
print "Error";
|
||||
if ($id) {
|
||||
|
||||
$product = new Product($db);
|
||||
$result = $product->fetch($id);
|
||||
|
||||
if ( $result ) {
|
||||
print '<div class="titre">Fiche produit : '.$product->ref.'</div>';
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print "<td>Référence</td><td>$product->ref</td></tr>\n";
|
||||
print "<td>Libellé</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>";
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'edit') {
|
||||
print "<hr><form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
||||
|
||||
print 'Edition de la fiche produit<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td>Référence</td><td><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
||||
print '<td>Libellé</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> </td><td><input type="submit"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
} else {
|
||||
print "Error";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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>';
|
||||
|
||||
print '<td width="20%" align="center">[<a href="fiche.php3?action=edit&id='.$id.'">Editer</a>]</td>';
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,6 +15,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
require("./pre.inc.php3");
|
||||
|
|
@ -44,37 +44,38 @@ if ($page == -1) { $page = 0 ; }
|
|||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
print '<div class="titre">Liste des produits</div>';
|
||||
|
||||
print_barre_liste("Liste des produits", $page, $PHP_SELF);
|
||||
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.duration,p.ref FROM llx_product as p";
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.ref FROM llx_product as p";
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||
$sql .= $db->plimit( $limit ,$offset);
|
||||
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||
$sql .= $db->plimit( $limit ,$offset);
|
||||
|
||||
if ( $db->query($sql) ) {
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
print "<TR class=\"liste_titre\">";
|
||||
print "<TD>Réf</TD>";
|
||||
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Nom</a></td>";
|
||||
print "<TD align=\"right\">Prix</TD>";
|
||||
print "</TR>\n";
|
||||
$var=True;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD><a href=\"fiche.php3?id=$objp->rowid\">$objp->ref</a></TD>\n";
|
||||
print "<TD>$objp->label</TD>\n";
|
||||
print '<TD align="right">'.price($objp->price).'</TD>';
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</TABLE>";
|
||||
$db->free();
|
||||
}
|
||||
if ( $db->query($sql) ) {
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
print "<TR class=\"liste_titre\"><td>";
|
||||
print_liste_field_titre("Réf",$PHP_SELF, "p.ref");
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Libellé",$PHP_SELF, "p.label");
|
||||
print "</td><TD align=\"right\">Prix de vente</TD>";
|
||||
print "</TR>\n";
|
||||
$var=True;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD><a href=\"fiche.php3?id=$objp->rowid\">$objp->ref</a></TD>\n";
|
||||
print "<TD>$objp->label</TD>\n";
|
||||
print '<TD align="right">'.price($objp->price).'</TD>';
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</TABLE>";
|
||||
$db->free();
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,6 +15,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
require("../main.inc.php3");
|
||||
|
||||
|
|
@ -33,21 +33,21 @@ function llxHeader($head = "", $urlp = "") {
|
|||
$menu = new Menu();
|
||||
|
||||
$menu->add("/product/index.php3", "Produits");
|
||||
|
||||
$menu->add_submenu("fiche.php3?&action=create","Nouveau produit");
|
||||
$menu->add("/service/index.php3", "Services");
|
||||
|
||||
$menu->add("/comm/index.php3", "Clients");
|
||||
$menu->add("/comm/clients.php3", "Clients");
|
||||
|
||||
$menu->add("/fourn/index.php3", "Fournisseurs");
|
||||
|
||||
|
||||
$menu->add_submenu("/soc.php3?&action=create","Nouvelle sociétée");
|
||||
$menu->add_submenu("contact.php3","Contacts");
|
||||
|
||||
|
||||
left_menu($menu->liste);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,6 +15,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
require("./pre.inc.php3");
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,6 +15,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
require("./pre.inc.php3");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user