20include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
21include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
72 $sql .=
" COUNT(t.rowid), t.priority";
73 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
74 if (!$user->hasRight(
'societe',
'client',
'voir')) {
75 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $user->id);
79 $sql .=
" GROUP BY t.priority";
83 dol_syslog(get_class($this).
'::'.__METHOD__, LOG_DEBUG);
84 $resql = $this->db->query($sql);
86 $num = $this->db->num_rows($resql);
90 $row = $this->db->fetch_row($resql);
91 if ($i < $limit || $num == $limit) {
103 $langs->transnoentitiesnoconv(
"Other"),
107 $this->db->free($resql);
109 $this->error =
"Error ".$this->db->lasterror();
110 dol_syslog(get_class($this).
'::'.__METHOD__.
' '.$this->error, LOG_ERR);
126 $sql =
"SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
127 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
128 if (!$user->hasRight(
'societe',
'client',
'voir')) {
129 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $user->id);
132 $sql .=
" GROUP BY year";
133 $sql .= $this->db->order(
'year',
'DESC');
149 $sqlwhere[] =
' t.entity IN ('.getEntity(
'project').
')';
151 if (!empty($this->userid)) {
152 $sqlwhere[] =
' t.fk_user_resp = '.((int) $this->userid);
155 if (!empty($this->socid)) {
156 $sqlwhere[] =
' p.fk_soc = '.((int) $this->socid);
158 if (!empty($this->year) && empty($this->month)) {
161 if (!empty($this->year) && !empty($this->month)) {
162 $sqlwhere[] =
" t.datec BETWEEN '".$this->db->idate(
dol_get_first_day($this->year, $this->month)).
"' AND '".$this->db->idate(
dol_get_last_day($this->year, $this->month)).
"'";
164 if (!empty($this->priority)) {
165 $sqlwhere[] =
" t.priority IN (".$this->db->sanitize($this->priority, 1).
")";
168 if (count($sqlwhere) > 0) {
169 $sqlwhere_str =
' WHERE '.implode(
' AND ', $sqlwhere);
172 return $sqlwhere_str;
188 $sql =
"SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
189 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
190 if (!$user->hasRight(
'societe',
'client',
'voir')) {
191 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
194 $sql .=
" GROUP BY dm";
195 $sql .= $this->db->order(
'dm',
'DESC');
223 $sql =
"SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.
")";
224 $sql .=
" FROM ".$this->from;
226 $sql .=
" AND ".$this->where;
227 $sql .=
" GROUP BY dm";
228 $sql .= $this->db->order(
'dm',
'DESC');
Parent class of statistics class.
_getAverageByMonth($year, $sql, $format=0)
Return the amount average par month for a given year.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
Class to manage statistics on project tasks.
getAllTaskByStatus($limit=5)
Return all tasks grouped by status.
getAverageByMonth($year)
Return average of entity by month.
getAmountByMonth($year, $format=0)
Return the Task amount by month for a year.
buildWhere()
Build the where part.
getAllByYear()
Return count, and sum of products.
getNbByMonth($year, $format=0)
Return Task number by month for a year.
__construct($db)
Constructor of the class.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.