* @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 estimate_of_annual_closed_project extends baseCalc { public $dataset = 'getTasks'; public $fieldList = array('t1.estimate', 't1.parent', 't1.status', 't1.isParent', 't3.status AS projectStatus', 't3.closedDate'); public $result = array(); public function calculate($row) { if($row->isParent == '1' || $row->status == 'cancel') return false; if($row->projectStatus != 'closed' || empty($row->closedDate)) return false; $year = $this->getYear($row->closedDate); if(!isset($this->result[$year])) $this->result[$year] = 0; $this->result[$year] += $row->estimate; } public function getResult($options = array()) { $records = $this->getRecords(array('year', 'value')); return $this->filterByOptions($records, $options); } }