diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
index db21706bb2a..589f292014b 100644
--- a/htdocs/product/stats/commande_fournisseur.php
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -22,10 +22,10 @@
*/
/**
- \file htdocs/product/stats/commande_fournisseur.php
- \ingroup product, service, commande
- \brief Page des stats des commandes fournisseurs pour un produit
- \version $Revision$
+ \file htdocs/product/stats/commande_fournisseur.php
+ \ingroup product, service, commande
+ \brief Page des stats des commandes fournisseurs pour un produit
+ \version $Revision$
*/
@@ -55,21 +55,19 @@ if (! $sortfield) $sortfield="c.date_creation";
$socid = 0;
if ($user->societe_id > 0)
{
- $action = '';
- $socid = $user->societe_id;
+ $action = '';
+ $socid = $user->societe_id;
}
else
{
$socid = 0;
}
-
/*
* Affiche fiche
*
*/
-
if ($_GET["id"] || $_GET["ref"])
{
$product = new Product($db);
@@ -80,118 +78,113 @@ if ($_GET["id"] || $_GET["ref"])
if ($result > 0)
{
- /*
- * En mode visu
- */
- $head=product_prepare_head($product, $user);
- $titre=$langs->trans("CardProduct".$product->type);
- dolibarr_fiche_head($head, 'referers', $titre);
+ /*
+ * En mode visu
+ */
+ $head=product_prepare_head($product, $user);
+ $titre=$langs->trans("CardProduct".$product->type);
+ dolibarr_fiche_head($head, 'referers', $titre);
+
+ print '
';
+
+ // Reference
+ print '';
+ print '| '.$langs->trans("Ref").' | ';
+ $product->load_previous_next_ref();
+ $previous_ref = $product->ref_previous?'ref_previous.'">'.img_previous().'':'';
+ $next_ref = $product->ref_next?'ref_next.'">'.img_next().'':'';
+ if ($previous_ref || $next_ref) print '';
+ print ' |
';
+
+ // Libelle
+ print '| '.$langs->trans("Label").' | '.$product->libelle.' |
';
+
+ // Prix
+ print '| '.$langs->trans("SellingPrice").' | '.price($product->price).' |
';
+
+ // Statut
+ print '| '.$langs->trans("Status").' | ';
+ print $product->getLibStatut(2);
+ print ' |
';
-
- print '';
-
- // Reference
- print '';
- print '| '.$langs->trans("Ref").' | ';
- $product->load_previous_next_ref();
- $previous_ref = $product->ref_previous?'ref_previous.'">'.img_previous().'':'';
- $next_ref = $product->ref_next?'ref_next.'">'.img_next().'':'';
- if ($previous_ref || $next_ref) print '';
- print ' | ';
- print '
';
-
- // Libelle
- print '| '.$langs->trans("Label").' | '.$product->libelle.' | ';
- print '
';
+ show_stats_for_company($product,$socid);
- // Prix
- print '| '.$langs->trans("SellingPrice").' | '.price($product->price).' |
';
-
- // Statut
- print '| '.$langs->trans("Status").' | ';
- print $product->getLibStatut(2);
- print ' |
';
-
- show_stats_for_company($product,$socid);
-
- print "
";
-
- print '';
-
-
- $sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount, c.ref,";
- $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid";
- if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."commande_fournisseurdet as d";
- if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.fk_soc = s.idp";
- $sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id;
- if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
- if ($socid)
+ print "
";
+ print '';
+
+ $sql = "SELECT distinct(s.nom), s.idp, s.code_client, c.rowid, c.total_ht as amount, c.ref,";
+ $sql.= " ".$db->pdate("c.date_creation")." as date, c.fk_statut as statut, c.rowid as commandeid";
+ if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."commande_fournisseurdet as d";
+ if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.fk_soc = s.idp";
+ $sql.= " AND d.fk_commande = c.rowid AND d.fk_product =".$product->id;
+ if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socid)
{
- $sql .= " AND c.fk_soc = ".$socid;
+ $sql .= " AND c.fk_soc = ".$socid;
}
- $sql.= " ORDER BY $sortfield $sortorder ";
- $sql.= $db->plimit($conf->liste_limit +1, $offset);
-
- $result = $db->query($sql);
- if ($result)
+ $sql.= " ORDER BY $sortfield $sortorder ";
+ $sql.= $db->plimit($conf->liste_limit +1, $offset);
+
+ $result = $db->query($sql);
+ if ($result)
{
- $num = $db->num_rows($result);
-
- print_barre_liste($langs->trans("SuppliersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num);
-
- $i = 0;
- print "";
-
- print '';
- print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield);
- print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield);
- print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield);
- print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&id=".$_GET["id"],'align="center"',$sortfield);
- print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount_ht","","&id=".$_GET["id"],'align="right"',$sortfield);
- print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield);
- print "
\n";
-
- $commandestatic=new Commande($db);
-
- if ($num > 0)
+ $num = $db->num_rows($result);
+
+ print_barre_liste($langs->trans("SuppliersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num);
+
+ $i = 0;
+ print "";
+
+ print '';
+ print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield);
+ print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"c.date_creation","","&id=".$_GET["id"],'align="center"',$sortfield);
+ print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.amount_ht","","&id=".$_GET["id"],'align="right"',$sortfield);
+ print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield);
+ print "
\n";
+
+ $commandestatic=new Commande($db);
+
+ if ($num > 0)
{
- $var=True;
- while ($i < $num && $i < $conf->liste_limit)
+ $var=True;
+ while ($i < $num && $i < $conf->liste_limit)
{
- $objp = $db->fetch_object($result);
- $var=!$var;
-
- print "";
- print '| '.img_object($langs->trans("ShowOrder"),"order").' ';
- print $objp->ref;
- print " | \n";
- print ''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).' | ';
- print "".$objp->code_client." | \n";
- print "";
- print dolibarr_print_date($objp->date)." | ";
- print "".price($objp->amount)." | \n";
- print ''.$commandestatic->LibStatut($objp->statut,$objp->facture,5).' | ';
- print "
\n";
- $i++;
+ $objp = $db->fetch_object($result);
+ $var=!$var;
+
+ print "";
+ print '| '.img_object($langs->trans("ShowOrder"),"order").' ';
+ print $objp->ref;
+ print " | \n";
+ print ''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).' | ';
+ print "".$objp->code_client." | \n";
+ print "";
+ print dolibarr_print_date($objp->date)." | ";
+ print "".price($objp->amount)." | \n";
+ print ''.$commandestatic->LibStatut($objp->statut,$objp->facture,5).' | ';
+ print "
\n";
+ $i++;
}
}
}
- else
+ else
{
- dolibarr_print_error($db);
+ dolibarr_print_error($db);
}
- print "
";
- print '
';
- $db->free($result);
+ print "
";
+ print '
';
+ $db->free($result);
}
}
else
{
- dolibarr_print_error();
+ dolibarr_print_error();
}
$db->close();