left_period_of_project.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * 按项目统计的剩余工期。
  4. * Left period of project.
  5. *
  6. * 范围:project
  7. * 对象:project
  8. * 目的:time
  9. * 度量名称:按项目统计的剩余工期
  10. * 单位:天
  11. * 描述:按项目统计的剩余工期表示项目在当前时间点上还剩下的工作时间。这个度量项可以帮助团队评估项目的剩余工作量和进度。通过比较剩余工期和剩余工时,可以预测项目是否能够按时完成,并采取适当的措施来调整进度,以确保项目的成功交付。
  12. * 定义:剩余工期=计划截止日期-当前日期;当剩余工期<0时,默认为0;当项目已关闭时,剩余工期默认为0;过滤已删除的项目。
  13. *
  14. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author zhouxin <zhouxin@easycorp.ltd>
  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 left_period_of_project extends baseCalc
  22. {
  23. public $dataset = 'getAllProjects';
  24. public $fieldList = array('t1.id', 't1.status', 't1.end');
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. if($row->status == 'closed')
  29. {
  30. $this->result[$row->id] = 0;
  31. }
  32. else
  33. {
  34. $diff = strtotime($row->end) - strtotime(date('Y-m-d'));
  35. if($diff <= 0)
  36. {
  37. $this->result[$row->id] = 0;
  38. }
  39. else
  40. {
  41. $this->result[$row->id] = $diff / 86400;
  42. }
  43. }
  44. }
  45. public function getResult($options = array())
  46. {
  47. $records = $this->getRecords(array('project', 'value'));
  48. return $this->filterByOptions($records, $options);
  49. }
  50. }