| '.$langs->trans("Ref").' | ';
if ($_error == 1)
{
print $langs->trans("RefAlreadyExists");
@@ -321,7 +337,7 @@ else
if ($conf->fournisseur->enabled)
{
- $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
+ $head[$h][0] = DOL_URL_ROOT."/fourn/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers");
$h++;
}
@@ -347,8 +363,7 @@ else
print '';
if ($conf->categorie->enabled)
- {
-
+ {
print '';
print '';
$cat = new Categorie ($db);
diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php
index a1a4189b422..530e2aced45 100644
--- a/htdocs/fourn/product/liste.php
+++ b/htdocs/fourn/product/liste.php
@@ -70,7 +70,10 @@ if (isset($_REQUEST['catid']))
$title=$langs->trans("ProductsAndServices");
-$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type";
+$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type";
+$sql .= ", pf.fk_soc";
+$sql .= ", ppf.price";
+$sql .= ", s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if ($_GET["fourn_id"] > 0)
@@ -84,6 +87,11 @@ if ($catid)
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
}
+
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = pf.fk_soc";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_soc = pf.fk_soc AND ppf.fk_product = p.rowid AND ppf.quantity = 1";
+
if ($_POST["mode"] == 'search')
{
$sql .= " WHERE p.ref like '%".$_POST["sall"]."%'";
@@ -118,23 +126,25 @@ if ($fourn_id > 0)
}
$sql .= " ORDER BY $sortfield $sortorder ";
-$sql .= $db->plimit($limit + 1 ,$offset);
-$result = $db->query($sql) ;
-if ($result)
+$sql .= $db->plimit($limit + 1 ,$offset);
+
+$resql = $db->query($sql) ;
+
+if ($resql)
{
- $num = $db->num_rows();
-
- $i = 0;
+ $num = $db->num_rows($resql);
- if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref))
+ $i = 0;
+
+ if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref))
{
- $objp = $db->fetch_object($i);
- Header("Location: fiche.php?id=$objp->rowid");
+ $objp = $db->fetch_object($resql);
+ Header("Location: fiche.php?id=$objp->rowid");
}
- $texte = $langs->trans("List");
-
+ $texte = $langs->trans("List");
+
llxHeader("","",$texte);
if ($sref || $snom || $_POST["sall"] || $_POST["search"])
@@ -145,7 +155,7 @@ if ($result)
{
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num);
}
-
+
/*
*
@@ -158,7 +168,6 @@ if ($result)
{
$c = new Categorie ($db, $catid);
$ways = $c->print_all_ways(' > ','fourn/product/liste.php');
-
print " > ".$ways[0]." \n";
}
print " ";
@@ -169,7 +178,8 @@ if ($result)
print " | ";
print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
- print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
+ print_liste_field_titre($langs->trans("Supplier"),"liste.php", "p.price","","","",$sortfield);
+ print_liste_field_titre($langs->trans("BuiingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
print " \n";
// Lignes des champs de filtre
@@ -184,31 +194,42 @@ if ($result)
print '';
print '';
print ' | ';
- print '';
+ print ' | ';
print '';
print ' ';
print ' | ';
print '';
print '';
-
+ $oldid = '';
$var=True;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object( $i);
$var=!$var;
- print "| ";
- print "rowid\">";
- if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
- else print img_object($langs->trans("ShowProduct"),"product");
- print " ";
- print "rowid\">$objp->ref | \n";
- print "$objp->label | \n";
+ print " ";
+
+ if ($oldid <> $objp->rowid)
+ {
+ $oldid = $objp->rowid;
+ print "| rowid\">";
+ if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
+ else print img_object($langs->trans("ShowProduct"),"product");
+ print " ";
+ print "rowid\">$objp->ref | \n";
+ print "$objp->label | \n";
+ }
+ else
+ {
+ print ' | ';
+ }
+
+ print ''.$objp->nom.' | ';
print ''.price($objp->price).' | ';
print " \n";
$i++;
}
- $db->free();
+ $db->free($resql);
print " ";
diff --git a/htdocs/fourn/product/pre.inc.php b/htdocs/fourn/product/pre.inc.php
index db5fa251bb3..c333550dcd3 100644
--- a/htdocs/fourn/product/pre.inc.php
+++ b/htdocs/fourn/product/pre.inc.php
@@ -59,7 +59,7 @@ function llxHeader($head = "", $title="", $help_url='',$addons='')
if ($user->societe_id == 0 && $user->rights->produit->creer)
{
- $menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&type=0", $langs->trans("NewProduct"));
+ $menu->add_submenu(DOL_URL_ROOT."/fourn/product/fiche.php?action=create&type=0&catid=".$_REQUEST['catid'], $langs->trans("NewProduct"));
}
}
|