19 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
20 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once
'task.class.php';
43 $this->task =
new Task($this->
db);
56 global $conf, $user, $langs;
61 $sql .=
" COUNT(t.rowid), t.priority";
62 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
63 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
64 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
68 $sql .=
" GROUP BY t.priority";
73 dol_syslog(get_class($this).
'::'.__METHOD__, LOG_DEBUG);
81 if ($i < $limit || $num == $limit) {
93 $langs->transnoentitiesnoconv(
"Other"),
99 $this->error =
"Error ".$this->db->lasterror();
100 dol_syslog(get_class($this).
'::'.__METHOD__.
' '.$this->error, LOG_ERR);
114 global $conf, $user, $langs;
120 $sql =
"SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
121 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
122 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
123 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
126 $sql .=
" GROUP BY year";
127 $sql .= $this->
db->order(
'year',
'DESC');
143 $sqlwhere[] =
' t.entity IN ('.getEntity(
'project').
')';
145 if (!empty($this->userid)) {
146 $sqlwhere[] =
' t.fk_user_resp = '.((int) $this->userid);
149 if (!empty($this->socid)) {
150 $sqlwhere[] =
' p.fk_soc = '.((int) $this->socid);
152 if (!empty($this->year) && empty($this->yearmonth)) {
153 $sqlwhere[] =
" date_format(t.datec,'%Y')='".$this->db->escape($this->year).
"'";
155 if (!empty($this->yearmonth)) {
158 if (!empty($this->priority)) {
159 $sqlwhere[] =
" t.priority IN (".$this->db->sanitize($this->priority, 1).
")";
162 if (count($sqlwhere) > 0) {
163 $sqlwhere_str =
' WHERE '.implode(
' AND ', $sqlwhere);
166 return $sqlwhere_str;
180 $this->yearmonth = $year;
182 $sql =
"SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
184 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
185 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
188 $sql .=
" GROUP BY dm";
189 $sql .= $this->
db->order(
'dm',
'DESC');
191 $this->yearmonth = 0;
219 $sql =
"SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.
")";
220 $sql .=
" FROM ".$this->from;
222 $sql .=
" AND ".$this->where;
223 $sql .=
" GROUP BY dm";
224 $sql .= $this->
db->order(
'dm',
'DESC');
Parent class of statistics class.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...
_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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.
$conf db
API class for accounts.