dolibarr  17.0.3
projectstats.class.php
1 <?php
2 /* Lead
3  * Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
19 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
20 
21 
25 class ProjectStats extends Stats
26 {
27  private $project;
28  public $userid;
29  public $socid;
30  public $year;
31  public $yearmonth;
32  public $status;
33  public $opp_status;
34 
35  //SQL stat
36  public $field;
37  public $from;
38  public $where;
39 
40 
46  public function __construct($db)
47  {
48  global $conf, $user;
49 
50  $this->db = $db;
51 
52  require_once 'project.class.php';
53  $this->project = new Project($this->db);
54 
55  $this->from = MAIN_DB_PREFIX.$this->project->table_element;
56  $this->field = 'opp_amount';
57  $this->where = " entity = ".$conf->entity;
58  if ($this->socid > 0) {
59  $this->where .= " AND fk_soc = ".((int) $this->socid);
60  }
61  if (is_array($this->userid) && count($this->userid) > 0) {
62  $this->where .= ' AND fk_user IN ('.$this->db->sanitize(join(',', $this->userid)).')';
63  } elseif ($this->userid > 0) {
64  $this->where .= " AND fk_user = ".((int) $this->userid);
65  }
66  }
67 
68 
77  public function getAllProjectByStatus($limit = 5)
78  {
79  global $conf, $user, $langs;
80 
81  $datay = array();
82 
83  $sql = "SELECT";
84  $sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label";
85  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
86  // No check is done on company permission because readability is managed by public status of project and assignement.
87  //if (! $user->rights->societe->client->voir && ! $user->socid)
88  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
89  $sql .= ", ".MAIN_DB_PREFIX."c_lead_status as cls";
90  $sql .= $this->buildWhere();
91  // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
92  //if ($socid > 0) $sql.= " AND t.fk_soc = ".((int) $socid);
93  // No check is done on company permission because readability is managed by public status of project and assignement.
94  //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
95  $sql .= " AND t.fk_opp_status = cls.rowid";
96  $sql .= " AND t.fk_statut <> 0"; // We want historic also, so all projects not draft
97  $sql .= " GROUP BY t.fk_opp_status, cls.code, cls.label";
98 
99  $result = array();
100 
101  dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG);
102  $resql = $this->db->query($sql);
103  if ($resql) {
104  $num = $this->db->num_rows($resql);
105  $i = 0;
106  $other = 0;
107  while ($i < $num) {
108  $row = $this->db->fetch_row($resql);
109  if ($i < $limit || $num == $limit) {
110  $label = (($langs->trans("OppStatus".$row[2]) != "OppStatus".$row[2]) ? $langs->trans("OppStatus".$row[2]) : $row[2]);
111  $result[$i] = array(
112  $label.' ('.price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency).')',
113  $row[0]
114  );
115  } else {
116  $other += $row[1];
117  }
118  $i++;
119  }
120  if ($num > $limit) {
121  $result[$i] = array(
122  $langs->transnoentitiesnoconv("Other"),
123  $other
124  );
125  }
126  $this->db->free($resql);
127  } else {
128  $this->error = "Error ".$this->db->lasterror();
129  dol_syslog(get_class($this).'::'.__METHOD__.' '.$this->error, LOG_ERR);
130  return -1;
131  }
132 
133  return $result;
134  }
135 
141  public function getAllByYear()
142  {
143  global $conf, $user, $langs;
144 
145  $datay = array();
146 
147  $wonlostfilter = 0; // No filter on status WON/LOST
148 
149  $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg,";
150  $sql .= " SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter ? " OR cls.code IN ('WON','LOST')" : ""), '0', 't.opp_percent')." / 100) as weighted";
151  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON cls.rowid = t.fk_opp_status";
152  // No check is done on company permission because readability is managed by public status of project and assignement.
153  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
154  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
155  $sql .= $this->buildWhere();
156  // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
157  //if ($socid > 0) $sql.= " AND t.fk_soc = ".((int) $socid);
158  // No check is done on company permission because readability is managed by public status of project and assignement.
159  //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
160  $sql .= " GROUP BY year";
161  $sql .= $this->db->order('year', 'DESC');
162 
163  return $this->_getAllByYear($sql);
164  }
165 
166 
172  public function buildWhere()
173  {
174  global $user;
175 
176  $sqlwhere_str = '';
177  $sqlwhere = array();
178 
179  // Get list of project id allowed to user (in a string list separated by coma)
180  $object = new Project($this->db);
181  $projectsListId = '';
182  if (empty($user->rights->projet->all->lire)) {
183  $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid);
184  }
185 
186  $sqlwhere[] = ' t.entity IN ('.getEntity('project').')';
187 
188  if (!empty($this->userid)) {
189  $sqlwhere[] = ' t.fk_user_resp = '.((int) $this->userid);
190  }
191 
192  // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project
193  if (!empty($this->socid)) {
194  $sqlwhere[] = ' t.fk_soc = '.((int) $this->socid);
195  }
196  if (!empty($this->year) && empty($this->yearmonth)) {
197  $sqlwhere[] = " date_format(t.datec,'%Y') = '".$this->db->escape($this->year)."'";
198  }
199  if (!empty($this->yearmonth)) {
200  $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'";
201  }
202 
203  if (!empty($this->status)) {
204  $sqlwhere[] = " t.fk_statut IN (".$this->db->sanitize($this->status).")";
205  }
206 
207  if (!empty($this->opp_status)) {
208  if (is_numeric($this->opp_status) && $this->opp_status > 0) {
209  $sqlwhere[] = " t.fk_opp_status = ".((int) $this->opp_status);
210  }
211  if ($this->opp_status == 'all') {
212  $sqlwhere[] = " (t.fk_opp_status IS NOT NULL AND t.fk_opp_status <> -1)";
213  }
214  if ($this->opp_status == 'openedopp') {
215  $sqlwhere[] = " (t.fk_opp_status IS NOT NULL AND t.fk_opp_status <> -1 AND t.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST')))";
216  }
217  if ($this->opp_status == 'notopenedopp') {
218  $sqlwhere[] = " (t.fk_opp_status IS NULL OR t.fk_opp_status = -1 OR t.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))";
219  }
220  if ($this->opp_status == 'none') {
221  $sqlwhere[] = " (t.fk_opp_status IS NULL OR t.fk_opp_status = -1)";
222  }
223  }
224 
225  if (empty($user->rights->projet->all->lire)) {
226  $sqlwhere[] = " t.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
227  }
228 
229  if (count($sqlwhere) > 0) {
230  $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere);
231  }
232 
233  return $sqlwhere_str;
234  }
235 
243  public function getNbByMonth($year, $format = 0)
244  {
245  global $user;
246 
247  $this->yearmonth = $year;
248 
249  $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb";
250  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
251  // No check is done on company permission because readability is managed by public status of project and assignement.
252  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
253  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
254  $sql .= $this->buildWhere();
255  $sql .= " GROUP BY dm";
256  $sql .= $this->db->order('dm', 'DESC');
257 
258  $this->yearmonth = 0;
259 
260  $res = $this->_getNbByMonth($year, $sql, $format);
261  // var_dump($res);print '<br>';
262  return $res;
263  }
264 
272  public function getAmountByMonth($year, $format = 0)
273  {
274  global $user;
275 
276  $this->yearmonth = $year;
277 
278  $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)";
279  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
280  // No check is done on company permission because readability is managed by public status of project and assignement.
281  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
282  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
283  $sql .= $this->buildWhere();
284  $sql .= " GROUP BY dm";
285  $sql .= $this->db->order('dm', 'DESC');
286  $this->yearmonth = 0;
287 
288  $res = $this->_getAmountByMonth($year, $sql, $format);
289  // var_dump($res);print '<br>';
290  return $res;
291  }
292 
293 
303  public function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1)
304  {
305  global $conf, $user, $langs;
306 
307  if ($startyear > $endyear) {
308  return -1;
309  }
310 
311  $datay = array();
312 
313  // Search into cache
314  if (!empty($cachedelay)) {
315  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
316  include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
317  }
318 
319  $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
320  $newmask = '0644';
321 
322  $nowgmt = dol_now();
323 
324  $foundintocache = 0;
325  if ($cachedelay > 0) {
326  $filedate = dol_filemtime($newpathofdestfile);
327  if ($filedate >= ($nowgmt - $cachedelay)) {
328  $foundintocache = 1;
329 
330  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
331  } else {
332  dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
333  }
334  }
335 
336  // Load file into $data
337  if ($foundintocache) { // Cache file found and is not too old
338  dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
339  $data = json_decode(file_get_contents($newpathofdestfile), true);
340  } else {
341  $year = $startyear;
342  while ($year <= $endyear) {
343  $datay[$year] = $this->getWeightedAmountByMonth($year, $wonlostfilter);
344  $year++;
345  }
346 
347  $data = array();
348  // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
349  for ($i = 0; $i < 12; $i++) {
350  $data[$i][] = $datay[$endyear][$i][0]; // set label
351  $year = $startyear;
352  while ($year <= $endyear) {
353  $data[$i][] = $datay[$year][$i][1]; // set yval for x=i
354  $year++;
355  }
356  }
357  }
358 
359  // Save cache file
360  if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) {
361  dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
362  if (!dol_is_dir($conf->user->dir_temp)) {
363  dol_mkdir($conf->user->dir_temp);
364  }
365  $fp = fopen($newpathofdestfile, 'w');
366  if ($fp) {
367  fwrite($fp, json_encode($data));
368  fclose($fp);
369  if (!empty($conf->global->MAIN_UMASK)) {
370  $newmask = $conf->global->MAIN_UMASK;
371  }
372  @chmod($newpathofdestfile, octdec($newmask));
373  } else {
374  dol_syslog("Failed to write cache file", LOG_ERR);
375  }
376  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
377  }
378 
379  return $data;
380  }
381 
382 
390  public function getWeightedAmountByMonth($year, $wonlostfilter = 1)
391  {
392  global $user;
393 
394  $this->yearmonth = $year;
395 
396  $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter ? " OR cls.code IN ('WON','LOST')" : ""), '0', 't.opp_percent')." / 100)";
397  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t LEFT JOIN ".MAIN_DB_PREFIX.'c_lead_status as cls ON t.fk_opp_status = cls.rowid';
398  // No check is done on company permission because readability is managed by public status of project and assignement.
399  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
400  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
401  $sql .= $this->buildWhere();
402  $sql .= " GROUP BY dm";
403  $sql .= $this->db->order('dm', 'DESC');
404  $this->yearmonth = 0;
405 
406  $res = $this->_getAmountByMonth($year, $sql);
407  // var_dump($res);print '<br>';
408  return $res;
409  }
410 
419  public function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0)
420  {
421  global $conf, $user, $langs;
422 
423  if ($startyear > $endyear) {
424  return -1;
425  }
426 
427  $datay = array();
428 
429  // Search into cache
430  if (!empty($cachedelay)) {
431  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
432  include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
433  }
434 
435  $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
436  $newmask = '0644';
437 
438  $nowgmt = dol_now();
439 
440  $foundintocache = 0;
441  if ($cachedelay > 0) {
442  $filedate = dol_filemtime($newpathofdestfile);
443  if ($filedate >= ($nowgmt - $cachedelay)) {
444  $foundintocache = 1;
445 
446  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
447  } else {
448  dol_syslog(get_class($this).'::'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
449  }
450  }
451 
452  // Load file into $data
453  if ($foundintocache) { // Cache file found and is not too old
454  dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
455  $data = json_decode(file_get_contents($newpathofdestfile), true);
456  } else {
457  $year = $startyear;
458  while ($year <= $endyear) {
459  $datay[$year] = $this->getTransformRateByMonth($year);
460  $year++;
461  }
462 
463  $data = array();
464  // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
465  for ($i = 0; $i < 12; $i++) {
466  $data[$i][] = $datay[$endyear][$i][0]; // set label
467  $year = $startyear;
468  while ($year <= $endyear) {
469  $data[$i][] = $datay[$year][$i][1]; // set yval for x=i
470  $year++;
471  }
472  }
473  }
474 
475  // Save cache file
476  if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) {
477  dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
478  if (!dol_is_dir($conf->user->dir_temp)) {
479  dol_mkdir($conf->user->dir_temp);
480  }
481  $fp = fopen($newpathofdestfile, 'w');
482  fwrite($fp, json_encode($data));
483  fclose($fp);
484  if (!empty($conf->global->MAIN_UMASK)) {
485  $newmask = $conf->global->MAIN_UMASK;
486  }
487  @chmod($newpathofdestfile, octdec($newmask));
488 
489  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
490  }
491 
492  return $data;
493  }
494 
502  public function getTransformRateByMonth($year, $format = 0)
503  {
504  global $user;
505 
506  $this->yearmonth = $year;
507 
508  $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
509  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
510  // No check is done on company permission because readability is managed by public status of project and assignement.
511  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
512  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
513  $sql .= $this->buildWhere();
514  $sql .= " GROUP BY dm";
515  $sql .= $this->db->order('dm', 'DESC');
516 
517  $res_total = $this->_getNbByMonth($year, $sql, $format);
518 
519  $this->status = 6;
520 
521  $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
522  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
523  // No check is done on company permission because readability is managed by public status of project and assignement.
524  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
525  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
526  $sql .= $this->buildWhere();
527  $sql .= " GROUP BY dm";
528  $sql .= $this->db->order('dm', 'DESC');
529 
530  $this->status = 0;
531  $this->yearmonth = 0;
532 
533  $res_only_wined = $this->_getNbByMonth($year, $sql, $format);
534 
535  $res = array();
536 
537  foreach ($res_total as $key => $total_row) {
538  //var_dump($total_row);
539  if (!empty($total_row[1])) {
540  $res[$key] = array($total_row[0], (100 * $res_only_wined[$key][1]) / $total_row[1]);
541  } else {
542  $res[$key] = array($total_row[0], 0);
543  }
544  }
545  // var_dump($res);print '<br>';
546  return $res;
547  }
548 
554  protected function getAverageByMonth($year)
555  {
556  $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
557  $sql .= " FROM ".$this->from;
558  $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
559  $sql .= " AND ".$this->where;
560  $sql .= " GROUP BY dm";
561  $sql .= $this->db->order('dm', 'DESC');
562 
563  return $this->_getAverageByMonth($year, $sql);
564  }
565 }
db
$conf db
API class for accounts.
Definition: inc.php:41
ProjectStats\__construct
__construct($db)
Constructor.
Definition: projectstats.class.php:46
Project
Class to manage projects.
Definition: project.class.php:35
dol_filemtime
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:597
ProjectStats
Class to manage statistics on projects.
Definition: projectstats.class.php:25
Stats
Parent class of statistics class.
Definition: stats.class.php:30
ProjectStats\getAllProjectByStatus
getAllProjectByStatus($limit=5)
Return all leads grouped by opportunity status.
Definition: projectstats.class.php:77
Stats\_getAmountByMonth
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
Definition: stats.class.php:494
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5823
ProjectStats\buildWhere
buildWhere()
Build the where part.
Definition: projectstats.class.php:172
$resql
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.
Definition: index.php:745
ProjectStats\getWeightedAmountByMonthWithPrevYear
getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $wonlostfilter=1)
Return amount of elements by month for several years.
Definition: projectstats.class.php:303
ProjectStats\getNbByMonth
getNbByMonth($year, $format=0)
Return Project number by month for a year.
Definition: projectstats.class.php:243
ProjectStats\getTransformRateByMonthWithPrevYear
getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay=0)
Return amount of elements by month for several years.
Definition: projectstats.class.php:419
Stats\_getAllByYear
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
Definition: stats.class.php:386
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
dol_get_first_day
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:575
dol_get_last_day
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:594
ProjectStats\getTransformRateByMonth
getTransformRateByMonth($year, $format=0)
Return the Project transformation rate by month for a year.
Definition: projectstats.class.php:502
Stats\_getNbByMonth
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
Definition: stats.class.php:437
ProjectStats\getAverageByMonth
getAverageByMonth($year)
Return average of entity by month.
Definition: projectstats.class.php:554
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2951
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5697
dol_is_dir
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:451
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6789
ProjectStats\getWeightedAmountByMonth
getWeightedAmountByMonth($year, $wonlostfilter=1)
Return the Project weighted opp amount by month for a year.
Definition: projectstats.class.php:390
ProjectStats\getAmountByMonth
getAmountByMonth($year, $format=0)
Return the Project amount by month for a year.
Definition: projectstats.class.php:272
ProjectStats\getAllByYear
getAllByYear()
Return count, and sum of products.
Definition: projectstats.class.php:141
Stats\_getAverageByMonth
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...
Definition: stats.class.php:552