Methods déclaration
This commit is contained in:
parent
728bcf677e
commit
67b9a7dc07
@ -15,6 +15,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
@ -193,4 +196,35 @@ class TaskStats extends Stats
|
|||||||
// var_dump($res);print '<br>';
|
// var_dump($res);print '<br>';
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the Task 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)
|
||||||
|
{
|
||||||
|
// Return an empty array at the moment because task has no amount
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return average of entity by month
|
||||||
|
* @param int $year year number
|
||||||
|
* @return int value
|
||||||
|
*/
|
||||||
|
protected function getAverageByMonth($year)
|
||||||
|
{
|
||||||
|
$sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
|
||||||
|
$sql .= " FROM ".$this->from;
|
||||||
|
$sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||||
|
$sql .= " AND ".$this->where;
|
||||||
|
$sql .= " GROUP BY dm";
|
||||||
|
$sql .= $this->db->order('dm', 'DESC');
|
||||||
|
|
||||||
|
return $this->_getAverageByMonth($year, $sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user