From c277bb4e2117c5146ac7226ba4cb64293198b506 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 19 Jun 2023 10:13:20 +0800 Subject: [PATCH] * Refactor, suspend execution page. --- module/execution/control.php | 21 +++---- module/execution/model.php | 46 ++++++--------- module/execution/ui/activate.html.php | 83 +++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 40 deletions(-) create mode 100644 module/execution/ui/activate.html.php diff --git a/module/execution/control.php b/module/execution/control.php index fb3c2f2fc1..3bc404b968 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -72,7 +72,7 @@ class execution extends control * @access public * @return object current object */ - public function commonAction($executionID = 0, $extra = '') + public function commonAction(int $executionID = 0, string $extra = '') { $this->loadModel('product'); @@ -89,7 +89,7 @@ class execution extends control $this->execution->setMenu($executionID, $buildID = 0, $extra); /* Assign. */ - $this->view->hidden = !empty($project->hasProduct) ? "" : 'hide'; + $this->view->hidden = !empty($project->hasProduct) ? '' : 'hide'; $this->view->executions = $this->executions; $this->view->execution = $execution; $this->view->childExecutions = $childExecutions; @@ -2327,7 +2327,7 @@ class execution extends control * @access public * @return void */ - public function activate($executionID, $from = 'execution') + public function activate(int $executionID, string $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -2336,20 +2336,17 @@ class execution extends control if(!empty($_POST)) { $this->execution->activate($executionID); - if(dao::isError()) return print(js::error(dao::getError())); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $project = $this->loadModel('project')->getById($execution->project); if($project->model == 'waterfall' or $project->model == 'waterfallplus') $this->loadModel('programplan')->computeProgress($executionID, 'activate'); $this->executeHooks($executionID); - if(isonlybody() and $from == 'kanban') - { - return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('doing')")); - } - else - { - return print(js::reload('parent.parent')); - } + + $response['closeModal'] = true; + $response['load'] = true; + if($from == 'kanban') $response['callback'] = "changeStatus('doing')"; + return $this->sendSuccess($response); } $newBegin = date('Y-m-d'); diff --git a/module/execution/model.php b/module/execution/model.php index 4752bc1e75..766388fe36 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1262,45 +1262,35 @@ class executionModel extends model $execution = fixer::input('post') ->add('id', $executionID) - ->setDefault('realEnd', '') + ->setDefault('realEnd', null) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('closedBy', '') - ->setDefault('closedDate', '') + ->setDefault('closedDate', null) ->stripTags($this->config->execution->editor->activate['id'], $this->config->allowedTags) - ->remove('comment,readjustTime,readjustTask') + ->remove('comment,readjustTask') ->get(); if(empty($oldExecution->totalConsumed) and helper::isZeroDate($oldExecution->realBegan)) $execution->status = 'wait'; + $begin = $execution->begin; + $end = $execution->end; - if(!$this->post->readjustTime) + if($begin > $end) dao::$errors['end'] = sprintf($this->lang->execution->errorLetterPlan, $end, $begin); + + if($oldExecution->grade > 1) { - unset($execution->begin); - unset($execution->end); - } - - if($this->post->readjustTime) - { - $begin = $execution->begin; - $end = $execution->end; - - if($begin > $end) dao::$errors["message"][] = sprintf($this->lang->execution->errorLetterPlan, $end, $begin); - - if($oldExecution->grade > 1) + $parent = $this->dao->select('begin,end')->from(TABLE_PROJECT)->where('id')->eq($oldExecution->parent)->fetch(); + $parentBegin = $parent->begin; + $parentEnd = $parent->end; + if($begin < $parentBegin) { - $parent = $this->dao->select('begin,end')->from(TABLE_PROJECT)->where('id')->eq($oldExecution->parent)->fetch(); - $parentBegin = $parent->begin; - $parentEnd = $parent->end; - if($begin < $parentBegin) - { - dao::$errors["message"][] = sprintf($this->lang->execution->errorLetterParent, $parentBegin); - } + dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterParent, $parentBegin); + } - if($end > $parentEnd) - { - dao::$errors["message"][] = sprintf($this->lang->execution->errorGreaterParent, $parentEnd); - } + if($end > $parentEnd) + { + dao::$errors['end'] = sprintf($this->lang->execution->errorGreaterParent, $parentEnd); } } @@ -1314,7 +1304,7 @@ class executionModel extends model ->exec(); /* Readjust task. */ - if($this->post->readjustTime and $this->post->readjustTask) + if($this->post->readjustTask) { $beginTimeStamp = strtotime($execution->begin); $tasks = $this->dao->select('id,estStarted,deadline,status')->from(TABLE_TASK) diff --git a/module/execution/ui/activate.html.php b/module/execution/ui/activate.html.php new file mode 100644 index 0000000000..cd41fc7df2 --- /dev/null +++ b/module/execution/ui/activate.html.php @@ -0,0 +1,83 @@ + + * @package execution + * @link https://www.zentao.net + */ +namespace zin; + +$space = common::checkNotCN() ? ' ' : ''; +formPanel +( + set::title($lang->execution->activate . $space . $lang->executionCommon), + set::headingClass('status-heading'), + set::titleClass('form-label .form-grid'), + set::shadow(false), + set::actions(array('submit')), + set::submitBtnText($lang->execution->activate . $space . $lang->executionCommon), + to::headingActions + ( + entityLabel + ( + setClass('my-3 gap-x-3'), + set::level(1), + set::text($execution->name), + set::entityID($execution->id), + set::reverse(true), + ) + ), + formRow + ( + formGroup + ( + set::width('1/2'), + set::label($lang->execution->beginAndEnd), + inputGroup + ( + input + ( + set::control('date'), + set::name('begin'), + set::value($newBegin), + ), + $lang->execution->to, + input + ( + set::control('date'), + set::name('end'), + set::value($newEnd), + ), + ) + ), + formGroup + ( + set::width('1/2'), + setClass('items-center'), + checkbox( + set::name('readjustTask'), + set::text($lang->execution->readjustTask), + set::value(1), + set::rootClass('ml-4'), + ) + ), + ), + formGroup + ( + set::label($lang->comment), + editor + ( + set::name('comment'), + set::rows('6'), + ), + ), +); + +h::hr(set::class('mt-6')); + +history(); +/* ====== Render page ====== */ +render('modalDialog');