diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index b01637d7b08..36372254b61 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -309,7 +309,7 @@ function show_stats_for_company($product,$socid)
print '
'.$langs->trans("TotalQuantity").' | ';
print '';
- // Propals
+ // Customer proposals
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
{
$nblines++;
@@ -327,7 +327,25 @@ function show_stats_for_company($product,$socid)
print '';
print '';
}
- // Commandes clients
+ // Supplier proposals
+ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
+ {
+ $nblines++;
+ $ret=$product->load_stats_proposal_supplier($socid);
+ if ($ret < 0) dol_print_error($db);
+ $langs->load("propal");
+ print '| ';
+ print ''.img_object('','propal').' '.$langs->trans("SupplierProposals").'';
+ print ' | ';
+ print $product->stats_proposal_supplier['suppliers'];
+ print ' | ';
+ print $product->stats_proposal_supplier['nb'];
+ print ' | ';
+ print $product->stats_proposal_supplier['qty'];
+ print ' | ';
+ print '
';
+ }
+ // Customer orders
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
$nblines++;
@@ -345,7 +363,7 @@ function show_stats_for_company($product,$socid)
print '';
print '';
}
- // Commandes fournisseurs
+ // Supplier orders
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
{
$nblines++;
@@ -363,25 +381,7 @@ function show_stats_for_company($product,$socid)
print '';
print '';
}
- // Contrats
- if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
- {
- $nblines++;
- $ret=$product->load_stats_contrat($socid);
- if ($ret < 0) dol_print_error($db);
- $langs->load("contracts");
- print '| ';
- print ''.img_object('','contract').' '.$langs->trans("Contracts").'';
- print ' | ';
- print $product->stats_contrat['customers'];
- print ' | ';
- print $product->stats_contrat['nb'];
- print ' | ';
- print $product->stats_contrat['qty'];
- print ' | ';
- print '
';
- }
- // Factures clients
+ // Customer invoices
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
{
$nblines++;
@@ -399,7 +399,7 @@ function show_stats_for_company($product,$socid)
print '';
print '';
}
- // Factures fournisseurs
+ // Supplier invoices
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
{
$nblines++;
@@ -418,6 +418,25 @@ function show_stats_for_company($product,$socid)
print '';
}
+ // Contracts
+ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
+ {
+ $nblines++;
+ $ret=$product->load_stats_contrat($socid);
+ if ($ret < 0) dol_print_error($db);
+ $langs->load("contracts");
+ print '| ';
+ print ''.img_object('','contract').' '.$langs->trans("Contracts").'';
+ print ' | ';
+ print $product->stats_contrat['customers'];
+ print ' | ';
+ print $product->stats_contrat['nb'];
+ print ' | ';
+ print $product->stats_contrat['qty'];
+ print ' | ';
+ print '
';
+ }
+
return $nblines++;
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index d3347557332..bdb9f3349af 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2133,6 +2133,49 @@ class Product extends CommonObject
}
+ /**
+ * Charge tableau des stats propale pour le produit/service
+ *
+ * @param int $socid Id thirdparty
+ * @return array Tableau des stats
+ */
+ function load_stats_proposal_supplier($socid=0)
+ {
+ global $conf;
+ global $user;
+
+ $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,";
+ $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
+ $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd";
+ $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
+ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE p.rowid = pd.fk_supplier_proposal";
+ $sql.= " AND p.fk_soc = s.rowid";
+ $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")";
+ $sql.= " AND pd.fk_product = ".$this->id;
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+ //$sql.= " AND pr.fk_statut != 0";
+ if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid;
+
+ $result = $this->db->query($sql);
+ if ( $result )
+ {
+ $obj=$this->db->fetch_object($result);
+ $this->stats_proposal_supplier['suppliers']=$obj->nb_suppliers;
+ $this->stats_proposal_supplier['nb']=$obj->nb;
+ $this->stats_proposal_supplier['rows']=$obj->nb_rows;
+ $this->stats_proposal_supplier['qty']=$obj->qty?$obj->qty:0;
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+
+
/**
* Charge tableau des stats commande client pour le produit/service
*
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index 5a371554058..4eb8992d837 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -228,7 +228,7 @@ if ($id > 0 || ! empty($ref))
print ''.$societestatic->getNomUrl(1).' | ';
print "".$objp->code_client." | \n";
print '';
- print dol_print_date($db->jdate($objp->date_commande))." | ";
+ print dol_print_date($db->jdate($objp->date_commande), 'dayhour')."";
print ''.$objp->qty." | \n";
print ''.price($objp->total_ht)." | \n";
print ''.$orderstatic->LibStatut($objp->statut,$objp->facture,5).' | ';
diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
index daf2a9c3654..4b9aa67236e 100644
--- a/htdocs/product/stats/commande_fournisseur.php
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -236,7 +236,7 @@ if ($id > 0 || ! empty($ref)) {
print '' . $societestatic->getNomUrl(1) . ' | ';
print "" . $objp->code_client . " | \n";
print '';
- print dol_print_date($db->jdate($objp->date_commande)) . " | ";
+ print dol_print_date($db->jdate($objp->date_commande), 'dayhour') . "";
print '' . $objp->qty . " | \n";
print '' . price($objp->total_ht) . " | \n";
print '' . $supplierorderstatic->getLibStatut(4) . ' | ';
diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php
index f9eed565903..8780a8a6a3b 100644
--- a/htdocs/product/stats/contrat.php
+++ b/htdocs/product/stats/contrat.php
@@ -190,7 +190,7 @@ if ($id > 0 || ! empty($ref))
print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->name,44).' | ';
print "".$objp->code_client." | \n";
print "";
- print dol_print_date($db->jdate($objp->date_contrat))." | ";
+ print dol_print_date($db->jdate($objp->date_contrat), 'dayhour')."";
//print "".price($objp->total_ht)." | \n";
//print '';
print ' | '.($objp->nb_initial>0?$objp->nb_initial:'').' | ';
diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php
index 8cdc0efd5c0..36359d1bd35 100644
--- a/htdocs/product/stats/facture.php
+++ b/htdocs/product/stats/facture.php
@@ -251,7 +251,7 @@ if ($id > 0 || ! empty($ref))
print ''.$societestatic->getNomUrl(1).' | ';
print "".$objp->code_client." | \n";
print '';
- print dol_print_date($db->jdate($objp->datef),'day')." | ";
+ print dol_print_date($db->jdate($objp->datef),'dayhour')."";
print ''.$objp->qty." | \n";
print ''.price($objp->total_ht)." | \n";
print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).' | ';
diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php
index 586741496c2..6618d8deac8 100644
--- a/htdocs/product/stats/facture_fournisseur.php
+++ b/htdocs/product/stats/facture_fournisseur.php
@@ -229,7 +229,7 @@ if ($id > 0 || ! empty($ref))
print '' . $societestatic->getNomUrl(1) . ' | ';
print "" . $objp->code_client . " | \n";
print '';
- print dol_print_date($db->jdate($objp->datef)) . " | ";
+ print dol_print_date($db->jdate($objp->datef), 'dayhour') . "";
print '' . $objp->qty . " | \n";
print '' . price($objp->total_ht) . " | \n";
print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ' | ';
diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php
index a5801c422e0..3f6eae0bfce 100644
--- a/htdocs/product/stats/propal.php
+++ b/htdocs/product/stats/propal.php
@@ -230,7 +230,7 @@ if ($id > 0 || ! empty($ref))
$societestatic->fetch($objp->socid);
print ''.$societestatic->getNomUrl(1).' | ';
print '';
- print dol_print_date($db->jdate($objp->datep)) . " | ";
+ print dol_print_date($db->jdate($objp->datep), 'dayhour') . "";
print "" . $objp->qty . " | \n";
print '' . price($objp->amount) . ' | ' . "\n";
print '' . $propalstatic->LibStatut($objp->statut, 5) . ' | ';