From 6208970fdeef33c81040ec6c31cf2155bce5b1f8 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 26 Oct 2022 16:41:16 +0800 Subject: [PATCH] * code for task #73476,73475,73474,73473. --- module/execution/control.php | 2 +- module/execution/model.php | 59 +++++++++++++++++++++++++++++++++++- module/project/model.php | 14 ++++++--- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index e717326780..56693a2170 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -743,7 +743,7 @@ class execution extends control /* Change for requirement story title. */ if($storyType == 'requirement') - { + { $this->lang->story->title = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->title); $this->lang->story->noStory = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->noStory); $this->lang->execution->createStory = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->execution->createStory); diff --git a/module/execution/model.php b/module/execution/model.php index 00e6af4b79..9430b98f7b 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -5035,7 +5035,6 @@ class executionModel extends model $_POST['end'] = $project->end; $_POST['status'] = 'wait'; $_POST['days'] = $project->days; - $_POST['products'] = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs(); $_POST['team'] = $project->team; $_POST['teamMembers'] = array($this->app->user->account); $_POST['acl'] = 'open'; @@ -5046,6 +5045,14 @@ class executionModel extends model $_POST['multiple'] = '0'; $_POST['hasProduct'] = $project->hasProduct; + $projectProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchAll(); + foreach($projectProducts as $projectProduct) + { + $_POST['products'][] = $projectProduct->product; + $_POST['branch'][] = $projectProduct->branch; + if($projectProduct->plan) $_POST['plans'][$projectProduct->product][$projectProduct->branch] = explode(',', trim($projectProduct->plan, ',')); + } + $executionID = $this->create(); if($project->model == 'kanban') { @@ -5057,4 +5064,54 @@ class executionModel extends model return $executionID; } + + /** + * Sync no multiple project to sprint. + * + * @param int $projectID + * @access public + * @return int + */ + public function syncNoMultipleSprint($projectID) + { + $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch(); + $post = $_POST; + + $_POST = array(); + $_POST['project'] = $projectID; + $_POST['name'] = $project->name; + $_POST['code'] = $project->code; + $_POST['begin'] = $project->begin; + $_POST['end'] = $project->end; + $_POST['days'] = $project->days; + $_POST['team'] = $project->team; + $_POST['PO'] = $project->PO; + $_POST['QD'] = $project->QD; + $_POST['PM'] = $project->PM; + $_POST['RD'] = $project->RD; + $_POST['status'] = $project->status; + $_POST['acl'] = 'open'; + + $projectProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchAll(); + foreach($projectProducts as $projectProduct) + { + $_POST['products'][] = $projectProduct->product; + $_POST['branch'][] = $projectProduct->branch; + if($projectProduct->plan) $_POST['plans'][$projectProduct->product][$projectProduct->branch] = explode(',', trim($projectProduct->plan, ',')); + } + + $teamMembers = $this->dao->select('*')->from(TABLE_TEAM)->where('type')->eq('project')->andWhere('root')->eq($projectID)->fetchPairs('account', 'account'); + $_POST['teamMembers'] = array_values($teamMembers); + + $executionID = $this->dao->select('*')->from(TABLE_EXECUTION)->where('project')->eq($projectID)->andWhere('type')->in('sprint,kanban')->andWhere('multiple')->eq(0)->fetch('id'); + if($executionID) + { + $this->update($executionID); + $this->updateProducts($executionID); + } + + $_POST = $post; + + return $executionID; + } } diff --git a/module/project/model.php b/module/project/model.php index 99f0c49f87..4ab4dd6210 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1441,7 +1441,7 @@ class projectModel extends model if($project->acl != 'open') $this->loadModel('user')->updateUserView($projectID, 'project'); - if(!$project->multiple and $project->model != 'waterfall') $this->loadModel('execution')->createDefaultSprint($projectID); + if(empty($project->multiple) and $project->model != 'waterfall') $this->loadModel('execution')->createDefaultSprint($projectID); return $projectID; } @@ -1617,6 +1617,8 @@ class projectModel extends model if($project->status == 'closed') $this->product->close($productID); } + if(empty($oldProject->multiple) and $oldProject->model != 'waterfall') $this->loadModel('execution')->syncNoMultipleSprint($projectID); + return common::createChanges($oldProject, $project); } } @@ -1667,6 +1669,7 @@ class projectModel extends model } if(dao::isError()) return false; + $this->loadModel('execution'); $this->lang->error->unique = $this->lang->error->repeat; foreach($projects as $projectID => $project) { @@ -1688,10 +1691,7 @@ class projectModel extends model if(dao::isError()) { $errors = dao::getError(); - foreach($errors as $key => $error) - { - dao::$errors[$key][0] = 'ID' . $projectID . $error[0]; - } + foreach($errors as $key => $error) dao::$errors[$key][0] = 'ID' . $projectID . $error[0]; return false; } @@ -1708,6 +1708,8 @@ class projectModel extends model if($project->acl == 'open') $this->loadModel('personnel')->updateWhitelist(array(), 'project', $projectID); if($project->acl != 'open') $this->loadModel('user')->updateUserView($projectID, 'project'); $this->executeHooks($projectID); + + if(empty($oldProject->multiple) and $oldProject->model != 'waterfall') $this->execution->syncNoMultipleSprint($projectID); } $allChanges[$projectID] = common::createChanges($oldProject, $project); } @@ -2135,6 +2137,8 @@ class projectModel extends model ->andWhere('account')->in($removedAccounts) ->exec(); } + + if(empty($project->multiple) and $project->model != 'waterfall') $this->loadModel('execution')->syncNoMultipleSprint($projectID); } /**