18 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
19 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41 require_once
'task.class.php';
42 $this->task =
new Task($this->
db);
55 global $conf, $user, $langs;
60 $sql .=
" COUNT(t.rowid), t.priority";
61 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
62 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
63 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
67 $sql .=
" GROUP BY t.priority";
72 dol_syslog(get_class($this).
'::'.__METHOD__.
"", LOG_DEBUG);
80 if ($i < $limit || $num == $limit) {
92 $langs->transnoentitiesnoconv(
"Other"),
98 $this->error =
"Error ".$this->db->lasterror();
99 dol_syslog(get_class($this).
'::'.__METHOD__.
' '.$this->error, LOG_ERR);
113 global $conf, $user, $langs;
119 $sql =
"SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
121 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
122 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
125 $sql .=
" GROUP BY year";
126 $sql .= $this->
db->order(
'year',
'DESC');
142 $sqlwhere[] =
' t.entity IN ('.getEntity(
'project').
')';
144 if (!empty($this->userid)) {
145 $sqlwhere[] =
' t.fk_user_resp = '.((int) $this->userid);
148 if (!empty($this->socid)) {
149 $sqlwhere[] =
' p.fk_soc = '.((int) $this->socid);
151 if (!empty($this->year) && empty($this->yearmonth)) {
152 $sqlwhere[] =
" date_format(t.datec,'%Y')='".$this->db->escape($this->year).
"'";
154 if (!empty($this->yearmonth)) {
157 if (!empty($this->priority)) {
158 $sqlwhere[] =
" t.priority IN (".$this->db->sanitize($this->priority, 1).
")";
161 if (count($sqlwhere) > 0) {
162 $sqlwhere_str =
' WHERE '.implode(
' AND ', $sqlwhere);
165 return $sqlwhere_str;
179 $this->yearmonth = $year;
181 $sql =
"SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t INNER JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = t.fk_projet";
183 if (empty($user->rights->societe->client->voir) && !$user->soc_id) {
184 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
187 $sql .=
" GROUP BY dm";
188 $sql .= $this->
db->order(
'dm',
'DESC');
190 $this->yearmonth = 0;
217 $sql =
"SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.
")";
218 $sql .=
" FROM ".$this->from;
220 $sql .=
" AND ".$this->where;
221 $sql .=
" GROUP BY dm";
222 $sql .= $this->
db->order(
'dm',
'DESC');
getAllByYear()
Return count, and sum of products.
$conf db
API class for accounts.
__construct($db)
Constructor of the class.
Parent class of statistics class.
Class to manage statistics on project tasks.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
getAverageByMonth($year)
Return average of entity by month.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
getAllTaskByStatus($limit=5)
Return all tasks grouped by status.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
getAmountByMonth($year, $format=0)
Return the Task amount by month for a year.
buildWhere()
Build the where part.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
getNbByMonth($year, $format=0)
Return Task number by month for a year.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...