dolibarr  16.0.5
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 
41  public function __construct($db)
42  {
43  global $conf, $user;
44 
45  $this->db = $db;
46 
47  require_once 'project.class.php';
48  $this->project = new Project($this->db);
49  }
50 
51 
60  public function getAllProjectByStatus($limit = 5)
61  {
62  global $conf, $user, $langs;
63 
64  $datay = array();
65 
66  $sql = "SELECT";
67  $sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label";
68  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
69  // No check is done on company permission because readability is managed by public status of project and assignement.
70  //if (! $user->rights->societe->client->voir && ! $user->socid)
71  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
72  $sql .= ", ".MAIN_DB_PREFIX."c_lead_status as cls";
73  $sql .= $this->buildWhere();
74  // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
75  //if ($socid > 0) $sql.= " AND t.fk_soc = ".((int) $socid);
76  // No check is done on company permission because readability is managed by public status of project and assignement.
77  //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))";
78  $sql .= " AND t.fk_opp_status = cls.rowid";
79  $sql .= " AND t.fk_statut <> 0"; // We want historic also, so all projects not draft
80  $sql .= " GROUP BY t.fk_opp_status, cls.code, cls.label";
81 
82  $result = array();
83 
84  dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG);
85  $resql = $this->db->query($sql);
86  if ($resql) {
87  $num = $this->db->num_rows($resql);
88  $i = 0;
89  $other = 0;
90  while ($i < $num) {
91  $row = $this->db->fetch_row($resql);
92  if ($i < $limit || $num == $limit) {
93  $label = (($langs->trans("OppStatus".$row[2]) != "OppStatus".$row[2]) ? $langs->trans("OppStatus".$row[2]) : $row[2]);
94  $result[$i] = array(
95  $label.' ('.price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency).')',
96  $row[0]
97  );
98  } else {
99  $other += $row[1];
100  }
101  $i++;
102  }
103  if ($num > $limit) {
104  $result[$i] = array(
105  $langs->transnoentitiesnoconv("Other"),
106  $other
107  );
108  }
109  $this->db->free($resql);
110  } else {
111  $this->error = "Error ".$this->db->lasterror();
112  dol_syslog(get_class($this).'::'.__METHOD__.' '.$this->error, LOG_ERR);
113  return -1;
114  }
115 
116  return $result;
117  }
118 
124  public function getAllByYear()
125  {
126  global $conf, $user, $langs;
127 
128  $datay = array();
129 
130  $wonlostfilter = 0; // No filter on status WON/LOST
131 
132  $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,";
133  $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";
134  $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";
135  // No check is done on company permission because readability is managed by public status of project and assignement.
136  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
137  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
138  $sql .= $this->buildWhere();
139  // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
140  //if ($socid > 0) $sql.= " AND t.fk_soc = ".((int) $socid);
141  // No check is done on company permission because readability is managed by public status of project and assignement.
142  //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))";
143  $sql .= " GROUP BY year";
144  $sql .= $this->db->order('year', 'DESC');
145 
146  return $this->_getAllByYear($sql);
147  }
148 
149 
155  public function buildWhere()
156  {
157  global $user;
158 
159  $sqlwhere_str = '';
160  $sqlwhere = array();
161 
162  // Get list of project id allowed to user (in a string list separated by coma)
163  $object = new Project($this->db);
164  $projectsListId = '';
165  if (empty($user->rights->projet->all->lire)) {
166  $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid);
167  }
168 
169  $sqlwhere[] = ' t.entity IN ('.getEntity('project').')';
170 
171  if (!empty($this->userid)) {
172  $sqlwhere[] = ' t.fk_user_resp = '.((int) $this->userid);
173  }
174 
175  // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project
176  if (!empty($this->socid)) {
177  $sqlwhere[] = ' t.fk_soc = '.((int) $this->socid);
178  }
179  if (!empty($this->year) && empty($this->yearmonth)) {
180  $sqlwhere[] = " date_format(t.datec,'%Y') = '".$this->db->escape($this->year)."'";
181  }
182  if (!empty($this->yearmonth)) {
183  $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'";
184  }
185 
186  if (!empty($this->status)) {
187  $sqlwhere[] = " t.fk_statut IN (".$this->db->sanitize($this->status).")";
188  }
189 
190  if (!empty($this->opp_status)) {
191  if (is_numeric($this->opp_status) && $this->opp_status > 0) {
192  $sqlwhere[] = " t.fk_opp_status = ".((int) $this->opp_status);
193  }
194  if ($this->opp_status == 'all') {
195  $sqlwhere[] = " (t.fk_opp_status IS NOT NULL AND t.fk_opp_status <> -1)";
196  }
197  if ($this->opp_status == 'openedopp') {
198  $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')))";
199  }
200  if ($this->opp_status == 'notopenedopp') {
201  $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'))";
202  }
203  if ($this->opp_status == 'none') {
204  $sqlwhere[] = " (t.fk_opp_status IS NULL OR t.fk_opp_status = -1)";
205  }
206  }
207 
208  if (empty($user->rights->projet->all->lire)) {
209  $sqlwhere[] = " t.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
210  }
211 
212  if (count($sqlwhere) > 0) {
213  $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere);
214  }
215 
216  return $sqlwhere_str;
217  }
218 
226  public function getNbByMonth($year, $format = 0)
227  {
228  global $user;
229 
230  $this->yearmonth = $year;
231 
232  $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb";
233  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
234  // No check is done on company permission because readability is managed by public status of project and assignement.
235  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
236  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
237  $sql .= $this->buildWhere();
238  $sql .= " GROUP BY dm";
239  $sql .= $this->db->order('dm', 'DESC');
240 
241  $this->yearmonth = 0;
242 
243  $res = $this->_getNbByMonth($year, $sql, $format);
244  // var_dump($res);print '<br>';
245  return $res;
246  }
247 
255  public function getAmountByMonth($year, $format = 0)
256  {
257  global $user;
258 
259  $this->yearmonth = $year;
260 
261  $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)";
262  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
263  // No check is done on company permission because readability is managed by public status of project and assignement.
264  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
265  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
266  $sql .= $this->buildWhere();
267  $sql .= " GROUP BY dm";
268  $sql .= $this->db->order('dm', 'DESC');
269  $this->yearmonth = 0;
270 
271  $res = $this->_getAmountByMonth($year, $sql, $format);
272  // var_dump($res);print '<br>';
273  return $res;
274  }
275 
276 
286  public function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1)
287  {
288  global $conf, $user, $langs;
289 
290  if ($startyear > $endyear) {
291  return -1;
292  }
293 
294  $datay = array();
295 
296  // Search into cache
297  if (!empty($cachedelay)) {
298  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
299  include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
300  }
301 
302  $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
303  $newmask = '0644';
304 
305  $nowgmt = dol_now();
306 
307  $foundintocache = 0;
308  if ($cachedelay > 0) {
309  $filedate = dol_filemtime($newpathofdestfile);
310  if ($filedate >= ($nowgmt - $cachedelay)) {
311  $foundintocache = 1;
312 
313  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
314  } else {
315  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.");
316  }
317  }
318 
319  // Load file into $data
320  if ($foundintocache) { // Cache file found and is not too old
321  dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
322  $data = json_decode(file_get_contents($newpathofdestfile), true);
323  } else {
324  $year = $startyear;
325  while ($year <= $endyear) {
326  $datay[$year] = $this->getWeightedAmountByMonth($year, $wonlostfilter);
327  $year++;
328  }
329 
330  $data = array();
331  // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
332  for ($i = 0; $i < 12; $i++) {
333  $data[$i][] = $datay[$endyear][$i][0]; // set label
334  $year = $startyear;
335  while ($year <= $endyear) {
336  $data[$i][] = $datay[$year][$i][1]; // set yval for x=i
337  $year++;
338  }
339  }
340  }
341 
342  // Save cache file
343  if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) {
344  dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
345  if (!dol_is_dir($conf->user->dir_temp)) {
346  dol_mkdir($conf->user->dir_temp);
347  }
348  $fp = fopen($newpathofdestfile, 'w');
349  if ($fp) {
350  fwrite($fp, json_encode($data));
351  fclose($fp);
352  if (!empty($conf->global->MAIN_UMASK)) {
353  $newmask = $conf->global->MAIN_UMASK;
354  }
355  @chmod($newpathofdestfile, octdec($newmask));
356  } else {
357  dol_syslog("Failed to write cache file", LOG_ERR);
358  }
359  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
360  }
361 
362  return $data;
363  }
364 
365 
373  public function getWeightedAmountByMonth($year, $wonlostfilter = 1)
374  {
375  global $user;
376 
377  $this->yearmonth = $year;
378 
379  $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)";
380  $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';
381  // No check is done on company permission because readability is managed by public status of project and assignement.
382  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
383  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
384  $sql .= $this->buildWhere();
385  $sql .= " GROUP BY dm";
386  $sql .= $this->db->order('dm', 'DESC');
387  $this->yearmonth = 0;
388 
389  $res = $this->_getAmountByMonth($year, $sql);
390  // var_dump($res);print '<br>';
391  return $res;
392  }
393 
402  public function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0)
403  {
404  global $conf, $user, $langs;
405 
406  if ($startyear > $endyear) {
407  return -1;
408  }
409 
410  $datay = array();
411 
412  // Search into cache
413  if (!empty($cachedelay)) {
414  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
415  include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
416  }
417 
418  $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_user'.$user->id.'.cache';
419  $newmask = '0644';
420 
421  $nowgmt = dol_now();
422 
423  $foundintocache = 0;
424  if ($cachedelay > 0) {
425  $filedate = dol_filemtime($newpathofdestfile);
426  if ($filedate >= ($nowgmt - $cachedelay)) {
427  $foundintocache = 1;
428 
429  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate;
430  } else {
431  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.");
432  }
433  }
434 
435  // Load file into $data
436  if ($foundintocache) { // Cache file found and is not too old
437  dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
438  $data = json_decode(file_get_contents($newpathofdestfile), true);
439  } else {
440  $year = $startyear;
441  while ($year <= $endyear) {
442  $datay[$year] = $this->getTransformRateByMonth($year);
443  $year++;
444  }
445 
446  $data = array();
447  // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
448  for ($i = 0; $i < 12; $i++) {
449  $data[$i][] = $datay[$endyear][$i][0]; // set label
450  $year = $startyear;
451  while ($year <= $endyear) {
452  $data[$i][] = $datay[$year][$i][1]; // set yval for x=i
453  $year++;
454  }
455  }
456  }
457 
458  // Save cache file
459  if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) {
460  dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
461  if (!dol_is_dir($conf->user->dir_temp)) {
462  dol_mkdir($conf->user->dir_temp);
463  }
464  $fp = fopen($newpathofdestfile, 'w');
465  fwrite($fp, json_encode($data));
466  fclose($fp);
467  if (!empty($conf->global->MAIN_UMASK)) {
468  $newmask = $conf->global->MAIN_UMASK;
469  }
470  @chmod($newpathofdestfile, octdec($newmask));
471 
472  $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
473  }
474 
475  return $data;
476  }
477 
485  public function getTransformRateByMonth($year, $format = 0)
486  {
487  global $user;
488 
489  $this->yearmonth = $year;
490 
491  $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
492  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
493  // No check is done on company permission because readability is managed by public status of project and assignement.
494  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
495  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
496  $sql .= $this->buildWhere();
497  $sql .= " GROUP BY dm";
498  $sql .= $this->db->order('dm', 'DESC');
499 
500  $res_total = $this->_getNbByMonth($year, $sql, $format);
501 
502  $this->status = 6;
503 
504  $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
505  $sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
506  // No check is done on company permission because readability is managed by public status of project and assignement.
507  //if (! $user->rights->societe->client->voir && ! $user->soc_id)
508  // $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user = ".((int) $user->id);
509  $sql .= $this->buildWhere();
510  $sql .= " GROUP BY dm";
511  $sql .= $this->db->order('dm', 'DESC');
512 
513  $this->status = 0;
514  $this->yearmonth = 0;
515 
516  $res_only_wined = $this->_getNbByMonth($year, $sql, $format);
517 
518  $res = array();
519 
520  foreach ($res_total as $key => $total_row) {
521  //var_dump($total_row);
522  if (!empty($total_row[1])) {
523  $res[$key] = array($total_row[0], (100 * $res_only_wined[$key][1]) / $total_row[1]);
524  } else {
525  $res[$key] = array($total_row[0], 0);
526  }
527  }
528  // var_dump($res);print '<br>';
529  return $res;
530  }
531 
537  protected function getAverageByMonth($year)
538  {
539  $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
540  $sql .= " FROM ".$this->from;
541  $sql .= $this->join;
542  $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
543  $sql .= " AND ".$this->where;
544  $sql .= " GROUP BY dm";
545  $sql .= $this->db->order('dm', 'DESC');
546 
547  return $this->_getAverageByMonth($year, $sql);
548  }
549 }
db
$conf db
API class for accounts.
Definition: inc.php:41
ProjectStats\__construct
__construct($db)
Constructor.
Definition: projectstats.class.php:41
Project
Class to manage projects.
Definition: project.class.php:35
dol_filemtime
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:593
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:60
Stats\_getAmountByMonth
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
Definition: stats.class.php:492
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
ProjectStats\buildWhere
buildWhere()
Build the where part.
Definition: projectstats.class.php:155
ProjectStats\getWeightedAmountByMonthWithPrevYear
getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $wonlostfilter=1)
Return amount of elements by month for several years.
Definition: projectstats.class.php:286
ProjectStats\getNbByMonth
getNbByMonth($year, $format=0)
Return Project number by month for a year.
Definition: projectstats.class.php:226
ProjectStats\getTransformRateByMonthWithPrevYear
getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay=0)
Return amount of elements by month for several years.
Definition: projectstats.class.php:402
Stats\_getAllByYear
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
Definition: stats.class.php:384
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
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:551
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:570
ProjectStats\getTransformRateByMonth
getTransformRateByMonth($year, $format=0)
Return the Project transformation rate by month for a year.
Definition: projectstats.class.php:485
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:435
ProjectStats\getAverageByMonth
getAverageByMonth($year)
Return average of entity by month.
Definition: projectstats.class.php:537
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
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.
Definition: index.php:742
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:5541
dol_is_dir
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:447
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
ProjectStats\getWeightedAmountByMonth
getWeightedAmountByMonth($year, $wonlostfilter=1)
Return the Project weighted opp amount by month for a year.
Definition: projectstats.class.php:373
ProjectStats\getAmountByMonth
getAmountByMonth($year, $format=0)
Return the Project amount by month for a year.
Definition: projectstats.class.php:255
ProjectStats\getAllByYear
getAllByYear()
Return count, and sum of products.
Definition: projectstats.class.php:124
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:550