From 05f6ade106d8f44bee5e726825dcf7a373c14080 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Thu, 20 Oct 2022 08:30:23 +0000 Subject: [PATCH] * Finish task #71569. --- module/port/config.php | 2 +- module/project/control.php | 45 ------------------------ module/project/js/edit.js | 57 ------------------------------- module/project/model.php | 24 ++++++++----- module/project/view/edit.html.php | 20 ----------- 5 files changed, 17 insertions(+), 131 deletions(-) diff --git a/module/port/config.php b/module/port/config.php index 98b61d8877..89a479b212 100644 --- a/module/port/config.php +++ b/module/port/config.php @@ -16,7 +16,7 @@ $config->port->dateFeilds = 'estStarted,realStarted,deadline,openedDate,assi $config->port->datetimeFeilds = ''; $config->port->listFields = ''; $config->port->sysLangFields = ',pri,status,type,mode,severity,os,browser,resolution,confirmed,source,reviewResult,stage,change,category'; -$config->port->sysDataFields = 'execution,product,user'; +$config->port->sysDataFields = 'project,execution,product,user'; $config->port->userFields = 'assignedTo,openedBy,finishedBy,canceledBy,closedBy,lastEditedBy,lastRunner,resolvedBy,reviewedBy,mailto'; $config->port->defaultZeroField = 'severity,pri'; diff --git a/module/project/control.php b/module/project/control.php index 6340f54eaa..0a5e8fe913 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -2209,51 +2209,6 @@ class project extends control $this->display(); } - /** - * AJAX: Check products. - * - * @param int $programID - * @param int $projectID - * @access public - * @return void - */ - public function ajaxCheckProduct($programID, $projectID) - { - /* Set vars. */ - $project = $this->project->getByID($projectID); - $oldTopPGM = $this->loadModel('program')->getTopByID($project->parent); - $newTopPGM = $this->program->getTopByID($programID); - - if($oldTopPGM == $newTopPGM) return; - - $response = array(); - $response['result'] = true; - $response['message'] = $this->lang->project->changeProgramTip; - - /* Get new program products. */ - $newProducts = $this->program->getProductPairs($programID, 'assign', 'noclosed'); - $response['newProducts'] = html::select("newProducts", array('0' => '') + $newProducts, '', "class='form-control chosen' onchange='loadBranches(this)'"); - - $multiLinkedProducts = $this->project->getMultiLinkedProducts($projectID); - $canChange = true; - if($multiLinkedProducts) - { - $multiLinkedProjects = array(); - $programIdList = $this->dao->select('id, program')->from(TABLE_PRODUCT)->where('id')->in(array_keys($multiLinkedProducts))->fetchPairs(); - foreach($multiLinkedProducts as $productID => $product) - { - if($programIdList[$productID] != $newTopPGM) $canChange = false; - $multiLinkedProjects[$productID] = $this->loadModel('product')->getProjectPairsByProduct($productID); - } - $response['result'] = false; - $response['message'] = $multiLinkedProducts; - $response['multiLinkedProjects'] = $multiLinkedProjects; - } - - if($canChange) return true; - echo json_encode($response); - } - /** * AJAX: get executions of a project in html select. * diff --git a/module/project/js/edit.js b/module/project/js/edit.js index b6118eca99..0b6701d26b 100644 --- a/module/project/js/edit.js +++ b/module/project/js/edit.js @@ -4,63 +4,6 @@ $(function() { var programID = $(this).val(); setAclList(programID); - - /* Determine whether the project can change the project set. */ - link = createLink('project', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID); - $.getJSON(link, function(data) - { - var changed = true; - - if(data && data.result) - { - changed = confirm(data.message); - if(changed) - { - /* Select change to the new program products. */ - var lastProductSelect = $('#productsBox .input-group:last select:first'); - if($(lastProductSelect).val() == 0) - { - var lastProductSelectID = $(lastProductSelect).attr("id"); - var lastProductSelectName = $(lastProductSelect).attr("name"); - $('#' + lastProductSelectID + '_chosen').remove(); - $(lastProductSelect).replaceWith(data.newProducts); - $('#productsBox .input-group:last select:first').attr('name', lastProductSelectName).attr('id', lastProductSelectID).chosen(); - } - } - } - - if(data && !data.result) - { - $('#promptTable tbody tr').remove(); - for(var i in data.message) - { - var product = data.message[i]; - $('#promptTable').append(" " + product +" " + linkedProjectsTip +""); - for(var j in data.multiLinkedProjects) - { - if(i == j) - { - html = '' - for(k in data.multiLinkedProjects[j]) - { - var project = data.multiLinkedProjects[j][k]; - html += "

" + project +"

"; - } - $('#promptTable').append("" + html + ""); - } - } - } - - changed = false; - $('#promptBox').modal({show: true}); - } - - if(!changed) $("#parent").val(oldParent).trigger("chosen:updated"); - oldParent = $('#parent').val(); - - budgetOverrunTips(); - outOfDateTip(); - }); }); adjustProductBoxMargin(); diff --git a/module/project/model.php b/module/project/model.php index 0f6f1a3343..af615515ae 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -768,6 +768,21 @@ class projectModel extends model return $statData; } + /** + * Get project pairs. + * + * @access public + * @return object + */ + public function getPairs() + { + return $this->dao->select('id, name')->from(TABLE_PROJECT) + ->where('type')->eq('project') + ->andWhere('deleted')->eq(0) + ->andWhere('vision')->eq($this->config->vision) + ->fetchPairs(); + } + /** * Get project pairs by programID. * @@ -1465,6 +1480,7 @@ class projectModel extends model ->where('project')->eq($project->id) ->andWhere('deleted')->eq('0') ->fetchAll(); + if(!empty($executionsCount)) { $minExecutionBegin = $this->dao->select('begin as minBegin')->from(TABLE_PROJECT)->where('project')->eq($project->id)->andWhere('deleted')->eq('0')->orderBy('begin_asc')->fetch(); @@ -1560,7 +1576,6 @@ class projectModel extends model if(!dao::isError()) { - $this->updateProductProgram($oldProject->parent, $project->parent, $_POST['products']); $this->updateProducts($projectID, $_POST['products']); $this->file->updateObjectID($this->post->uid, $projectID, 'project'); @@ -2329,13 +2344,6 @@ class projectModel extends model $existedProducts[$productID][$branch] = true; } - /* Delete the execution linked products that is not linked with the execution. */ - if((int)$projectID > 0) - { - $executions = $this->dao->select('id')->from(TABLE_EXECUTION)->where('project')->eq((int)$projectID)->fetchPairs('id'); - $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($executions)->andWhere('product')->notin($products)->exec(); - } - $oldProductKeys = array_keys($oldProjectProducts); $needUpdate = array_merge(array_diff($oldProductKeys, $products), array_diff($products, $oldProductKeys)); if($needUpdate) $this->user->updateUserView($needUpdate, 'product', $members); diff --git a/module/project/view/edit.html.php b/module/project/view/edit.html.php index eefb607f35..d3143939aa 100755 --- a/module/project/view/edit.html.php +++ b/module/project/view/edit.html.php @@ -245,24 +245,4 @@ -