From adaa7cd1d23e9183b9a82a70e76d47e721275ed1 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 10 Nov 2021 09:49:02 +0800 Subject: [PATCH] * Add dynamic when batch edit main branch. --- module/branch/model.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index c832db544d..6d336a34a0 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -200,17 +200,22 @@ class branchModel extends model { if($branchID == BRANCH_MAIN) { - if($data->default != BRANCH_MAIN) continue; - - $this->dao->update(TABLE_BRANCH) - ->set('default')->eq(0) - ->where('product')->eq($productID) - ->exec(); - - if(dao::isError()) die(js::error('branch#' . $branchID . dao::getError(true))); - $newMainBranch = new stdClass(); - $newMainBranch->default = 1; + if($data->default == BRANCH_MAIN) + { + $this->dao->update(TABLE_BRANCH) + ->set('default')->eq(0) + ->where('product')->eq($productID) + ->exec(); + + if(dao::isError()) die(js::error('branch#' . $branchID . dao::getError(true))); + + $newMainBranch->default = 1; + } + else + { + $newMainBranch->default = 0; + } $changes[$branchID] = common::createChanges($oldBranchList[BRANCH_MAIN], $newMainBranch); }