task.html.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?php
  2. /**
  3. * The task view file of dashboard module for lite vision of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Wenrui LI <liwenrui@easycorp.ltd>
  8. * @package dashboard
  9. * @version $Id: task.html.php 5101 2013-07-12 00:44:27Z chencongzhi520@gmail.com $
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <?php include $this->app->getModuleRoot() . '/common/view/header.html.php';?>
  14. <?php js::set('mode', $mode);?>
  15. <?php js::set('total', $pager->recTotal);?>
  16. <?php js::set('rawMethod', $app->rawMethod);?>
  17. <div id="mainMenu" class="clearfix">
  18. <div class="btn-toolbar pull-left">
  19. <?php $recTotalLabel = " <span class='label label-light label-badge'>{$pager->recTotal}</span>"; ?>
  20. <?php if($app->rawMethod == 'contribute'):?>
  21. <?php
  22. foreach($lang->my->featureBar[$app->rawMethod]['task'] as $key => $name)
  23. {
  24. echo html::a(inlink($app->rawMethod, "mode=$mode&type=$key"), "<span class='text'>{$name}</span>" . ($type == $key ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == $key ? ' btn-active-text' : '') . "'");
  25. }
  26. ?>
  27. <?php endif;?>
  28. </div>
  29. </div>
  30. <div id="mainContent">
  31. <?php if(empty($tasks)):?>
  32. <div class="table-empty-tip">
  33. <p><span class="text-muted"><?php echo $lang->task->noTask;?></span></p>
  34. </div>
  35. <?php else:?>
  36. <form id='myTaskForm' class="main-table table-task skip-iframe-modal" method="post">
  37. <?php
  38. $canBatchEdit = (common::hasPriv('task', 'batchEdit') and $type == 'assignedTo');
  39. $canBatchClose = (common::hasPriv('task', 'batchClose') and $type != 'closedBy');
  40. $canFinish = common::hasPriv('task', 'finish');
  41. $canClose = common::hasPriv('task', 'close');
  42. $canRecordEstimate = common::hasPriv('task', 'recordEstimate');
  43. $canEdit = common::hasPriv('task', 'edit');
  44. $canBatchCreate = common::hasPriv('task', 'batchCreate');
  45. ?>
  46. <table class="table has-sort-head table-fixed" id='taskTable'>
  47. <?php $vars = "mode=$mode&type=$type&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"; ?>
  48. <thead>
  49. <tr>
  50. <th class="c-id">
  51. <?php if($canBatchEdit or $canBatchClose):?>
  52. <div class="checkbox-primary check-all" title="<?php echo $lang->selectAll?>">
  53. <label></label>
  54. </div>
  55. <?php endif;?>
  56. <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?>
  57. </th>
  58. <th class='c-pri'><?php common::printOrderLink('pri', $orderBy, $vars, $lang->priAB);?></th>
  59. <th class='c-name'><?php common::printOrderLink('name', $orderBy, $vars, $lang->task->name);?></th>
  60. <?php if($config->systemMode == 'ALM'):?>
  61. <th class='c-project'><?php common::printOrderLink('project', $orderBy, $vars, $lang->my->projects);?></th>
  62. <?php endif;?>
  63. <th class='c-project'><?php common::printOrderLink('execution', $orderBy, $vars, $lang->my->executions);?></th>
  64. <?php if($type != 'openedBy'): ?>
  65. <th class='c-user'><?php common::printOrderLink('openedBy', $orderBy, $vars, $lang->openedByAB);?></th>
  66. <?php endif;?>
  67. <th class='c-date text-center'><?php common::printOrderLink('deadline', $orderBy, $vars, $lang->task->deadlineAB);?></th>
  68. <?php if($type != 'assignedTo'): ?>
  69. <th class='c-user'><?php common::printOrderLink('assignedTo', $orderBy, $vars, $lang->task->assignedTo);?></th>
  70. <?php endif;?>
  71. <?php if($type != 'finishedBy'): ?>
  72. <th class='c-user'><?php common::printOrderLink('finishedBy', $orderBy, $vars, $lang->task->finishedBy);?></th>
  73. <?php endif;?>
  74. <th class='c-hours'><?php common::printOrderLink('estimate', $orderBy, $vars, $lang->task->estimateAB);?></th>
  75. <th class='c-hours'><?php common::printOrderLink('consumed', $orderBy, $vars, $lang->task->consumedAB);?></th>
  76. <th class='c-hours'><?php common::printOrderLink('left', $orderBy, $vars, $lang->task->leftAB);?></th>
  77. <th class='c-status'><?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
  78. <th class='c-actions-6'><?php echo $lang->actions;?></th>
  79. </tr>
  80. </thead>
  81. <tbody id='myTaskList'>
  82. <?php foreach($tasks as $task):?>
  83. <?php $canBeChanged = common::canBeChanged('task', $task);?>
  84. <tr data-id='<?php echo $task->id;?>' data-status='<?php echo $task->status?>' data-estimate='<?php echo $task->estimate?>' data-consumed='<?php echo $task->consumed?>' data-left='<?php echo $task->left?>'>
  85. <td class="c-id">
  86. <?php if($canBatchEdit or $canBatchClose):?>
  87. <div class="checkbox-primary">
  88. <input type='checkbox' name='taskIDList[]' value='<?php echo $task->id;?>' <?php if(!$canBeChanged) echo 'disabled';?>/>
  89. <label></label>
  90. </div>
  91. <?php endif;?>
  92. <?php printf('%03d', $task->id);?>
  93. </td>
  94. <td class="c-pri"><span class='label-pri <?php echo 'label-pri-' . $task->pri;?>' title='<?php echo zget($lang->task->priList, $task->pri);?>'><?php echo zget($lang->task->priList, $task->pri);?></span></td>
  95. <td class='c-name <?php if(!empty($task->children)) echo 'has-child';?>' title='<?php echo $task->name?>'>
  96. <?php if(!empty($task->team)) echo '<span class="label label-badge label-light">' . $this->lang->task->multipleAB . '</span> ';?>
  97. <?php
  98. if($task->parent > 0)
  99. {
  100. echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ' . html::a($this->createLink('task', 'view', "taskID=$task->id", '', '', $task->project), $task->parentName . ' / '. $task->name, '', "title='{$task->parentName} / {$task->name}'");
  101. }
  102. else
  103. {
  104. $onlybody = $task->executionType == 'kanban' ? true : '';
  105. $class = $task->executionType == 'kanban' ? 'iframe' : '';
  106. echo html::a($this->createLink('task', 'view', "taskID=$task->id", '', $onlybody, $task->project), $task->name, null, "class='$class' data-width='80%' style='color: $task->color'");
  107. }
  108. ?>
  109. <?php if(!empty($task->children)) echo '<a class="task-toggle" data-id="' . $task->id . '"><i class="icon icon-angle-double-right"></i></a>';?>
  110. </td>
  111. <?php if($config->systemMode == 'ALM'):?>
  112. <td class='c-project' title="<?php echo $task->projectName;?>"><?php echo html::a($this->createLink('project', 'index', "projectID=$task->project"), $task->projectName);?></td>
  113. <?php endif;?>
  114. <td class='c-project' title="<?php echo $task->executionName;?>"><?php echo html::a($this->createLink('execution', 'task', "executionID=$task->execution"), $task->executionName, '');?></td>
  115. <?php if($type != 'openedBy'): ?>
  116. <td class='c-user'><?php echo zget($users, $task->openedBy);?></td>
  117. <?php endif;?>
  118. <td class="text-center <?php echo isset($task->delay) ? 'delayed' : '';?>"><?php if(substr($task->deadline, 0, 4) > 0) echo substr($task->deadline, 5, 6);?></td>
  119. <?php if($type != 'assignedTo'): ?>
  120. <td class="c-assignedTo has-btn"> <?php $this->task->printAssignedHtml($task, $users);?></td>
  121. <?php endif;?>
  122. <?php if($type != 'finishedBy'): ?>
  123. <td class='c-user'><?php echo zget($users, $task->finishedBy);?></td>
  124. <?php endif;?>
  125. <td class='c-hours' title="<?php echo round($task->estimate, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($task->estimate, 1) . $lang->execution->workHourUnit;?></td>
  126. <td class='c-hours' title="<?php echo round($task->consumed, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($task->consumed, 1) . $lang->execution->workHourUnit;?></td>
  127. <td class='c-hours' title="<?php echo round($task->left, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($task->left, 1) . $lang->execution->workHourUnit;?></td>
  128. <td class='c-status'>
  129. <?php $storyChanged = (!empty($task->storyStatus) and $task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion and !in_array($task->status, array('cancel', 'closed')));?>
  130. <?php !empty($storyChanged) ? print("<span class='status-story status-changed'>{$this->lang->my->storyChanged}</span>") : print("<span class='status-task status-{$task->status}'> " . $this->processStatus('task', $task) . "</span>");?>
  131. </td>
  132. <td class='c-actions'>
  133. <?php
  134. if($canBeChanged)
  135. {
  136. if($task->needConfirm)
  137. {
  138. $this->lang->task->confirmStoryChange = $this->lang->confirm;
  139. common::printIcon('task', 'confirmStoryChange', "taskid=$task->id", '', 'list', '', 'hiddenwin', '', '', '', '', $task->project);
  140. }
  141. else
  142. {
  143. $canStart = ($task->status != 'pause' and common::hasPriv('task', 'start'));
  144. $canRestart = ($task->status == 'pause' and common::hasPriv('task', 'restart'));
  145. if($task->status != 'pause') common::printIcon('task', 'start', "taskID=$task->id", $task, 'list', '', '', 'iframe', true, '', '', $task->project);
  146. if($task->status == 'pause') common::printIcon('task', 'restart', "taskID=$task->id", $task, 'list', '', '', 'iframe', true, '', '', $task->project);
  147. common::printIcon('task', 'finish', "taskID=$task->id", $task, 'list', '', '', 'iframe', true, '', '', $task->project);
  148. common::printIcon('task', 'close', "taskID=$task->id", $task, 'list', '', '', 'iframe', true, '', '', $task->project);
  149. if(($canStart or $canRestart or $canFinish or $canClose) and ($canRecordEstimate or $canEdit or $canBatchCreate))
  150. {
  151. echo "<div class='dividing-line'></div>";
  152. }
  153. common::printIcon('task', 'recordEstimate', "taskID=$task->id", $task, 'list', 'time', '', 'iframe', true, '', '', $task->project);
  154. common::printIcon('task', 'edit', "taskID=$task->id", $task, 'list', '', '', 'iframe', true, "data-width='95%'", '', $task->project);
  155. }
  156. }
  157. ?>
  158. </td>
  159. </tr>
  160. <?php if(!empty($task->children)):?>
  161. <?php $i = 0;?>
  162. <?php foreach($task->children as $key => $child):?>
  163. <?php $class = $i == 0 ? ' table-child-top' : '';?>
  164. <?php $class .= ($i + 1 == count($task->children)) ? ' table-child-bottom' : '';?>
  165. <tr class='table-children<?php echo $class;?> parent-<?php echo $task->id;?>' data-id='<?php echo $child->id?>' data-status='<?php echo $child->status?>' data-estimate='<?php echo $child->estimate?>' data-consumed='<?php echo $child->consumed?>' data-left='<?php echo $child->left?>'>
  166. <td class="c-id">
  167. <?php if($canBatchEdit or $canBatchClose):?>
  168. <div class="checkbox-primary">
  169. <input type='checkbox' name='taskIDList[]' value='<?php echo $child->id;?>' <?php if(!$canBeChanged) echo 'disabled';?>/>
  170. <label></label>
  171. </div>
  172. <?php endif;?>
  173. <?php printf('%03d', $child->id);?>
  174. </td>
  175. <td class="c-pri"><span class='label-pri <?php echo 'label-pri-' . $child->pri;?>' title='<?php echo zget($lang->task->priList, $child->pri);?>'><?php echo zget($lang->task->priList, $child->pri);?></span></td>
  176. <td class='c-name' title='<?php echo $child->name?>'>
  177. <?php if($child->parent > 0) echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ';?>
  178. <?php echo html::a($this->createLink('task', 'view', "taskID=$child->id", '', '', $child->project), $child->name, null, "style='color: $child->color'");?>
  179. </td>
  180. <?php if($config->systemMode == 'ALM'):?>
  181. <td class='c-project' title="<?php echo $child->projectName;?>"><?php echo html::a($this->createLink('project', 'view', "projectID=$child->project"), $child->projectName);?></td>
  182. <?php endif;?>
  183. <td class='c-project' title="<?php echo $child->projectName;?>"><?php echo html::a($this->createLink('execution', 'task', "executionID=$child->project"), $child->executionName, '');?></td>
  184. <?php if($type != 'openedBy'): ?>
  185. <td class='c-user'><?php echo zget($users, $child->openedBy);?></td>
  186. <?php endif;?>
  187. <td class="text-center <?php echo isset($child->delay) ? 'delayed' : '';?>"><?php if(substr($child->deadline, 0, 4) > 0) echo substr($child->deadline, 5, 6);?></td>
  188. <?php if($type != 'assignedTo'): ?>
  189. <td class="c-assignedTo has-btn"> <?php $this->task->printAssignedHtml($child, $users);?></td>
  190. <?php endif;?>
  191. <?php if($type != 'finishedBy'): ?>
  192. <td class='c-user'><?php echo zget($users, $child->finishedBy);?></td>
  193. <?php endif;?>
  194. <td class='c-hours' title="<?php echo round($child->estimate, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($child->estimate, 1) . ' ' . $lang->execution->workHourUnit;?></td>
  195. <td class='c-hours' title="<?php echo round($child->consumed, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($child->consumed, 1) . ' ' . $lang->execution->workHourUnit;?></td>
  196. <td class='c-hours' title="<?php echo round($child->left, 1) . ' ' . $lang->execution->workHour;?>"><?php echo round($child->left, 1) . ' ' . $lang->execution->workHourUnit;?></td>
  197. <td class='c-status'>
  198. <?php $storyChanged = (!empty($child->storyStatus) and $child->storyStatus == 'active' and $child->latestStoryVersion > $child->storyVersion and !in_array($child->status, array('cancel', 'closed')));?>
  199. <?php !empty($storyChanged) ? print("<span class='status-story status-changed'>{$this->lang->my->storyChanged}</span>") : print("<span class='status-task status-{$child->status}'> " . $this->processStatus('task', $child) . "</span>");?>
  200. </td>
  201. <td class='c-actions'>
  202. <?php
  203. if($canBeChanged)
  204. {
  205. if($child->needConfirm)
  206. {
  207. $this->lang->task->confirmStoryChange = $this->lang->confirm;
  208. common::printIcon('task', 'confirmStoryChange', "taskid=$child->id", '', 'list', '', 'hiddenwin', '', '', '', '', $child->project);
  209. }
  210. else
  211. {
  212. $canStart = ($child->status != 'pause' and common::hasPriv('task', 'start'));
  213. $canRestart = ($child->status == 'pause' and common::hasPriv('task', 'restart'));
  214. if($child->status != 'pause') common::printIcon('task', 'start', "taskID=$child->id", $child, 'list', '', '', 'iframe', true, '', '', $child->project);
  215. if($child->status == 'pause') common::printIcon('task', 'restart', "taskID=$child->id", $child, 'list', '', '', 'iframe', true, '', '', $child->project);
  216. common::printIcon('task', 'finish', "taskID=$child->id", $child, 'list', '', '', 'iframe', true, '', '', $child->project);
  217. common::printIcon('task', 'close', "taskID=$child->id", $child, 'list', '', '', 'iframe', true, '', '', $child->project);
  218. if(($canStart or $canRestart or $canFinish or $canClose) and ($canRecordEstimate or $canEdit or $canBatchCreate))
  219. {
  220. echo "<div class='dividing-line'></div>";
  221. }
  222. common::printIcon('task', 'recordEstimate', "taskID=$child->id", $child, 'list', 'time', '', 'iframe', true, '', '', $child->project);
  223. common::printIcon('task', 'edit', "taskID=$child->id", $child, 'list', '', '', '', '', '', '', $child->project);
  224. common::printIcon('task', 'batchCreate', "executionID=$child->execution&storyID=$child->story&moduleID=$child->module&taskID=$child->id&iframe=true", $child, 'list', 'split', '', 'iframe', true, '', $this->lang->task->children, $child->project);
  225. }
  226. }
  227. ?>
  228. </td>
  229. </tr>
  230. <?php $i ++;?>
  231. <?php endforeach;?>
  232. <?php endif;?>
  233. <?php endforeach;?>
  234. </tbody>
  235. </table>
  236. <div class="table-footer">
  237. <?php if($canBatchClose or $canBatchEdit):?>
  238. <div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
  239. <?php endif;?>
  240. <div class="table-actions btn-toolbar">
  241. <?php
  242. if($canBatchEdit)
  243. {
  244. $actionLink = $this->createLink('task', 'batchEdit');
  245. $misc = "data-form-action='$actionLink'";
  246. echo html::commonButton($lang->edit, $misc);
  247. }
  248. if($canBatchClose)
  249. {
  250. $actionLink = $this->createLink('task', 'batchClose', null, '', '', $task->project);
  251. echo html::commonButton($lang->close, "onclick=\"setFormAction('$actionLink', 'hiddenwin')\"");
  252. }
  253. ?>
  254. </div>
  255. <div class="table-statistic"><?php echo $summary;?></div>
  256. <?php $pager->show('right', 'pagerjs');?>
  257. </div>
  258. </form>
  259. <?php endif;?>
  260. </div>
  261. <?php js::set('tasks', $tasks);?>
  262. <script>
  263. $(function()
  264. {
  265. /* Update table summary text. */
  266. var checkedSummary = '<?php echo $lang->execution->checkedSummary?>';
  267. var pageSummary = '<?php echo $lang->execution->pageSummary?>';
  268. $('#myTaskForm').table(
  269. {
  270. hot: true,
  271. replaceId: 'myTaskList',
  272. statisticCreator: function(table)
  273. {
  274. var $table = table.getTable();
  275. var $checkedRows = $table.find(table.isDataTable ? '.datatable-row-left.checked' : 'tbody>tr.checked');
  276. var $originTable = table.isDataTable ? table.$.find('.datatable-origin') : null;
  277. var checkedTotal = $checkedRows.length;
  278. var $rows = checkedTotal ? $checkedRows : $table.find(table.isDataTable ? '.datatable-rows .datatable-row-left' : 'tbody>tr');
  279. var checkedWait = 0;
  280. var checkedDoing = 0;
  281. var checkedEstimate = 0;
  282. var checkedConsumed = 0;
  283. var checkedLeft = 0;
  284. var taskIdList = [];
  285. $rows.each(function()
  286. {
  287. var $row = $(this);
  288. if ($originTable)
  289. {
  290. $row = $originTable.find('tbody>tr[data-id="' + $row.data('id') + '"]');
  291. }
  292. var data = $row.data();
  293. taskIdList.push(data.id);
  294. var status = data.status;
  295. if(status === 'wait') checkedWait++;
  296. if(status === 'doing') checkedDoing++;
  297. var canStatistics = false;
  298. if(!$row.hasClass('table-children'))
  299. {
  300. canStatistics = true;
  301. }
  302. else
  303. {
  304. var parentID = 0;
  305. var classes = $row.attr('class').split(' ');
  306. for(i in classes)
  307. {
  308. if(classes[i].indexOf('parent-') >= 0) parentID = classes[i].replace('parent-', '');
  309. }
  310. if(parentID && taskIdList.indexOf(parseInt(parentID)) < 0) canStatistics = true;
  311. }
  312. if(canStatistics)
  313. {
  314. checkedEstimate += Number(data.estimate);
  315. checkedConsumed += Number(data.consumed);
  316. if(status != 'cancel' && status != 'closed') checkedLeft += Number(data.left);
  317. }
  318. });
  319. return (checkedTotal ? checkedSummary : pageSummary).replace('%total%', $rows.length).replace('%wait%', checkedWait)
  320. .replace('%doing%', checkedDoing)
  321. .replace('%estimate%', checkedEstimate.toFixed(1))
  322. .replace('%consumed%', checkedConsumed.toFixed(1))
  323. .replace('%left%', checkedLeft.toFixed(1));
  324. }
  325. })
  326. });
  327. </script>
  328. <?php include $this->app->getModuleRoot() . '/common/view/footer.html.php';?>