Finished MaintenanceNotification

This commit is contained in:
Frank Schubert
2024-11-13 18:15:24 +01:00
parent 97dc4446dc
commit 47f71f2310
8 changed files with 465 additions and 14 deletions

View File

@@ -86,9 +86,10 @@ class MaintenanceNotificationController extends mfBaseController {
protected function saveAction() {
$r = $this->request;
var_dump($r->get());
$id = $r->id;
//var_dump($r);exit;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$notification = new MaintenanceNotification($id);
@@ -111,10 +112,10 @@ class MaintenanceNotificationController extends mfBaseController {
$data["plz"] = json_encode(explode(",", $plz_string));
}
// from / to -> date/time -> DateTime
try {
$from = new DateTime($r->from_date." ".$r->from_time);
$from->setTimezone(new DateTimeZone("Europe/Vienna"));
} catch(Exception $e) {
$this->layout()->setFlash("Ungültiges Wartungsfenster Von-Zeitpunkt", "error");
if($mode = "edit") {
@@ -126,6 +127,7 @@ class MaintenanceNotificationController extends mfBaseController {
try {
$to = new DateTime($r->to_date." ".$r->to_time);
$to->setTimezone(new DateTimeZone("Europe/Vienna"));
} catch(Exception $e) {
$this->layout()->setFlash("Ungültiges Wartungsfenster Bis-Zeitpunkt", "error");
if($mode = "edit") {
@@ -135,10 +137,19 @@ class MaintenanceNotificationController extends mfBaseController {
}
$data["to"] = $to->getTimestamp();
// send_ts - feld einbauen -> DateTime
try {
$send_ts = new DateTime($r->sendts_day." ".$r->sendts_hour.":00");
//var_dump($send_ts);exit;
} catch(Exception $e) {
$this->layout()->setFlash("Ungültige Versandzeitpunkt", "error");
if($mode = "edit") {
return $this->editAction();
}
return $this->addAction();
}
$data["send_ts"] = $send_ts->getTimestamp();
//var_dump($data);exit;
if($mode == "add") {
$notification = MaintenanceNotification::create($data);
@@ -159,4 +170,25 @@ class MaintenanceNotificationController extends mfBaseController {
}
protected function delete() {
$id = $this->request->id;
if(!is_numeric($id) || $id < 1) {
$this->layout()->setFlash("Wartungsmeldung nicht gefunden", "error");
$this->redirect("MaintenanceNotification");
}
$notification = new MaintenanceNotification($id);
if(!$notification || !$notification->id) {
$this->layout()->setFlash("Wartungsmeldung nicht gefunden", "error");
$this->redirect("MaintenanceNotification");
}
$notification->delete();
$this->layout()->setFlash("Wartungsmeldung erfolgreich gelöscht", $notification);
$this->redirect("MaintenanceNotification");
}
}