From 2c176439d3b4f5c35ae9fd6f7a6c3e073a0e79fe Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 15 Jun 2022 15:09:34 +0800 Subject: [PATCH 1/5] * Finish task #57095. --- module/common/view/datatable.fix.html.php | 6 + module/datatable/control.php | 12 + module/datatable/model.php | 2 +- module/execution/config.php | 108 ++++++++ module/execution/control.php | 13 +- module/execution/css/all.css | 13 +- module/execution/js/all.js | 22 ++ module/execution/model.php | 164 ++++++++++++ module/execution/view/all.html.php | 302 ++++++---------------- 9 files changed, 407 insertions(+), 235 deletions(-) diff --git a/module/common/view/datatable.fix.html.php b/module/common/view/datatable.fix.html.php index 48a26082c2..e13d43ca25 100644 --- a/module/common/view/datatable.fix.html.php +++ b/module/common/view/datatable.fix.html.php @@ -24,6 +24,12 @@ $(function() { $dropmenu.append("
  • ' data-toggle='modal' data-type='ajax'>datatable->custom?>
  • "); } + else if(typeof(from) != 'undefined') + { + + + $dropmenu.append("
  • datatable->custom?>
  • "); + } else { $dropmenu.append("
  • datatable->custom?>
  • "); diff --git a/module/datatable/control.php b/module/datatable/control.php index 2d52476456..f365b7e8b1 100644 --- a/module/datatable/control.php +++ b/module/datatable/control.php @@ -97,6 +97,18 @@ class datatable extends control unset($cols['caseCount']); } + if($module == 'execution' and $method == 'all') + { + if($extra == 'execution' or $extra == 'project') + { + unset($cols['percent']); + unset($cols['attribute']); + unset($cols['actions']); + } + + if($extra == 'project' or $extra == 'stage') unset($cols['project']); + } + $this->view->cols = $cols; $this->view->setting = $setting; $this->display(); diff --git a/module/datatable/model.php b/module/datatable/model.php index 4e2e6993b2..e69834e266 100644 --- a/module/datatable/model.php +++ b/module/datatable/model.php @@ -158,7 +158,7 @@ class datatableModel extends model $title = (isset($col->name) and $col->name) ? "title='$col->name'" : $title; if($id == 'id' and (int)$width < 90) $width = '90px'; $align = $id == 'actions' ? 'text-center' : ''; - $align = in_array($id, array('budget', 'teamCount', 'estimate', 'consume')) ? 'text-right' : $align; + $align = in_array($id, array('budget', 'teamCount', 'estimate', 'consume', 'consumed', 'left')) ? 'text-right' : $align; $style = ''; $data = ''; diff --git a/module/execution/config.php b/module/execution/config.php index 6467b32538..d8f5428dc9 100644 --- a/module/execution/config.php +++ b/module/execution/config.php @@ -137,3 +137,111 @@ $config->execution->gantt->linkType['end']['begin'] = 0; $config->execution->gantt->linkType['begin']['begin'] = 1; $config->execution->gantt->linkType['end']['end'] = 2; $config->execution->gantt->linkType['begin']['end'] = 3; + +$config->execution->datatable = new stdclass(); +$config->execution->datatable->defaultField = array('id', 'name', 'code', 'project', 'PM', 'status', 'progress', 'begin', 'end', 'estimate', 'consumed', 'left', 'burn'); + +$config->execution->datatable->fieldList['id']['title'] = 'idAB'; +$config->execution->datatable->fieldList['id']['fixed'] = 'left'; +$config->execution->datatable->fieldList['id']['width'] = '70'; +$config->execution->datatable->fieldList['id']['required'] = 'yes'; + +$config->execution->datatable->fieldList['name']['title'] = 'name'; +$config->execution->datatable->fieldList['name']['fixed'] = 'left'; +$config->execution->datatable->fieldList['name']['width'] = 'auto'; +$config->execution->datatable->fieldList['name']['required'] = 'yes'; + +$config->execution->datatable->fieldList['code']['title'] = 'code'; +$config->execution->datatable->fieldList['code']['fixed'] = 'no'; +$config->execution->datatable->fieldList['code']['width'] = '90'; +$config->execution->datatable->fieldList['code']['required'] = 'no'; + +$config->execution->datatable->fieldList['project']['title'] = 'project'; +$config->execution->datatable->fieldList['project']['fixed'] = 'no'; +$config->execution->datatable->fieldList['project']['width'] = '100'; +$config->execution->datatable->fieldList['project']['required'] = 'no'; + +$config->execution->datatable->fieldList['PM']['title'] = 'owner'; +$config->execution->datatable->fieldList['PM']['fixed'] = 'no'; +$config->execution->datatable->fieldList['PM']['width'] = '70'; +$config->execution->datatable->fieldList['PM']['required'] = 'no'; + +$config->execution->datatable->fieldList['status']['title'] = 'status'; +$config->execution->datatable->fieldList['status']['fixed'] = 'no'; +$config->execution->datatable->fieldList['status']['width'] = '80'; +$config->execution->datatable->fieldList['status']['required'] = 'no'; + +$config->execution->datatable->fieldList['progress']['title'] = 'progress'; +$config->execution->datatable->fieldList['progress']['fixed'] = 'no'; +$config->execution->datatable->fieldList['progress']['width'] = '40'; +$config->execution->datatable->fieldList['progress']['required'] = 'no'; +$config->execution->datatable->fieldList['progress']['sort'] = 'no'; + +$config->execution->datatable->fieldList['percent']['title'] = 'percent'; +$config->execution->datatable->fieldList['percent']['fixed'] = 'no'; +$config->execution->datatable->fieldList['percent']['width'] = '80'; +$config->execution->datatable->fieldList['percent']['required'] = 'no'; +$config->execution->datatable->fieldList['percent']['sort'] = 'no'; + +$config->execution->datatable->fieldList['attribute']['title'] = 'attribute'; +$config->execution->datatable->fieldList['attribute']['fixed'] = 'no'; +$config->execution->datatable->fieldList['attribute']['width'] = '80'; +$config->execution->datatable->fieldList['attribute']['required'] = 'no'; +$config->execution->datatable->fieldList['attribute']['sort'] = 'no'; + +$config->execution->datatable->fieldList['openedDate']['title'] = 'openedDate'; +$config->execution->datatable->fieldList['openedDate']['fixed'] = 'no'; +$config->execution->datatable->fieldList['openedDate']['width'] = '85'; +$config->execution->datatable->fieldList['openedDate']['required'] = 'no'; + +$config->execution->datatable->fieldList['begin']['title'] = 'begin'; +$config->execution->datatable->fieldList['begin']['fixed'] = 'no'; +$config->execution->datatable->fieldList['begin']['width'] = '85'; +$config->execution->datatable->fieldList['begin']['required'] = 'no'; + +$config->execution->datatable->fieldList['end']['title'] = 'end'; +$config->execution->datatable->fieldList['end']['fixed'] = 'no'; +$config->execution->datatable->fieldList['end']['width'] = '85'; +$config->execution->datatable->fieldList['end']['required'] = 'no'; + +$config->execution->datatable->fieldList['realBegan']['title'] = 'realBegan'; +$config->execution->datatable->fieldList['realBegan']['fixed'] = 'no'; +$config->execution->datatable->fieldList['realBegan']['width'] = '90'; +$config->execution->datatable->fieldList['realBegan']['required'] = 'no'; +$config->execution->datatable->fieldList['realBegan']['sort'] = 'no'; + +$config->execution->datatable->fieldList['realEnd']['title'] = 'realEnd'; +$config->execution->datatable->fieldList['realEnd']['fixed'] = 'no'; +$config->execution->datatable->fieldList['realEnd']['width'] = '90'; +$config->execution->datatable->fieldList['realEnd']['required'] = 'no'; +$config->execution->datatable->fieldList['realEnd']['sort'] = 'no'; + +$config->execution->datatable->fieldList['estimate']['title'] = 'estimate'; +$config->execution->datatable->fieldList['estimate']['fixed'] = 'no'; +$config->execution->datatable->fieldList['estimate']['width'] = '70'; +$config->execution->datatable->fieldList['estimate']['required'] = 'no'; +$config->execution->datatable->fieldList['estimate']['sort'] = 'no'; + +$config->execution->datatable->fieldList['consumed']['title'] = 'consumed'; +$config->execution->datatable->fieldList['consumed']['fixed'] = 'no'; +$config->execution->datatable->fieldList['consumed']['width'] = '70'; +$config->execution->datatable->fieldList['consumed']['required'] = 'no'; +$config->execution->datatable->fieldList['consumed']['sort'] = 'no'; + +$config->execution->datatable->fieldList['left']['title'] = 'left'; +$config->execution->datatable->fieldList['left']['fixed'] = 'no'; +$config->execution->datatable->fieldList['left']['width'] = '70'; +$config->execution->datatable->fieldList['left']['required'] = 'no'; +$config->execution->datatable->fieldList['left']['sort'] = 'no'; + +$config->execution->datatable->fieldList['burn']['title'] = 'burn'; +$config->execution->datatable->fieldList['burn']['fixed'] = 'no'; +$config->execution->datatable->fieldList['burn']['width'] = '80'; +$config->execution->datatable->fieldList['burn']['required'] = 'no'; +$config->execution->datatable->fieldList['burn']['sort'] = 'no'; + +$config->execution->datatable->fieldList['actions']['title'] = 'actions'; +$config->execution->datatable->fieldList['actions']['fixed'] = 'right'; +$config->execution->datatable->fieldList['actions']['width'] = '180'; +$config->execution->datatable->fieldList['actions']['required'] = 'yes'; +$config->execution->datatable->fieldList['actions']['sort'] = 'no'; diff --git a/module/execution/control.php b/module/execution/control.php index c456b62e4a..7c7337064e 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3394,6 +3394,7 @@ class execution extends control $this->app->loadLang('product'); $this->app->loadLang('stage'); $this->app->loadLang('programplan'); + $this->loadModel('datatable'); $from = $this->app->tab; if($from == 'execution') $this->session->set('executionList', $this->app->getURI(true), 'execution'); @@ -3443,6 +3444,16 @@ class execution extends control $parents = array(); if($parentIdList) $parents = $this->execution->getByIdList($parentIdList); + $isStage = (isset($project->model) and $project->model == 'waterfall') ? true : false; + if($isStage) + { + $this->config->execution->datatable->defaultField = array('id', 'name', 'PM', 'status', 'progress', 'percent', 'attribute', 'begin', 'end', 'realBegan', 'realEnd', 'actions'); + } + elseif($this->app->tab == 'project') + { + $this->config->execution->datatable->defaultField = array('id', 'name', 'code', 'PM', 'status', 'progress', 'begin', 'end', 'estimate', 'consumed', 'left', 'burn'); + } + $this->view->executionStats = $executionStats; $this->view->productList = $this->loadModel('product')->getProductPairsByProject($projectID); $this->view->productID = $productID; @@ -3454,7 +3465,7 @@ class execution extends control $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->status = $status; $this->view->from = $from; - $this->view->isStage = (isset($project->model) and $project->model == 'waterfall') ? true : false; + $this->view->isStage = $isStage; $this->display(); } diff --git a/module/execution/css/all.css b/module/execution/css/all.css index 94fb295ae9..77caf18d70 100644 --- a/module/execution/css/all.css +++ b/module/execution/css/all.css @@ -1,3 +1,4 @@ +body {margin-bottom: 25px;} #product_chosen .chosen-single {width: 180px;} .table-children {border-left: 2px solid #cbd0db; border-right: 2px solid #cbd0db;} @@ -12,21 +13,19 @@ .table th.hours {padding-right: 8px !important;} .main-table tbody > tr.table-children > td:first-child::before {width: 3px;} td.hours {text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} -td.flex {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center;} +td.flex {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center; margin-bottom: -1px;} td.flex span.label-badge {margin-left: 5px; min-width: 50px;} td.flex span.label-badge.label-light {min-width: 22px;} td.flex span.project-type-label {margin-left: 5px; min-width: 36px;} @-moz-document url-prefix() {.main-table tbody > tr.table-children > td:first-child::before {width: 4px;}} -.c-status, .c-date, .c-percent, .c-attribute, .c-end, .c-begin {width: 80px;} -.c-estimate, .c-consumed, .c-left, .c-pm {width: 70px;} -.c-progress {width: 40px;} -.c-burn {width: 60px;} -.c-code, .c-percent, .c-realBegan, .c-realEnd{width: 90px;} .c-name > span {margin-right: 2px;} td.flex span.project-type-label {min-width: 40px;} .label-children {min-width:22px !important;} .c-name > a, .table-children .text-left > a {padding-left: 5px;} .has-child > span {margin-right: 5px;} -.c-name > .text-ellipsis {text-overflow: clip} +.c-name > .text-ellipsis {text-overflow: clip;} + +.c-project{text-overflow: unset !important;} +canvas {height: 30px;} diff --git a/module/execution/js/all.js b/module/execution/js/all.js index be30acdd24..f9c4eb24c9 100644 --- a/module/execution/js/all.js +++ b/module/execution/js/all.js @@ -6,6 +6,28 @@ $(function() for(i = 0; i < data.list.length; i++) list += $(data.list[i].item).attr('data-id') + ','; $.post(createLink('execution', 'updateOrder'), {'executions' : list, 'orderBy' : orderBy}); }); + + var nameWidth = $('#executionsForm thead th.c-name').width(); + if(nameWidth < 150 && !useDatatable) $('#executionsForm thead th.c-name').css('width', '150px'); + + toggleFold('#executionsForm', unfoldExecutions, projectID, 'execution'); + + $('.table td.has-child > .plan-toggle').each(function() + { + var fold = $(this).hasClass('collapsed'); + var parentID = $(this).closest('tr').attr('data-id'); + if(fold) $('.parent-' + parentID).hide(); + if(!fold) $('.parent-' + parentID).show(); + }); + + if(useDatatable) + { + $('.table td.has-child > .plan-toggle').click(function() + { + var parentID = $(this).closest('tr').attr('data-id'); + $('.parent-' + parentID).toggle(); + }); + } }); function byProduct(productID, projectID, status) diff --git a/module/execution/model.php b/module/execution/model.php index bb760866c5..c34d5b6910 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4143,4 +4143,168 @@ class executionModel extends model return $menu; } + + /** + * printCell + * + * @param object $col + * @param object $execution + * @param array $users + * @param string $mode + * @param bool $isStage + * @param int $productID + * @param bool $child + * @access public + * @return void + */ + public function printCell($col, $execution, $users, $mode = 'datatable', $isStage = false, $productID = 0, $child = false) + { + $canBatchEdit = common::hasPriv('execution', 'batchEdit'); + $id = $col->id; + $onlyChildStage = ($execution->grade == 2 and $execution->project != $execution->parent); + + if(!$isStage and $col->id == 'actions') return; + if(($this->config->systemMode == 'classic' or ($this->config->systemMode == 'new' and $this->app->tab != 'execution')) and $col->id == 'project') return; + + if($col->show) + { + $class = "c-{$id}"; + + if($id == 'id') $class .= ' cell-id'; + if($id == 'name') $class .= ' text-left flex'; + if($id == 'code') $class .= ' text-left'; + if($id == 'project') $class .= ' text-left c-name'; + if($id == 'status') $class .= ' text-center'; + if($id == 'actions') $class .= ' text-center'; + + if($id == 'name' and !$child) $class .= ' sort-handler'; + if(in_array($id, array('estimate', 'consumed', 'left'))) $class .= ' hours'; + + $title = ''; + if($id == 'name') + { + $title = " title='{$execution->name}'"; + if(!empty($execution->children)) $class .= ' has-child'; + } + + if($id == 'project') $title = " title='{$execution->projectName}'"; + + if($id == 'status') + { + $executionStatus = $this->processStatus('execution', $execution); + $title = " title='{$executionStatus}'"; + } + + if(in_array($id, array('estimate', 'consumed', 'left'))) + { + $totalTitle = 'total' . ucfirst($id); + $title .= $execution->hours->{$totalTitle} . $this->lang->execution->workHour; + } + + echo ""; + if($id == 'burn') + { + $burnValue = join(',', $execution->burns); + echo ""; + } + + switch($id) + { + case 'id': + if($canBatchEdit) + { + echo "
    "; + } + echo printf('%03d', $execution->id); + break; + case 'name': + $label = $execution->type == 'stage' ? 'label-warning' : 'label-info'; + $executionLink = $execution->projectModel == 'kanban' ? html::a(helper::createLink('execution', 'kanban', 'executionID=' . $execution->id), $execution->name, '', "class='text-ellipsis'") : html::a(helper::createLink('execution', 'task', 'execution=' . $execution->id), $execution->name, '', "class='text-ellipsis'"); + if(!$onlyChildStage) echo "{$this->lang->execution->typeList[$execution->type]}"; + if($onlyChildStage) echo "{$this->lang->programplan->childrenAB} "; + echo !empty($execution->children) ? "$execution->name" : $executionLink; + if(isset($execution->delay)) echo "{$this->lang->execution->delayed} "; + if(!empty($execution->children)) + { + echo ""; + } + break; + case 'code': + echo $execution->code; + break; + case 'project': + echo "{$execution->projectName}"; + break; + case 'PM': + echo zget($users, $execution->PM); + break; + case 'status': + echo "$executionStatus"; + break; + case 'progress': + echo html::ring($execution->hours->progress); + break; + case 'percent': + echo $execution->percent . '%'; + break; + case 'attribute': + echo zget($this->lang->stage->typeList, $execution->attribute, ''); + break; + case 'begin': + echo helper::isZeroDate($execution->begin) ? '' : $execution->begin; + break; + case 'end': + echo helper::isZeroDate($execution->end) ? '' : $execution->end; + break; + case 'realBegan': + echo helper::isZeroDate($execution->realBegan) ? '' : $execution->realBegan; + break; + case 'realEnd': + echo helper::isZeroDate($execution->realEnd) ? '' : $execution->realEnd; + break; + case 'estimate': + echo $execution->hours->totalEstimate . $this->lang->execution->workHourUnit; + break; + case 'consumed': + echo $execution->hours->totalConsumed . $this->lang->execution->workHourUnit; + break; + case 'left': + echo $execution->hours->totalLeft . $this->lang->execution->workHourUnit; + break; + case 'actions': + common::printIcon('execution', 'start', "executionID={$execution->id}", $execution, 'list', '', '', 'iframe', true); + $class = !empty($execution->children) ? 'disabled' : ''; + common::printIcon('task', 'create', "executionID={$execution->id}", $execution, 'list', '', '', $class, false, "data-app='execution'"); + + if($execution->grade == 1 && $this->loadModel('programplan')->isCreateTask($execution->id)) + { + common::printIcon('programplan', 'create', "program={$execution->parent}&productID=$productID&planID=$execution->id", $execution, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan); + } + else + { + $disabled = ($execution->grade == 2) ? ' disabled' : ''; + echo common::hasPriv('programplan', 'create') ? html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"') : ''; + } + + common::printIcon('programplan', 'edit', "stageID=$execution->id&projectID=$execution->project", $execution, 'list', '', '', 'iframe', true); + + $disabled = !empty($execution->children) ? ' disabled' : ''; + if($execution->status != 'closed' and common::hasPriv('execution', 'close', $execution)) + { + common::printIcon('execution', 'close', "stageID=$execution->id", $execution, 'list', 'off', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->close); + } + elseif($execution->status == 'closed' and common::hasPriv('execution', 'activate', $execution)) + { + common::printIcon('execution', 'activate', "stageID=$execution->id", $execution, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate); + } + + if(common::hasPriv('execution', 'delete', $execution)) + { + common::printIcon('execution', 'delete', "stageID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete); + } + break; + } + echo ''; + } + } } diff --git a/module/execution/view/all.html.php b/module/execution/view/all.html.php index 8625ccaa59..ccabe39eed 100644 --- a/module/execution/view/all.html.php +++ b/module/execution/view/all.html.php @@ -11,6 +11,19 @@ ?> + +datatable->$datatableId->mode) and $config->datatable->$datatableId->mode == 'datatable');?> + + + +execution->all->unfoldExecutions) ? json_decode($config->execution->all->unfoldExecutions, true) : array(); +$unfoldExecutions = zget($unfoldExecutions, $projectID, array()); +js::set('unfoldExecutions', $unfoldExecutions); +js::set('unfoldAll', $lang->execution->treeLevel['all']); +js::set('foldAll', $lang->execution->treeLevel['root']); +?>