class ExpenseReportStats extends Stats (View source)

Class to manage the statistics of the expensereports and expense notes

Properties

protected DoliDB $db from  Stats
protected array<string, int> $lastfetchdate from  Stats
string $cachefilesuffix from  Stats
string $from
string $where
string $from_line from  Stats
string $field_date from  Stats
string $field
string $field_line from  Stats
string $error from  Stats
int $year from  Stats
int $month from  Stats
string $table_element
int $socid
int $userid

Methods

array<int<0, 11>, array{0: int<1, 12>, 1: int}>
getNbByMonth(int $year, int $format = 0)

Return the quantity of invoices per month for a given year

array<int<0, 11>, array{0: int<1, 12>, 1: int}>
getNbByMonthWithPrevYear(int $endyear, int $startyear, int $cachedelay = 0, int $format = 0, int $startmonth = 1)

Return nb of elements by month for several years

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
getAmountByMonth(int $year, int $format = 0)

Renvoie le montant de facture par mois pour une annee donnee

array<int<0, 11>, array<string|int|float>>
getAmountByMonthWithPrevYear(int $endyear, int $startyear, int $cachedelay = 0, int $format = 0, int $startmonth = 1)

Return amount of elements by month for several years.

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
getAverageByMonth(int $year)

Return average amount

array<array<int|float>>
getAverageByMonthWithPrevYear(int $endyear, int $startyear)

Return average of entity by month for several years

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
getAllByProductEntry(int $year, int $cachedelay = 0, int $limit = 10)

Return count, and sum of products

from  Stats
array<array{0: int, 1: int}>
_getNbByYear(string $sql)

Return nb of elements by year

from  Stats
_getAllByYear(string $sql)

Return nb of elements, total amount and avg amount each year

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int}>
_getNbByMonth(int $year, string $sql, int<0, 2> $format = 0)

Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month for a given year

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
_getAmountByMonth(int $year, string $sql, int<0, 2> $format = 0)

Return the amount per month for a given year

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
_getAverageByMonth($year, string $sql, $format = 0)

Return the amount average par month for a given year

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
_getAllByProduct($sql, int $limit = 10)

Return number or total of product refs

from  Stats
array<int, array{0: int, 1: int}>
_getAmountByYear($sql)

Returns the summed amounts per year for a given number of past years ending now

from  Stats
array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>
getAllByProduct(int $year, $limit = 0)

Return nb, amount of predefined product for year

from  Stats
void
__construct(DoliDB $db, int $socid = 0, int $userid = 0)

Constructor

array<array{0: int, 1: int}>
getNbByYear()

Return nb of expense report per year

getAllByYear()

Return nb, total and average

Details

array<int<0, 11>, array{0: int<1, 12>, 1: int}> getNbByMonth(int $year, int $format = 0)

Return the quantity of invoices per month for a given year

Parameters

int $year number
int $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int}>

Array of nb each month

array<int<0, 11>, array{0: int<1, 12>, 1: int}> getNbByMonthWithPrevYear(int $endyear, int $startyear, int $cachedelay = 0, int $format = 0, int $startmonth = 1)

Return nb of elements by month for several years

Parameters

int $endyear

Start year

int $startyear

End year

int $cachedelay

Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)

int $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

int $startmonth

month of the fiscal year start min 1 max 12 ; if 1 = january

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int}>

Array of values

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> getAmountByMonth(int $year, int $format = 0)

Renvoie le montant de facture par mois pour une annee donnee

Parameters

int $year

year number

int $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of values by month

array<int<0, 11>, array<string|int|float>> getAmountByMonthWithPrevYear(int $endyear, int $startyear, int $cachedelay = 0, int $format = 0, int $startmonth = 1)

Return amount of elements by month for several years.

Criteria used to build request are defined into the constructor of parent class into xxx/class/xxxstats.class.php The caller of class can add more filters into sql request by adding criteris into the $stats->where property just after calling constructor.

Parameters

int $endyear

Start year

int $startyear

End year

int $cachedelay

Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)

int $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

int $startmonth

month of the fiscal year start min 1 max 12 ; if 1 = january

Return Value

array<int<0, 11>, array<string|int|float>>

Array of values

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> getAverageByMonth(int $year)

Return average amount

Parameters

int $year

year number

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of values

array<array<int|float>> getAverageByMonthWithPrevYear(int $endyear, int $startyear)

Return average of entity by month for several years

Parameters

int $endyear

Start year

int $startyear

End year

Return Value

array<array<int|float>>

Array of values

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> getAllByProductEntry(int $year, int $cachedelay = 0, int $limit = 10)

Return count, and sum of products

Parameters

int $year Year
int $cachedelay

Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)

int $limit Limit

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of values

protected array<array{0: int, 1: int}> _getNbByYear(string $sql)

Return nb of elements by year

Parameters

string $sql

SQL request

Return Value

array<array{0: int, 1: int}>

Array of nb each year

protected _getAllByYear(string $sql)

Return nb of elements, total amount and avg amount each year

Parameters

string $sql

SQL request @return 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 with nb, total amount, average for each year

protected array<int<0, 11>, array{0: int<1, 12>, 1: int}> _getNbByMonth(int $year, string $sql, int<0, 2> $format = 0)

Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month for a given year

Parameters

int $year Year
string $sql SQL
int<0, 2> $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int}>

Array of nb each month

protected array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> _getAmountByMonth(int $year, string $sql, int<0, 2> $format = 0)

Return the amount per month for a given year

Parameters

int $year Year
string $sql SQL
int<0, 2> $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of nb each month

protected array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> _getAverageByMonth($year, string $sql, $format = 0)

Return the amount average par month for a given year

@param int $year Year

Parameters

$year
string $sql

SQL @param int<0,2> $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

$format

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of average each month

protected array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> _getAllByProduct($sql, int $limit = 10)

Return number or total of product refs

@param string $sql SQL

Parameters

$sql
int $limit Limit

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of total of product refs each month

protected array<int, array{0: int, 1: int}> _getAmountByYear($sql)

Returns the summed amounts per year for a given number of past years ending now

@param string $sql SQL

Parameters

$sql

Return Value

array<int, array{0: int, 1: int}>

Array of sum of amounts

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}> getAllByProduct(int $year, $limit = 0)

Return nb, amount of predefined product for year

Parameters

int $year

Year to scan @param int $limit Limit

$limit

Return Value

array<int<0, 11>, array{0: int<1, 12>, 1: int|float}>

Array of values

void __construct(DoliDB $db, int $socid = 0, int $userid = 0)

Constructor

Parameters

DoliDB $db

Database handler

int $socid

Id third party

int $userid

Id user for filter

Return Value

void

array<array{0: int, 1: int}> getNbByYear()

Return nb of expense report per year

Return Value

array<array{0: int, 1: int}>

Array of nb each year

getAllByYear()

Return nb, total and average

@return 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