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)
*

View File

@ -1606,6 +1606,48 @@ class FactureFournisseur extends CommonInvoice
$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
*

View File

@ -154,7 +154,9 @@ if (empty($user->societe_id))
! empty($conf->propal->enabled) && $user->rights->propale->lire,
! empty($conf->commande->enabled) && $user->rights->commande->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
$includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.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."/commande/class/commande.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
$classes=array('Client',
'Prospect',
@ -173,10 +177,12 @@ if (empty($user->societe_id))
'Adherent',
'Product',
'Service',
'Propal',
'Commande',
'Facture',
'Contrat');
'Propal',
'Commande',
'Facture',
'Contrat',
'CommandeFournisseur',
'FactureFournisseur');
// Cle array returned by the method load_state_board for each line
$keys=array('customers',
'prospects',
@ -184,10 +190,12 @@ if (empty($user->societe_id))
'members',
'products',
'services',
'proposals',
'orders',
'invoices',
'Contracts');
'proposals',
'orders',
'invoices',
'Contracts',
'supplier_orders',
'supplier_invoices');
// Dashboard Icon lines
$icons=array('company',
'company',
@ -195,10 +203,12 @@ if (empty($user->societe_id))
'user',
'product',
'service',
'propal',
'order',
'bill',
'order');
'propal',
'order',
'bill',
'order',
'order',
'bill');
// Translation keyword
$titres=array("ThirdPartyCustomersStats",
"ThirdPartyProspectsStats",
@ -209,7 +219,9 @@ if (empty($user->societe_id))
"CommercialProposalsShort",
"CustomersOrders",
"BillsCustomers",
"Contracts");
"Contracts",
"SuppliersOrders",
"SuppliersInvoices");
// Dashboard Link lines
$links=array(DOL_URL_ROOT.'/comm/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.'/commande/list.php?mainmenu=commercial',
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
$langfile=array("companies",
"prospects",