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("FiberPlanDispatchersleeve/Index"); $fiberplandispatchersleeves = FiberPlanDispatchersleeveModel::getAll(); $this->layout()->set("fiberplandispatchersleeves", $fiberplandispatchersleeves); } protected function addAction() { $fiberPlanDispatchers=FiberPlanDispatcherModel::getAll(); $this->layout()->set("fiberPlanDispatchers", $fiberPlanDispatchers); $this->layout()->setTemplate("FiberPlanDispatchersleeve/Form"); } protected function editAction() { $id = $this->request->id; if (!is_numeric($id) || !$id) { $this->layout()->setFlash("Muffen nicht gefunden", "error"); $this->redirect("FiberPlanDispatchersleeve"); } $fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id); if ($fiberplandispatchersleeves->id != $id) { $this->layout()->setFlash("Muffen nicht gefunden", "error"); $this->redirect("FiberPlanDispatchersleeve"); } $this->layout()->set("fiberplandispatchersleeves", $fiberplandispatchersleeves); 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"; $fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id); if (!$fiberplandispatchersleeves->id) { $this->layout()->setFlash("Muffe nicht gefunden", "error"); $this->redirect("FiberPlanDispatchersleeve"); } } else { $mode = "add"; } $data = []; $data['fiberPlanDispatcher_id'] = trim($r->fiberPlanDispatcher_id); $data['name'] = trim($r->name); if (!$data['fiberPlanDispatcher_id']) { $data['fiberPlanDispatcher_id']=NULL; } if (!$data['name']) { $data['name']=NULL; } // var_dump($_FILES); // var_dump($upload); // exit; if ($mode == "edit") { $fiberplandispatchersleeves->update($data); } else { $fiberplandispatchersleeves = FiberPlanDispatchersleeveModel::create($data); } // var_dump($filestore); // exit; $id = $fiberplandispatchersleeves->save(); if (!$id) { $this->layout()->setFlash("Muffen konnte nicht angelegt werden", "error"); $this->redirect("FiberPlanDispatchersleeve"); } if ($mode == "edit") { $this->layout()->setFlash("Muffen erfolgreich geƤndert", "success"); } else if ($mode = "add") { $this->layout()->setFlash("Muffen erfolgreich angelegt", "success"); } $this->redirect("FiberPlanDispatchersleeve"); } protected function deleteAction() { $id = $this->request->id; $fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id); if (!$fiberplandispatchersleeves->id || $fiberplandispatchersleeves->id != $id) { $this->layout()->setFlash("Muffen nicht gefunden.", "error"); $this->redirect("FiberPlanDispatchersleeve"); } $fiberplandispatchersleeves->delete(); $this->redirect("FiberPlanDispatchersleeve"); } }