';
-
-print getCustomerInvoicePieChart($socid);
+print getNumberInvoicesPieChart('customers');
+//print getCustomerInvoicePieChart($socid);
print '
';
print getCustomerInvoiceDraftTable($max, $socid);
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 0cbb89ae47b..43cff7d3c3e 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -458,8 +458,9 @@ function getPurchaseInvoicePieChart($socid = 0)
/**
* Return an HTML table that contains a pie chart of the number of customers or supplier invoices
- * @param string $mode Can be customer or fourn
- * @return string A HTML table that contains a pie chart of customers or supplier invoices
+ *
+ * @param string $mode Can be 'customers' or 'suppliers'
+ * @return string A HTML table that contains a pie chart of customers or supplier invoices
*/
function getNumberInvoicesPieChart($mode)
{
@@ -487,13 +488,17 @@ function getNumberInvoicesPieChart($mode)
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement > '".date_format($datenowadd30, 'Y-m-d')."'", 1, 0).") as nbnotlate30";
if ($mode == 'customers') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
- } elseif ($mode == 'fourn') {
+ } elseif ($mode == 'fourn' || $mode == 'suppliers') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
} else {
return '';
}
$sql .= " WHERE f.type <> 2";
$sql .= " AND f.fk_statut = 1";
+ if (isset($user->socid) && $user->socid > 0) {
+ $sql .= " AND f.fk_soc = ".((int) $user->socid);
+ }
+
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
@@ -519,14 +524,15 @@ function getNumberInvoicesPieChart($mode)
$result = '
';
$result .= '
';
$result .= '';
- $result .= '| '.$langs->trans("Statistics").' - ';
+ $result .= ' | '.$langs->trans("Statistics").' - ';
if ($mode == 'customers') {
- $result .= $langs->trans("CustomerInvoice").' | ';
- } elseif ($mode == 'fourn') {
- $result .= $langs->trans("SupplierInvoice").'';
+ $result .= $langs->trans("CustomerInvoice");
+ } elseif ($mode == 'fourn' || $mode == 'suppliers') {
+ $result .= $langs->trans("SupplierInvoice");
} else {
return '';
}
+ $result .= '';
$result .= '
';
$dolgraph = new DolGraph();
@@ -539,13 +545,13 @@ function getNumberInvoicesPieChart($mode)
$dolgraph->setWidth('300');
if ($mode == 'customers') {
$dolgraph->draw('idgraphcustomerinvoices');
- } elseif ($mode == 'fourn') {
+ } elseif ($mode == 'fourn' || $mode == 'suppliers') {
$dolgraph->draw('idgraphfourninvoices');
} else {
return '';
}
$result .= '';
- $result .= '| '.$dolgraph->show($total ? 0 : 1).' | ';
+ $result .= ''.$dolgraph->show($total ? 0 : 1).' | ';
$result .= '
';
$result .= '
';
$result .= '
';
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index e76426f54c2..c695eed9285 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -58,8 +58,8 @@ print load_fiche_titre($langs->trans("SupplierInvoicesArea"), '', 'supplier_invo
print '
';
print '
';
-
-print getPurchaseInvoicePieChart($socid);
+print getNumberInvoicesPieChart('suppliers');
+//print getPurchaseInvoicePieChart($socid);
print '
';
print getDraftSupplierTable($maxDraftCount, $socid);