zentaobiz.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * 获取基本统计数据。
  4. * Get basic metrics.
  5. *
  6. * @param array $executions
  7. * @param object $project
  8. * @access public
  9. * @return object
  10. */
  11. public function getExecutionBasicMetrics($executions, $project)
  12. {
  13. $countItems = array('total', 'doingNum', 'closedNum', 'delayNum', 'closedRate', 'delayRate');
  14. $chartItems = array('statusMap');
  15. $tableItems = array('doingSummary', 'closedSummary');
  16. $metricsCount = $this->project->getMetricsCount($executions, $countItems);
  17. $metricsChart = $this->project->getMetricsChart($executions, $chartItems);
  18. $metricsTable = $this->project->getMetricsTable($executions, $project, $tableItems);
  19. $statistics = new stdclass();
  20. foreach($countItems as $item) $statistics->{$item} = $metricsCount->{$item};
  21. foreach($chartItems as $item) $statistics->{$item} = $metricsChart->{$item};
  22. foreach($tableItems as $item) $statistics->{$item} = $metricsTable->{$item};
  23. return $statistics;
  24. }
  25. /**
  26. * 构建执行的基本统计配置。
  27. * Build chart config.
  28. *
  29. * @param array $bugs
  30. * @param object $execution
  31. * @access public
  32. * @return array
  33. * @param object $project
  34. * @param mixed[] $executions
  35. */
  36. public function buildBasicExecutionConfig($executions, $project)
  37. {
  38. $this->loadModel('report');
  39. $settings = array();
  40. $metrics = $this->getExecutionBasicMetrics($executions, $project);
  41. $xAxis = $this->config->report->reportChart->xAxis;
  42. $yAxis = 80;
  43. $name = in_array($project->model, array('waterfall', 'waterfallplus', 'ipd')) ? $this->lang->stage->common : $this->lang->project->reportSettings->execution;
  44. $width = $this->config->report->reportChart->oneQuarter;
  45. foreach(array('total', 'doingNum', 'closedNum', 'delayNum') as $index => $field)
  46. {
  47. $fieldName = sprintf($this->lang->project->reportSettings->$field, $name);
  48. $settings = array_merge($settings, $this->report->buildTextChartConfig($metrics->$field, $fieldName, $xAxis, $yAxis, $index, $width));
  49. }
  50. $yAxis += $this->config->report->reportChart->textHeight + $this->config->report->reportChart->padding * 8;
  51. $xAxis = 0;
  52. foreach(array('closedRate', 'delayRate') as $index => $field)
  53. {
  54. $fieldName = str_replace('%s', $name, $this->lang->project->reportSettings->$field);
  55. $fieldTips = str_replace('%s', $name, $this->lang->project->reportSettings->tips->$field);
  56. $settings = array_merge($settings, $this->report->buildWaterChartConfig($fieldName, $metrics->$field, $xAxis, $yAxis, $index, $fieldTips, 2));
  57. }
  58. $yAxis += $this->config->report->reportChart->waterHeight + $this->config->report->reportChart->padding * 9;
  59. $xAxis = 0;
  60. $statusTitle = sprintf($this->lang->project->reportSettings->statusMap, $name);
  61. $settings = array_merge($settings, $this->report->buildBarChartConfig($statusTitle, $metrics->statusMap, $yAxis));
  62. $yAxis -= $this->config->report->reportChart->padding * 4.6;
  63. foreach(array('doingSummary', 'closedSummary') as $type)
  64. {
  65. $yAxis += $this->config->report->reportChart->barHeight + $this->config->report->reportChart->padding * 9;
  66. $title = sprintf($this->lang->project->reportSettings->$type, $name);
  67. $tips = str_replace('%s', $name, $this->lang->project->reportSettings->tips->$type);
  68. $settings = array_merge($settings, $this->report->buildTableChartConfig($title, $metrics->{$type}->headers, $metrics->{$type}->dataset, $yAxis, 0, array(), '', $tips));
  69. }
  70. return $settings;
  71. }
  72. /**
  73. * Append extras data to post data.
  74. *
  75. * @param object $postData
  76. * @param int $copyProjectID
  77. * @access protected
  78. * @return object|false
  79. */
  80. public function prepareCreateExtras($postData, $copyProjectID = 0)
  81. {
  82. $project = parent::prepareCreateExtras($postData, $copyProjectID);
  83. if(!empty($project->workflowGroup))
  84. {
  85. $projectType = $this->dao->select('projectType')->from(TABLE_WORKFLOWGROUP)->where('id')->eq($project->workflowGroup)->fetch('projectType');
  86. $project->hasProduct = strpos(',product,ipd,tpd,cbb,cpdproduct,', ",$projectType,") !== false ? '1' : '0';
  87. if($project->model == 'ipd') $project->category = strpos(',cpdproduct,cpdproject,', ",$projectType,") !== false ? 'CPD' : strtoupper($projectType);
  88. }
  89. return $project;
  90. }
  91. /**
  92. * Validate $postData and prepare $project for update.
  93. *
  94. * @param object $postData
  95. * @param int $hasProduct
  96. * @access protected
  97. * @return object|false
  98. */
  99. protected function prepareProject($postData, $hasProduct)
  100. {
  101. $project = parent::prepareProject($postData, $hasProduct);
  102. if(!empty($project->workflowGroup))
  103. {
  104. $projectType = $this->dao->select('projectType')->from(TABLE_WORKFLOWGROUP)->where('id')->eq($project->workflowGroup)->fetch('projectType');
  105. $project->hasProduct = strpos(',product,ipd,tpd,cbb,cpdproduct,', ",$projectType,") !== false ? '1' : '0';
  106. if($project->model == 'ipd') $project->category = strpos(',cpdproduct,cpdproject,', ",$projectType,") !== false ? 'CPD' : strtoupper($projectType);
  107. }
  108. return $project;
  109. }