dolibarr/htdocs/product/fiche.php

679 lines
23 KiB
PHP
Raw Normal View History

2002-05-04 23:28:42 +02:00
<?PHP
2003-06-22 00:44:29 +02:00
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
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
*/
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
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
}
2003-09-10 15:03:59 +02:00
llxHeader("","","Fiche produit");
2003-08-06 14:25:49 +02:00
2003-06-22 00:44:29 +02:00
if ($action == 'add')
{
2002-06-29 00:46:44 +02:00
$product = new Product($db);
2002-05-04 23:28:42 +02:00
2003-10-28 13:40:08 +01:00
$product->ref = $HTTP_POST_VARS["ref"];
$product->libelle = $HTTP_POST_VARS["libelle"];
$product->price = $HTTP_POST_VARS["price"];
$product->tva_tx = $HTTP_POST_VARS["tva_tx"];
$product->type = $HTTP_POST_VARS["type"];
2003-11-18 10:32:24 +01:00
$product->envente = $HTTP_POST_VARS["statut"];
2003-10-28 13:40:08 +01:00
$product->description = $HTTP_POST_VARS["desc"];
$product->duration_value = $HTTP_POST_VARS["duration_value"];
2003-10-28 13:40:08 +01:00
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
2002-05-04 23:28:42 +02:00
2002-06-29 00:46:44 +02:00
$id = $product->create($user);
$action = '';
2002-06-29 00:46:44 +02:00
}
2002-05-04 23:28:42 +02:00
if ($action == 'addinpropal')
{
$propal = New Propal($db);
$propal->fetch($HTTP_POST_VARS["propalid"]);
2003-11-18 10:32:24 +01:00
$result = $propal->insert_product($id, $HTTP_POST_VARS["qty"], $HTTP_POST_VARS["remise_percent"]);
2003-09-08 13:02:40 +02:00
if ( $result < 0)
{
$mesg = "erreur $result";
}
else
{
$mesg = ucfirst($types[$type]) . ' ajout<75> <20> la proposition ';
2003-09-11 22:18:51 +02:00
$mesg .= '<a href="../comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
2003-09-08 13:02:40 +02:00
}
$action = '';
}
2003-09-13 16:20:14 +02:00
if ($HTTP_POST_VARS["action"] == 'addinfacture' &&
( $user->rights->facture->modifier || $user->rights->facture->creer))
{
$product = new Product($db);
$result = $product->fetch($id);
$facture = New Facture($db);
$facture->fetch($HTTP_POST_VARS["factureid"]);
2003-09-13 15:49:07 +02:00
$facture->addline($HTTP_POST_VARS["factureid"],
2003-09-14 21:13:44 +02:00
addslashes($product->libelle),
2003-09-13 15:49:07 +02:00
$product->price,
$HTTP_POST_VARS["qty"],
$product->tva_tx, $id);
$action = '';
$mesg = 'Produit ajout<75> <20> la facture ';
2003-09-11 22:18:51 +02:00
$mesg .= '<a href="../compta/facture.php?facid='.$facture->id.'">'.$facture->ref.'</a>';
}
if ($HTTP_POST_VARS["action"] == 'add_fourn' && $cancel <> 'Annuler')
2003-10-08 19:07:24 +02:00
{
$product = new Product($db);
if( $product->fetch($id) )
{
if ($product->add_fournisseur($user, $HTTP_POST_VARS["id_fourn"], $HTTP_POST_VARS["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 ($HTTP_POST_VARS["action"] == 'update' &&
$cancel <> 'Annuler' &&
( $user->rights->produit->modifier || $user->rights->produit->creer))
2003-06-22 00:44:29 +02:00
{
2002-05-04 23:28:42 +02:00
$product = new Product($db);
2003-09-13 16:20:14 +02:00
if ($product->fetch($id))
2003-07-12 12:32:37 +02:00
{
$product->ref = $HTTP_POST_VARS["ref"];
$product->libelle = $HTTP_POST_VARS["libelle"];
$product->price = $HTTP_POST_VARS["price"];
$product->tva_tx = $HTTP_POST_VARS["tva_tx"];
$product->description = $HTTP_POST_VARS["desc"];
$product->envente = $HTTP_POST_VARS["statut"];
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
$product->duration_value = $HTTP_POST_VARS["duration_value"];
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
2003-09-13 16:20:14 +02:00
if ($product->check())
{
if ( $product->update($id, $user))
{
$action = '';
$mesg = 'Fiche mise <20> jour';
}
else
{
$action = 're-edit';
2003-09-13 16:20:14 +02:00
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
}
}
else
{
$action = 're-edit';
2003-09-13 16:20:14 +02:00
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
}
2003-07-12 12:32:37 +02:00
}
2002-06-29 00:46:44 +02:00
}
2003-09-09 23:32:52 +02:00
if ($HTTP_POST_VARS["action"] == 'update_price' &&
$cancel <> 'Annuler' &&
( $user->rights->produit->modifier || $user->rights->produit->creer))
{
$product = new Product($db);
$result = $product->fetch($id);
$product->price = $HTTP_POST_VARS["price"];
if ( $product->update_price($id, $user) > 0 )
{
$action = '';
$mesg = 'Fiche mise <20> jour';
}
else
{
$action = 'edit_price';
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
}
}
if ($cancel == 'Annuler')
{
$action = '';
}
2002-06-29 00:46:44 +02:00
/*
*
*
*/
2002-12-14 17:32:49 +01:00
if ($action == 'create')
{
2003-08-03 13:43:59 +02:00
print "<form action=\"$PHP_SELF?type=$type\" method=\"post\">\n";
2003-08-03 12:50:09 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"add\">\n";
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
print '<div class="titre">Nouveau '.$types[$type].'</div><br>'."\n";
2002-06-29 00:46:44 +02:00
2003-10-21 11:48:06 +02:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
2003-09-13 16:05:17 +02:00
print '<tr>';
2002-06-29 00:46:44 +02:00
print '<td>R<>f<EFBFBD>rence</td><td><input name="ref" size="20" value=""></td></tr>';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Libell<6C></td><td><input name="libelle" size="40" value=""></td></tr>';
print "<tr>".'<td>Prix de vente</td><TD><input name="price" size="10" value=""></td></tr>';
print "<tr>".'<td>Taux TVA</td><TD>';
2003-06-22 00:44:29 +02:00
$html = new Form($db);
print $html->select_tva("tva_tx");
print '</td></tr>';
2003-11-18 10:32:24 +01:00
print '<tr><td>Statut</td><td>';
print '<select name="statut">';
print '<option value="1">En vente</option>';
print '<option value="0" SELECTED>Hors Vente</option>';
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">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
{
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Dur<75>e</td><TD><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'">';
2003-08-03 13:43:59 +02:00
print '<input name="duration_unit" type="radio" value="d">jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w">semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m">mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
print '</td></tr>';
}
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>&nbsp;</td><td><input type="submit" value="Cr<43>er"></td></tr>';
2002-06-29 00:46:44 +02:00
print '</table>';
print '</form>';
2002-12-14 17:32:49 +01:00
}
else
{
if ($id)
{
if ($action <> 're-edit')
{
$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 )
{
if ($action <> 'edit' && $action <> 're-edit')
{
2003-10-12 16:32:22 +02:00
print '<table border="0" width="100%" cellspacing="0" cellpadding="4">';
2003-09-15 18:00:16 +02:00
print '<tr class="liste_titre">';
2003-10-21 17:07:27 +02:00
print '<td><form action="liste.php?type='.$product->type.'" method="post">';
print 'R<>f : <input class="flat" type="text" size="10" name="sref">&nbsp;<input class="flat" type="submit" value="go">';
print '</form></td><td><form action="liste.php" method="post">';
print 'Libell<6C> : <input class="flat" type="text" size="20" name="snom">&nbsp;<input class="flat" type="submit" value="go">';
print '</form></td><td>&nbsp;</td></tr></table>';
2003-07-11 07:56:06 +02:00
2003-09-15 18:00:16 +02:00
print_fiche_titre('Fiche '.$types[$product->type].' : '.$product->ref, $mesg);
2002-06-29 00:46:44 +02:00
2003-10-21 11:48:06 +02:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
2003-09-15 18:00:16 +02:00
print "<tr>";
print '<td width="20%">R<>f<EFBFBD>rence</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
{
2003-09-15 18:00:16 +02:00
print "En vente";
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
{
2003-09-15 18:00:16 +02:00
print "<b>Cet article n'est pas en vente</b>";
2003-08-03 13:43:59 +02:00
}
print '</td></tr>';
2003-10-21 17:11:55 +02:00
print "<tr><td>Libell<6C></td><td>$product->libelle</td>";
2003-09-15 18:00:16 +02:00
print '<td><a href="stats/fiche.php?id='.$id.'">Statistiques</a></td></tr>';
print '<tr><td>Prix de vente</td><td>'.price($product->price).'</td>';
print '<td valign="top" rowspan="4">';
2003-10-21 17:07:27 +02:00
print 'Fournisseurs [<a href="fiche.php?id='.$id.'&amp;action=ajout_fourn">Ajouter</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";
2003-10-08 19:07:24 +02:00
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product =$id";
$sql .= " ORDER BY lower(s.nom)";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
2003-10-21 11:48:06 +02:00
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
2003-10-08 19:07:24 +02:00
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</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
print '<tr><td>Taux TVA</td><TD>'.$product->tva_tx.' %</td></tr>';
2003-11-18 10:32:24 +01:00
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
{
2003-11-18 10:32:24 +01:00
print '<tr><td><a href="stock/product.php?id='.$product->id.'">Stock</a></td>';
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>';
}
2003-09-15 18:00:16 +02:00
print "<tr><td valign=\"top\">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)
{
print "<tr>".'<td>Dur<75>e</td><TD>'.$product->duration_value.'&nbsp;';
if ($product->duration_value > 1)
{
$plu = "s";
}
switch ($product->duration_unit)
{
case "d":
print "jour$plu&nbsp;";
break;
case "w":
print "semaine$plu&nbsp;";
break;
case "m":
print 'mois&nbsp;';
break;
case "y":
print "an$plu&nbsp;";
break;
}
print '</td></tr>';
}
print "</table>";
}
2003-09-09 23:32:52 +02:00
2003-09-15 18:00:16 +02:00
if ($action == 'edit_price' && $user->rights->produit->creer)
{
print '<hr><div class="titre">Nouveau prix</div><br>';
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update_price">';
2003-11-03 15:35:13 +01:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
2003-09-15 18:00:16 +02:00
print '<tr><td width="20%">Prix de vente</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" value="Enregistrer">&nbsp;';
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
print '</table>';
print '</form>';
2003-10-08 19:07:24 +02:00
}
/*
* Ajouter un fournisseur
*
*/
if ($action == 'ajout_fourn' && $user->rights->produit->creer)
{
print_titre ("Ajouter un founisseur");
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add_fourn">';
2003-11-03 15:35:13 +01:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="4"><tr>';
2003-10-08 19:07:24 +02:00
print '<td>Fournisseurs</td><td><select name="id_fourn">';
$sql = "SELECT s.idp, s.nom, s.ville FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur=1";
2003-10-08 19:07:24 +02:00
$sql .= " ORDER BY lower(s.nom)";
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object( $i);
print '<option value="'.$obj->idp.'">'.$obj->nom . " (".$obj->ville.")";
$i++;
}
}
print '</select></td><td>R<>f<EFBFBD>rence</td><td><input name="ref_fourn" size="25" value=""></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" value="Enregistrer">&nbsp;';
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
print '</table>';
print '</form>';
2003-09-15 18:00:16 +02:00
}
2003-10-08 19:07:24 +02:00
}
2003-09-09 23:32:52 +02:00
2002-05-04 23:28:42 +02:00
if (($action == 'edit' || $action == 're-edit') && $user->rights->produit->creer)
2002-12-14 17:32:49 +01:00
{
print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, $mesg);
2002-12-14 17:32:49 +01:00
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update">';
2002-12-14 17:32:49 +01:00
2003-11-03 15:35:13 +01:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td width="20%">R<>f<EFBFBD>rence</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
2003-09-14 21:13:44 +02:00
print '<td>Libell<6C></td><td colspan="2"><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
2003-09-09 23:32:52 +02:00
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Taux TVA</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>';
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Statut</td><td colspan="2">';
2003-07-12 12:32:37 +02:00
print '<select name="statut">';
if ($product->envente)
{
print '<option value="1" SELECTED>En vente</option>';
print '<option value="0">Hors Vente</option>';
}
else
{
print '<option value="1">En vente</option>';
print '<option value="0" SELECTED>Hors Vente</option>';
}
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">';
}
2003-09-13 16:05:17 +02:00
print "<tr>".'<td valign="top">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)
{
2003-09-13 16:05:17 +02:00
print "<tr>".'<td>Dur<75>e</td><td colspan="2"><input name="duration_value" size="6" maxlength="5" value="'.$product->duration_value.'">';
2003-08-04 15:26:25 +02:00
switch ($product->duration_unit)
{
case "d":
print '<input name="duration_unit" type="radio" value="d" checked>jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w">semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m">mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
break;
case "w":
print '<input name="duration_unit" type="radio" value="d">jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w" checked>semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m">mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
break;
case "m":
print '<input name="duration_unit" type="radio" value="d">jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w">semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m" checked>mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
break;
case "y":
print '<input name="duration_unit" type="radio" value="d">jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w">semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m">mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y" checked>ann<6E>e';
break;
default:
print '<input name="duration_unit" type="radio" value="d">jour&nbsp;';
print '<input name="duration_unit" type="radio" value="w">semaine&nbsp;';
print '<input name="duration_unit" type="radio" value="m">mois&nbsp;';
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
break;
}
2003-08-03 13:43:59 +02:00
print '</td></tr>';
2003-08-03 12:50:09 +02:00
}
2003-09-13 16:05:17 +02:00
print "<tr>".'<td colspan="3" align="center"><input type="submit" value="Enregistrer">&nbsp;';
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
2002-12-14 17:32:49 +01:00
print '</table>';
print '</form>';
}
2002-12-14 17:32:49 +01:00
}
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
2003-10-21 11:48:06 +02:00
print '<br><table id="actions" width="100%" cellspacing="0" cellpadding="3">';
2003-09-09 23:32:52 +02:00
if ($action == '')
2002-12-14 17:32:49 +01:00
{
2003-09-09 23:32:52 +02:00
if ($user->rights->produit->modifier || $user->rights->produit->creer)
{
print '<td width="20%" align="center"><a href="fiche.php?action=edit_price&amp;id='.$id.'">Changer le prix</a></td>';
2003-09-09 23:32:52 +02:00
}
else
{
print '<td width="20%" align="center">-</td>';
}
2002-12-14 17:32:49 +01:00
}
else
2003-09-09 23:32:52 +02:00
{
print '<td width="20%" align="center">-</td>';
}
print '<td width="20%" align="center">-</td>';
if ($action == '')
2002-12-14 17:32:49 +01:00
{
2003-08-06 14:25:49 +02:00
if ($user->rights->produit->modifier || $user->rights->produit->creer)
{
print '<td width="20%" align="center"><a href="fiche.php?action=edit&amp;id='.$id.'">Editer</a></td>';
2003-08-06 14:25:49 +02:00
}
else
{
print '<td width="20%" align="center">-</td>';
}
2002-12-14 17:32:49 +01:00
}
2003-09-09 23:32:52 +02:00
else
{
print '<td width="20%" align="center">-</td>';
}
2002-06-29 00:46:44 +02:00
print '<td width="20%" align="center">-</td>';
2003-11-18 10:32:24 +01:00
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
{
print '<td width="20%" align="center"><a href="stock/product.php?id='.$id.'&amp;action=correction">Correction stock</a></td>';
}
else
{
print '<td width="20%" align="center">-</td>';
}
2002-06-29 00:46:44 +02:00
print '</table><br>';
2002-05-04 23:28:42 +02:00
if ($id && $action == '' && $product->envente)
{
$htmls = new Form($db);
$propal = New Propal($db);
2003-07-07 12:28:02 +02:00
print '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
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;
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
$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=\"../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";
2003-08-11 20:37:35 +02:00
print "<td>". strftime("%d %B %Y",$objp->dp)."</td>\n";
2003-09-11 22:18:51 +02:00
print '<form method="POST" action="fiche.php?id='.$id.'">';
2003-08-11 20:37:35 +02:00
print '<input type="hidden" name="action" value="addinpropal">';
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="Ajouter">';
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))
{
2003-09-11 22:18:51 +02:00
print '<form method="POST" action="fiche.php?id='.$id.'">';
2003-08-11 20:37:35 +02:00
print '<input type="hidden" name="action" value="addinpropal">';
2003-11-03 15:35:13 +01:00
print '<table class="border" width="100%" cellpadding="3" cellspacing="0">';
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="Ajouter">';
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)
{
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;
2003-10-21 11:48:06 +02:00
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
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";
2003-08-11 20:37:35 +02:00
print "<td>". strftime("%d %B %Y",$objp->df)."</td>\n";
2003-09-11 22:18:51 +02:00
print '<form method="POST" action="fiche.php?id='.$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="Ajouter">';
print "</td>";
print '</form></tr>';
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . "<br>" . $sql;
}
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>");
?>