* @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 consume_of_monthly_closed_project extends baseCalc { public $dataset = 'getProjectTasks'; public $fieldList = array('t1.closedDate', 't2.consumed', 't1.id as project', 't1.status'); public $result = array(); public function calculate($data) { $project = $data->project; $consumed = $data->consumed; $status = $data->status; if($status != 'closed') return false; $year = $this->getYear($data->closedDate); if(!$year) return false; $month = substr($data->closedDate, 5, 2); if(!is_numeric($consumed) || empty($consumed)) return false; if(!isset($this->result[$year])) $this->result[$year] = array(); if(!isset($this->result[$year][$month])) $this->result[$year][$month] = array(); $this->result[$year][$month][$project] = round($consumed, 2); } public function getResult($options = array()) { $records = $this->getRecords(array('year', 'month', 'project', 'value')); return $this->filterByOptions($records, $options); } }