ajaxzentaochart.html.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * The ajaxZentaoChart view file of reporttemplate module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(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 Shujie Tian <tianshujie@chandao.com>
  7. * @package reporttemplate
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. h::css("thead.freeze{position: sticky; top: -2px; z-index: 2;}");
  12. $buildTable = function($options) use($lang)
  13. {
  14. $dataset = zget($options, 'dataset', array());
  15. if(empty($dataset)) return div(setClass('canvas border rounded py-3 px-3 text-center text-gray'), $lang->noData);
  16. $theadRows = array();
  17. foreach(zget($options, 'headers', array()) as $header)
  18. {
  19. $columns = array();
  20. foreach($header as $row)
  21. {
  22. $columns[] = h::th(zget($row, 'label', ''), isset($row['helpIcon']) ? h::span(icon('help'), set::title($row['hint'])) : null, !empty($row['rowspan']) && $row['rowspan'] > 1 ? set::rowspan($row['rowspan']) : null, !empty($row['colspan']) && $row['colspan'] > 1 ? set::colspan($row['colspan']) : null);
  23. }
  24. $theadRows[] = h::tr($columns);
  25. }
  26. $allRowspan = zget($options, 'rowspan', array());
  27. $lineRowspan = array();
  28. $tbodyRows = array();
  29. foreach($dataset as $lineIndex => $line)
  30. {
  31. $row = array();
  32. foreach($line as $colIndex => $cell)
  33. {
  34. if(isset($lineRowspan[$colIndex]) && $lineRowspan[$colIndex] > 1)
  35. {
  36. $lineRowspan[$colIndex]--;
  37. continue;
  38. }
  39. $lineRowspan[$colIndex] = isset($allRowspan[$lineIndex][$colIndex]) ? $allRowspan[$lineIndex][$colIndex] : 0;
  40. $colspan = 1;
  41. $className = '';
  42. if(is_array($cell))
  43. {
  44. $colspan = isset($cell['colspan']) && $cell['colspan'] > 1 ? $cell['colspan'] : $colspan;
  45. $className = isset($cell['className']) ? $cell['className'] : $className;
  46. $cell = isset($cell['text']) ? $cell['text'] : '';
  47. }
  48. $row[] = h::td
  49. (
  50. html($cell),
  51. set::title(strip_tags((string)$cell)),
  52. $className ? set::className($className) : null,
  53. $lineRowspan[$colIndex] > 1 ? set::rowspan($lineRowspan[$colIndex]) : null,
  54. $colspan > 1 ? set::colspan($colspan) : null
  55. );
  56. }
  57. $tbodyRows[] = h::tr($row);
  58. }
  59. return h::table(setClass('table bordered text-center'), h::thead(setClass('freeze whitespace-nowrap'), $theadRows), h::tbody(setClass('whitespace-nowrap'), $tbodyRows));
  60. };
  61. if(strpos($type, '_gantt') !== false && !empty($canUseGantt))
  62. {
  63. $userList = array();
  64. foreach($users as $account => $realname) $userList[] = array('key' => $account, 'label' => $realname);
  65. }
  66. $noticeTip = '';
  67. if($notTemplate)
  68. {
  69. if(strpos($type, '_gantt') !== false && empty($canUseGantt)) $noticeTip = sprintf($lang->reporttemplate->notice->noSupport, $lang->reporttemplate->chartList['project']['basicStatistic']['gantt']);
  70. if(isset($chart) && empty($chart['options'])) $noticeTip = $lang->reporttemplate->emptyDataTip;
  71. }
  72. $isChart = isset($chart['options']) && zget($chart, 'chartType', '') != 'table';
  73. $isTable = isset($chart['options']) && zget($chart, 'chartType', '') == 'table';
  74. $titleTip = '';
  75. $tipHeight = '';
  76. if(!empty($chart['tips'])) $titleTip = $chart['tips'];
  77. if($module == 'project' && $chartKey == 'summary') $tipHeight = 'h-44';
  78. $actions = array();
  79. $hasCondition = true;
  80. if(in_array($module, array('project', 'execution'))) $hasCondition = false;
  81. if($module == 'project' && $chartKey == 'summary') $hasCondition = true;
  82. if($hasCondition) $actions[] = array('icon' => 'menu-backend', 'text' => $lang->settings, 'data-toggle' => 'modal', 'url' => createLink('reporttemplate', 'ajaxBuildZentaoChartConfig', "type={$type}&blockID={$blockID}&projectID={$projectID}"));
  83. $actions[] = array('icon' => 'trash', 'text' => $lang->delete, 'zui-on-click' => "deleteZentaoChart($blockID)");
  84. div
  85. (
  86. set('data-id', $blockID),
  87. setClass('zentao-chart my-3'),
  88. setCssVar('--affine-font-base', '13px!important'),
  89. setStyle('font-size', '13px'),
  90. setStyle('max-height', '500px'),
  91. setStyle('overflow-y', 'auto'),
  92. css('.is-readonly .zentao-chart-actions {display: none}'),
  93. div
  94. (
  95. setClass('zentao-chart-heading row items-center gap-2 mb-1'),
  96. h2
  97. (
  98. setClass('font-bold text-xl'),
  99. $title,
  100. $titleTip ? span(setClass('pl-1'), setData(array('toggle' => 'dropdown', 'trigger' => 'hover')), icon('help')) : null,
  101. $titleTip ? h::menu(setClass("dropdown-menu custom p-1 {$tipHeight} overflow-auto"), setStyle(array('font-weight' => 'normal', 'font-size' => '12px', 'line-height' => '1.5')), html($titleTip)) : null
  102. ),
  103. div
  104. (
  105. setClass('zentao-chart-actions toolbar flex-auto justify-end'),
  106. dropdown
  107. (
  108. set::trigger('hover'),
  109. set::placement('bottom-end'),
  110. set::items($actions),
  111. btn(set::icon('ellipsis-v'), set::caret(false), set::type('ghost'))
  112. )
  113. )
  114. ),
  115. !$notTemplate ? div
  116. (
  117. setClass('canvas border rounded py-3 px-3'),
  118. div
  119. (
  120. setClass('config-tip text-center px-3 py-2 text-gray-400'),
  121. div($lang->reporttemplate->chartBlockTip),
  122. div($conditionText)
  123. )
  124. ) : null,
  125. $noticeTip ? div
  126. (
  127. setClass('canvas border rounded py-3 px-3'),
  128. div
  129. (
  130. setClass('config-tip text-center px-3 py-2 text-gray-400'),
  131. div($noticeTip)
  132. )
  133. ) : null,
  134. $isChart ? div
  135. (
  136. setClass('chartBox chart'),
  137. echarts(set($chart['options']), set::width('100%'), set::height(300), zget($chart, 'chartType', '') == 'waterpolo' ? set::exts('liquidfill') : null)
  138. ) : null,
  139. $isTable ? div(setClass('chartBox table'), set::style(array('max-height' => '300px', 'overflow-y' => 'auto')), $buildTable($chart['options'])) : null,
  140. !empty($canUseGantt) ? div
  141. (
  142. setClass('chartBox gantt'),
  143. $this->view->notTemplate ? setData('link', createLink('programplan', 'browse', "projectID=$projectID&productID=0&type=gantt")) : null,
  144. zui::gantt
  145. (
  146. set::onInit(jsRaw('window.onInitGantt')),
  147. set::data($ganttData['data']),
  148. set::links($ganttData['links']),
  149. set::ganttFields($ganttFields),
  150. set::showFields('text,PM,status,begin,deadline,duration'),
  151. set::userList($userList),
  152. set::exts('zentao')
  153. )
  154. ) : null
  155. );