From 775093c9eead2847921245c3c5aa50cddb48062d Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Wed, 24 Jul 2024 18:47:28 +0200 Subject: [PATCH] add unapprove action, fixes #67 --- controllers/timesheet.php | 30 +++++++++++++++++++++++++----- views/timesheet/admin_index.php | 4 ++++ views/timesheet/index.php | 4 ++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/controllers/timesheet.php b/controllers/timesheet.php index c292dcb..ed2ce2e 100644 --- a/controllers/timesheet.php +++ b/controllers/timesheet.php @@ -425,7 +425,7 @@ class TimesheetController extends PluginController { } if ($timesheet && $timesheet->sum !== null) { - $timesheet->finished = true; + $timesheet->finished = 1; $timesheet->finished_at = date('Y-m-d'); $timesheet->store(); $timesheet->send_finished_mail(); @@ -447,9 +447,9 @@ class TimesheetController extends PluginController { //sämtliche Bestätigungsvorgänge verlieren Gültgkeit, wenn der Stundenzettel zur Veränderung durch Hilfskraft freigegeben wird if ($timesheet) { - $timesheet->finished = false; - $timesheet->approved = false; - $timesheet->complete = false; + $timesheet->finished = 0; + $timesheet->approved = 0; + $timesheet->complete = 0; $timesheet->finished_at = null; $timesheet->approved_at = null; $timesheet->approver_id = null; @@ -471,7 +471,7 @@ class TimesheetController extends PluginController { } if ($timesheet) { - $timesheet->approved = true; + $timesheet->approved = 1; $timesheet->approved_at = date('Y-m-d'); $timesheet->approver_id = $GLOBALS['user']->id; $timesheet->store(); @@ -481,6 +481,26 @@ class TimesheetController extends PluginController { $this->redirect('timesheet/index/'. $timesheet->contract->id); } + public function unapprove_action($timesheet_id) + { + $timesheet = StundenzettelTimesheet::find($timesheet_id); + + if (!$timesheet->can_approve($GLOBALS['user']->id)) { + throw new AccessDeniedException($this->_("Sie haben keine Zugriffsberechtigung")); + } + + if ($timesheet) { + $timesheet->approved = 0; + $timesheet->complete = 0; + $timesheet->approved_at = null; + $timesheet->approver_id = null; + $timesheet->store(); + PageLayout::postMessage(MessageBox::success($this->_("Bestätigungsvermerk wurde gelöscht."))); + } + + $this->redirect('timesheet/index/'. $timesheet->contract->id); + } + public function complete_action($timesheet_id) { $timesheet = StundenzettelTimesheet::find($timesheet_id); diff --git a/views/timesheet/admin_index.php b/views/timesheet/admin_index.php index b277e5d..10b16a1 100644 --- a/views/timesheet/admin_index.php +++ b/views/timesheet/admin_index.php @@ -58,6 +58,10 @@ <? $menu->addLink($controller->url_for('timesheet/approve', $timesheet->id), $controller->_('Korrektheit der Angaben bestätigen'), Icon::create($status_infos['approved']['icon']) ) ?> + <? else: ?> + <? $menu->addLink($controller->url_for('timesheet/unapprove', $timesheet->id), + $controller->_('Bestätigungsvermerk zurückziehen'), Icon::create('refresh') + ) ?> <? endif ?> <? $menu->addLink($controller->url_for('timesheet/unlock', $timesheet->id), $controller->_('Einreichen rückgängig machen'), Icon::create('rotate-left'), diff --git a/views/timesheet/index.php b/views/timesheet/index.php index a4bf4e0..7b99784 100644 --- a/views/timesheet/index.php +++ b/views/timesheet/index.php @@ -56,6 +56,10 @@ <? $menu->addLink($controller->url_for('timesheet/approve', $timesheet->id), $controller->_('Korrektheit der Angaben bestätigen'), Icon::create($status_infos['approved']['icon']) ) ?> + <? else: ?> + <? $menu->addLink($controller->url_for('timesheet/unapprove', $timesheet->id), + $controller->_('Bestätigungsvermerk zurückziehen'), Icon::create('refresh') + ) ?> <? endif ?> <? $menu->addLink($controller->url_for('timesheet/unlock', $timesheet->id), $controller->_('Einreichen rückgängig machen'), Icon::create('rotate-left'), -- GitLab