Zeiterfassung Urlaubstage
neue Migrations Vorbereitung für Logging von versendeten SMSen und Mails zweck rate Limit
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingHolidayController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingHoliday/Index");
|
||||
$timerecordingholidays = TimerecordingHolidayModel::getAll();
|
||||
$this->layout()->set("timerecordingholidays", $timerecordingholidays);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingHoliday/Form");
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Feiertag nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
$timerecordingholidays = new TimerecordingHoliday($id);
|
||||
if ($timerecordingholidays->id != $id) {
|
||||
$this->layout()->setFlash("Feiertag nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
$this->layout()->set("timerecordingholidays", $timerecordingholidays);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$timerecordingholidays = new TimerecordingHoliday($id);
|
||||
if (!$timerecordingholidays->id) {
|
||||
$this->layout()->setFlash("Feiertage nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['timestamp'] = trim($r->timestamp);
|
||||
$data['description'] = trim($r->description);
|
||||
|
||||
|
||||
if (!$data['timestamp']) {
|
||||
$this->layout()->setFlash("Datum darf nicht leer sein", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
if (!$data['description']) {
|
||||
$this->layout()->setFlash("Name darf nicht leer sein", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
|
||||
// var_dump($_FILES);
|
||||
// var_dump($upload);
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mode == "edit") {
|
||||
$timerecordingholidays->update($data);
|
||||
|
||||
} else {
|
||||
$timerecordingholidays = TimerecordingHolidayModel::create($data);
|
||||
}
|
||||
// var_dump($filestore);
|
||||
// exit;
|
||||
$id = $timerecordingholidays->save();
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("Feiertag konnte nicht angelegt werden", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
$this->layout()->setFlash("Feiertag erfolgreich geändert", "success");
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("Feiertag erfolgreich angelegt", "success");
|
||||
}
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordingholidays = new TimerecordingHoliday($id);
|
||||
if (!$timerecordingholidays->id || $timerecordingholidays->id != $id) {
|
||||
$this->layout()->setFlash("Feiertag nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
$timerecordingholidays->delete();
|
||||
$this->redirect("TimerecordingHoliday");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user