dolibarr/htdocs/product/fiche.php

790 lines
25 KiB
PHP
Raw Normal View History

2004-10-20 22:06:49 +02:00
<?php
2004-07-27 11:59:21 +02:00
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2002-05-04 23:28:42 +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-05-04 23:28:42 +02:00
*/
/*!
\file htdocs/product/fiche.php
\ingroup product
\brief Page de la fiche produit
\version $Revision$
*/
2003-09-11 22:18:51 +02:00
require("./pre.inc.php");
require("../propal.class.php");
require("../facture.class.php");
2002-05-04 23:28:42 +02:00
$langs->load("products");
2003-08-06 14:25:49 +02:00
$user->getrights('produit');
2003-08-11 20:37:35 +02:00
$user->getrights('propale');
$user->getrights('facture');
$mesg = '';
2002-05-04 23:28:42 +02:00
2003-08-06 14:25:49 +02:00
if (!$user->rights->produit->lire)
{
2003-08-06 14:26:52 +02:00
accessforbidden();
2003-08-06 14:25:49 +02:00
}
$types[0] = $langs->trans("Product");
$types[1] = $langs->trans("Service");
2004-11-26 18:08:23 +01:00
2004-11-26 18:15:00 +01:00
if ($_GET["action"] == 'fastappro')
2004-11-26 18:08:23 +01:00
{
$product = new Product($db);
2004-11-26 18:15:00 +01:00
$product->fetch($_GET["id"]);
2004-11-26 18:37:39 +01:00
$result = $product->fastappro($user);
2004-11-26 18:08:23 +01:00
Header("Location: fiche.php?id=".$_GET["id"]);
}
2004-10-23 23:34:49 +02:00
// Action ajout d'un produit ou service
2004-07-14 12:25:14 +02:00
if ($_POST["action"] == 'add' && $user->rights->produit->creer)
2003-06-22 00:44:29 +02:00
{
2002-06-29 00:46:44 +02:00
$product = new Product($db);
2002-05-04 23:28:42 +02:00
$product->ref = $_POST["ref"];
$product->libelle = $_POST["libelle"];
$product->price = $_POST["price"];
$product->tva_tx = $_POST["tva_tx"];
$product->type = $_POST["type"];
$product->envente = $_POST["statut"];
$product->description = $_POST["desc"];
$product->duration_value = $_POST["duration_value"];
$product->duration_unit = $_POST["duration_unit"];
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
$e_product = $product;
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
$id = $product->create($user);
if ($id > 0)
{
Header("Location: fiche.php?id=$id");
}
else
{
if ($id == -3)
{
$_error = 1;
$_GET["action"] = "create";
$_GET["type"] = $_POST["type"];
}
}
2002-06-29 00:46:44 +02:00
}
2002-05-04 23:28:42 +02:00
2004-10-23 23:34:49 +02:00
// Action mise a jour d'un produit ou service
2004-07-14 12:25:14 +02:00
if ($_POST["action"] == 'update' &&
$_POST["cancel"] <> $langs->trans("Cancel") &&
2004-11-22 09:08:59 +01:00
$user->rights->produit->creer)
2004-07-14 12:25:14 +02:00
{
$product = new Product($db);
if ($product->fetch($_POST["id"]))
2004-07-14 12:25:14 +02:00
{
$product->ref = $_POST["ref"];
$product->libelle = $_POST["libelle"];
$product->price = $_POST["price"];
$product->tva_tx = $_POST["tva_tx"];
$product->description = $_POST["desc"];
$product->envente = $_POST["statut"];
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
$product->duration_value = $_POST["duration_value"];
$product->duration_unit = $_POST["duration_unit"];
if ($product->check())
{
2004-10-23 23:34:49 +02:00
if ($product->update($product->id, $user) > 0)
{
$_GET["action"] = '';
2004-10-23 23:34:49 +02:00
$_GET["id"] = $_POST["id"];
}
else
{
$_GET["action"] = 're-edit';
2004-10-23 23:34:49 +02:00
$_GET["id"] = $_POST["id"];
$mesg = $product->mesg_error;
}
}
2004-07-14 12:25:14 +02:00
else
{
$_GET["action"] = 're-edit';
2004-10-23 23:34:49 +02:00
$_GET["id"] = $_POST["id"];
$mesg = $langs->trans("ErrorProductBadRefOrLabel");
}
2004-07-14 12:25:14 +02:00
}
}
2004-07-14 12:25:14 +02:00
if ($_POST["action"] == 'addinpropal')
{
$propal = New Propal($db);
$propal->fetch($_POST["propalid"]);
2004-07-14 12:25:14 +02:00
$result = $propal->insert_product($_GET["id"], $_POST["qty"], $_POST["remise_percent"]);
2003-09-08 13:02:40 +02:00
if ( $result < 0)
{
$mesg = $langs->trans("ErrorUnknown").": $result";
2003-09-08 13:02:40 +02:00
}
Header("Location: ../comm/propal.php?propalid=".$propal->id);
}
2004-11-22 09:08:59 +01:00
if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
{
$product = new Product($db);
$result = $product->fetch($_GET["id"]);
$facture = New Facture($db);
$facture->fetch($_POST["factureid"]);
$facture->addline($_POST["factureid"],
2003-09-14 21:13:44 +02:00
addslashes($product->libelle),
2003-09-13 15:49:07 +02:00
$product->price,
$_POST["qty"],
$product->tva_tx, $product->id);
2004-07-28 15:50:29 +02:00
Header("Location: ../compta/facture.php?facid=".$facture->id);
}
if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel"))
2003-10-08 19:07:24 +02:00
{
2003-10-08 19:07:24 +02:00
$product = new Product($db);
if( $product->fetch($_GET["id"]) )
2003-10-08 19:07:24 +02:00
{
if ($product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]) > 0)
2003-10-08 19:07:24 +02:00
{
$action = '';
$mesg = 'Founisseur ajout<75>';
}
else
{
$action = '';
}
2003-10-08 19:07:24 +02:00
}
}
if ($_GET["action"] == 'remove_fourn')
{
$product = new Product($db);
if( $product->fetch($_GET["id"]) )
{
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
{
2004-07-13 19:48:10 +02:00
$_GET["action"] = '';
2004-10-23 01:34:25 +02:00
$mesg = $langs->trans("SupplierRemoved");
}
else
{
2004-07-13 19:48:10 +02:00
$_GET["action"] = '';
}
}
}
2003-10-08 19:07:24 +02:00
if ($_POST["action"] == 'update_price' &&
2004-11-22 09:08:59 +01:00
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
2003-09-09 23:32:52 +02:00
{
$product = new Product($db);
2004-07-13 19:48:10 +02:00
$result = $product->fetch($_GET["id"]);
2003-09-09 23:32:52 +02:00
$product->price = ereg_replace(" ","",$_POST["price"]);
2004-07-21 11:59:06 +02:00
if ( $product->update_price($product->id, $user) > 0 )
2003-09-09 23:32:52 +02:00
{
$_GET["action"] = '';
2003-09-09 23:32:52 +02:00
$mesg = 'Fiche mise <20> jour';
}
else
{
$_GET["action"] = 'edit_price';
2003-09-09 23:32:52 +02:00
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
}
}
if ($_POST["cancel"] == $langs->trans("Cancel"))
2003-09-09 23:32:52 +02:00
{
$action = '';
Header("Location: fiche.php?id=".$_POST["id"]);
2003-09-09 23:32:52 +02:00
}
2004-07-14 12:25:14 +02:00
2004-10-23 23:34:49 +02:00
llxHeader("","",$langs->trans("CardProduct".$product->type));
2004-07-14 12:25:14 +02:00
2002-06-29 00:46:44 +02:00
/*
2004-07-14 12:25:14 +02:00
* Cr<EFBFBD>ation du produit
*
2002-06-29 00:46:44 +02:00
*/
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
2002-12-14 17:32:49 +01:00
{
$html = new Form($db);
$nbligne=0;
$product = new Product($db);
if ($_error == 1)
{
$product = $e_product;
}
print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">';
2004-07-14 12:25:14 +02:00
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
2004-09-04 14:03:36 +02:00
print '<div class="titre">';
if ($_GET["type"]==0) { print $langs->trans("NewProduct"); }
if ($_GET["type"]==1) { print $langs->trans("NewService"); }
print '</div><br>'."\n";
2002-06-29 00:46:44 +02:00
2004-10-23 01:34:25 +02:00
print '<table class="border" width="100%">';
2003-09-13 16:05:17 +02:00
print '<tr>';
2004-09-04 14:03:36 +02:00
print '<td>'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$product->ref.'">';
if ($_error == 1)
{
print "Cette r<>f<EFBFBD>rence existe d<>j<EFBFBD>";
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
2004-10-23 01:34:25 +02:00
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td><input name="price" size="10" value="'.$product->price.'"></td></tr>';
2004-09-04 14:03:36 +02:00
$langs->load("bills");
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
2004-11-28 17:05:02 +01:00
print $html->select_tva("tva_tx",$conf->defaulttx);
print '</td></tr>';
2004-09-04 14:03:36 +02:00
print '<tr><td>'.$langs->trans("Status").'</td><td>';
2003-11-18 10:32:24 +01:00
print '<select name="statut">';
2004-09-04 14:03:36 +02:00
print '<option value="1">'.$langs->trans("OnSell").'</option>';
print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
2003-11-18 10:32:24 +01:00
print '</td></tr>';
if ($_GET["type"] == 0 && defined("MAIN_MODULE_STOCK"))
{
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
print '<input name="seuil_stock_alerte" size="4" value="0">';
print '</td></tr>';
}
else
{
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
}
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
2002-06-29 00:46:44 +02:00
print '<textarea name="desc" rows="8" cols="50">';
print "</textarea></td></tr>";
if ($_GET["type"] == 1)
2003-08-03 13:43:59 +02:00
{
print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'"> &nbsp;';
print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").'&nbsp;';
print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").'&nbsp;';
print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").'&nbsp;';
print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").'&nbsp;';
2003-08-03 13:43:59 +02:00
print '</td></tr>';
}
print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
2002-06-29 00:46:44 +02:00
print '</table>';
print '</form>';
2002-12-14 17:32:49 +01:00
}
else
{
2004-10-23 23:34:49 +02:00
/*
* Fiche produit
*/
2004-07-13 16:00:29 +02:00
if ($_GET["id"])
2002-12-14 17:32:49 +01:00
{
2004-10-23 23:34:49 +02:00
2004-07-13 19:48:10 +02:00
if ($_GET["action"] <> 're-edit')
{
$product = new Product($db);
$result = $product->fetch($_GET["id"]);
}
2002-06-29 00:46:44 +02:00
2002-12-14 17:32:49 +01:00
if ( $result )
{
2004-07-13 19:48:10 +02:00
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
/*
2004-10-23 23:34:49 +02:00
* En mode visu
*/
// Zone recherche
2004-08-20 11:04:51 +02:00
print '<div class="formsearch">';
print '<form action="liste.php" method="post">';
print '<input type="hidden" name="type" value="'.$product->type.'">';
print $langs->trans("Ref").': <input class="flat" type="text" size="10" name="sref">&nbsp;<input class="flat" type="submit" value="'.$langs->trans("Go").'"> &nbsp;';
print $langs->trans("Label").': <input class="flat" type="text" size="20" name="snom">&nbsp;<input class="flat" type="submit" value="'.$langs->trans("Go").'">';
2004-08-20 11:04:51 +02:00
print '</form></div>';
$h=0;
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
$head[$h][1] = $langs->trans("Price");
$h++;
if($product->type == 0)
{
if ($conf->stock->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
$head[$h][1] = 'Stock';
$h++;
}
2004-12-04 20:31:50 +01:00
if ($conf->fournisseur->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers");
$h++;
}
}
2004-07-26 18:52:00 +02:00
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans('Statistics');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
2004-07-13 16:00:29 +02:00
print($mesg);
print '<table class="border" width="100%">';
2003-09-15 18:00:16 +02:00
print "<tr>";
2004-08-07 18:04:02 +02:00
print '<td width="20%">'.$langs->trans("Ref").'</td><td width="40%">'.$product->ref.'</td>';
2003-11-03 15:35:13 +01:00
print '<td width="40%">';
2003-09-15 18:00:16 +02:00
if ($product->envente)
2003-08-03 13:43:59 +02:00
{
2004-10-23 01:34:25 +02:00
print $langs->trans("OnSell");
2003-08-03 13:43:59 +02:00
}
2003-09-15 18:00:16 +02:00
else
2003-08-03 13:43:59 +02:00
{
2004-10-23 01:52:57 +02:00
print $langs->trans("NotOnSell");
2003-08-03 13:43:59 +02:00
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
2004-10-23 01:34:25 +02:00
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
2004-07-27 11:59:21 +02:00
if ($product->type == 0)
{
$nblignefour=4;
}
else
{
$nblignefour=4;
2004-07-27 11:59:21 +02:00
}
print '<td valign="top" rowspan="'.$nblignefour.'">';
print $langs->trans("Suppliers").' [<a href="fiche.php?id='.$product->id.'&amp;action=ajout_fourn">'.$langs->trans("Add").'</a>]';
2003-10-08 19:07:24 +02:00
$sql = "SELECT s.nom, s.idp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
2004-07-13 16:00:29 +02:00
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
2003-10-08 19:07:24 +02:00
$sql .= " ORDER BY lower(s.nom)";
if ( $db->query($sql) )
{
2004-11-22 09:08:59 +01:00
$num_fournisseur = $db->num_rows();
2003-10-08 19:07:24 +02:00
$i = 0;
print '<table class="noborder" width="100%">';
2003-10-08 19:07:24 +02:00
$var=True;
2004-11-22 09:08:59 +01:00
while ($i < $num_fournisseur)
2003-10-08 19:07:24 +02:00
{
$objp = $db->fetch_object($i);
2003-10-08 19:07:24 +02:00
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
print '<td align="right">';
print '<a href="fiche.php?id='.$product->id.'&amp;action=remove_fourn&amp;id_fourn='.$objp->idp.'">';
2004-10-23 01:34:25 +02:00
print img_disable($langs->trans("Remove")).'</a></td></tr>';
2003-10-08 19:07:24 +02:00
$i++;
}
print '</table>';
$db->free();
}
2003-09-15 18:00:16 +02:00
print '</td></tr>';
2003-09-09 23:32:52 +02:00
2004-09-04 14:03:36 +02:00
$langs->load("bills");
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.' %</td></tr>';
2003-11-18 10:32:24 +01:00
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
{
2004-09-04 14:03:36 +02:00
print '<tr><td><a href="stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
2003-11-18 10:32:24 +01:00
if ($product->no_stock)
{
2003-11-18 10:32:24 +01:00
print "<td>Pas de d<>finition de stock pour ce produit";
}
else
{
2003-11-18 10:32:24 +01:00
if ($product->stock_reel <= $product->seuil_stock_alerte)
{
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
}
else
{
print "<td>".$product->stock_reel;
2003-11-18 10:32:24 +01:00
}
}
2003-11-18 10:32:24 +01:00
print '</td></tr>';
}
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
2003-09-09 23:32:52 +02:00
2003-09-15 18:00:16 +02:00
if ($product->type == 1)
{
2004-10-23 01:34:25 +02:00
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.'&nbsp;';
2003-09-15 18:00:16 +02:00
if ($product->duration_value > 1)
{
2004-10-23 01:34:25 +02:00
$dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
}
else {
2004-10-23 01:34:25 +02:00
$dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
}
print $langs->trans($dur[$product->duration_unit])."&nbsp;";
2003-09-15 18:00:16 +02:00
print '</td></tr>';
}
print "</table><br>\n";
print "</div>\n";
}
2003-09-09 23:32:52 +02:00
/*
* Edition du prix
*
*/
if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
2004-07-13 16:00:29 +02:00
{
print '<div class="titre">'.$langs->trans("NewPrice").'</div>';
2004-07-21 11:59:06 +02:00
print '<form action="fiche.php?id='.$product->id.'" method="post">';
2004-07-13 16:00:29 +02:00
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans('SellingPrice').'</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
2004-07-13 16:00:29 +02:00
print '</table>';
print '</form>';
}
/*
* Ajouter un fournisseur
*
*/
if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer)
2004-07-13 16:00:29 +02:00
{
2004-10-23 01:34:25 +02:00
$langs->load("suppliers");
print_titre($langs->trans("AddSupplier"));
2004-07-26 18:52:00 +02:00
print '<form action="fiche.php?id='.$product->id.'" method="post">';
2004-07-13 16:00:29 +02:00
print '<input type="hidden" name="action" value="add_fourn">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%"><tr>';
print '<td>'.$langs->trans("Suppliers").'</td><td><select name="id_fourn">';
2004-07-13 16:00:29 +02:00
$sql = "SELECT s.idp, s.nom, s.ville FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur=1";
$sql .= " ORDER BY lower(s.nom)";
if ($db->query($sql))
2003-10-08 19:07:24 +02:00
{
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($i);
print '<option value="'.$obj->idp.'">'.$obj->nom . ($obj->ville?" ($obj->ville)":"");
$i++;
}
2004-07-13 16:00:29 +02:00
}
2004-08-07 18:04:02 +02:00
print '</select></td><td>'.$langs->trans("Ref").'</td><td><input name="ref_fourn" size="25" value=""></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
2004-07-13 16:00:29 +02:00
print '</table>';
print '</form>';
}
}
2004-07-13 16:00:29 +02:00
/*
* Fiche en mode edition
*/
2004-07-13 19:48:10 +02:00
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer)
2002-12-14 17:32:49 +01:00
{
2004-10-23 23:34:49 +02:00
print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, "");
if ($mesg) {
print '<br><div class="error">'.$mesg.'</div><br>';
}
print "<form action=\"fiche.php\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
2004-08-07 18:04:02 +02:00
print "<tr>".'<td width="20%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
print '<td>'.$langs->trans("Label").'</td><td colspan="2"><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
2003-09-09 23:32:52 +02:00
2004-09-04 14:03:36 +02:00
$langs->load("bills");
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">';
2003-06-22 00:44:29 +02:00
$html = new Form($db);
print $html->select_tva("tva_tx", $product->tva_tx);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
2003-07-12 12:32:37 +02:00
print '<select name="statut">';
if ($product->envente)
{
print '<option value="1" selected>'.$langs->trans("OnSell").'</option>';
print '<option value="0">'.$langs->trans("NotOnSell").'</option>';
2003-07-12 12:32:37 +02:00
}
else
{
print '<option value="1">'.$langs->trans("OnSell").'</option>';
print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
2003-07-12 12:32:37 +02:00
}
print '</td></tr>';
2003-11-18 10:32:24 +01:00
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
{
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
print '</td></tr>';
}
else
{
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
}
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
2002-12-14 17:32:49 +01:00
print '<textarea name="desc" rows="8" cols="50">';
print $product->description;
print "</textarea></td></tr>";
2003-08-03 12:50:09 +02:00
if ($product->type == 1)
{
2004-10-23 01:52:57 +02:00
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">';
print '&nbsp; ';
2004-12-19 01:22:37 +01:00
print '<input name="duration_unit" type="radio" value="d"'.($product->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day");
2004-10-23 01:52:57 +02:00
print '&nbsp; ';
2004-12-19 01:22:37 +01:00
print '<input name="duration_unit" type="radio" value="w"'.($product->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week");
2004-10-23 01:52:57 +02:00
print '&nbsp; ';
2004-12-19 01:22:37 +01:00
print '<input name="duration_unit" type="radio" value="m"'.($product->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month");
2004-10-23 01:52:57 +02:00
print '&nbsp; ';
2004-12-19 01:22:37 +01:00
print '<input name="duration_unit" type="radio" value="y"'.($product->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
2003-08-03 13:43:59 +02:00
print '</td></tr>';
2003-08-03 12:50:09 +02:00
}
print '<tr><td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
2002-12-14 17:32:49 +01:00
print '</table>';
print '</form>';
}
2002-12-14 17:32:49 +01:00
}
else
{
print $langs->trans("ErrorUnknown");
2002-12-14 17:32:49 +01:00
}
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
print "\n<div class=\"tabsAction\">\n";
2004-07-13 19:48:10 +02:00
if ($_GET["action"] == '')
2002-12-14 17:32:49 +01:00
{
2004-11-22 09:08:59 +01:00
if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1)
{
2004-11-26 18:08:23 +01:00
print '<a class="tabAction" href="fiche.php?action=fastappro&amp;id='.$product->id.'">'.$langs->trans("Commander").'</a>';
2004-11-22 09:08:59 +01:00
}
if ( $user->rights->produit->creer)
2003-09-09 23:32:52 +02:00
{
print '<a class="tabAction" href="fiche.php?action=edit_price&amp;id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>';
2003-09-09 23:32:52 +02:00
}
2004-11-22 09:08:59 +01:00
if ( $user->rights->produit->creer)
2003-08-06 14:25:49 +02:00
{
print '<a class="tabAction" href="fiche.php?action=edit&amp;id='.$product->id.'">'.$langs->trans("Edit").'</a>';
2003-08-06 14:25:49 +02:00
}
2002-12-14 17:32:49 +01:00
}
2004-11-22 09:08:59 +01:00
2003-11-18 10:32:24 +01:00
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
{
2004-07-13 19:48:10 +02:00
print '<a class="tabAction" href="stock/product.php?id='.$product->id.'&amp;action=correction">Correction stock</a>';
2003-11-18 10:32:24 +01:00
}
print "\n</div>\n";
2002-05-04 23:28:42 +02:00
if ($_GET["id"] && $_GET["action"] == '' && $product->envente)
{
$htmls = new Form($db);
$propal = New Propal($db);
2004-10-23 01:34:25 +02:00
print '<table width="100%" class="noborder">';
2003-08-11 20:37:35 +02:00
if($user->rights->propale->creer)
{
2003-09-13 16:05:17 +02:00
print "<tr>".'<td width="50%" valign="top">';
2003-08-28 16:58:51 +02:00
print_titre("Ajouter <20> ma proposition") . '</td>';
2003-10-08 19:07:24 +02:00
print '<td width="50%" valign="top">';
print_titre("Ajouter aux autres propositions") . '</td>';
2003-08-11 20:37:35 +02:00
print '</tr>';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td width="50%" valign="top">';
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
2003-08-11 20:37:35 +02:00
$sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id;
$sql .= " ORDER BY p.datec DESC, tms DESC";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
2004-10-23 01:34:25 +02:00
print '<table class="noborder" width="100%">';
2003-08-11 20:37:35 +02:00
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($i);
2003-08-11 20:37:35 +02:00
$var=!$var;
2004-10-23 01:34:25 +02:00
print "<tr $bc[$var]>";
2003-09-11 22:18:51 +02:00
print "<td><a href=\"../comm/propal.php?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
2004-08-23 10:39:30 +02:00
print "<td>". strftime("%d %b",$objp->dp)."</td>\n";
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
print '<input type="hidden" name="action" value="addinpropal">';
2003-08-11 20:37:35 +02:00
print '<td><input type="hidden" name="propalid" value="'.$objp->propalid.'">';
2003-11-18 10:32:24 +01:00
print '<input type="text" name="qty" size="3" value="1">&nbsp;Rem.';
print '<input type="text" name="remise_percent" size="3" value="0"> %';
print " ".$product->stock_proposition;
2003-08-11 20:37:35 +02:00
print '</td><td>';
print '<input type="submit" value="'.$langs->trans("Add").'">';
2003-08-11 20:37:35 +02:00
print "</td>";
print '</form></tr>';
$i++;
}
print "</table>";
$db->free();
}
2003-08-11 20:37:35 +02:00
print '</td>';
if($user->rights->propale->creer)
{
2003-08-11 20:37:35 +02:00
print '<td width="50%" valign="top">';
$otherprop = $propal->liste_array(1, '<>'.$user->id);
if (sizeof($otherprop))
{
2004-07-28 15:50:29 +02:00
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
2003-08-11 20:37:35 +02:00
print '<input type="hidden" name="action" value="addinpropal">';
2004-10-23 01:34:25 +02:00
print '<table class="border" width="100%">';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Autres Propositions</td><td>';
2003-08-11 20:37:35 +02:00
$htmls->select_array("propalid", $otherprop);
print '</td><td>';
2003-11-18 10:32:24 +01:00
print '<input type="text" name="qty" size="3" value="1">&nbsp;Rem.';
print '<input type="text" name="remise_percent" size="3" value="0"> %';
2003-08-11 20:37:35 +02:00
print '</td><td>';
print '<input type="submit" value="'.$langs->trans("Add").'">';
2003-09-13 15:39:12 +02:00
print '</td></tr>';
2003-08-11 20:37:35 +02:00
print '</table></form>';
}
print '</td>';
}
print '</tr>';
}
2003-08-11 20:37:35 +02:00
if($user->rights->facture->creer)
{
2004-09-04 14:03:36 +02:00
$langs->load("bills");
2003-09-13 16:05:17 +02:00
print "<tr>".'<td width="50%" valign="top">';
2003-08-28 16:58:51 +02:00
print_titre("Ajouter <20> ma facture");
2003-08-11 20:37:35 +02:00
print '</td><td width="50%" valign="top">';
print_titre("Ajouter aux autres factures");
print '</td></tr>';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td width="50%" valign="top">';
2003-08-11 20:37:35 +02:00
$sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
2003-08-11 20:37:35 +02:00
$sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id;
$sql .= " ORDER BY f.datec DESC, f.rowid DESC";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
2004-10-23 01:34:25 +02:00
print '<table class="noborder" width="100%">';
2003-08-11 20:37:35 +02:00
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
2003-09-11 22:18:51 +02:00
print "<td><a href=\"../compta/facture.php?facid=$objp->factureid\">$objp->facnumber</a></TD>\n";
print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
2004-08-23 10:39:30 +02:00
print "<td>". strftime("%d %b",$objp->df)."</td>\n";
2004-07-28 15:50:29 +02:00
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
2003-08-11 20:37:35 +02:00
print '<input type="hidden" name="action" value="addinfacture">';
print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">';
2003-11-18 10:32:24 +01:00
print '<input type="text" name="qty" size="3" value="1">&nbsp;Rem.';
print '<input type="text" name="remise_percent" size="3" value="0"> %';
2003-08-11 20:37:35 +02:00
print '</td><td>';
print '<input type="submit" value="'.$langs->trans("Add").'">';
2003-08-11 20:37:35 +02:00
print "</td>";
print '</form></tr>';
$i++;
}
print "</table>";
$db->free();
}
else
{
2004-10-23 01:34:25 +02:00
dolibarr_print_error($db);
2003-08-11 20:37:35 +02:00
}
print '</td><td width="50%" valign="top">';
print '</td></tr></table>';
}
}
2002-05-04 23:28:42 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>