* @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) * @Link https://www.zentao.net */ class hour_of_annual_effort extends baseCalc { public $dataset = 'getEfforts'; public $fieldList = array('t1.date', 't1.consumed'); public $result = array(); public function calculate($row) { $year = $this->getYear($row->date); if(!$year) return false; $consumed = $row->consumed; if(!isset($this->result[$year])) $this->result[$year] = 0; $this->result[$year] += $consumed; } public function getResult($options = array()) { $records = $this->getRecords(array('year', 'value')); return $this->filterByOptions($records, $options); } }