diff --git a/module/branch/model.php b/module/branch/model.php index f2d2901baf..d3cf858eb5 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -11,6 +11,12 @@ */ class branchModel extends model { + public function getById($branchID) + { + if(empty($branchID)) return $this->lang->branch->all; + return $this->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch('name'); + } + public function getPairs($productID, $params = '') { $branches = $this->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->andWhere('deleted')->eq(0)->orderBy('id_desc')->fetchPairs('id', 'name'); diff --git a/module/build/control.php b/module/build/control.php index 6d96297e92..b2295656b7 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -39,20 +39,24 @@ class build extends control $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($projectID); - $products = $this->project->getProducts($projectID, false); - $product = $this->loadModel('product')->getById(key($products)); + $project = $this->loadModel('project')->getById($projectID); - $this->view->title = $project->name . $this->lang->colon . $this->lang->build->create; - $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$projectID"), $project->name); - $this->view->position[] = $this->lang->build->create; - $this->view->products = $products; - $this->view->product = $product; - $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($product->id); - $this->view->projectID = $projectID; - $this->view->lastBuild = $this->build->getLast($projectID); - $this->view->users = $this->user->getPairs('nodeleted'); - $this->view->orderBy = $orderBy; + $productGroups = $this->project->getProducts($projectID); + $productID = key($productGroups); + $products = array(); + foreach($productGroups as $product) $products[$product->id] = $product->name; + + $this->view->title = $project->name . $this->lang->colon . $this->lang->build->create; + $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$projectID"), $project->name); + $this->view->position[] = $this->lang->build->create; + $this->view->productGroups = $productGroups; + $this->view->products = $products; + $this->view->product = $productGroups[$productID]; + $this->view->branches = $productGroups[$productID]->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID); + $this->view->projectID = $projectID; + $this->view->lastBuild = $this->build->getLast($projectID); + $this->view->users = $this->user->getPairs('nodeleted'); + $this->view->orderBy = $orderBy; $this->display(); } @@ -91,17 +95,21 @@ class build extends control $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($build->project); - $products = $this->project->getProducts($build->project, false); + $project = $this->loadModel('project')->getById($build->project); - $this->view->title = $project->name . $this->lang->colon . $this->lang->build->edit; - $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $project->name); - $this->view->position[] = $this->lang->build->edit; - $this->view->products = $products; - $this->view->branches = $build->productType == 'normal' ? array() : $this->loadModel('branch')->getPairs($build->product); - $this->view->build = $build; - $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $build->builder); - $this->view->orderBy = $orderBy; + $productGroups = $this->project->getProducts($build->project); + $products = array(); + foreach($productGroups as $product) $products[$product->id] = $product->name; + + $this->view->title = $project->name . $this->lang->colon . $this->lang->build->edit; + $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $project->name); + $this->view->position[] = $this->lang->build->edit; + $this->view->productGroups = $productGroups; + $this->view->products = $products; + $this->view->branches = $build->productType == 'normal' ? array() : $this->loadModel('branch')->getPairs($build->product); + $this->view->build = $build; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $build->builder); + $this->view->orderBy = $orderBy; $this->display(); } diff --git a/module/build/js/common.js b/module/build/js/common.js index 2aa47df802..fc06646a70 100644 --- a/module/build/js/common.js +++ b/module/build/js/common.js @@ -12,6 +12,11 @@ function loadBranches(productID) { $('#product').closest('.input-group').append(data); $('#branch').css('width', '100px'); + for(i in productGroups[productID]['branches']) + { + $('#branch').val(i); + break; + } } }); } diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index 271e7e2fe1..d10a6a8dd5 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -28,7 +28,7 @@