Implemente les stats de comptage de facture, propal et commande sur la page accueil des rsum stats, ce qui permet de supprimer la page stats.php qui fait double emploi et qui n'ait pas au norme de dev ni scurise.

This commit is contained in:
Laurent Destailleur
2007-05-04 22:37:06 +00:00
parent 89c8519343
commit 950de6f884
8 changed files with 142 additions and 246 deletions

View File

@@ -2266,6 +2266,46 @@ class Commande extends CommonObject
$this->total_ttc = $xnbp*119.6;
}
/**
* \brief 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();
$sql = "SELECT count(co.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = co.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE 1 = 1";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND IFNULL(c.visible,1)=1";
}
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["orders"]=$obj->nb;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}