count_of_task_in_reason.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * 按关闭原因统计的任务数。
  4. * Count of task in closed reason.
  5. *
  6. * 范围:closedReason
  7. * 对象:task
  8. * 目的:scale
  9. * 度量名称:按关闭原因统计的任务数
  10. * 单位:个
  11. * 描述:按关闭原因统计的任务数
  12. * 定义:按关闭原因统计的任务数
  13. *
  14. * @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author Yanyi Cao <caoyanyi@chandao.com>
  16. * @package
  17. * @uses func
  18. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  19. * @Link https://www.zentao.net
  20. */
  21. class count_of_task_in_reason extends baseCalc
  22. {
  23. public $dataset = '';
  24. public $fieldList = array();
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. if($row->status != 'closed') return;
  29. if(!isset($this->result[$row->closedReason])) $this->result[$row->closedReason] = array();
  30. $this->result[$row->closedReason][$row->id] = $row->id;
  31. }
  32. public function getResult($options = array())
  33. {
  34. foreach($this->result as $closedReason => $tasks)
  35. {
  36. if(!is_array($tasks)) continue;
  37. $this->result[$closedReason] = count($tasks);
  38. }
  39. $records = $this->getRecords(array('reason', 'value'));
  40. return $this->filterByOptions($records, $options);
  41. }
  42. }