zentaomax.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. public function getProjectByType($projectID = 0, $type = 'stage')
  3. {
  4. $projects = $this->dao->select('id, name, begin, end, PM')->from(TABLE_PROJECT)
  5. ->where('project')->eq($projectID)
  6. ->beginIF($type != 'all')->andWhere('type')->eq($type)->fi()
  7. ->andWhere('deleted')->eq(0)
  8. ->fetchAll('id');
  9. foreach($projects as $id => $project)
  10. {
  11. $tasks = $this->dao->select('COUNT(1) AS tasks')->from(TABLE_TASK)->where('execution')->eq($id)->andWhere('deleted')->eq(0)->fetch();
  12. $project->tasks = $tasks->tasks;
  13. }
  14. return $projects;
  15. }
  16. public function getStaff($executionIdList)
  17. {
  18. return $this->dao->select('count(distinct account) as count, execution')
  19. ->from(TABLE_EFFORT)
  20. ->where('objectType')->eq('task')
  21. ->andWhere('execution')->in($executionIdList)
  22. ->groupBy('execution')
  23. ->fetchAll('execution');
  24. }
  25. public function getPV($executionIdList)
  26. {
  27. $pvList = $this->dao->select('execution,sum(estimate) as estimate')->from(TABLE_TASK)
  28. ->where('execution')->in($executionIdList)
  29. ->groupBy('execution')
  30. ->fetchPairs();
  31. return $pvList;
  32. }
  33. public function getEV($executionIdList)
  34. {
  35. $evList = $this->dao->select('execution,sum(consumed) as consumed')->from(TABLE_TASK)
  36. ->where('execution')->in($executionIdList)
  37. ->andWhere('status')->ne('cancel')
  38. ->groupBy('execution')
  39. ->fetchPairs();
  40. return $evList;
  41. }
  42. public function getMeasReportByID($reportID)
  43. {
  44. return $this->dao->select('*')->from(TABLE_PROGRAMREPORT)->where('id')->eq($reportID)->fetch();
  45. }
  46. public function getMeasReports($projectID = 0, $templateID = 0)
  47. {
  48. return $this->dao->select('*')
  49. ->from(TABLE_PROGRAMREPORT)
  50. ->where('deleted')->eq(0)
  51. ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
  52. ->beginIF($templateID)->andWhere('template')->eq($templateID)->fi()
  53. ->fetchAll();
  54. }
  55. public function buildReportList($projectID = 0)
  56. {
  57. $project = $this->dao->findByID($projectID)->from(TABLE_PROJECT)->fetch();
  58. if(common::hasPriv('report', 'customeredReport'))
  59. {
  60. $templates = $this->loadModel('measurement')->getTemplatePairs($project->model);
  61. foreach($templates as $templateID => $templateName)
  62. {
  63. $this->lang->reportList->program->lists[] = $templateName . "|report|customeredreport|program={$projectID}&templateID=$templateID";
  64. }
  65. }
  66. if(common::hasPriv('report', 'show'))
  67. {
  68. $reportList = $this->getReportList('cmmi');
  69. foreach($reportList as $report)
  70. {
  71. $name = json_decode($report->name, true);
  72. if(!is_array($name) or empty($name)) $name[$this->app->getClientLang()] = $report->name;
  73. if(empty($report->module)) continue;
  74. $reportName = !isset($name[$this->app->getClientLang()]) ? $name['en'] : $name[$this->app->getClientLang()];
  75. $reportName = $this->replace4Workflow($reportName);
  76. $this->lang->reportList->program->lists[] = $reportName . "|report|show|reportID={$report->id}&reportModule=program";
  77. }
  78. }
  79. }
  80. public function saveMeasReport($projectID = 0, $templateID = 0, $content = '')
  81. {
  82. $report = fixer::input('post')
  83. ->add('project', $projectID)
  84. ->add('template', $templateID)
  85. ->add('createdBy', $this->app->user->account)
  86. ->add('createdDate', helper::now())
  87. ->remove('parseContent, saveReport')
  88. ->get();
  89. $report->params = json_encode($report->params);
  90. $report->content = $content;
  91. $this->dao->insert(TABLE_PROGRAMREPORT)
  92. ->data($report)
  93. ->check('name', 'notempty')
  94. ->autocheck()
  95. ->exec();
  96. if(dao::isError()) return false;
  97. return $this->dao->lastInsertID();
  98. }