diff --git a/module/product/control.php b/module/product/control.php index 6deac9301c..9c847266f5 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -333,7 +333,6 @@ class product extends control $this->view->rdUsers = $rdUsers; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); $this->view->programs = array('') + $this->loadModel('program')->getTopPGMPairs(); - $this->view->lines = array('') + $this->loadModel('tree')->getLinePairs(); $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); unset($this->lang->product->typeList['']); @@ -481,7 +480,7 @@ class product extends control $this->view->rdUsers = $rdUsers; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); $this->view->programs = array('') + $this->loadModel('program')->getTopPGMPairs(); - $this->view->lines = array('') + $this->loadModel('tree')->getLinePairs(); + $this->view->lines = array('') + $this->product->getLinePairs($product->program); $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); $this->view->canChangePGM = $canChangePGM; $this->view->singleLinkProjects = $singleLinkProjects; @@ -556,7 +555,7 @@ class product extends control $this->view->title = $this->lang->product->batchEdit; $this->view->position[] = $this->lang->product->batchEdit; - $this->view->lines = array('') + $this->tree->getLinePairs(); + $this->view->lines = array('') + $this->product->getLinePairs(); $this->view->productIDList = $productIDList; $this->view->products = $products; $this->view->poUsers = $poUsers; @@ -804,7 +803,7 @@ class product extends control $this->view->product = $product; $this->view->actions = $this->loadModel('action')->getList('product', $productID); $this->view->users = $this->user->getPairs('noletter'); - $this->view->lines = array('') + $this->loadModel('tree')->getLinePairs(); + $this->view->lines = array('') + $this->product->getLinePairs(); $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', $pager, $productID); $this->view->roadmaps = $this->product->getRoadmap($productID, 0, 6); @@ -872,6 +871,19 @@ class product extends control die($output); } + /** + * Ajax get product lines. + * + * @param int $programID + * @access public + * @return void + */ + public function ajaxGetLine($programID) + { + $lines = $this->product->getLinePairs($programID); + die(html::select('line', array('' => '') + $lines, '', "class='form-control chosen'")); + } + /** * Drop menu page. * @@ -1100,7 +1112,7 @@ class product extends control unset($fields[$key]); } - $lines = $this->loadModel('tree')->getLinePairs(); + $lines = $this->product->getLinePairs(); $productStats = $this->product->getStats($orderBy, null, $status); foreach($productStats as $i => $product) { diff --git a/module/product/js/create.js b/module/product/js/create.js index b478c4fc3f..32f955c4c7 100644 --- a/module/product/js/create.js +++ b/module/product/js/create.js @@ -13,3 +13,15 @@ function loadProductLines(rootID) $(this).find('select').chosen() }); } + +$('#program').change(function() +{ + var programID = $(this).val(); + + $.get(createLink('product', 'ajaxGetLine', 'programID=' + programID), function(data) + { + $('#line_chosen').remove(); + $('#line').replaceWith(data); + $('#line').chosen(); + }) +}) diff --git a/module/product/js/edit.js b/module/product/js/edit.js index b04517f85c..367d94af08 100644 --- a/module/product/js/edit.js +++ b/module/product/js/edit.js @@ -13,6 +13,18 @@ $(function() } } }) + + $('#program').change(function() + { + var programID = $(this).val(); + + $.get(createLink('product', 'ajaxGetLine', 'programID=' + programID), function(data) + { + $('#line_chosen').remove(); + $('#line').replaceWith(data); + $('#line').chosen(); + }) + }) }); /** diff --git a/module/product/model.php b/module/product/model.php index 666e826772..b5a58650a1 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -388,7 +388,7 @@ class productModel extends model if(empty($products)) return $products; - $lines = $this->loadModel('tree')->getLinePairs($useShort = true); + $lines = $this->getLinePairs(); $productList = array(); foreach($lines as $id => $name) { @@ -1358,6 +1358,22 @@ class productModel extends model return $stats; } + /** + * Get product line pairs. + * + * @param int $programID + * @access public + * @return void + */ + public function getLinePairs($programID = 0) + { + return $this->dao->select('id,name')->from(TABLE_MODULE) + ->where('type')->eq('line') + ->beginIF($programID)->andWhere('root')->eq($programID)->fi() + ->andWhere('deleted')->eq(0) + ->fetchPairs(); + } + /** * Get the summary of product's stories. * diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php index edbe49f8b4..abbdb91279 100644 --- a/module/product/view/create.html.php +++ b/module/product/view/create.html.php @@ -25,6 +25,10 @@