From 5bcad0bd6223cc20379c7cd1fb07546b549b5908 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 16 Jun 2022 17:09:30 +0800 Subject: [PATCH] * If the project linked with the product belongs to the changed program, the unmodifiable information will not be prompted. --- module/product/control.php | 17 ++++++++++------- module/product/js/edit.js | 10 +++++++++- module/product/view/edit.html.php | 2 ++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 35aa4b316f..8fad1c3b89 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -462,33 +462,35 @@ class product extends control if(!empty($unmodifiableProjects)) $canChangeProgram = false; /* Get the projects linked with this product. */ - $projectPairs = $this->dao->select('t2.id,t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $projects = $this->dao->select('t2.id,t2.name,t2.path')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->where('t1.product')->eq($productID) ->andWhere('t2.type')->eq('project') ->andWhere('t2.deleted')->eq('0') - ->fetchPairs(); + ->fetchAll('id'); - if(!empty($projectPairs)) + $projectPathList = array(); + if(!empty($projects)) { - foreach($projectPairs as $projectID => $projectName) + foreach($projects as $projectID => $project) { + $projectPathList[$projectID] = $project->path; if($canChangeProgram) { $products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs(); if(count($products) == 1) { - $singleLinkProjects[$projectID] = $projectName; + $singleLinkProjects[$projectID] = $project->name; } if(count($products) > 1) { - $multipleLinkProjects[$projectID] = $projectName; + $multipleLinkProjects[$projectID] = $project->name; } } else { - if(isset($unmodifiableProjects[$projectID])) $linkStoriesProjects[$projectID] = $projectName; + if(isset($unmodifiableProjects[$projectID])) $linkStoriesProjects[$projectID] = $project->name; } } } @@ -579,6 +581,7 @@ class product extends control $this->view->singleLinkProjects = $singleLinkProjects; $this->view->multipleLinkProjects = $multipleLinkProjects; $this->view->linkStoriesProjects = $linkStoriesProjects; + $this->view->projectPathList = $projectPathList; unset($this->lang->product->typeList['']); $this->display(); diff --git a/module/product/js/edit.js b/module/product/js/edit.js index 8cc74a545b..65a0f89de6 100644 --- a/module/product/js/edit.js +++ b/module/product/js/edit.js @@ -3,7 +3,15 @@ $(function() $('#program').change(function() { var programID = $(this).val(); - if(!canChangeProgram || singleLinkProjects.length !== 0 || multipleLinkProjects.length !== 0) + var canChange = true; + for(var i = 0; i < linkStoriesProjectIDList.length; i ++) + { + var projectID = linkStoriesProjectIDList[i]; + var path = projectPathList[projectID]; + if(path.indexOf(',' + programID + ',') < 0) canChange = false; + } + + if(!canChange && (!canChangeProgram || singleLinkProjects.length !== 0 || multipleLinkProjects.length !== 0)) { $('#changeProgram').modal({show: true}); if(!canChangeProgram) diff --git a/module/product/view/edit.html.php b/module/product/view/edit.html.php index ea2fe65ee7..5f31bd10e8 100644 --- a/module/product/view/edit.html.php +++ b/module/product/view/edit.html.php @@ -17,6 +17,8 @@ + +