diff --git a/htdocs/fourn/pre.inc.php b/htdocs/fourn/pre.inc.php
index 3ddc7cbb780..2e0eed466b0 100644
--- a/htdocs/fourn/pre.inc.php
+++ b/htdocs/fourn/pre.inc.php
@@ -52,6 +52,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/fiche.php?action=create","Nouvelle");
}
+ $menu->add(DOL_URL_ROOT."/product/liste.php?type=0","Produits");
+
left_menu($menu->liste);
}
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index 815c21f509a..1e6d851130f 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -370,5 +370,30 @@ class Product
return $this->_get_stats($sql);
}
+ /*
+ *
+ *
+ */
+ Function add_fournisseur($user, $id_fourn, $ref_fourn)
+ {
+
+ $sql = "INSERT INTO llx_product_fournisseur ";
+ $sql .= " (datec, fk_product, fk_soc, ref_fourn, fk_user_author)";
+ $sql .= " VALUES (now(), $this->id, $id_fourn, '$ref_fourn', $user->id)";
+
+ if ($this->db->query($sql) )
+ {
+ return 1;
+ }
+ else
+ {
+ print $this->db->error() . ' in ' . $sql;
+ return -1;
+ }
+ }
+ /*
+ *
+ *
+ */
}
?>
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 74704612c44..f360c3bb869 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -91,6 +91,21 @@ if ($HTTP_POST_VARS["action"] == 'addinfacture' &&
$mesg .= ''.$facture->ref.'';
}
+if ($HTTP_POST_VARS["action"] == 'add_fourn')
+{
+ $product = new Product($db);
+ if( $product->fetch($id) )
+ {
+ if ($product->add_fournisseur($user, $HTTP_POST_VARS["id_fourn"], $HTTP_POST_VARS["ref_fourn"]))
+ {
+ $action = '';
+ $mesg = 'Founisseur ajouté';
+ }
+ }
+
+}
+
+
if ($HTTP_POST_VARS["action"] == 'update' &&
$cancel <> 'Annuler' &&
( $user->rights->produit->modifier || $user->rights->produit->creer))
@@ -233,9 +248,31 @@ else
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 'Fournisseurs [Ajouter]';
+
+ $sql = "SELECT s.nom, s.idp";
+ $sql .= " FROM llx_societe as s, llx_product_fournisseur as pf";
+ $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;
+ print '';
+ $var=True;
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object( $i);
+ $var=!$var;
+ print "";
+ print '| '.$objp->nom.' | ';
+ $i++;
+ }
+ print ' ';
+ $db->free();
+ }
+
print ' |
';
print "".'| Taux TVA | '.$product->tva_tx.' % |
';
@@ -265,7 +302,6 @@ else
}
print '';
}
-
print "";
}
@@ -280,7 +316,40 @@ else
print '';
print '';
print '';
+ }
+ /*
+ * Ajouter un fournisseur
+ *
+ */
+ if ($action == 'ajout_fourn' && $user->rights->produit->creer)
+ {
+ print_titre ("Ajouter un founisseur");
+ print "';
}
+
}
@@ -422,11 +491,10 @@ if ($id && $action == '' && $product->envente)
{
print "".'| ';
print_titre("Ajouter à ma proposition") . ' | ';
- if($user->rights->propale->creer)
- {
- print '';
- print_titre("Ajouter aux autres propositions") . ' | ';
- }
+
+ 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";
diff --git a/htdocs/product/pre.inc.php b/htdocs/product/pre.inc.php
index 71413a7a0f4..ab1eb94f3f0 100644
--- a/htdocs/product/pre.inc.php
+++ b/htdocs/product/pre.inc.php
@@ -61,8 +61,7 @@ function llxHeader($head = "", $urlp = "", $title="")
$menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories");
}
- // La notion de service est abandonnée pour le moment
- // $menu->add(DOL_URL_ROOT."/service/index.php", "Services");
+ $menu->add(DOL_URL_ROOT."/fourn/index.php", "Fournisseurs");
$menu->add("stats/", "Statistiques");
$menu->add_submenu("popuprop.php", "Popularité");
diff --git a/mysql/migration/1.0.0-1.1.0.sql b/mysql/migration/1.0.0-1.1.0.sql
index b09fc4f6859..8c042bce0e8 100644
--- a/mysql/migration/1.0.0-1.1.0.sql
+++ b/mysql/migration/1.0.0-1.1.0.sql
@@ -13,3 +13,19 @@ alter table llx_propaldet add subprice real default 0;
alter table llx_facturedet add remise_percent real default 0;
alter table llx_facturedet add remise real default 0;
alter table llx_facturedet add subprice real default 0;
+
+
+create table llx_product_fournisseur
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ datec datetime,
+ tms timestamp,
+ fk_product integer,
+ fk_soc integer,
+ ref_fourn varchar(30),
+ fk_user_author integer,
+
+ key(fk_product),
+ key(fk_soc)
+);
+
|