Added Networksection

This commit is contained in:
Frank Schubert
2021-07-20 21:54:23 +02:00
parent a1f47267c8
commit aa624278b4
7 changed files with 275 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
class NetworksectionController extends mfBaseController {
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") {
$section = NetworksectionModel::create(["network_id" => $network_id, "name" => $name]);
//var_dump($section);exit;
$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);
}
}