diff --git a/module/branch/control.php b/module/branch/control.php index d5c800e012..d97b39b1f4 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -307,7 +307,7 @@ class branch extends control * * @param int $productID * @access public - * @return void + * @return object */ public function mergeBranch($productID) { @@ -324,8 +324,8 @@ class branch extends control $this->loadModel('action')->create('branch', $targetBranch, 'MergedBranch', '', implode(',', $mergedBranches)); - if(dao::isError()) $this->send(array('message' => dao::getError(), 'result' => 'fail')); + if(dao::isError()) return $this->send(array('message' => dao::getError(), 'result' => 'fail')); - $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success')); + return $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success')); } } diff --git a/module/branch/model.php b/module/branch/model.php index 61f86fd977..8bd6cc7c45 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -164,12 +164,11 @@ class branchModel extends model */ public function create($productID, $withMerge = false) { - $removedFields = $withMerge ? 'createBranch,mergedBranchIDList,targetBranch' : ''; $branch = fixer::input('post') ->add('product', $productID) ->add('createdDate', helper::today()) ->add('status', 'active') - ->remove($removedFields) + ->removeIF($withMerge, 'createBranch,mergedBranchIDList,targetBranch') ->get(); $lastOrder = (int)$this->dao->select('`order`')->from(TABLE_BRANCH)->where('product')->eq($productID)->orderBy('order_desc')->limit(1)->fetch('order');