needlogin=true; $me = new User(); $me->loadMe(); $this->me = $me; $this->layout()->set("me",$me); if(!$me->isAdmin()) { $this->redirect("Dashboard"); } } protected function saveAction() { $r = $this->request; //var_dump($r);exit; if(!$r->network_id) { $this->layout()->setFlash("Netzgebiet nicht gefunden", "error"); $this->redirect("Network", "Index"); } $network_id = $r->network_id; $network = new Network($network_id); if(!$network->id) { $this->layout()->setFlash("Netzgebiet nicht gefunden", "error"); $this->redirect("Network", "Index"); } $sections = $r->sections; if(!is_array($sections) || !count($sections)) { $this->redirect("Network", "Index", [], "view=sections&net=".$network_id); } //var_dump($sections);exit; foreach($sections as $section_id => $name) { if($section_id == "new" && $name) { $section = NetworksectionModel::create(["network_id" => $network_id, "name" => $name]); //var_dump($section);exit; $section->save(); continue; } if(is_numeric($section_id)) { $section = new Networksection($section_id); if(!$section->id) { continue; } $section->name = $name; $section->edit_by = $this->me->id; $section->save(); } } $this->redirect("Network", "Index", [], "view=sections&net=".$network_id); } protected function deleteAction() { $id = $this->request->id; if(!is_numeric($id) || !$id) { $this->layout()->setFlash("Bauabschnitt nicht gefunden", "error"); $this->redirect("Network", "Index"); } $section = new Networksection($id); if(!$section->id) { $this->layout()->setFlash("Bauabschnitt nicht gefunden", "error"); $this->redirect("Network", "Index"); } $network_id = $section->network_id; $section->delete(); $this->layout()->setFlash("Bauabschnitt gelöscht", "success"); $this->redirect("Network", "Index", [], "view=sections&net=".$network_id); } }