diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
new file mode 100644
index 00000000000..203b06a3b2b
--- /dev/null
+++ b/htdocs/contrat/contrat.class.php
@@ -0,0 +1,115 @@
+
+ *
+ * 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$
+ *
+ */
+
+class Contrat
+{
+ var $id;
+ var $db;
+
+ /*
+ * Initialisation
+ *
+ */
+
+ Function Contrat($DB)
+ {
+ include_once("../societe.class.php3");
+ $this->db = $DB ;
+ $this->product = new Product($DB);
+ $this->societe = new Societe($DB);
+ }
+ /*
+ *
+ *
+ *
+ */
+ Function fetch ($id)
+ {
+ $sql = "SELECT rowid, enservice, fk_soc, fk_product";
+ $sql .= " FROM llx_contrat WHERE rowid = $id";
+
+ $result = $this->db->query($sql) ;
+
+ if ( $result )
+ {
+ $result = $this->db->fetch_array();
+
+ $this->id = $result["rowid"];
+ $this->enservice = $result["enservice"];
+ $this->product->fetch($result["fk_product"]);
+ $this->societe->fetch($result["fk_soc"]);
+ $this->db->free();
+ }
+ else
+ {
+ print $this->db->error();
+ }
+
+ return $result;
+ }
+ /*
+ *
+ *
+ */
+ Function create_from_facture($factureid, $user, $socid)
+ {
+ $sql = "SELECT p.rowid FROM llx_product as p, llx_facturedet as f";
+ $sql .= " WHERE p.rowid = f.fk_product AND p.fk_product_type = 1 AND f.fk_facture = ".$factureid;
+
+ if ($this->db->query($sql))
+ {
+ $num = $this->db->num_rows();
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($i);
+ $contrats[$i] = $objp->rowid;
+ $i++;
+ }
+
+ $this->db->free();
+
+ while (list($key, $value) = each ($contrats))
+ {
+ $sql = "INSERT INTO llx_contrat (fk_product, fk_facture, fk_soc, fk_user_author)";
+ $sql .= " VALUES ($value, $factureid, $socid, $user->id)";
+ if (! $this->db->query($sql))
+ {
+ print $this->db->error();
+ }
+ }
+ }
+ else
+ {
+ print $this->db->error();
+ }
+
+ return $result;
+ }
+ /*
+ *
+ *
+ */
+
+}
+?>
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
new file mode 100644
index 00000000000..bf0e949d84f
--- /dev/null
+++ b/htdocs/contrat/fiche.php
@@ -0,0 +1,354 @@
+
+ *
+ * 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("./contrat.class.php");
+require("../facture.class.php3");
+
+llxHeader();
+
+$db = new Db();
+$mesg = '';
+
+if ($action == 'add')
+{
+ $contrat = new Contrat($db);
+
+ $id = $product->create($user);
+ $action = '';
+}
+
+if ($action == 'update' && $cancel <> 'Annuler')
+{
+ $product = new Product($db);
+
+ $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->update($id, $user))
+ {
+ $action = '';
+ $mesg = 'Fiche mise à jour';
+ }
+ else
+ {
+ $action = 'edit';
+ $mesg = 'Fiche non mise à jour !' . " " . $product->mesg_error;
+ }
+}
+/*
+ *
+ *
+ */
+if ($action == 'create')
+{
+ print "
';
+
+}
+
+
+$db->close();
+
+llxFooter("Dernière modification $Date$ révision $Revision$");
+?>
diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php
new file mode 100644
index 00000000000..03c55e5c5e9
--- /dev/null
+++ b/htdocs/contrat/index.php
@@ -0,0 +1,94 @@
+
+ *
+ * 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");
+
+$db = new Db();
+
+
+llxHeader();
+
+if ($page == -1) {
+ $page = 0 ;
+}
+
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+
+if ($sortfield == "")
+{
+ $sortfield="c.tms";
+}
+
+if ($sortorder == "")
+{
+ $sortorder="DESC";
+}
+
+$sql = "SELECT s.nom, c.rowid as cid, c.enservice, p.label, p.rowid, s.idp as sidp";
+$sql .= " FROM llx_contrat as c, llx_societe as s, llx_product as p";
+$sql .= " WHERE c.fk_soc = s.idp AND c.fk_product = p.rowid";
+$sql .= " ORDER BY $sortfield $sortorder ";
+$sql .= $db->plimit($limit + 1 ,$offset);
+
+if ( $db->query($sql) )
+{
+ $num = $db->num_rows();
+ $i = 0;
+
+
+ print_barre_liste("Liste des contrats", $page, $PHP_SELF, "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
+
+ print '
";
+
+}
+else
+{
+ print $db->error() . " " .$sql;
+}
+
+
+$db->close();
+
+llxFooter("Dernière modification $Date$ révision $Revision$");
+?>
diff --git a/htdocs/contrat/pre.inc.php b/htdocs/contrat/pre.inc.php
new file mode 100644
index 00000000000..eb1d1eee79b
--- /dev/null
+++ b/htdocs/contrat/pre.inc.php
@@ -0,0 +1,48 @@
+
+ *
+ * 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("../main.inc.php3");
+
+$types[0] = "produit";
+$types[1] = "service";
+
+function llxHeader($head = "", $urlp = "")
+{
+ global $user, $conf;
+
+ /*
+ *
+ *
+ */
+ top_menu($head);
+
+ $menu = new Menu();
+
+ $menu->add(DOL_URL_ROOT."/contrat/index.php", "Contrats");
+
+ left_menu($menu->liste);
+ /*
+ *
+ *
+ */
+
+}
+?>