Faserplanung Vorbereitung für Kabelverschaltung
* Menüpunkt Kabelverschaltung hinzugefügt * Initialfiles für Kabelverschaltung
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
class FiberPlanCable extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
private $fiberPlanPipe;
|
||||
private $network;
|
||||
private $address;
|
||||
|
||||
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
if (!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
<?php
|
||||
|
||||
class FiberPlanCableController 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()
|
||||
{
|
||||
$this->layout()->setTemplate("FiberPlanCable/Index");
|
||||
$fiberplanpipemanufacturers = FiberPlanPipeModel::getAllPipeManufacturer();
|
||||
$fiberplanpipes = FiberPlanPipeModel::getAllPipe();
|
||||
$fiberplancables = FiberPlanCableModel::getAll();
|
||||
$type_descrition_definition = FiberPlanPipeModel::$type_descrition_definition;
|
||||
$lineworkeraddresses = FiberPlanCableModel::getLineworkerAddresses();
|
||||
$networks = NetworkModel::getAll();
|
||||
$this->layout()->set("lineworkeraddresses", $lineworkeraddresses);
|
||||
$this->layout()->set("networks", $networks);
|
||||
$this->layout()->set("type_descrition_definition", $type_descrition_definition);
|
||||
$this->layout()->set("fiberplanpipemanufacturers", $fiberplanpipemanufacturers);
|
||||
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
|
||||
$this->layout()->set("fiberplancables", $fiberplancables);
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
$fiberplanpipe_id = $this->request->fiberplanpipe_id;
|
||||
$network_id = $this->request->network_id;
|
||||
$pop_id = $this->request->pop_id;
|
||||
$dispatcher_id = $this->request->dispatcher_id;
|
||||
$poprack_id = $this->request->poprack_id;
|
||||
$bdtype = $this->request->bdtype;
|
||||
|
||||
switch ($do) {
|
||||
case "FiberPlanPipe":
|
||||
$return = $this->getFiberPlanPipe($network_id);
|
||||
break;
|
||||
case "FiberPlanPipeSub":
|
||||
$return = $this->getFiberPlanPipeSub($fiberplanpipe_id);
|
||||
break;
|
||||
case "getPops":
|
||||
$return = $this->getPops($network);
|
||||
break;
|
||||
case "poprack":
|
||||
$return = $this->getpoprack($pop_id);
|
||||
break;
|
||||
case "poprackmodule":
|
||||
$return = $this->getpoprackmodule($poprack_id);
|
||||
break;
|
||||
case "poprackmoduleall":
|
||||
$return = $this->getpoprackmoduleall($pop_id);
|
||||
break;
|
||||
case "dispatchersleeve":
|
||||
$return = $this->getdispatchersleeve($dispatcher_id);
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function detailAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
|
||||
$fiberplancables = new FiberPlanCable($id);
|
||||
if ($fiberplancables->id != $id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
|
||||
$fiberPlanCablePipes = FiberPlanCablePipeModel::search(['fiberPlanCable_id' => $id]);
|
||||
if ($fiberPlanCablePipes) {
|
||||
foreach ($fiberPlanCablePipes as $fiberPlanCablePipe) {
|
||||
$fiberPlanPipesEndpoints[] = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $fiberPlanCablePipe->fiberPlanPipe_id]);
|
||||
}
|
||||
}
|
||||
$fiberPlanCableEndpoints = FiberPlanCableEndpointModel::search(['fiberPlanCable_id' => $id]);
|
||||
//$fiberPlanPipeSub = FiberPlanCableModel::getFiberPlanPipeSub($fiberplancables->data->fiberPlanPipe_id, 1);
|
||||
$fiberPlanPipeTemplates = FiberPlanPipeTemplateModel::getAll();
|
||||
$lineworkeraddresses = FiberPlanCableModel::getLineworkerAddresses();
|
||||
|
||||
$fiberplanpipemanufacturers = FiberPlanPipeManufacturerModel::getOne(1);
|
||||
|
||||
$this->layout()->set("lineworkeraddresses", $lineworkeraddresses);
|
||||
$this->layout()->set("fiberplanpipemanufacturers", $fiberplanpipemanufacturers);
|
||||
// $this->layout()->set("fiberPlanPipeSub", $fiberPlanPipeSub);
|
||||
$this->layout()->set("fiberplancables", $fiberplancables);
|
||||
$this->layout()->set("fiberPlanPipeTemplates", $fiberPlanPipeTemplates);
|
||||
$this->layout()->set("fiberPlanCablePipes", $fiberPlanCablePipes);
|
||||
$this->layout()->set("fiberPlanPipesEndpoints", $fiberPlanPipesEndpoints);
|
||||
$this->layout()->set("fiberPlanCableEndpoints", $fiberPlanCableEndpoints);
|
||||
|
||||
}
|
||||
|
||||
protected function getFiberPlanPipe($network_id)
|
||||
{
|
||||
FiberPlanCableModel::getFiberPlanPipe($network_id);
|
||||
}
|
||||
|
||||
protected function getFiberPlanPipeSub($fiberplanpipe_id)
|
||||
{
|
||||
FiberPlanCableModel::getFiberPlanPipeSub($fiberplanpipe_id);
|
||||
}
|
||||
|
||||
protected function getpoprack($pop_id)
|
||||
{
|
||||
PoprackModel::getpoprack($pop_id);
|
||||
}
|
||||
|
||||
protected function getdispatchersleeve($dispatcher_id)
|
||||
{
|
||||
PoprackModel::getdispatchersleeve($dispatcher_id);
|
||||
}
|
||||
|
||||
protected function getpoprackmodule($poprack_id)
|
||||
{
|
||||
PoprackmoduleModel::getpoprackmodule($poprack_id);
|
||||
}
|
||||
|
||||
protected function getpoprackmoduleall($pop_id)
|
||||
{
|
||||
PoprackmoduleModel::getpoprackmoduleall($pop_id);
|
||||
}
|
||||
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$networks = NetworkModel::getAll();
|
||||
$fiberPlanPipes = FiberPlanPipeModel::getAll();
|
||||
$lineworkeraddresses = FiberPlanCableModel::getLineworkerAddresses();
|
||||
$this->layout()->set("networks", $networks);
|
||||
$this->layout()->set("fiberPlanPipes", $fiberPlanPipes);
|
||||
$this->layout()->set("lineworkeraddresses", $lineworkeraddresses);
|
||||
|
||||
$this->layout()->setTemplate("FiberPlanCable/Form");
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
$fiberplancables = new FiberPlanCable($id);
|
||||
if ($fiberplancables->id != $id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
$fiberPlanCablePipes = FiberPlanCablePipeModel::search(['fiberPlanCable_id' => $id]);
|
||||
foreach ($fiberPlanCablePipes as $fiberPlanCablePipe) {
|
||||
$fiberPlanPipeNetworks[$fiberPlanCablePipe->fiberPlanPipe_id] = FiberPlanPipeEndpointModel::searchNetworks(['fiberPlanPipe_id' => $fiberPlanCablePipe->fiberPlanPipe_id]);
|
||||
}
|
||||
if ($fiberPlanCablePipes) {
|
||||
foreach ($fiberPlanCablePipes as $fiberPlanCablePipe) {
|
||||
$fiberPlanPipesEndpoints[] = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $fiberPlanCablePipe->fiberPlanPipe_id]);
|
||||
}
|
||||
}
|
||||
$fiberPlanCableEndpoints = FiberPlanCableEndpointModel::search(['fiberPlanCable_id' => $id]);
|
||||
|
||||
|
||||
$this->layout()->set("fiberplancables", $fiberplancables);
|
||||
$this->layout()->set("fiberPlanPipeNetworks", $fiberPlanPipeNetworks);
|
||||
$this->layout()->set("fiberPlanCablePipes", $fiberPlanCablePipes);
|
||||
$this->layout()->set("fiberPlanPipesEndpoints", $fiberPlanPipesEndpoints);
|
||||
$this->layout()->set("fiberPlanCableEndpoints", $fiberPlanCableEndpoints);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$fiberplancables = new FiberPlanCable($id);
|
||||
if (!$fiberplancables->id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
// $destinationendpoint_sleeve_id = $r->destinationendpoint_sleeve_id;
|
||||
// $destinationendpoint_sleeve_start = $r->destinationendpoint_sleeve_start;
|
||||
// $destinationendpoint_sleeve_end = $r->destinationendpoint_sleeve_end;
|
||||
|
||||
// if (!empty($destinationendpoint_sleeve_id)) {
|
||||
// $counter = 0;
|
||||
// foreach ($destinationendpoint_sleeve_id as $key => $sleeve) {
|
||||
// if ($destinationendpoint_sleeve_start[$key] && $destinationendpoint_sleeve_end[$key] && $sleeve) {
|
||||
//
|
||||
// $endpoint['data'][$counter]['sleeve_id'] = $sleeve;
|
||||
// $endpoint['data'][$counter]['startport'] = $destinationendpoint_sleeve_start[$key];
|
||||
// $endpoint['data'][$counter]['endport'] = $destinationendpoint_sleeve_end[$key];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $endpoint = json_encode($endpoint);
|
||||
|
||||
|
||||
// $destinationstartpoint_poprackmodule_id = $r->destinationstartpoint_poprackmodule_id;
|
||||
// $destinationstartpoint_poprackmodule_start = $r->destinationstartpoint_poprackmodule_start;
|
||||
// $destinationstartpoint_poprackmodule_end = $r->destinationstartpoint_poprackmodule_end;
|
||||
// $destinationstartpoint_poprackmodule_rackid = $r->destinationstartpoint_poprackmodule_rackid;
|
||||
// $destinationendpoint_poprackmodule_id = $r->destinationendpoint_poprackmodule_id;
|
||||
// $destinationendpoint_poprackmodule_start = $r->destinationendpoint_poprackmodule_start;
|
||||
// $destinationendpoint_poprackmodule_end = $r->destinationendpoint_poprackmodule_end;
|
||||
// $destinationendpoint_poprackmodule_rackid = $r->destinationendpoint_poprackmodule_rackid;
|
||||
|
||||
// if (!empty($destinationstartpoint_poprackmodule_id)) {
|
||||
// $counter = 0;
|
||||
// $startpoint['pop_id'] = $r->destinationstartpoint_id;
|
||||
// foreach ($destinationstartpoint_poprackmodule_id as $key => $poprackmodule) {
|
||||
// $startpoint['data'][$counter]['rack_id'] = $destinationstartpoint_poprackmodule_rackid[$key];
|
||||
// $startpoint['data'][$counter]['module_id'] = $poprackmodule;
|
||||
// $startpoint['data'][$counter]['startport'] = $destinationstartpoint_poprackmodule_start[$key];
|
||||
// $startpoint['data'][$counter]['endport'] = $destinationstartpoint_poprackmodule_end[$key];
|
||||
// $counter++;
|
||||
// }
|
||||
// $startpoint = json_encode($startpoint);
|
||||
// }
|
||||
// if (!empty($destinationendpoint_poprackmodule_id)) {
|
||||
// $counter = 0;
|
||||
// $endpoint['pop_id'] = $r->destinationendpoint_id;
|
||||
// foreach ($destinationendpoint_poprackmodule_id as $key => $poprackmodule) {
|
||||
// $endpoint['data'][$counter]['rack_id'] = $destinationendpoint_poprackmodule_rackid[$key];
|
||||
// $endpoint['data'][$counter]['module_id'] = $poprackmodule;
|
||||
// $endpoint['data'][$counter]['startport'] = $destinationendpoint_poprackmodule_start[$key];
|
||||
// $endpoint['data'][$counter]['endport'] = $destinationendpoint_poprackmodule_end[$key];
|
||||
// $counter++;
|
||||
// }
|
||||
// $endpoint = json_encode($endpoint);
|
||||
// }
|
||||
|
||||
$data = [];
|
||||
$data['description'] = trim($r->description);
|
||||
$data['fibers'] = trim($r->fibers);
|
||||
$data['diameter'] = trim($r->diameter);
|
||||
$data['lenght'] = trim($r->lenght);
|
||||
$data['state'] = trim($r->state);
|
||||
$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 = "FiberPlanCable";
|
||||
$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 .= 'FiberPlanCable';
|
||||
}
|
||||
$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($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['fibers']) {
|
||||
$this->layout()->setFlash("Fasern darf nicht leer sein", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['diameter']) {
|
||||
$this->layout()->setFlash("Durchmesser (MM) darf nicht leer sein", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['lenght']) {
|
||||
$this->layout()->setFlash("Länge (M) darf nicht leer sein", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['state']) {
|
||||
$this->layout()->setFlash("Status darf nicht leer sein", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['responsible']) {
|
||||
$this->layout()->setFlash("Zuständig darf nicht leer sein", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
if (!$data['responsible_text']) {
|
||||
$data['responsible_text'] = NULL;
|
||||
}
|
||||
if (!$data['address_id']) {
|
||||
$data['address_id'] = NULL;
|
||||
}
|
||||
if (!$data['comment']) {
|
||||
$data['comment'] = NULL;
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
$fiberplancables->update($data);
|
||||
|
||||
} else {
|
||||
$fiberplancables = FiberPlanCableModel::create($data);
|
||||
}
|
||||
|
||||
$id = $fiberplancables->save();
|
||||
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis konnte nicht angelegt werden", "error");
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
|
||||
$fiberplanpipe = $r->fiberplanpipe;
|
||||
$fiberplanpipe_id = $r->fiberplanpipe_id;
|
||||
$fiberplanpipesub = $r->fiberplanpipesub;
|
||||
|
||||
|
||||
if ($fiberplanpipe) {
|
||||
$FiberPlanCablePipes = FiberPlanCablePipeModel::search(['fiberPlanCable_id' => $id]);
|
||||
$counter = 1;
|
||||
foreach ($fiberplanpipe as $key => $pipe) {
|
||||
$data = [];
|
||||
$data['fiberPlanCable_id'] = $id;
|
||||
$data['fiberPlanPipe_id'] = $pipe;
|
||||
$data['fiberPlanPipe_sub'] = $fiberplanpipesub[$key];
|
||||
$data['sort'] = $counter;
|
||||
$data['direction'] = 0;
|
||||
|
||||
|
||||
if (is_numeric($fiberplanpipe_id[$key])) {
|
||||
$fiberPlanCablePipe = new FiberPlanCablePipe($fiberplanpipe_id[$key]);
|
||||
$fiberPlanCablePipe->update($data);
|
||||
unset($FiberPlanCablePipes[$fiberplanpipe_id[$key]]);
|
||||
} else {
|
||||
|
||||
$fiberPlanCablePipe = FiberPlanCablePipeModel::create($data);
|
||||
}
|
||||
$idfpp = $fiberPlanCablePipe->save();
|
||||
$counter++;
|
||||
}
|
||||
foreach ($FiberPlanCablePipes as $FiberPlanCablePipe) {
|
||||
$FiberPlanCablePipe->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if ($r->destinationstartpoint_poprackmodule_id) {
|
||||
// PoprackmodulepatchModel::clearPort($id);
|
||||
// $destinationstartpoint_poprackmodule_start = $r->destinationstartpoint_poprackmodule_start;
|
||||
// $destinationstartpoint_poprackmodule_end = $r->destinationstartpoint_poprackmodule_end;
|
||||
// foreach ($r->destinationstartpoint_poprackmodule_id as $key => $poprackmodule) {
|
||||
// $startport = $destinationstartpoint_poprackmodule_start[$key];
|
||||
// $endport = $destinationstartpoint_poprackmodule_end[$key];
|
||||
// PoprackmodulepatchModel::updatebyPortRange($poprackmodule, $startport, $endport, $id);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if ($r->destinationendpoint_poprackmodule_id) {
|
||||
// PoprackmodulepatchModel::clearPort($id);
|
||||
// $destinationendpoint_poprackmodule_start = $r->destinationendpoint_poprackmodule_start;
|
||||
// $destinationendpoint_poprackmodule_end = $r->destinationendpoint_poprackmodule_end;
|
||||
// foreach ($r->destinationendpoint_poprackmodule_id as $key => $poprackmodule) {
|
||||
// $startport = $destinationendpoint_poprackmodule_start[$key];
|
||||
// $endport = $destinationendpoint_poprackmodule_end[$key];
|
||||
// PoprackmodulepatchModel::updatebyPortRange($poprackmodule, $startport, $endport, $id);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
if ($mode == "edit") {
|
||||
$this->layout()->setFlash("Kabelverzeichnis erfolgreich geändert", "success");
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("Kabelverzeichnis erfolgreich angelegt", "success");
|
||||
}
|
||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$fiberplancables = new FiberPlanCable($id);
|
||||
if (!$fiberplancables->id || $fiberplancables->id != $id) {
|
||||
$this->layout()->setFlash("Kabelverzeichnis nicht gefunden.", "error");
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
|
||||
$fiberplancables->delete();
|
||||
$this->redirect("FiberPlanCable");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
|
||||
class FiberPlanCableModel
|
||||
{
|
||||
private $description;
|
||||
private $fibers;
|
||||
private $diameter;
|
||||
private $fiberPlanPipe_id;
|
||||
private $fiberPlanPipe_sub;
|
||||
private $startpoint_rack_id;
|
||||
private $endpoint_rack_id;
|
||||
private $startpoint_rackmodule_id;
|
||||
private $endpoint_rackmodule_id;
|
||||
private $startpoint_port;
|
||||
private $endpoint_port;
|
||||
private $startpoint_system;
|
||||
private $endpoint_system;
|
||||
|
||||
|
||||
private $lenght;
|
||||
private $state;
|
||||
private $responsible;
|
||||
private $responsible_text;
|
||||
private $address_id;
|
||||
private $network_id;
|
||||
private $comment;
|
||||
|
||||
|
||||
public static function find($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new FiberPlanCable();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("FiberPlanCable", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new FiberPlanCable($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("FiberPlanCable", "*", "1=1");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new FiberPlanCable($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("FiberPlanCable", "*", "$where ");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new FiberPlanCable($data);
|
||||
if ($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("FiberPlanCable", "*", "$where");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new FiberPlanCable($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter)
|
||||
{
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if (array_key_exists("network_id", $filter)) {
|
||||
$networkid = $filter['network_id'];
|
||||
if (is_numeric($networkid)) {
|
||||
$where .= " AND network_id=$networkid";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
public static function getFiberPlanPipe($network_id)
|
||||
{
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT * FROM `FiberPlanPipeEndpoint`";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$ok=0;
|
||||
$FiberplanPipeEndpoint = new FiberPlanPipeEndpoint($data);
|
||||
|
||||
if ($data->fiberPlanDispatcher_id) {
|
||||
if ($FiberplanPipeEndpoint->fiberPlanDispatcher->network_id == $network_id) {
|
||||
$ok=1;
|
||||
}
|
||||
}
|
||||
if ($data->building_id) {
|
||||
if ($FiberplanPipeEndpoint->building->network_id == $network_id) {
|
||||
$ok=1;
|
||||
}
|
||||
}
|
||||
if ($data->pop_id) {
|
||||
$sql = "SELECT id FROM PopNetwork WHERE pop_id='" . $data->pop_id . "' AND network_id='" . $network_id . "'";
|
||||
$result = $db->query($sql);
|
||||
if ($db->num_rows($result)) {
|
||||
$ok=1;
|
||||
}
|
||||
}
|
||||
if ($ok==1) {
|
||||
$items[$FiberplanPipeEndpoint->fiberPlanPipe_id]['description'] = $FiberplanPipeEndpoint->fiberPlanPipe->description;
|
||||
$items[$FiberplanPipeEndpoint->fiberPlanPipe_id]['id'] = $FiberplanPipeEndpoint->fiberPlanPipe_id;
|
||||
}
|
||||
|
||||
}
|
||||
$response['success'] = true;
|
||||
$response['data'] = $items;
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFiberPlanPipeSub($fiberplanpipe_id, $internal = 0)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$sql = "SELECT `FiberPlanPipe`.`id`,`type`, `type_description`, `fiberPlanPipeTemplate_id`,`pipe7x4`, `pipe14x10`,colors FROM `FiberPlanPipe`
|
||||
LEFT JOIN `FiberPlanPipeTemplate` ON `FiberPlanPipeTemplate`.`id`=`FiberPlanPipe`.`fiberPlanPipeTemplate_id`
|
||||
LEFT JOIN `FiberPlanPipeManufacturer` ON `FiberPlanPipeTemplate`.`fiberPlanPipeManufacturer_id`=`FiberPlanPipeManufacturer`.`id`
|
||||
WHERE `FiberPlanPipe`.`id`='" . $fiberplanpipe_id . "'
|
||||
";
|
||||
$res = $db->query($sql);
|
||||
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$items[] = $data;
|
||||
}
|
||||
|
||||
$response['success'] = true;
|
||||
$response['data'] = $items;
|
||||
$response['variables']['type_description'] = FiberPlanPipeModel::$type_descrition_definition;
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
}
|
||||
|
||||
if ($internal == 0) {
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
} else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLineworkerAddresses()
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `Addresstype`.`id`,`Address`.`company` FROM `Addresstype`
|
||||
INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
|
||||
WHERE `type` = 'lineworker' ORDER by `Address`.`company` ";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new FiberPlanCable($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function generateEndpoint($endpoint, $destination, $html = 1)
|
||||
{
|
||||
|
||||
$endpoint = json_decode($endpoint, true);
|
||||
$popid = $endpoint['pop_id'];
|
||||
$racks = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `id`, `pop_id`, `name`, `he` FROM `Poprack` WHERE `pop_id`='" . $popid . "' ";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$racks[$data['id']] = $data['name'];
|
||||
}
|
||||
}
|
||||
$sql = "SELECT `Poprackmodule`.`id`, `Poprackmodule`.`poprack_id`, `Poprackmodule`.`type`, `Poprackmodule`.`device_id`, `Poprackmodule`.`name`, `Poprackmodule`.`start_he`, `Poprackmodule`.`end_he`, `Poprackmodule`.`ports`, `Poprackmodule`.`plug`, `Poprackmodule`.`width`, `Poprackmodule`.`position`,pop_id FROM `Poprackmodule`
|
||||
INNER JOIN `Poprack` ON (`Poprack`.`id`=`Poprackmodule`.`poprack_id`)
|
||||
WHERE `Poprack`.`pop_id`= '" . $popid . "'";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
if ($data['plug'] == 1) $plug = 'LC/APC';
|
||||
elseif ($data['plug'] == 2) $plug = 'SC/APC';
|
||||
elseif ($data['plug'] == 3) $plug = 'E2000/APC';
|
||||
$racksmodules[$data['poprack_id']][$data['id']]['name'] = $data['name'];
|
||||
$racksmodules[$data['poprack_id']][$data['id']]['plug'] = $plug;
|
||||
$racksmodules[$data['poprack_id']][$data['id']]['ports'] = $data['ports'];
|
||||
$racksmodules[$data['poprack_id']][$data['id']]['start_he'] = $data['start_he'];
|
||||
}
|
||||
}
|
||||
$counter = 1;
|
||||
$oldrack = "";
|
||||
|
||||
if ($html == "0") {
|
||||
$return['racks'] = $racks;
|
||||
$return['racksmodules'] = $racksmodules;
|
||||
|
||||
return $return;
|
||||
}
|
||||
foreach ($endpoint['data'] as $module) {
|
||||
unset($option);
|
||||
if ($counter === 1) {
|
||||
|
||||
foreach ($racks as $rackid => $rack) {
|
||||
if ($rackid == $module['rack_id']) $selected = 'selected="selected"';
|
||||
else $selected = "";
|
||||
|
||||
$option .= '<option ' . $selected . ' value="' . $rackid . '">' . $rack . '</option>';
|
||||
}
|
||||
$return = '<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="lenght">Schrank <i data-popid="5" class="fa-regular fa-circle-plus add-rack"></i></label>
|
||||
<div class="col-lg-5">
|
||||
<select name="destination' . $destination . '_poprack_id" required="required" class="select2 form-control poprack_id">' . $option . '</select>
|
||||
</div>
|
||||
</div>';
|
||||
$return .= '<div class="destinationmodules">';
|
||||
unset($option);
|
||||
foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
|
||||
if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
|
||||
else $selected = "";
|
||||
$option .= '<option ' . $selected . ' data-ports="' . $racksmodule['ports'] . '" value="' . $racksmoduleid . '">(HE:' . $racksmodule['start_he'] . ') ' . $racksmodule['name'] . ' (' . $racksmodule['plug'] . ' ' . $racksmodule['ports'] . 'p)</option>';
|
||||
}
|
||||
|
||||
$return .= '<div class="form-group module-row row">
|
||||
<label class="col-lg-2 col-form-label" for="lenght"><span class="fibersum">(1-24)</span><i class="fa-regular fa-circle-plus add-module" data-poprackid="3"></i></label>
|
||||
<div class="col-lg-5">
|
||||
<select name="destination' . $destination . '_poprackmodule_id[]" required="required" class="select2 form-control poprackmodule_id">' . $option . '</select>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">von</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_start[]" value="' . $module["startport"] . '" type="number" class="form-control ports-start">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">bis</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_end[]" value="' . $module["endport"] . '" type="number" class="form-control ports-end">
|
||||
<input style="display:none" name="destination' . $destination . '_poprackmodule_rackid[]" value="' . $module["rack_id"] . '" type="number" class="form-control ports-rackid">
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
||||
} else if ($oldrack != $module['rack_id']) {
|
||||
unset($option);
|
||||
|
||||
foreach ($racks as $rackid => $rack) {
|
||||
if ($rackid == $module['rack_id']) $selected = 'selected="selected"';
|
||||
else $selected = "";
|
||||
|
||||
$option .= '<option ' . $selected . ' value="' . $rackid . '">' . $rack . '</option>';
|
||||
}
|
||||
$return .= '</div>';
|
||||
$return .= '<div class="form-group row" style="border-top: 1px dotted #9b9b9b;padding-top: 15px;">
|
||||
<label class="col-lg-2 col-form-label" for="lenght">Schrank <i data-popid="5" class="fa-regular fa-circle-minus remove-rack"></i></label>
|
||||
<div class="col-lg-5">
|
||||
<select name="destination' . $destination . '_poprack_id" required="required" class="select2 form-control poprack_id">' . $option . '</select>
|
||||
</div>
|
||||
</div>';
|
||||
$return .= '<div class="destinationmodules">';
|
||||
unset($option);
|
||||
foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
|
||||
if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
|
||||
else $selected = "";
|
||||
$option .= '<option ' . $selected . ' data-ports="' . $racksmodule['ports'] . '" value="' . $racksmoduleid . '">(HE:' . $racksmodule['start_he'] . ') ' . $racksmodule['name'] . ' (' . $racksmodule['plug'] . ' ' . $racksmodule['ports'] . 'p)</option>';
|
||||
}
|
||||
$return .= '<div class="form-group module-row row">
|
||||
<label class="col-lg-2 col-form-label" for="lenght"><span class="fibersum">(1-24)</span><i class="fa-regular fa-circle-plus add-module" data-poprackid="' . $module['rack_id'] . '"></i></label>
|
||||
<div class="col-lg-5">
|
||||
<select name="destination' . $destination . '_poprackmodule_id[]" required="required" class="select2 form-control poprackmodule_id">' . $option . '</select>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">von</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_start[]" value="' . $module["startport"] . '" type="number" class="form-control ports-start">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">bis</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_end[]" value="' . $module["endport"] . '" type="number" class="form-control ports-end">
|
||||
<input style="display:none" name="destination' . $destination . '_poprackmodule_rackid[]" value="' . $module["rack_id"] . '" type="number" class="form-control ports-rackid">
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
unset($option);
|
||||
foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
|
||||
if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
|
||||
else $selected = "";
|
||||
$option .= '<option ' . $selected . ' data-ports="' . $racksmodule['ports'] . '" value="' . $racksmoduleid . '">(HE:' . $racksmodule['start_he'] . ') ' . $racksmodule['name'] . ' (' . $racksmodule['plug'] . ' ' . $racksmodule['ports'] . 'p)</option>';
|
||||
}
|
||||
$return .= '<div class="form-group module-row row">
|
||||
<label class="col-lg-2 col-form-label" for="lenght"><span class="fibersum">(1-24)</span><i class="fa-regular fa-circle-minus remove-module" data-poprackid="' . $module['rack_id'] . '"></i></label>
|
||||
<div class="col-lg-5">
|
||||
<select name="destination' . $destination . '_poprackmodule_id[]" required="required" class="select2 form-control poprackmodule_id">' . $option . '</select>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">von</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_start[]" value="' . $module["startport"] . '" type="number" class="form-control ports-start">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">bis</div>
|
||||
</div>
|
||||
<input name="destination' . $destination . '_poprackmodule_end[]" value="' . $module["endport"] . '" type="number" class="form-control ports-end">
|
||||
<input style="display:none" name="destination' . $destination . '_poprackmodule_rackid[]" value="' . $module["rack_id"] . '" type="number" class="form-control ports-rackid">
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$oldrack = $module['rack_id'];
|
||||
$counter++;
|
||||
}
|
||||
$return .= "</div>";
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user