Files
thetool/application/Timerecording/TimerecordingController.php
Spitzer Daniel 828caa35c9 Mobile Integration,Pop Multiple Networks,DataTables responsible update,Migrations
Mobile Integration:
* in footer.php js eingefügt damit das mobile Menu funktioniert
* in menu.php bzw. app.css neue Klasse eingefügt mobile-hide um in der mobilen Version Menupünkte zu verstecken

Pop Multiple Networks
* Pops können nun mehrere Netzgebiete haben
* Netzgebiete und Pop ansicht angepasst
* (Script muss ausgeführt werden um die PopNetwork Table vom Bestand zu befüllen)

DataTables responsible update
* Datatables update und responsible addon
* Diverse Anpassungen für Responsible in:
  - Pops, Geräte Hersteller, Geräte Typen, Devices, Benutzer

Anpassungen auf neu getProperty

Migrations
* PopNetwork
* Poprackmodulepatch
2024-01-09 16:25:26 +01:00

146 lines
4.6 KiB
PHP

<?php
class TimerecordingController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["employee"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("Timerecording/Index");
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$timerecordings = TimerecordingModel::search(['user_id' => $this->me->id]);
$this->layout()->set("timerecordings", $timerecordings);
}
protected function addAction()
{
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$this->layout()->setTemplate("Timerecording/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Buchung nicht gefunden", "error");
$this->redirect("Timerecording");
}
$timerecordings = new Timerecording($id);
if ($timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden", "error");
$this->redirect("Timerecording");
}
$this->layout()->set("timerecordings", $timerecordings);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
$enddate = $r->enddate;
if (!$enddate && $r->start && $r->end) {
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
} elseif ($enddate) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($enddate . " 23:59:00");
} else if (!$enddate && !$r->start && !$r->end) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = NULL;
}
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordings = new Timerecording($id);
if (!$timerecordings->id) {
$this->layout()->setFlash("Buchungen nicht gefunden", "error");
$this->redirect("Timerecording");
}
} else {
$mode = "add";
}
$data = [];
$data['user_id'] = $this->me->id;
$data['start'] = $starttime;
$data['end'] = $endtime;
$data['timerecordingCategory_id'] = trim($r->timerecordingCategory_id);
$data['commend'] = trim($r->commend);
if (!$data['user_id']) {
$this->layout()->setFlash("Benutzer darf nicht leer sein", "error");
$this->redirect("Timerecording");
}
if ($data['start'] < 1577833200) {
$this->layout()->setFlash("Ungültige Startzeit", "error");
$this->redirect("Timerecording");
}
if ($data['end'] && $data['end'] < 1577833200) {
$this->layout()->setFlash("Ungültige Endzeit", "error");
$this->redirect("Timerecording");
}
if (!$data['timerecordingCategory_id']) {
$data['timerecordingCategory_id'] = NULL;
}
if (!$data['commend']) {
$data['commend'] = NULL;
}
if ($mode == "edit") {
$timerecordings->update($data);
} else {
$timerecordings = TimerecordingModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordings->save();
if (!$id) {
$this->layout()->setFlash("Buchung konnte nicht angelegt werden", "error");
$this->redirect("Timerecording");
}
if ($mode == "edit") {
$this->layout()->setFlash("Buchung erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Buchung erfolgreich angelegt", "success");
}
$this->redirect("Timerecording");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordings = new Timerecording($id);
if (!$timerecordings->id || $timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
$this->redirect("Timerecording");
}
$timerecordings->delete();
$this->redirect("Timerecording");
}
}