gantt.html.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * The gantt view file of execution module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2026 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @license ZPL (http://zpl.pub/page/zplv12.html)
  7. * @author Hao Sun <sunhao@chandao.com>
  8. * @package execution
  9. * @version $Id: editrelation.html.php 935 2024-08-08 15:14:24Z $
  10. * @link https://www.zentao.net
  11. */
  12. namespace zin;
  13. if($config->vision == 'lite') include 'header.html.php';
  14. jsVar('executionID', $executionID);
  15. $ganttLang = new stdclass();
  16. $ganttLang->exporting = $lang->programplan->exporting;
  17. $ganttLang->exportFail = $lang->programplan->exportFail;
  18. $ganttLang->zooming = $lang->execution->gantt->zooming;
  19. $ganttLang->hideCriticalPath = $lang->programplan->hideCriticalPath;
  20. $ganttLang->showCriticalPath = $lang->programplan->showCriticalPath;
  21. $ganttLang->fullScreen = $lang->execution->gantt->fullScreen;
  22. $ganttLang->taskStatusList = $lang->task->statusList;
  23. $ganttLang->ganttSetting = $lang->execution->ganttSetting;
  24. $ganttLang->edit = $lang->programplan->edit;
  25. $ganttLang->submit = $lang->programplan->submit;
  26. $ganttLang->today = $lang->programplan->today;
  27. $ganttLang->scrollToToday = $lang->execution->gantt->scrollToToday;
  28. $ganttLang->deleteRelation = $lang->execution->gantt->confirmDelete;
  29. $ganttLang->errorTaskDrag = $lang->programplan->error->taskDrag;
  30. $ganttLang->errorPlanDrag = $lang->programplan->error->planDrag;
  31. $ganttLang->wrongRelation = $lang->execution->error->wrongGanttRelation;
  32. $ganttLang->wrongRelationSource = $lang->execution->error->wrongGanttRelationSource;
  33. $ganttLang->wrongRelationTarget = $lang->execution->error->wrongGanttRelationTarget;
  34. $ganttLang->wrongKanbanTasks = $lang->execution->error->wrongKanbanTasks;
  35. $ganttLang->warningNoToday = $lang->execution->gantt->warning->noTodayMarker;
  36. $fileName = ($execution->type == 'stage' ? "$project->name-" : '') . $executionName . '-' . $lang->execution->ganttchart;
  37. $typeHtml = '<span class="toggle-all-icon"><i class="icon-expand-alt"></i></span><a data-toggle="dropdown" href="#browseTypeList"><span class="text">' . $lang->execution->gantt->browseType[$ganttType] . '</span><span class="caret"></span></a>';
  38. $typeHtml .= '<menu class="dropdown-menu menu" id="browseTypeList">';
  39. foreach($lang->execution->gantt->browseType as $ganttBrowseType => $typeName)
  40. {
  41. $link = createLink('execution', 'gantt', "executionID=$executionID&type=$ganttBrowseType");
  42. $typeHtml .= '<li class="menu-item' . ($ganttType == $ganttBrowseType ? " active" : '') . '">' . html::a($link, $typeName, '', "class='item-content'") . '</li>';
  43. }
  44. $typeHtml .= '</menu>';
  45. $notSort = array('delay', 'delayDays');
  46. $ganttFields = [];
  47. $ganttFields['column_text'] = $typeHtml;
  48. $ganttFields['column_percent'] = $lang->execution->ganttCustom['progress'];
  49. $ganttFields['column_start_date'] = array('text' => $lang->execution->ganttCustom['begin']);
  50. $ganttFields['column_end_date'] = array('text' => $lang->execution->gantt->endDate);
  51. foreach($lang->execution->ganttCustom as $field => $name)
  52. {
  53. if($field == 'progress') continue;
  54. $ganttField = "column_{$field}";
  55. if(isset($ganttFields[$ganttField])) continue;
  56. $ganttFields[$ganttField] = in_array($field, $notSort) ? $name : array('text' => $name);
  57. }
  58. list($orderField, $orderDirect) = $this->execution->parseOrderBy($orderBy);
  59. foreach($ganttFields as $colName => $value)
  60. {
  61. $field = str_replace('column_', '', $colName);
  62. if(is_null($value) || is_array($value))
  63. {
  64. list($fieldOrderBy, $fieldClass) = $this->execution->buildKanbanOrderBy($field, $orderField, $orderDirect);
  65. $text = (is_array($value) && !empty($value['text'])) ? $value['text'] : $lang->execution->ganttCustom[$field];
  66. $value = \html::a(createLink('execution', 'gantt', "executionID=$executionID&type=$ganttType&orderBy=$fieldOrderBy"), $text, '', "class='$fieldClass'");
  67. }
  68. $ganttFields[$colName] = $value;
  69. }
  70. h::css("#browseTypeList .menu-item .item-content{height:30px;}");
  71. h::css("#browseTypeList .menu-item.active .item-content{color: var(--menu-selected-color); font-weight: 700;}");
  72. h::css("#browseTypeList .menu-item.active .item-content:hover{color: #fff;}");
  73. $hasGanttType = isset($ganttType);
  74. featureBar
  75. (
  76. $hasGanttType ? btn
  77. (
  78. setID('criticalPath'),
  79. setClass('mr-2'),
  80. set::type('ghost'),
  81. on::click()->call('updateCriticalPath'),
  82. setData('showText', $lang->execution->gantt->showCriticalPath),
  83. setData('hideText', $lang->execution->gantt->hideCriticalPath),
  84. $lang->execution->gantt->showCriticalPath
  85. ) : null,
  86. $hasGanttType ? btn
  87. (
  88. setID('fullScreenBtn'),
  89. setClass('mr-4'),
  90. set::type('ghost'),
  91. set::icon('fullscreen'),
  92. on::click()->call('enterGanttFullscreen'),
  93. $lang->execution->gantt->fullScreen
  94. ) : null,
  95. $hasGanttType ? null : btn
  96. (
  97. set::type('secondary'),
  98. set::url('execution', 'gantt', "executionID=$executionID"),
  99. $lang->goback
  100. ),
  101. div
  102. (
  103. setID('ganttPris'),
  104. setClass('row gap-2'),
  105. strong($lang->task->pri . " : "),
  106. array_map(function($pri, $color)
  107. {
  108. if($pri <= 0 || $pri > 4) return null;
  109. return span(setClass('h-5 w-5 center'), style::background($color), $pri);
  110. }, array_keys($lang->execution->gantt->progressColor), $lang->execution->gantt->progressColor)
  111. )
  112. );
  113. $toolbarItems = [];
  114. if($hasGanttType)
  115. {
  116. if(hasPriv('execution', 'ganttsetting')) $toolbarItems[] = ['type' => 'ghost', 'text' => $lang->execution->ganttSetting, 'icon' => 'cog-outline muted', 'url' => createLink('execution', 'ganttsetting', "executionID=$executionID"), 'data-toggle' => 'modal', 'data-size' => '45%'];
  117. if(hasPriv('execution', 'relation') && $config->vision != 'lite') $toolbarItems[] = ['type' => 'ghost', 'text' => $lang->execution->maintainRelation, 'icon' => 'list-alt muted', 'url' => createLink('execution', 'relation', "executionID=$executionID") . "#app={$app->tab}"];
  118. }
  119. if($this->app->rawMethod != 'relation' and $this->app->rawMethod != 'maintainrelation')
  120. {
  121. $exportItems = [];
  122. $exportItems[] = ['text' => $lang->execution->gantt->exportImg, 'url' => 'javascript:exportGantt()'];
  123. $exportItems[] = ['text' => $lang->execution->gantt->exportPDF, 'url' => 'javascript:exportGantt("pdf")'];
  124. $toolbarItems[] = ['text' => $lang->export, 'icon' => 'export muted', 'type' => 'dropdown', 'items' => $exportItems];
  125. }
  126. elseif(hasPriv('execution', 'maintainRelation'))
  127. {
  128. $toolbarItems[] = ['type' => 'secondary', 'text' => $lang->execution->gantt->editRelationOfTasks, 'icon' => 'plus', 'url' => createLink('execution', 'maintainRelation', "executionID=$executionID")];
  129. }
  130. $checkObject = new stdclass();
  131. $checkObject->execution = $executionID;
  132. $canCreateTask = hasPriv('task', 'create', $checkObject);
  133. $toolbarItems[] = ['type' => 'primary', 'disabled' => !$canCreateTask, 'text' => $lang->task->create, 'icon' => 'plus', 'url' => $canCreateTask ? createLink('task', 'create', "execution=$executionID" . (isset($moduleID) ? "&storyID=&moduleID=$moduleID" : '')) : null, 'data-toggle' => 'modal', 'data-size' => 'lg'];
  134. toolbar(set::items($toolbarItems));
  135. gantt
  136. (
  137. set('ganttLang', $ganttLang),
  138. set('ganttFields', $ganttFields),
  139. set('canEdit', hasPriv('execution', 'ganttEdit')),
  140. set('zooming', !empty($zooming) ? $zooming : 'day'),
  141. set('users', $users),
  142. set('showFields', str_replace('assignedTo', 'owner_id', $config->execution->ganttCustom->ganttFields)),
  143. set::exportFileName($fileName),
  144. set::weekend(array('weekend' => zget($config->execution, 'weekend', 2), 'restDay' => zget($config->execution, 'restDay', 0))),
  145. set('options', $executionData)
  146. );