diff --git a/controllers/timesheet.php b/controllers/timesheet.php index c292dcb06ea1926e40728a5a25e3384066850139..ed2ce2ebfa949ed9358c352a72f47efc011de581 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 b277e5d8a6b2118a6e61621b146d0f089e7bfc4c..10b16a184c0132bdd8986da1ade37172e0fef70c 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 a4bf4e0d717e8c8f01c8c53b758cbb4b1e8e9ce4..7b997843f1e910dcfd507c882359f11d2c0db059 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'),