New add stats on interventions

This commit is contained in:
Maxime Kohlhaas
2016-04-23 13:16:19 +02:00
parent df4d016684
commit 4e42e73f60
2 changed files with 48 additions and 0 deletions

View File

@@ -89,6 +89,46 @@ class Fichinter extends CommonObject
$this->statuts_logo[3]='statut4';
}
/**
* Load indicators into this->nb for board
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $user;
$this->nb=array();
$clause = "WHERE";
$sql = "SELECT count(fi.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.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." fi.entity IN (".getEntity($this->element, 1).")";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["fichinters"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Create an intervention into data base