Add : statistics on supplier orders and invoices on home page

This commit is contained in:
MAxime Kohlhaas 2014-10-25 17:22:03 +02:00
parent c8378b6b84
commit 3a626d8503
3 changed files with 113 additions and 16 deletions

View File

@ -1923,6 +1923,47 @@ class CommandeFournisseur extends CommonOrder
} }
} }
/**
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 si ko, >0 si ok
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$clause = "WHERE";
$sql = "SELECT count(co.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." co.entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["supplier_orders"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *

View File

@ -1606,6 +1606,48 @@ class FactureFournisseur extends CommonInvoice
$this->total_ttc = $xnbp*119.6; $this->total_ttc = $xnbp*119.6;
} }
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$clause = "WHERE";
$sql = "SELECT count(f.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." f.entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["supplier_invoices"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *

View File

@ -154,7 +154,9 @@ if (empty($user->societe_id))
! empty($conf->propal->enabled) && $user->rights->propale->lire, ! empty($conf->propal->enabled) && $user->rights->propale->lire,
! empty($conf->commande->enabled) && $user->rights->commande->lire, ! empty($conf->commande->enabled) && $user->rights->commande->lire,
! empty($conf->facture->enabled) && $user->rights->facture->lire, ! empty($conf->facture->enabled) && $user->rights->facture->lire,
! empty($conf->contrat->enabled) && $user->rights->contrat->activer); ! empty($conf->contrat->enabled) && $user->rights->contrat->activer,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire);
// Class file containing the method load_state_board for each line // Class file containing the method load_state_board for each line
$includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php", $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php", DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php",
@ -165,7 +167,9 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
// Name class containing the method load_state_board for each line // Name class containing the method load_state_board for each line
$classes=array('Client', $classes=array('Client',
'Prospect', 'Prospect',
@ -176,7 +180,9 @@ if (empty($user->societe_id))
'Propal', 'Propal',
'Commande', 'Commande',
'Facture', 'Facture',
'Contrat'); 'Contrat',
'CommandeFournisseur',
'FactureFournisseur');
// Cle array returned by the method load_state_board for each line // Cle array returned by the method load_state_board for each line
$keys=array('customers', $keys=array('customers',
'prospects', 'prospects',
@ -187,7 +193,9 @@ if (empty($user->societe_id))
'proposals', 'proposals',
'orders', 'orders',
'invoices', 'invoices',
'Contracts'); 'Contracts',
'supplier_orders',
'supplier_invoices');
// Dashboard Icon lines // Dashboard Icon lines
$icons=array('company', $icons=array('company',
'company', 'company',
@ -198,7 +206,9 @@ if (empty($user->societe_id))
'propal', 'propal',
'order', 'order',
'bill', 'bill',
'order'); 'order',
'order',
'bill');
// Translation keyword // Translation keyword
$titres=array("ThirdPartyCustomersStats", $titres=array("ThirdPartyCustomersStats",
"ThirdPartyProspectsStats", "ThirdPartyProspectsStats",
@ -209,7 +219,9 @@ if (empty($user->societe_id))
"CommercialProposalsShort", "CommercialProposalsShort",
"CustomersOrders", "CustomersOrders",
"BillsCustomers", "BillsCustomers",
"Contracts"); "Contracts",
"SuppliersOrders",
"SuppliersInvoices");
// Dashboard Link lines // Dashboard Link lines
$links=array(DOL_URL_ROOT.'/comm/list.php', $links=array(DOL_URL_ROOT.'/comm/list.php',
DOL_URL_ROOT.'/comm/prospect/list.php', DOL_URL_ROOT.'/comm/prospect/list.php',
@ -220,7 +232,9 @@ if (empty($user->societe_id))
DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial', DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial',
DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial', DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial',
DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy', DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
DOL_URL_ROOT.'/contrat/list.php'); DOL_URL_ROOT.'/contrat/list.php',
DOL_URL_ROOT.'/fourn/commande/list.php',
DOL_URL_ROOT.'/fourn/facture/list.php');
// Translation lang files // Translation lang files
$langfile=array("companies", $langfile=array("companies",
"prospects", "prospects",