From af5b6ff489910791a8c6dffec12c3bc85dd56a56 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 4 Nov 2021 11:48:22 +0800 Subject: [PATCH] * Finish task #43899. --- module/productplan/control.php | 23 ++++++++++++++++++++--- module/productplan/js/create.js | 12 ++++++++++++ module/productplan/model.php | 2 +- module/productplan/view/create.html.php | 1 + 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index 1344fa2b5b..fcd0b36611 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -78,9 +78,10 @@ class productplan extends control $this->view->position[] = $this->lang->productplan->common; $this->view->position[] = $this->lang->productplan->create; - $this->view->lastPlan = $lastPlan; - $this->view->branch = $branchID; - $this->view->parent = $parent; + $this->view->productID = $productID; + $this->view->lastPlan = $lastPlan; + $this->view->branch = $branchID; + $this->view->parent = $parent; $this->display(); } @@ -632,4 +633,20 @@ class productplan extends control foreach($this->post->unlinkBugs as $bugID) $this->productplan->unlinkBug($bugID); die(js::locate($this->createLink('productplan', 'view', "planID=$planID&type=bug&orderBy=$orderBy"), 'parent')); } + + + /** + * AJAX: Get last plan. + * + * @param int $productID + * @param int $branch + * @param int $parent + * @access public + * @return object + */ + public function ajaxGetLast($productID, $branch = 0, $parent = 0) + { + $lastPlan = $this->productplan->getLast($productID, $branch, $parent); + echo json_encode($lastPlan); + } } diff --git a/module/productplan/js/create.js b/module/productplan/js/create.js index bc8e174472..893e9333a7 100644 --- a/module/productplan/js/create.js +++ b/module/productplan/js/create.js @@ -62,3 +62,15 @@ $('#future').on('change', function() $('#end').removeAttr('disabled').parents('tr').show(); } }); + +$('#branch').change(function() +{ + var branchID = $(this).val(); + var link = createLink('productplan', 'ajaxGetLast', "productID=" + productID + "&branch=" + branchID); + + $.post(link, function(data) + { + data = JSON.parse(data); + if(data) $('#title').parent().next('td').html('(' + data.title + ')'); + }) +}) diff --git a/module/productplan/model.php b/module/productplan/model.php index 76cabb9a9f..0e76645121 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -60,7 +60,7 @@ class productplanModel extends model ->beginIF($parent > 0)->andWhere('parent')->eq((int)$parent)->fi() ->andWhere('product')->eq((int)$productID) ->andWhere('end')->ne('2030-01-01') - ->beginIF($branch)->andWhere('branch')->eq($branch)->fi() + ->andWhere('branch')->eq($branch) ->orderBy('end desc') ->limit(1) ->fetch(); diff --git a/module/productplan/view/create.html.php b/module/productplan/view/create.html.php index e973129590..41300bbb3d 100644 --- a/module/productplan/view/create.html.php +++ b/module/productplan/view/create.html.php @@ -13,6 +13,7 @@ execution->weekend);?> +