Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into 16.0
This commit is contained in:
commit
317530fc8b
@ -372,7 +372,7 @@ class FormProjets
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||||
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
||||||
$out .= $comboenhancement;
|
$out .= $comboenhancement;
|
||||||
$morecss = 'minwidth200 maxwidth500';
|
$morecss .= ' minwidth200 maxwidth500';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($option_only)) {
|
if (empty($option_only)) {
|
||||||
|
|||||||
@ -131,6 +131,54 @@ class ExpeditionStats extends Stats
|
|||||||
return $this->_getNbByYear($sql);
|
return $this->_getNbByYear($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the orders amount by month for a year
|
||||||
|
*
|
||||||
|
* @param int $year Year to scan
|
||||||
|
* @param 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 array Array with amount by month
|
||||||
|
*/
|
||||||
|
public function getAmountByMonth($year, $format = 0)
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.")";
|
||||||
|
$sql .= " FROM ".$this->from;
|
||||||
|
if (empty($user->rights->societe->client->voir) && !$this->socid) {
|
||||||
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
}
|
||||||
|
$sql .= $this->join;
|
||||||
|
$sql .= " WHERE ".$this->where;
|
||||||
|
$sql .= " GROUP BY dm";
|
||||||
|
$sql .= $this->db->order('dm', 'DESC');
|
||||||
|
|
||||||
|
$res = $this->_getAmountByMonth($year, $sql, $format);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the orders amount average by month for a year
|
||||||
|
*
|
||||||
|
* @param int $year year for stats
|
||||||
|
* @return array array with number by month
|
||||||
|
*/
|
||||||
|
public function getAverageByMonth($year)
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.")";
|
||||||
|
$sql .= " FROM ".$this->from;
|
||||||
|
if (empty($user->rights->societe->client->voir) && !$this->socid) {
|
||||||
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
}
|
||||||
|
$sql .= $this->join;
|
||||||
|
$sql .= " WHERE ".$this->where;
|
||||||
|
$sql .= " GROUP BY dm";
|
||||||
|
$sql .= $this->db->order('dm', 'DESC');
|
||||||
|
|
||||||
|
return $this->_getAverageByMonth($year, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return nb, total and average
|
* Return nb, total and average
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user