From 4458e57c9d2ba840f9335249ab45ba2fc197e6f5 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Mon, 21 Dec 2020 10:39:49 +0800 Subject: [PATCH] * Adjust code. --- module/holiday/control.php | 14 ++++++++++++-- module/holiday/model.php | 23 ----------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/module/holiday/control.php b/module/holiday/control.php index a56b361c7d..4d90381041 100644 --- a/module/holiday/control.php +++ b/module/holiday/control.php @@ -103,8 +103,18 @@ class holiday extends control } else { - $result = $this->holiday->delete($id); - if(!$result) $this->send(array('result' => 'fail', 'message' => dao::getError())); + $holidayInformation = $this->dao->select('begin, end')->from(TABLE_HOLIDAY)->where('id')->eq($id)->fetch(); + $this->dao->delete()->from(TABLE_HOLIDAY)->where('id')->eq($id)->exec(); + + /* Update project. */ + $this->holiday->updateProjectPlanDuration($holidayInformation->begin, $holidayInformation->end); + $this->holiday->updateProjectRealDuration($holidayInformation->begin, $holidayInformation->end); + + /* Update task. */ + $this->holiday->updateTaskPlanDuration($holidayInformation->begin, $holidayInformation->end); + $this->holiday->updateTaskRealDuration($holidayInformation->begin, $holidayInformation->end); + + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); die(js::reload('parent')); } } diff --git a/module/holiday/model.php b/module/holiday/model.php index b91a963963..9df505064c 100644 --- a/module/holiday/model.php +++ b/module/holiday/model.php @@ -128,29 +128,6 @@ class holidayModel extends model return !dao::isError(); } - /** - * Delete a holiday. - * - * @param int $id - * @access public - * @return bool - */ - public function delete($id, $null = null) - { - $holidayInformation = $this->dao->select('begin, end')->from(TABLE_HOLIDAY)->where('id')->eq($id)->fetch(); - $this->dao->delete()->from(TABLE_HOLIDAY)->where('id')->eq($id)->exec(); - - /* Update project. */ - $this->updateProjectPlanDuration($holidayInformation->begin, $holidayInformation->end); - $this->updateProjectRealDuration($holidayInformation->begin, $holidayInformation->end); - - /* Update task. */ - $this->updateTaskPlanDuration($holidayInformation->begin, $holidayInformation->end); - $this->updateTaskRealDuration($holidayInformation->begin, $holidayInformation->end); - - return !dao::isError(); - } - /** * Get holidays by begin and end. *