Finished MaintenanceNotification
This commit is contained in:
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user