* @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 count_of_assigned_task extends baseCalc { public $dataset = ''; public $fieldList = array(); public $result = array(); public function calculate($row) { $assignedTo = $row->assignedTo; $mode = $row->mode; if($row->status == 'closed') return false; if($mode == 'multi') { foreach(explode(',', $row->teamMembers) as $user) { if(!$user) continue; if(!isset($this->result[$user])) $this->result[$user] = array(); $this->result[$user][$row->id] = $row->id; } } else { if(!isset($this->result[$assignedTo])) $this->result[$assignedTo] = array(); $this->result[$assignedTo][$row->id] = $row->id; } } public function getResult($options = array()) { foreach($this->result as $assignedTo => $tasks) { if(!is_array($tasks)) { unset($this->result[$assignedTo]); continue; } $this->result[$assignedTo] = count($tasks); } $records = $this->getRecords(array('user', 'value')); return $this->filterByOptions($records, $options); } }