From ece016ae153b0951ff4d71d3e49a3fc389b28366 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 9 Oct 2023 16:02:29 +0800 Subject: [PATCH] * When deleting a plan, the parent field of the parent plan is not updated. --- module/productplan/model.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/module/productplan/model.php b/module/productplan/model.php index b545f25f07..b2b7c0a1b9 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -813,20 +813,14 @@ class productplanModel extends model */ public function changeParentField(int $planID): bool { - $plan = $this->getById($planID); + $plan = $this->getByID($planID); if($plan->parent <= 0) return true; $childCount = count($this->getChildren($plan->parent)); $parent = $childCount == 0 ? '0' : '-1'; - if($childCount > 0) - { - $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq($parent)->where('id')->eq((int)$plan->parent)->exec(); - } - else - { - $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq('0')->where('id')->eq((int)$planID)->exec(); - } + if($childCount >= 0) $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq($parent)->where('id')->eq((int)$plan->parent)->exec(); + $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq('0')->where('id')->eq($planID)->exec(); return !dao::isError(); }