Faserplanung
* Schächte/Verteiler * Rohrplanung
This commit is contained in:
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
|
||||
class FiberPlanPipeController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->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()
|
||||
{
|
||||
$networks = NetworkModel::getAll();
|
||||
$this->layout()->setTemplate("FiberPlanPipe/Index");
|
||||
$fiberplanpipes = FiberPlanPipeModel::getAll();
|
||||
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
|
||||
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
|
||||
$this->layout()->set("networks", $networks);
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
|
||||
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$networks = NetworkModel::getAll();
|
||||
$fiberplanpipetemplates = FiberPlanPipeModel::getTemplates();
|
||||
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
|
||||
$this->layout()->set("networks", $networks);
|
||||
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
|
||||
$this->layout()->set("fiberplanpipetemplates", $fiberplanpipetemplates);
|
||||
|
||||
$this->layout()->setTemplate("FiberPlanPipe/Form");
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
$network = $this->request->network_id;
|
||||
$bdtype = $this->request->bdtype;
|
||||
|
||||
|
||||
switch ($do) {
|
||||
case "getBuildingInfo":
|
||||
$return = $this->getBuildingInfo($network, $bdtype);
|
||||
break;
|
||||
case "getPops":
|
||||
$return = $this->getPops($network);
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function detailAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$networks = NetworkModel::getAll();
|
||||
$this->layout()->setTemplate("FiberPlanPipe/Detail");
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
$fiberplanpipes = new FiberPlanPipe($id);
|
||||
if ($fiberplanpipes->id != $id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
|
||||
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
|
||||
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
|
||||
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
|
||||
$this->layout()->set("networks", $networks);
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
|
||||
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
|
||||
$fiberplanpipes = new FiberPlanPipe($id);
|
||||
if ($fiberplanpipes->id != $id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
|
||||
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
|
||||
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
var_dump($r->get());
|
||||
die();
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$fiberplanpipes = new FiberPlanPipe($id);
|
||||
if (!$fiberplanpipes->id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnisse nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['description'] = trim($r->description);
|
||||
$data['gisid'] = trim($r->gisid);
|
||||
$data['type'] = trim($r->type);
|
||||
$data['type_description'] = trim($r->type_description);
|
||||
$data['fiberplanpipetemplate_id'] = trim($r->fiberplanpipetemplate_id);
|
||||
$data['length'] = trim($r->length);
|
||||
$data['status'] = trim($r->status);
|
||||
$data['responsible'] = trim($r->responsible);
|
||||
$data['responsible_text'] = trim($r->responsible_text);
|
||||
$data['address_id'] = trim($r->address_id);
|
||||
$data['comment'] = trim($r->comment);
|
||||
|
||||
$returnUrl = "FiberPlanPipe";
|
||||
$returnAction = "Index";
|
||||
$returnVariables = array();
|
||||
$returnAnker = "";
|
||||
if ($this->request->returnto) {
|
||||
|
||||
if (strpos($this->request->returnto, "-") !== false) {
|
||||
$urls = explode('-', $this->request->returnto);
|
||||
$urlCounter = 0;
|
||||
$returnUrlGen = "";
|
||||
foreach ($urls as $url) {
|
||||
if ($urlCounter > 0) {
|
||||
$returnUrlGen .= "/";
|
||||
$returnUrlGen .= ucfirst($url);
|
||||
} else {
|
||||
$returnUrlGen .= 'FiberPlanPipe';
|
||||
}
|
||||
$urlCounter++;
|
||||
}
|
||||
$returnAction = "";
|
||||
$returnVariables['id'] = $id;
|
||||
$returnUrl = $returnUrlGen;
|
||||
} else {
|
||||
$returnUrl = ucfirst($this->request->returnto);
|
||||
|
||||
}
|
||||
}
|
||||
if (!$data['description']) {
|
||||
$this->layout()->setFlash("Bezeichnung darf nicht leer sein", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
if (!$data['type']) {
|
||||
$data['type'] = NULL;
|
||||
}
|
||||
if (!$data['gisid']) {
|
||||
$data['gisid'] = NULL;
|
||||
}
|
||||
if (!$data['responsible_text']) {
|
||||
$data['responsible_text'] = NULL;
|
||||
}
|
||||
if (!$data['address_id']) {
|
||||
$data['address_id'] = NULL;
|
||||
}
|
||||
if (!$data['type_description']) {
|
||||
$data['type_description'] = NULL;
|
||||
}
|
||||
if (!$data['fiberplanpipetemplate_id']) {
|
||||
$data['fiberplanpipetemplate_id'] = NULL;
|
||||
}
|
||||
if (!$data['length']) {
|
||||
$data['length'] = NULL;
|
||||
}
|
||||
if (!$data['startpoint']) {
|
||||
$data['startpoint'] = NULL;
|
||||
}
|
||||
if (!$data['endpoint']) {
|
||||
$data['endpoint'] = NULL;
|
||||
}
|
||||
if (!$data['status']) {
|
||||
$data['status'] = NULL;
|
||||
}
|
||||
if (!$data['responsible']) {
|
||||
$data['responsible'] = NULL;
|
||||
}
|
||||
if (!$data['comment']) {
|
||||
$data['comment'] = NULL;
|
||||
}
|
||||
|
||||
|
||||
// var_dump($_FILES);
|
||||
// var_dump($upload);
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mode == "edit") {
|
||||
$fiberplanpipes->update($data);
|
||||
|
||||
} else {
|
||||
$fiberplanpipes = FiberPlanPipeModel::create($data);
|
||||
}
|
||||
// var_dump($filestore);
|
||||
// exit;
|
||||
$id = $fiberplanpipes->save();
|
||||
|
||||
$endpoint_id = $r->endpointid;
|
||||
$endpoint_type = $r->endpoint_type;
|
||||
$endpoint = $r->endpoint;
|
||||
|
||||
if (!empty($endpoint)) {
|
||||
$counter = 1;
|
||||
foreach ($endpoint as $key => $Endpoint) {
|
||||
if ($endpoint_type[$key] == 4) {
|
||||
$endpointarray['fiberPlanDispatcher_id'] = $Endpoint;
|
||||
} else if ($endpoint_type[$key] == 2) {
|
||||
$endpointarray['pop_id'] = $Endpoint;
|
||||
}
|
||||
$endpointarray['fiberPlanPipe_id'] = $id;
|
||||
$endpointarray['sort'] = $counter;
|
||||
if ($endpoint_id[$key]) {
|
||||
$fiberplanpipeendpoint = new FiberPlanPipeEndpoint($id);
|
||||
$fiberplanpipeendpoint->update($endpointarray);
|
||||
} else {
|
||||
$fiberplanpipeendpoint = FiberPlanPipeEndpointModel::create($endpointarray);
|
||||
}
|
||||
$fiberplanpipeendpoint->save();
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis konnte nicht angelegt werden", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
$this->layout()->setFlash("Rohrverzeichnis erfolgreich geändert", "success");
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("Rohrverzeichnis erfolgreich angelegt", "success");
|
||||
}
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$fiberplanpipes = new FiberPlanPipe($id);
|
||||
if (!$fiberplanpipes->id || $fiberplanpipes->id != $id) {
|
||||
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden.", "error");
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
|
||||
$fiberplanpipes->delete();
|
||||
$this->redirect("FiberPlanPipe");
|
||||
}
|
||||
|
||||
protected function getBuildingInfo($network, $bdtype)
|
||||
{
|
||||
FiberPlanPipeModel::getBuildingInfo($network, $bdtype);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user