bugstatisticblock.html.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /**
  3. * The bugstatistic block view file of block module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Yuting Wang <wangyuting@easycorp.ltd>
  7. * @package block
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $app->control->loadModel('project');
  12. $active = isset($params['active']) ? $params['active'] : key($products);
  13. $product = null;
  14. $items = array();
  15. foreach($products as $productItem)
  16. {
  17. $projectID = isset($params['projectID']) ? $params['projectID'] : 0;
  18. $params = helper::safe64Encode("module={$block->module}&projectID={$projectID}&active={$productItem->id}");
  19. $isShadow = $productItem->shadow;
  20. $url = createLink('bug', 'browse', "productID=$productItem->id");
  21. if($isShadow)
  22. {
  23. $project = $this->project->getByShadowProduct($productItem->id);
  24. $url = createLink('project', 'bug', "projectID=$project->id");
  25. }
  26. $items[] = array
  27. (
  28. 'id' => $productItem->id,
  29. 'text' => $productItem->name,
  30. 'url' => $url,
  31. 'data-app' => $isShadow && !empty($project) ? 'project' : 'qa',
  32. 'activeUrl' => createLink('block', 'printBlock', "blockID={$block->id}&params={$params}")
  33. );
  34. if($productItem->id == $active) $product = $productItem;
  35. }
  36. statisticBlock
  37. (
  38. to::titleSuffix
  39. (
  40. icon
  41. (
  42. setClass('text-light text-sm cursor-pointer'),
  43. toggle::tooltip
  44. (
  45. array
  46. (
  47. 'title' => sprintf($lang->block->tooltips['metricTime'], $metricTime),
  48. 'placement' => $app->getClientLang() == 'en' ? 'bottom-end' : 'bottom',
  49. 'type' => 'white',
  50. 'className' => 'text-dark border border-light leading-5'
  51. )
  52. ),
  53. 'help'
  54. )
  55. ),
  56. set::block($block),
  57. set::active($active),
  58. set::items($items),
  59. div
  60. (
  61. setClass('flex' . ($longBlock ? ' flex-nowrap' : ' flex-wrap')),
  62. cell
  63. (
  64. setClass('flex flex-wrap items-center content-center progress-circle'),
  65. set::width($longBlock ? '30%' : '100%'),
  66. div
  67. (
  68. setClass('flex justify-center w-full col'),
  69. div
  70. (
  71. setClass('row text-sm items-center font-bold gap-1 pl-5 pb-1'),
  72. $lang->block->qastatistic->fixBugRate,
  73. icon
  74. (
  75. setClass('text-light text-sm'),
  76. toggle::tooltip
  77. (
  78. array
  79. (
  80. 'title' => $lang->block->tooltips['resolvedRate'],
  81. 'placement' => 'bottom',
  82. 'type' => 'white',
  83. 'className' => 'text-dark border border-light leading-5'
  84. )
  85. ),
  86. 'help'
  87. )
  88. ),
  89. progressCircle(set::percent($resolvedRate), set::size(112), set::text(false), set::circleWidth('0.06'), div(span(setClass('text-2xl font-bold'), $resolvedRate), '%'))
  90. ),
  91. cell
  92. (
  93. setClass('flex justify-center w-full mt-3 gap-x-4'),
  94. col
  95. (
  96. span
  97. (
  98. setClass('flex justify-center'),
  99. $totalBugs
  100. ),
  101. span
  102. (
  103. setClass('text-sm text-gray'),
  104. $lang->block->bugstatistic->effective
  105. )
  106. ),
  107. col
  108. (
  109. span
  110. (
  111. setClass('flex justify-center'),
  112. $closedBugs
  113. ),
  114. span
  115. (
  116. setClass('text-sm text-gray'),
  117. $lang->block->bugstatistic->fixed
  118. )
  119. ),
  120. col
  121. (
  122. span
  123. (
  124. setClass('flex justify-center'),
  125. $unresovledBugs
  126. ),
  127. span
  128. (
  129. setClass('text-sm text-gray'),
  130. $lang->block->bugstatistic->activated
  131. )
  132. )
  133. )
  134. ),
  135. cell
  136. (
  137. setClass('chart bar-chart p-4' . ($longBlock ? ' mt-3' : ' pb-0')),
  138. set::width($longBlock ? '70%' : '100%'),
  139. echarts
  140. (
  141. set::title(array('text' => $lang->block->qastatistic->bugStatusStat, 'textStyle' => array('fontSize' => '12'))),
  142. set::color(array('#66a2ff', '#9ea3b0')),
  143. set::width('100%'),
  144. set::height(200),
  145. set::tooltip(array('trigger' => 'axis')),
  146. set::grid(array('left' => '10px', 'top' => '50px', 'right' => '0', 'bottom' => '0', 'containLabel' => true)),
  147. set::legend(array('show' => true, 'right' => '0', 'top' => '25px', 'textStyle' => array('fontSize' => '11'))),
  148. set::xAxis(array('type' => 'category', 'data' => array_keys($activateBugs), 'splitLine' => array('show' => false), 'axisTick' => array('alignWithLabel' => true, 'interval' => 0), 'axisLabel' => array('fontSize' => $longBlock ? '8' : '10'))),
  149. set::yAxis(array('type' => 'value', 'splitLine' => array('show' => false), 'axisLine' => array('show' => true, 'color' => '#DDD'), 'axisLabel' => array('showMaxLabel' => true, 'interval' => 'auto'))),
  150. set::tooptop(array('show' => true, 'formatter' => '{b}: {c}')),
  151. set::series
  152. (
  153. array
  154. (
  155. array
  156. (
  157. 'type' => 'bar',
  158. 'barWidth' => '8',
  159. 'name' => $lang->bug->createAB,
  160. 'data' => array_values($activateBugs)
  161. ),
  162. array
  163. (
  164. 'type' => 'bar',
  165. 'barWidth' => '8',
  166. 'name' => $lang->bug->close,
  167. 'data' => array_values($closeBugs)
  168. )
  169. )
  170. )
  171. )
  172. )
  173. )
  174. );
  175. render();