From 8089ffe9a678fd5a2e3097fd69fd35e5ae3dc328 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Fri, 18 Dec 2020 16:18:41 +0800 Subject: [PATCH] * Adjust code. --- module/group/lang/resource.php | 2 -- module/product/model.php | 2 ++ module/programplan/control.php | 31 ++----------------------------- module/programplan/model.php | 27 +++++++++++++++++---------- 4 files changed, 21 insertions(+), 41 deletions(-) diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index aa999809e6..dfe0967401 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -689,12 +689,10 @@ $lang->resource->programplan = new stdclass(); $lang->resource->programplan->browse = 'browse'; $lang->resource->programplan->create = 'create'; $lang->resource->programplan->edit = 'edit'; -$lang->resource->programplan->delete = 'delete'; $lang->programplan->methodOrder[5] = 'browse'; $lang->programplan->methodOrder[10] = 'create'; $lang->programplan->methodOrder[15] = 'edit'; -$lang->programplan->methodOrder[20] = 'delete'; /* Task. */ $lang->resource->task = new stdclass(); diff --git a/module/product/model.php b/module/product/model.php index eeb4b47afd..a2aacb254f 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1405,6 +1405,8 @@ class productModel extends model */ public function replaceStoryConcept($productID = 0) { + if($this->cookie->lastProduct) return false; + $this->loadModel('custom'); $product = $this->getByID($productID); $lastProduct = $this->getByID($this->cookie->lastProduct); diff --git a/module/programplan/control.php b/module/programplan/control.php index f546187efb..3ca46d2b1a 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -152,10 +152,11 @@ class programplan extends control if($_POST) { $changes = $this->programplan->update($planID, $projectID); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); if($changes) { - $actionID = $this->loadModel('action')->create('programplan', $planID, 'edited'); + $actionID = $this->loadModel('action')->create('execution', $planID, 'edited'); $this->action->logHistory($actionID, $changes); } $locate = isonlybody() ? 'parent' : inlink('browse', "program=$plan->program&type=lists"); @@ -172,34 +173,6 @@ class programplan extends control $this->display(); } - /** - * Delete a project plan. - * - * @param int $planID - * @param string $confirm - * @access public - * @return void - */ - public function delete($planID, $confirm = 'no') - { - if($confirm == 'no') - { - die(js::confirm($this->lang->programplan->confirmDelete, $this->createLink('programplan', 'delete', "planID=$planID&confirm=yes"))); - } - else - { - $response['result'] = 'success'; - $response['message'] = ''; - $this->programplan->delete(TABLE_PROJECT, $planID); - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - } - $this->send($response); - } - } - /** * Save custom settings via ajax. * diff --git a/module/programplan/model.php b/module/programplan/model.php index 5e2c0a317b..4b9184addb 100644 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -470,6 +470,7 @@ class programplanModel extends model if($totalPercent > 100) return dao::$errors['message'][] = $this->lang->programplan->error->percentOver; + $this->loadModel('action'); $this->loadModel('user'); $this->loadModel('project'); $this->app->loadLang('doc'); @@ -485,27 +486,27 @@ class programplanModel extends model $data->days = helper::diffDate($data->end, $data->begin) + 1; if($data->id) { - $planID = $data->id; + $stageID = $data->id; unset($data->id); - $oldPlan = $this->getByID($planID); - $planChanged = ($oldPlan->name != $data->name || $oldPlan->milestone != $data->milestone || $oldPlan->begin != $data->begin || $oldPlan->end != $data->end); + $oldStage = $this->getByID($stageID); + $planChanged = ($oldStage->name != $data->name || $oldStage->milestone != $data->milestone || $oldStage->begin != $data->begin || $oldStage->end != $data->end); - if($planChanged) $data->version = $oldPlan->version + 1; + if($planChanged) $data->version = $oldStage->version + 1; $this->dao->update(TABLE_PROJECT)->data($data) ->autoCheck() ->batchCheck($this->config->programplan->edit->requiredFields, 'notempty') ->checkIF($plan->percent != '', 'percent', 'float') - ->where('id')->eq($planID) + ->where('id')->eq($stageID) ->exec(); - if($data->acl != 'open') $this->user->updateUserView($planID, 'sprint'); + if($data->acl != 'open') $this->user->updateUserView($stageID, 'sprint'); /* Record version change information. */ if($planChanged) { $spec = new stdclass(); - $spec->project = $planID; + $spec->project = $stageID; $spec->version = $data->version; $spec->name = $data->name; $spec->milestone = $data->milestone; @@ -513,6 +514,10 @@ class programplanModel extends model $spec->end = $data->end; $this->dao->insert(TABLE_PROJECTSPEC)->data($spec)->exec(); } + + $changes = common::createChanges($oldStage, $data); + $actionID = $this->action->create('execution', $stageID, 'edited'); + $this->action->logHistory($actionID, $changes); } else { @@ -574,6 +579,8 @@ class programplanModel extends model $spec->begin = $data->begin; $spec->end = $data->end; $this->dao->insert(TABLE_PROJECTSPEC)->data($spec)->exec(); + + $this->action->create('execution', $stageID, 'opened', '', join(',', $_POST['products'])); } } @@ -801,11 +808,11 @@ class programplanModel extends model } common::printIcon('programplan', 'edit', "planID=$plan->id&projectID=$projectID", $plan, 'list', '', '', 'iframe', true); + $disabled = !empty($plan->children) ? ' disabled' : ''; - if(common::hasPriv('programplan', 'delete', $plan)) + if(common::hasPriv('project', 'delete', $plan)) { - $deleteURL = helper::createLink('programplan', 'delete', "planID=$plan->id&confirm=yes"); - echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"programplanForm\", confirmDelete)", '', '', "title='{$this->lang->programplan->delete}' class='btn $disabled'"); + common::printIcon('project', 'delete', "planID=$plan->id&confirm=no", $plan, 'list', 'trash', 'hiddenwin' , $disabled); } break; }