diff --git a/module/branch/control.php b/module/branch/control.php index 99e9904989..8d3215b5c7 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -305,12 +305,11 @@ class branch extends control /** * Merge multiple branches into one branch. * - * @param int $productID * @access public * @return void */ - public function mergeBranch($productID) + public function mergeBranch() { - $this->display(); + $this->branch->mergeBranch(); } } diff --git a/module/branch/js/manage.js b/module/branch/js/manage.js index ecb028bb6e..aa7aa85e34 100644 --- a/module/branch/js/manage.js +++ b/module/branch/js/manage.js @@ -49,7 +49,7 @@ $(function() { if($(this).prop('checked')) { - $('#targetBranches').attr('disabled', true).trigger('chosen:updated'); + $('#targetBranch').attr('disabled', true).trigger('chosen:updated'); var newBranchName = '' + branchLang.name + ""; var newBranchDesc = '' + branchLang.desc + ""; @@ -57,10 +57,35 @@ $(function() } else { - $('#targetBranches').attr('disabled', false).trigger('chosen:updated'); + $('#targetBranch').attr('disabled', false).trigger('chosen:updated'); $('#name').closest('tr').remove(); $('#desc').closest('tr').remove(); } }) + + $('#saveButton').on('click', function() + { + var mergedBranchIDList = []; + $("input:checkbox[name^='branchIDList']:checked").each(function() + { + mergedBranchIDList.push($(this).val()); + }); + + var isChecked = $('#newBranch').attr('checked') ? true : false; + if(isChecked) + { + var postData = {'newBranchName' : $('#name').val(), 'newBranchDesc' : $('#desc').val(), 'newBranch' : isChecked, 'mergedBranchIDList' : mergedBranchIDList}; + } + else + { + var postData = {'targetBranch' : $('#targetBranch').val(), 'mergedBranchIDList' : mergedBranchIDList}; + } + + $.post(createLink('branch', 'mergeBranch'), postData, function() + { + $('#mergeBranch').modal('hide'); + window.location.reload(); + }); + }); }); diff --git a/module/branch/model.php b/module/branch/model.php index 92abc5029e..0e7e5c5844 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -574,4 +574,15 @@ class branchModel extends model $this->lang->branch->confirmActivate = str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->confirmActivate); $this->lang->branch->existName = str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->existName); } + + /** + * Merge branch. + * + * @access public + * @return void + */ + public function mergeBranch() + { + $data = fixer::input('post')->get(); + } } diff --git a/module/branch/view/manage.html.php b/module/branch/view/manage.html.php index 8c31bbb6c5..2c6b84ea03 100644 --- a/module/branch/view/manage.html.php +++ b/module/branch/view/manage.html.php @@ -151,12 +151,9 @@ branch->mergeTo;?>
- + -
- - -
+ branch->createAction, '', "id='newBranch'")?>
@@ -167,7 +164,7 @@ - + save, "id='saveButton'", 'btn btn-primary btn-wide');?> goback, $this->createLink('branch', 'manage', "productID=$productID"), 'self', '', 'btn btn-wide');?>