dolibarr 21.0.0-alpha
ProjectStats Class Reference

Class to manage statistics on projects. More...

Inheritance diagram for ProjectStats:
Collaboration diagram for ProjectStats:

Public Member Functions

 __construct ($db)
 Constructor.
 
 getAllProjectByStatus ($limit=5)
 Return all leads grouped by opportunity status.
 
 getAllByYear ()
 Return count, and sum of products.
 
 buildWhere ()
 Build the where part.
 
 getNbByMonth ($year, $format=0)
 Return Project number by month for a year.
 
 getAmountByMonth ($year, $format=0)
 Return the Project amount by month for a year.
 
 getWeightedAmountByMonthWithPrevYear ($endyear, $startyear, $cachedelay=0, $wonlostfilter=1)
 Return amount of elements by month for several years.
 
 getWeightedAmountByMonth ($year, $wonlostfilter=1)
 Return the Project weighted opp amount by month for a year.
 
 getTransformRateByMonthWithPrevYear ($endyear, $startyear, $cachedelay=0)
 Return amount of elements by month for several years.
 
 getTransformRateByMonth ($year, $format=0)
 Return the Project transformation rate by month for a year.
 
- Public Member Functions inherited from Stats
 getNbByMonthWithPrevYear ($endyear, $startyear, $cachedelay=0, $format=0, $startmonth=1)
 Return nb of elements by month for several years.
 
 getAmountByMonthWithPrevYear ($endyear, $startyear, $cachedelay=0, $format=0, $startmonth=1)
 Return amount of elements by month for several years.
 
 getAverageByMonthWithPrevYear ($endyear, $startyear)
 Return average of entity by month for several years.
 
 getAllByProductEntry ($year, $cachedelay=0, $limit=10)
 Return count, and sum of products.
 
 getAllByProduct ($year, $limit=0)
 Return nb, amount of predefined product for year.
 

Protected Member Functions

 getAverageByMonth ($year)
 Return average of entity by month.
 
- Protected Member Functions inherited from Stats
 _getNbByYear ($sql)
 Return nb of elements by 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 for a given year.
 
 _getAmountByMonth ($year, $sql, $format=0)
 Return the amount per month for a given year.
 
 _getAverageByMonth ($year, $sql, $format=0)
 Return the amount average par month for a given year.
 
 _getAllByProduct ($sql, $limit=10)
 Return number or total of product refs.
 
 _getAmountByYear ($sql)
 Returns the summed amounts per year for a given number of past years ending now.
 

Detailed Description

Class to manage statistics on projects.

Definition at line 26 of file projectstats.class.php.

Constructor & Destructor Documentation

◆ __construct()

ProjectStats::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 45 of file projectstats.class.php.

Member Function Documentation

◆ buildWhere()

ProjectStats::buildWhere ( )

◆ getAllByYear()

ProjectStats::getAllByYear ( )

Return count, and sum of products.

Returns
array<array{year:string,nb:string,nb_diff:float,total?:float,avg?:float,weighted?:float,total_diff?:float,avg_diff?:float,avg_weighted?:float}> Array of values

Definition at line 140 of file projectstats.class.php.

References Stats\_getAllByYear(), and buildWhere().

◆ getAllProjectByStatus()

ProjectStats::getAllProjectByStatus ( $limit = 5)

Return all leads grouped by opportunity status.

Warning: There is no filter on WON/LOST because we want this for statistics.

Parameters
int$limitLimit results
Returns
array|int Array with value or -1 if error
Exceptions
Exception

Definition at line 76 of file projectstats.class.php.

References buildWhere(), dol_syslog(), price(), and price2num().

◆ getAmountByMonth()

ProjectStats::getAmountByMonth ( $year,
$format = 0 )

Return the Project amount by month for a year.

Parameters
int$yearYear to scan
int$format0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
Returns
array<int<0,11>,array{0:int<1,12>,1:int|float}> Array with amount by month

Reimplemented from Stats.

Definition at line 267 of file projectstats.class.php.

References Stats\_getAmountByMonth(), and buildWhere().

◆ getAverageByMonth()

ProjectStats::getAverageByMonth ( $year)
protected

Return average of entity by month.

Parameters
int$yearyear number
Returns
array<int<0,11>,array{0:int<1,12>,1:int|float}> Array with number by month

Reimplemented from Stats.

Definition at line 536 of file projectstats.class.php.

References Stats\_getAverageByMonth(), dol_get_first_day(), and dol_get_last_day().

◆ getNbByMonth()

ProjectStats::getNbByMonth ( $year,
$format = 0 )

Return Project number by month for a year.

Parameters
int$yearYear to scan
int$format0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
Returns
array<int<0,11>,array{0:int<1,12>,1:int}> Array with number by month

Reimplemented from Stats.

Definition at line 242 of file projectstats.class.php.

References Stats\_getNbByMonth(), and buildWhere().

◆ getTransformRateByMonth()

ProjectStats::getTransformRateByMonth ( $year,
$format = 0 )

Return the Project transformation rate by month for a year.

Parameters
int$yearYear to scan
int$format0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
Returns
array<int<0,11>,array{0:int<1,12>,1:int|float}> Array with amount by month

Definition at line 487 of file projectstats.class.php.

References Stats\_getNbByMonth(), buildWhere(), and status.

Referenced by getTransformRateByMonthWithPrevYear().

◆ getTransformRateByMonthWithPrevYear()

ProjectStats::getTransformRateByMonthWithPrevYear ( $endyear,
$startyear,
$cachedelay = 0 )

Return amount of elements by month for several years.

Parameters
int$endyearEnd year
int$startyearStart year
int$cachedelayaccept for cache file (0=No read, no save of cache, -1=No read but save)
Returns
array|int Array of values or <0 if error

Definition at line 405 of file projectstats.class.php.

References dol_filemtime(), dol_is_dir(), dol_mkdir(), dol_now(), dol_syslog(), dolChmod(), and getTransformRateByMonth().

◆ getWeightedAmountByMonth()

ProjectStats::getWeightedAmountByMonth ( $year,
$wonlostfilter = 1 )

Return the Project weighted opp amount by month for a year.

Parameters
int$yearYear to scan
int$wonlostfilterAdd a filter on status won/lost
Returns
array<int<0,11>,array{0:int<1,12>,1:int|float}> Array with amount by month

Definition at line 379 of file projectstats.class.php.

References Stats\_getAmountByMonth(), and buildWhere().

Referenced by getWeightedAmountByMonthWithPrevYear().

◆ getWeightedAmountByMonthWithPrevYear()

ProjectStats::getWeightedAmountByMonthWithPrevYear ( $endyear,
$startyear,
$cachedelay = 0,
$wonlostfilter = 1 )

Return amount of elements by month for several years.

Parameters
int$endyearStart year
int$startyearEnd year
int$cachedelayDelay we accept for cache file (0=No read, no save of cache, -1=No read but save)
int$wonlostfilterAdd a filter on status won/lost
Returns
array|int<-1,-1> Array of values or <0 if error

Definition at line 295 of file projectstats.class.php.

References dol_filemtime(), dol_is_dir(), dol_mkdir(), dol_now(), dol_syslog(), dolChmod(), and getWeightedAmountByMonth().


The documentation for this class was generated from the following file: