diff --git a/htdocs/product/stock/entrepot.php b/htdocs/product/stock/entrepot.php
new file mode 100644
index 00000000000..b09f0d2b21d
--- /dev/null
+++ b/htdocs/product/stock/entrepot.php
@@ -0,0 +1,516 @@
+
+ *
+ * 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.
+ *
+ * $Id$
+ * $Source$
+ *
+ */
+
+require("./pre.inc.php");
+require("./entrepot.class.php");
+
+$mesg = '';
+
+llxHeader("","","Fiche stock");
+
+if ($action == 'add')
+{
+ $entrepot = new Entrepot($db);
+
+ $entrepot->ref = $HTTP_POST_VARS["ref"];
+ $entrepot->libelle = $HTTP_POST_VARS["libelle"];
+ $entrepot->description = $HTTP_POST_VARS["desc"];
+
+
+ $id = $entrepot->create($user);
+ $action = '';
+}
+
+if ($action == 'addinpropal')
+{
+ $propal = New Propal($db);
+
+ $propal->fetch($HTTP_POST_VARS["propalid"]);
+ $result = $propal->insert_product($id, $HTTP_POST_VARS["qty"]);
+ if ( $result < 0)
+ {
+ $mesg = "erreur $result";
+ }
+ else
+ {
+ $mesg = ucfirst($types[$type]) . ' ajouté à la proposition ';
+ $mesg .= ''.$propal->ref.'';
+ }
+ $action = '';
+}
+
+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"]);
+ $facture->addline($HTTP_POST_VARS["factureid"],
+ addslashes($product->libelle),
+ $product->price,
+ $HTTP_POST_VARS["qty"],
+ $product->tva_tx, $id);
+
+ $action = '';
+ $mesg = 'Produit ajouté à la facture ';
+ $mesg .= ''.$facture->ref.'';
+}
+
+if ($HTTP_POST_VARS["action"] == 'update' &&
+ $cancel <> 'Annuler' &&
+ ( $user->rights->produit->modifier || $user->rights->produit->creer))
+{
+ $product = new Product($db);
+ if ($product->fetch($id))
+ {
+
+ $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->duration_value = $HTTP_POST_VARS["duration_value"];
+ $product->duration_unit = $HTTP_POST_VARS["duration_unit"];
+
+ if ($product->check())
+ {
+ if ( $product->update($id, $user))
+ {
+ $action = '';
+ $mesg = 'Fiche mise à jour';
+ }
+ else
+ {
+ $action = 're-edit';
+ $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
+ }
+ }
+ else
+ {
+ $action = 're-edit';
+ $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
+ }
+ }
+}
+
+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 à jour';
+ }
+ else
+ {
+ $action = 'edit_price';
+ $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
+ }
+}
+
+if ($cancel == 'Annuler')
+{
+ $action = '';
+}
+/*
+ * Affichage
+ *
+ */
+if ($action == 'create')
+{
+ print "
';
+}
+else
+{
+ if ($id)
+ {
+ if ($action <> 're-edit')
+ {
+ $product = new Product($db);
+ $result = $product->fetch($id);
+ }
+
+ if ( $result )
+ {
+ if ($action <> 'edit' && $action <> 're-edit')
+ {
+ print '';
+
+
+ print_fiche_titre('Fiche '.$types[$product->type].' : '.$product->ref, $mesg);
+
+ print '';
+ print "";
+ print '| Référence | '.$product->ref.' | ';
+ print '';
+ if ($product->envente)
+ {
+ print "En vente";
+ }
+ else
+ {
+ print "Cet article n'est pas en vente";
+ }
+ print ' |
';
+ print "Libellé | $product->libelle | ";
+ print 'Statistiques | ';
+ print '| Prix de vente | '.price($product->price).' | ';
+ print '';
+ print "Propositions commerciales : ".$product->count_propale();
+ print " Proposé à ".$product->count_propale_client()." clients";
+ print " Factures : ".$product->count_facture();
+ print ' |
';
+
+ print "".'| Taux TVA | '.$product->tva_tx.' % |
';
+ print "| Description | ".nl2br($product->description)." |
";
+
+ if ($product->type == 1)
+ {
+ print "".'| Durée | '.$product->duration_value.' ';
+ if ($product->duration_value > 1)
+ {
+ $plu = "s";
+ }
+ switch ($product->duration_unit)
+ {
+ case "d":
+ print "jour$plu ";
+ break;
+ case "w":
+ print "semaine$plu ";
+ break;
+ case "m":
+ print 'mois ';
+ break;
+ case "y":
+ print "an$plu ";
+ break;
+ }
+ print ' |
';
+ }
+
+ print "
";
+ }
+
+ if ($action == 'edit_price' && $user->rights->produit->creer)
+ {
+ print '
Nouveau prix
';
+ print "';
+ }
+ }
+
+
+ if (($action == 'edit' || $action == 're-edit') && $user->rights->produit->creer)
+ {
+ print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, $mesg);
+
+ print "';
+ }
+ }
+ else
+ {
+ print "Error";
+ }
+}
+
+/* ************************************************************************** */
+/* */
+/* Barre d'action */
+/* */
+/* ************************************************************************** */
+
+print '
';
+if ($action == '')
+{
+ if ($user->rights->produit->modifier || $user->rights->produit->creer)
+ {
+ print '| [Changer le prix] | ';
+ }
+ else
+ {
+ print '- | ';
+ }
+}
+else
+{
+ print '- | ';
+}
+print '- | ';
+print '- | ';
+
+if ($action == '')
+{
+ if ($user->rights->produit->modifier || $user->rights->produit->creer)
+ {
+ print '[Editer] | ';
+ }
+ else
+ {
+ print '- | ';
+ }
+}
+else
+{
+ print '- | ';
+}
+print '- | ';
+print '
';
+
+if ($id && $action == '' && $product->envente)
+{
+
+ $htmls = new Form($db);
+ $propal = New Propal($db);
+
+ print '';
+ if($user->rights->propale->creer)
+ {
+ print "".'| ';
+ print_titre("Ajouter à ma proposition") . ' | ';
+ if($user->rights->propale->creer)
+ {
+ print '';
+ print_titre("Ajouter aux autres propositions") . ' | ';
+ }
+ print '
';
+ print "".'| ';
+ $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp";
+ $sql .= " FROM llx_societe as s, llx_propal as p";
+ $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 '";
+ $db->free();
+ }
+
+ print ' | ';
+
+ if($user->rights->propale->creer)
+ {
+ print '';
+
+ $otherprop = $propal->liste_array(1, '<>'.$user->id);
+ if (sizeof($otherprop))
+ {
+ print '';
+ }
+ print ' | ';
+ }
+ print '
';
+ }
+
+ if($user->rights->facture->creer)
+ {
+ print "".'| ';
+ print_titre("Ajouter à ma facture");
+ print ' | ';
+ print_titre("Ajouter aux autres factures");
+ print ' |
';
+ print "".'';
+ $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
+ $sql .= " FROM llx_societe as s, llx_facture as f";
+ $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;
+ print '";
+ $db->free();
+ }
+ else
+ {
+ print $db->error() . " " . $sql;
+ }
+ print ' | ';
+ print ' |
';
+ }
+}
+
+
+$db->close();
+
+llxFooter("Dernière modification $Date$ révision $Revision$");
+?>