From 1bfaba775120e73f5158e1ec9e81d0df3c176478 Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Thu, 21 Jan 2021 16:03:34 +0800 Subject: [PATCH] * Fix bugs. --- module/product/control.php | 5 +- module/program/control.php | 45 +++++++----- module/program/js/prjedit.js | 12 ++++ module/program/view/prjedit.html.php | 2 + .../program/view/prjmanageproducts.html.php | 2 +- module/project/control.php | 70 +++++++++++++------ module/project/js/edit.js | 14 ++++ module/project/lang/de.php | 1 + module/project/lang/en.php | 1 + module/project/lang/fr.php | 1 + module/project/lang/vi.php | 1 + module/project/lang/zh-cn.php | 1 + module/project/lang/zh-tw.php | 1 + module/project/view/edit.html.php | 2 + module/project/view/manageproducts.html.php | 8 ++- 15 files changed, 122 insertions(+), 44 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 078a0808f3..07b464c2d5 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -124,7 +124,6 @@ class product extends control { /* Lower browse type. */ $browseType = strtolower($browseType); - $projectStoryBrowseType = $browseType; /* Load datatable. */ $this->loadModel('datatable'); @@ -200,8 +199,8 @@ class product extends control $products = $this->product->getProductsByProject($this->session->PRJ); $productPlans = $this->loadModel('project')->getPlans($products); - if($projectStoryBrowseType == 'bybranch') $param = $branch; - $stories = $this->story->getProjectStories($this->session->PRJ, $sort, $projectStoryBrowseType, $param, 'story', '', $pager, $productID, $branch); + if($browseType == 'bybranch') $param = $branch; + $stories = $this->story->getProjectStories($this->session->PRJ, $sort, $browseType, $param, 'story', '', $pager, $productID, $branch); } /* Process the sql, get the conditon partion, save it to session. */ diff --git a/module/program/control.php b/module/program/control.php index e2ee13b7d1..a313bc5e9b 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -965,14 +965,14 @@ class program extends control $this->loadModel('productplan'); /* Navigation stay in program when enter from program list. */ - if($from == 'PRJ') + if($from == 'PRJ') { $this->lang->program->menu = $this->lang->waterfall->setMenu; $moduleIndex = array_search('program', $this->lang->noMenuModule); if($moduleIndex !== false) unset($this->lang->noMenuModule[$moduleIndex]); $this->lang->navGroup->program = 'project'; } - if($from == 'pgmbrowse') + if($from == 'pgmbrowse') { $this->lang->navGroup->program = 'program'; } @@ -1006,6 +1006,18 @@ class program extends control $linkedProducts = $programID != $project->parent ? array() : $this->project->getProducts($projectID); $parentProgram = $this->program->getPGMByID($programID); + /* If the story of the product which linked the execution under the project, you don't allow to remove the product. */ + $projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->fetchAll('story'); + $projectStoryIdList = array_keys($projectStories); + $notRemoveProducts = array(); + foreach($linkedProducts as $productID => $linkedProduct) + { + $productStories = $this->loadModel('story')->getProductStories($productID); + $productStoryIdList = array_keys($productStories); + $storyIntersect = array_intersect($projectStoryIdList, $productStoryIdList); + if(!empty($storyIntersect)) array_push($notRemoveProducts, $productID); + } + foreach($linkedProducts as $product) { if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name; @@ -1020,20 +1032,21 @@ class program extends control $this->view->title = $this->lang->program->PRJEdit; $this->view->position[] = $this->lang->program->PRJEdit; - $this->view->PMUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM); - $this->view->users = $this->user->getPairs('noclosed|nodeleted'); - $this->view->project = $project; - $this->view->programList = $this->program->getParentPairs(); - $this->view->programID = $programID; - $this->view->allProducts = array('0' => '') + $allProducts; - $this->view->productPlans = $productPlans; - $this->view->linkedProducts = $linkedProducts; - $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), '', $linkedBranches); - $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); - $this->view->from = $from; - $this->view->parentProgram = $parentProgram; - $this->view->remainBudget = $this->program->getParentRemainBudget($parentProgram) + $project->budget; - $this->view->budgetUnitList = $this->program->getBudgetUnitList(); + $this->view->PMUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM); + $this->view->users = $this->user->getPairs('noclosed|nodeleted'); + $this->view->project = $project; + $this->view->programList = $this->program->getParentPairs(); + $this->view->programID = $programID; + $this->view->allProducts = array('0' => '') + $allProducts; + $this->view->productPlans = $productPlans; + $this->view->linkedProducts = $linkedProducts; + $this->view->notRemoveProducts = $notRemoveProducts; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), '', $linkedBranches); + $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); + $this->view->from = $from; + $this->view->parentProgram = $parentProgram; + $this->view->remainBudget = $this->program->getParentRemainBudget($parentProgram) + $project->budget; + $this->view->budgetUnitList = $this->program->getBudgetUnitList(); $this->display(); } diff --git a/module/program/js/prjedit.js b/module/program/js/prjedit.js index 45d24a5cc3..583e9019f9 100644 --- a/module/program/js/prjedit.js +++ b/module/program/js/prjedit.js @@ -7,6 +7,18 @@ $(function() adjustProductBoxMargin(); adjustPlanBoxMargin(); + + /* If the story of the product which linked the execution under the project, you don't allow to remove the product. */ + $("#productsBox select").each(function() + { + var isExisted = $.inArray($(this).attr('data-last'), notRemoveProducts); + if(isExisted != -1) + { + $(this).prop('disabled', true).trigger("chosen:updated"); + $(this).siblings('div').find('span').attr('title', tip); + } + }); + }); /** diff --git a/module/program/view/prjedit.html.php b/module/program/view/prjedit.html.php index 5169296acb..2809f58712 100644 --- a/module/program/view/prjedit.html.php +++ b/module/program/view/prjedit.html.php @@ -20,6 +20,8 @@ program->PGMChangeTips);?> program->PRJLongTime);?> + +program->notAllowRemoveProducts);?> parent ? $lang->program->PGMPRJAclList : $lang->program->PRJAclList;?> program->PRJEdit->requiredFields;?>