64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?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);
|
|
}
|
|
} |