execution.html.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * The all view file of execution module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Sun Guangming<sunguangming@easycorp.ltd>
  8. * @package execution
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. $this->app->loadLang('kanban');
  13. $kanbanview = 'kanban';
  14. if(!empty($_COOKIE['kanbanview'])) $kanbanview = $_COOKIE['kanbanview'];
  15. if(!common::hasPriv('execution', $kanbanview))
  16. {
  17. foreach(explode('|', 'kanban|task|calendar|gantt|tree|grouptask') as $view)
  18. {
  19. if(!common::hasPriv('execution', $view)) continue;
  20. $kanbanview = $view;
  21. break;
  22. }
  23. }
  24. $fnGetKanbanTeams = function($kanbanID) use ($memberGroup, $users, $usersAvatar)
  25. {
  26. $teams = zget($memberGroup, $kanbanID, array());
  27. $count = 0;
  28. $teamElements = array();
  29. foreach($teams as $member)
  30. {
  31. if($count > 2) break;
  32. $count ++;
  33. $teamElements[] = div(set::title(zget($users, $member->account)), avatar(set::src(zget($usersAvatar, $member->account)), set::text(zget($member, 'realname', '')), set::size('sm'), set::className('mr-1')));
  34. }
  35. if(count($teams) > 4) $teamElements[] = span('… ');
  36. if(count($teams) > 3)
  37. {
  38. $lastMember = end($teams);
  39. $teamElements[] = div(set::title(zget($users, $lastMember->account)), avatar(set::src(zget($usersAvatar, $lastMember->account)), set::text(zget($lastMember, 'realname', '')), set::size('sm')));
  40. }
  41. return $teamElements;
  42. };
  43. $fnBuildSingleCard = function($kanban) use ($executionActions, $lang, $kanbanview, $memberGroup, $fnGetKanbanTeams)
  44. {
  45. $canActions = (common::hasPriv('execution','edit') or (!empty($executionActions) and isset($executionActions[$kanban->id])));
  46. $teams = zget($memberGroup, $kanban->id, array());
  47. $actionItems = array();
  48. if(common::hasPriv('execution','edit')) $actionItems[] = array('url' => createLink('execution', 'edit', "executionID={$kanban->id}"), 'text' => $lang->kanban->edit, 'icon' => 'edit', 'data-toggle' => 'modal', 'data-size' => 'lg');
  49. if(!empty($executionActions[$kanban->id]))
  50. {
  51. if(in_array('start', $executionActions[$kanban->id])) $actionItems[] = array('url' => createLink('execution', 'start', "executionID={$kanban->id}"), 'text' => $lang->execution->start, 'icon' => 'play', 'data-toggle' => 'modal', 'data-size' => 'lg');
  52. if(in_array('putoff', $executionActions[$kanban->id])) $actionItems[] = array('url' => createLink('execution', 'putoff', "executionID={$kanban->id}"), 'text' => $lang->execution->putoff, 'icon' => 'calendar', 'data-toggle' => 'modal', 'data-size' => 'lg');
  53. if(in_array('suspend', $executionActions[$kanban->id])) $actionItems[] = array('url' => createLink('execution', 'suspend', "executionID={$kanban->id}"), 'text' => $lang->execution->suspend, 'icon' => 'pause', 'data-toggle' => 'modal', 'data-size' => 'lg');
  54. if(in_array('close', $executionActions[$kanban->id])) $actionItems[] = array('url' => createLink('execution', 'close', "executionID={$kanban->id}"), 'text' => $lang->execution->close, 'icon' => 'off', 'data-toggle' => 'modal', 'data-size' => 'lg');
  55. if(in_array('activate', $executionActions[$kanban->id])) $actionItems[] = array('url' => createLink('execution', 'activate', "executionID={$kanban->id}"), 'text' => $lang->execution->activate, 'icon' => 'magic', 'data-toggle' => 'modal', 'data-size' => 'lg');
  56. if(in_array('delete', $executionActions[$kanban->id])) $actionItems[] = array('data-url' => createLink('execution', 'delete', "executionID={$kanban->id}"), 'text' => $lang->execution->delete, 'icon' => 'trash', 'data-request' => 'ajax-submit');
  57. }
  58. return cell
  59. (
  60. setID("kanban-{$kanban->id}"),
  61. setClass('kanban-card flex-none w-1/4'),
  62. set('data-url', createLink('execution', $kanbanview, "kanbanID=$kanban->id")),
  63. div
  64. (
  65. setClass('panel'),
  66. div
  67. (
  68. setClass('panel-heading justify-start'),
  69. set::style(array('position' => 'relative')),
  70. span(setClass("label kanban-status-{$kanban->status} flex-none"), zget($lang->execution->statusList, $kanban->status)),
  71. h::strong(setClass('kanban-name flex-auto text-clip'), set::title($kanban->name), $kanban->name),
  72. $canActions ? div
  73. (
  74. setClass("kanban-actions kanban-actions{$kanban->id}"),
  75. dropdown(set::caret(false), btn
  76. (
  77. setClass('ghost square open-url not-open-url'),
  78. set::icon('ellipsis-v')
  79. ), set::items($actionItems))
  80. ) : null
  81. ),
  82. div
  83. (
  84. setClass('panel-body'),
  85. div(setClass('kanban-desc'), html($kanban->desc)),
  86. row
  87. (
  88. setClass('kanban-footer bottom-6'),
  89. set::style(array('position' => 'relative')),
  90. cell
  91. (
  92. setClass('kanban-members'),
  93. $fnGetKanbanTeams($kanban->id)
  94. ),
  95. cell
  96. (
  97. setClass('kanban-members-count'),
  98. sprintf($lang->project->teamSumCount, count($teams))
  99. ),
  100. cell
  101. (
  102. setClass('kanban-acl'),
  103. span(icon($kanban->acl == 'private' ? 'lock' : 'inherit-space', setClass('mr-1')), zget($lang->execution->kanbanAclList, $kanban->acl, ''))
  104. )
  105. )
  106. )
  107. )
  108. );
  109. };
  110. $fnShowCards = function($kanbanList) use ($fnBuildSingleCard)
  111. {
  112. $cards = array();
  113. foreach($kanbanList as $kanban) $cards[] = $fnBuildSingleCard($kanban);
  114. return row(setClass('kanban-cards flex flex-wrap'), $cards);
  115. };
  116. data('recTotal', count($kanbanList));
  117. featureBar
  118. (
  119. set::current($status),
  120. set::linkParams("status={key}&projectID={$projectID}&orderBy=&productID=0&recTotal=0&recPerPage=10&pageID=1")
  121. );
  122. toolbar
  123. (
  124. hasPriv('execution', 'create') ? item(set(array
  125. (
  126. 'icon' => 'plus',
  127. 'text' => $lang->project->createKanban,
  128. 'class' => "primary create-execution-btn",
  129. 'url' => createLink('execution', 'create', "projectID={$projectID}")
  130. ))) : null
  131. );
  132. $fnEmptyTip = function() use($allExecutionsNum, $lang, $projectID)
  133. {
  134. return div
  135. (
  136. setClass('dtable-empty-tip'),
  137. p
  138. (
  139. $this->app->getClientLang() == 'en' ? setClass( 'flex items-center gap-4') : null,
  140. span(setClass('text-muted'), $lang->execution->noExecution),
  141. (common::hasPriv('execution', 'create') && $allExecutionsNum) ? a(set::href(createLink('execution', 'create', "projectID=$projectID")), setClass('btn primary-pale border-primary'), set('data-app', 'project'), icon('plus'), $lang->project->createKanban) : null
  142. )
  143. );
  144. };
  145. div
  146. (
  147. setClass('dtable'),
  148. empty($kanbanList) ? $fnEmptyTip() : $fnShowCards($kanbanList)
  149. );