' . $dropcounter . ' Fasern
';
+ } else {
+ $body .= '
= $pipesub; ?>
diff --git a/Layout/default/FiberPlanPipe/Index.php b/Layout/default/FiberPlanPipe/Index.php
index 516d0cf2d..2ac6548c1 100644
--- a/Layout/default/FiberPlanPipe/Index.php
+++ b/Layout/default/FiberPlanPipe/Index.php
@@ -75,10 +75,8 @@ foreach ($pipworkeraddresses as $pipworkeraddress) {
-
| Bezeichnung |
Type/Bezeichnung |
-
Länge (m) |
Netzgebiet(e) |
Anfangspunkt |
@@ -88,10 +86,8 @@ foreach ($pipworkeraddresses as $pipworkeraddress) {
|
-
|
|
-
|
|
|
diff --git a/Layout/default/menu.php b/Layout/default/menu.php
index 376821e31..eb7785992 100644
--- a/Layout/default/menu.php
+++ b/Layout/default/menu.php
@@ -98,7 +98,7 @@
is(["Admin","netowner","pipeplanner","lineplanner","pipeworker","netoperator","lineworker"]) && $me->can("Filestore")): ?>"> Dateiablage
is(["Admin","netowner","pipeplanner","pipeplanner"]) && $me->is("employee")): ?>"> Verteiler und Schächte
is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?>"> Rohrverzeichnis
-is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?>
+ is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?>"> Kabelverzeichnis
diff --git a/application/FiberPlanCable/FiberPlanCable.php b/application/FiberPlanCable/FiberPlanCable.php
new file mode 100644
index 000000000..49b94cecc
--- /dev/null
+++ b/application/FiberPlanCable/FiberPlanCable.php
@@ -0,0 +1,62 @@
+$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;
+ }
+
+}
\ No newline at end of file
diff --git a/application/FiberPlanCable/FiberPlanCableController.php b/application/FiberPlanCable/FiberPlanCableController.php
new file mode 100644
index 000000000..ef11149ff
--- /dev/null
+++ b/application/FiberPlanCable/FiberPlanCableController.php
@@ -0,0 +1,425 @@
+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");
+ }
+
+}
diff --git a/application/FiberPlanCable/FiberPlanCableModel.php b/application/FiberPlanCable/FiberPlanCableModel.php
new file mode 100644
index 000000000..8d654785e
--- /dev/null
+++ b/application/FiberPlanCable/FiberPlanCableModel.php
@@ -0,0 +1,424 @@
+ $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 .= '';
+ }
+ $return = '';
+ $return .= '';
+ unset($option);
+ foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
+ if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
+ else $selected = "";
+ $option .= ' ';
+ }
+
+ $return .= ' ';
+
+
+ } else if ($oldrack != $module['rack_id']) {
+ unset($option);
+
+ foreach ($racks as $rackid => $rack) {
+ if ($rackid == $module['rack_id']) $selected = 'selected="selected"';
+ else $selected = "";
+
+ $option .= ' ';
+ }
+ $return .= ' ';
+ $return .= '';
+ $return .= '';
+ unset($option);
+ foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
+ if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
+ else $selected = "";
+ $option .= ' ';
+ }
+ $return .= ' ';
+ } else {
+ unset($option);
+ foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) {
+ if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"';
+ else $selected = "";
+ $option .= ' ';
+ }
+ $return .= ' ';
+ }
+
+ $oldrack = $module['rack_id'];
+ $counter++;
+ }
+ $return .= " ";
+ return $return;
+
+ }
+
+}
diff --git a/application/FiberPlanCableEndpoint/FiberPlanCableEndpoint.php b/application/FiberPlanCableEndpoint/FiberPlanCableEndpoint.php
new file mode 100644
index 000000000..eeccb4358
--- /dev/null
+++ b/application/FiberPlanCableEndpoint/FiberPlanCableEndpoint.php
@@ -0,0 +1,65 @@
+$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;
+}
+
+}
\ No newline at end of file
diff --git a/application/FiberPlanCableEndpoint/FiberPlanCableEndpointController.php b/application/FiberPlanCableEndpoint/FiberPlanCableEndpointController.php
new file mode 100644
index 000000000..5b0333406
--- /dev/null
+++ b/application/FiberPlanCableEndpoint/FiberPlanCableEndpointController.php
@@ -0,0 +1,161 @@
+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("FiberPlanCableEndpoint/Index");
+ $fiberplancableendpoints = FiberPlanCableEndpointModel::getAll();
+ $this->layout()->set("fiberplancableendpoints", $fiberplancableendpoints);
+
+ }
+
+ protected function addAction()
+ {
+ $fiberPlanCables=FiberPlanCableModel::getAll();
+ $this->layout()->set("fiberPlanCables", $fiberPlanCables);
+ $pops=PopModel::getAll();
+ $this->layout()->set("pops", $pops);
+ $racks=RackModel::getAll();
+ $this->layout()->set("racks", $racks);
+ $modules=ModuleModel::getAll();
+ $this->layout()->set("modules", $modules);
+ $fiberPlanDispatchers=FiberPlanDispatcherModel::getAll();
+ $this->layout()->set("fiberPlanDispatchers", $fiberPlanDispatchers);
+ $buildings=BuildingModel::getAll();
+ $this->layout()->set("buildings", $buildings);
+
+ $this->layout()->setTemplate("FiberPlanCableEndpoint/Form");
+
+ }
+
+ protected function editAction()
+ {
+ $id = $this->request->id;
+
+ if (!is_numeric($id) || !$id) {
+ $this->layout()->setFlash("f nicht gefunden", "error");
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+ $fiberplancableendpoints = new FiberPlanCableEndpoint($id);
+ if ($fiberplancableendpoints->id != $id) {
+ $this->layout()->setFlash("f nicht gefunden", "error");
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+ $this->layout()->set("fiberplancableendpoints", $fiberplancableendpoints);
+ return $this->addAction();
+ }
+
+ protected function saveAction()
+ {
+ $r = $this->request;
+ $id = $r->id;
+ //var_dump($r->get());exit;
+ if (is_numeric($id) && $id > 0) {
+ $mode = "edit";
+ $fiberplancableendpoints = new FiberPlanCableEndpoint($id);
+ if (!$fiberplancableendpoints->id) {
+ $this->layout()->setFlash("f nicht gefunden", "error");
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+ } else {
+ $mode = "add";
+ }
+
+ $data = [];
+ $data['fiberPlanCable_id'] = trim($r->fiberPlanCable_id);
+ $data['pop_id'] = trim($r->pop_id);
+ $data['rack_id'] = trim($r->rack_id);
+ $data['module_id'] = trim($r->module_id);
+ $data['fiberPlanDispatcher_id'] = trim($r->fiberPlanDispatcher_id);
+ $data['building_id'] = trim($r->building_id);
+ $data['startport'] = trim($r->startport);
+ $data['endport'] = trim($r->endport);
+
+
+ if (!$data['fiberPlanCable_id']) {
+ $data['fiberPlanCable_id']=NULL;
+ }
+ if (!$data['pop_id']) {
+ $data['pop_id']=NULL;
+ }
+ if (!$data['rack_id']) {
+ $data['rack_id']=NULL;
+ }
+ if (!$data['module_id']) {
+ $data['module_id']=NULL;
+ }
+ if (!$data['fiberPlanDispatcher_id']) {
+ $data['fiberPlanDispatcher_id']=NULL;
+ }
+ if (!$data['building_id']) {
+ $data['building_id']=NULL;
+ }
+ if (!$data['startport']) {
+ $data['startport']=NULL;
+ }
+ if (!$data['endport']) {
+ $data['endport']=NULL;
+ }
+
+
+// var_dump($_FILES);
+// var_dump($upload);
+// exit;
+
+
+ if ($mode == "edit") {
+ $fiberplancableendpoints->update($data);
+
+ } else {
+ $fiberplancableendpoints = FiberPlanCableEndpointModel::create($data);
+ }
+// var_dump($filestore);
+// exit;
+ $id = $fiberplancableendpoints->save();
+
+ if (!$id) {
+ $this->layout()->setFlash("f konnte nicht angelegt werden", "error");
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+ if ($mode == "edit") {
+ $this->layout()->setFlash("f erfolgreich geändert", "success");
+ } else if ($mode = "add") {
+ $this->layout()->setFlash("f erfolgreich angelegt", "success");
+ }
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+
+ protected function deleteAction()
+ {
+ $id = $this->request->id;
+ $fiberplancableendpoints = new FiberPlanCableEndpoint($id);
+ if (!$fiberplancableendpoints->id || $fiberplancableendpoints->id != $id) {
+ $this->layout()->setFlash("f nicht gefunden.", "error");
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+ $fiberplancableendpoints->delete();
+ $this->redirect("FiberPlanCableEndpoint");
+ }
+
+}
diff --git a/application/FiberPlanCableEndpoint/FiberPlanCableEndpointModel.php b/application/FiberPlanCableEndpoint/FiberPlanCableEndpointModel.php
new file mode 100644
index 000000000..9eb9b2b6a
--- /dev/null
+++ b/application/FiberPlanCableEndpoint/FiberPlanCableEndpointModel.php
@@ -0,0 +1,131 @@
+ $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("FiberPlanCableEndpoint", "*", "id=$id LIMIT 1");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new FiberPlanCableEndpoint($data);
+ }
+ return $item;
+ }
+
+ public static function getAll()
+ {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("FiberPlanCableEndpoint", "*", "1=1");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new FiberPlanCableEndpoint($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst()
+ {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("FiberPlanCableEndpoint", "*", "$where ");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new FiberPlanCableEndpoint($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("FiberPlanCableEndpoint", "*", "$where");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[$data->fiberPlanPipeEndpoint_id][] = new FiberPlanCableEndpoint($data);
+ }
+ }
+ return $items;
+ }
+
+ private static function getSqlFilter($filter)
+ {
+ $where = "1=1 ";
+
+ //var_dump($filter);exit;
+ if (array_key_exists("fiberPlanCable_id", $filter)) {
+ $fiberPlanCable_id = $filter['fiberPlanCable_id'];
+ if (is_numeric($fiberPlanCable_id)) {
+ $where .= " AND fiberPlanCable_id=$fiberPlanCable_id ORDER by sort";
+ }
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+}
diff --git a/application/FiberPlanCablePipe/FiberPlanCablePipe.php b/application/FiberPlanCablePipe/FiberPlanCablePipe.php
new file mode 100644
index 000000000..f2f2a98b1
--- /dev/null
+++ b/application/FiberPlanCablePipe/FiberPlanCablePipe.php
@@ -0,0 +1,61 @@
+$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;
+}
+
+}
\ No newline at end of file
diff --git a/application/FiberPlanCablePipe/FiberPlanCablePipeController.php b/application/FiberPlanCablePipe/FiberPlanCablePipeController.php
new file mode 100644
index 000000000..dcbc966ba
--- /dev/null
+++ b/application/FiberPlanCablePipe/FiberPlanCablePipeController.php
@@ -0,0 +1,137 @@
+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("FiberPlanCablePipe/Index");
+ $fiberplancablepipes = FiberPlanCablePipeModel::getAll();
+ $this->layout()->set("fiberplancablepipes", $fiberplancablepipes);
+
+ }
+
+ protected function addAction()
+ {
+ $fiberPlanCables=FiberPlanCableModel::getAll();
+ $this->layout()->set("fiberPlanCables", $fiberPlanCables);
+ $fiberPlanPipes=FiberPlanPipeModel::getAll();
+ $this->layout()->set("fiberPlanPipes", $fiberPlanPipes);
+
+ $this->layout()->setTemplate("FiberPlanCablePipe/Form");
+
+ }
+
+ protected function editAction()
+ {
+ $id = $this->request->id;
+
+ if (!is_numeric($id) || !$id) {
+ $this->layout()->setFlash("Faserplanpipe nicht gefunden", "error");
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+ $fiberplancablepipes = new FiberPlanCablePipe($id);
+ if ($fiberplancablepipes->id != $id) {
+ $this->layout()->setFlash("Faserplanpipe nicht gefunden", "error");
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+ $this->layout()->set("fiberplancablepipes", $fiberplancablepipes);
+ return $this->addAction();
+ }
+
+ protected function saveAction()
+ {
+ $r = $this->request;
+ $id = $r->id;
+ //var_dump($r->get());exit;
+ if (is_numeric($id) && $id > 0) {
+ $mode = "edit";
+ $fiberplancablepipes = new FiberPlanCablePipe($id);
+ if (!$fiberplancablepipes->id) {
+ $this->layout()->setFlash("Faserplanpipes nicht gefunden", "error");
+ $this->redirect("FiberPlanCablePipe");
+ }
+ } else {
+ $mode = "add";
+ }
+
+ $data = [];
+ $data['fiberPlanCable_id'] = trim($r->fiberPlanCable_id);
+ $data['fiberPlanPipe_id'] = trim($r->fiberPlanPipe_id);
+ $data['fiberPlanPipe_sub'] = trim($r->fiberPlanPipe_sub);
+ $data['sort'] = trim($r->sort);
+
+
+ if (!$data['fiberPlanCable_id']) {
+ $data['fiberPlanCable_id']=NULL;
+ }
+ if (!$data['fiberPlanPipe_id']) {
+ $data['fiberPlanPipe_id']=NULL;
+ }
+ if (!$data['fiberPlanPipe_sub']) {
+ $data['fiberPlanPipe_sub']=NULL;
+ }
+ if (!$data['sort']) {
+ $data['sort']=NULL;
+ }
+
+
+// var_dump($_FILES);
+// var_dump($upload);
+// exit;
+
+
+ if ($mode == "edit") {
+ $fiberplancablepipes->update($data);
+
+ } else {
+ $fiberplancablepipes = FiberPlanCablePipeModel::create($data);
+ }
+// var_dump($filestore);
+// exit;
+ $id = $fiberplancablepipes->save();
+
+ if (!$id) {
+ $this->layout()->setFlash("Faserplanpipe konnte nicht angelegt werden", "error");
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+ if ($mode == "edit") {
+ $this->layout()->setFlash("Faserplanpipe erfolgreich geändert", "success");
+ } else if ($mode = "add") {
+ $this->layout()->setFlash("Faserplanpipe erfolgreich angelegt", "success");
+ }
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+
+ protected function deleteAction()
+ {
+ $id = $this->request->id;
+ $fiberplancablepipes = new FiberPlanCablePipe($id);
+ if (!$fiberplancablepipes->id || $fiberplancablepipes->id != $id) {
+ $this->layout()->setFlash("Faserplanpipe nicht gefunden.", "error");
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+ $fiberplancablepipes->delete();
+ $this->redirect("FiberPlanCablePipe");
+ }
+
+}
diff --git a/application/FiberPlanCablePipe/FiberPlanCablePipeModel.php b/application/FiberPlanCablePipe/FiberPlanCablePipeModel.php
new file mode 100644
index 000000000..cd311c9ee
--- /dev/null
+++ b/application/FiberPlanCablePipe/FiberPlanCablePipeModel.php
@@ -0,0 +1,129 @@
+ $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("FiberPlanCablePipe", "*", "id=$id LIMIT 1");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new FiberPlanCablePipe($data);
+ }
+ return $item;
+ }
+
+ public static function getAll()
+ {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("FiberPlanCablePipe", "*", "1=1");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new FiberPlanCablePipe($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst()
+ {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("FiberPlanCablePipe", "*", "$where ");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new FiberPlanCablePipe($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("FiberPlanCablePipe", "*", "$where");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[$data->id] = new FiberPlanCablePipe($data);
+ }
+ }
+ return $items;
+ }
+
+ private static function getSqlFilter($filter)
+ {
+ $where = "1=1 ";
+
+ //var_dump($filter);exit;
+ if (array_key_exists("fiberPlanCable_id", $filter)) {
+ $fiberPlanCable_id = $filter['fiberPlanCable_id'];
+ if (is_numeric($fiberPlanCable_id)) {
+ $where .= " AND fiberPlanCable_id=$fiberPlanCable_id ORDER by sort";
+ }
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/FiberPlanPipeEndpoint/FiberPlanPipeEndpointModel.php b/application/FiberPlanPipeEndpoint/FiberPlanPipeEndpointModel.php
index 9e575847c..bf963c509 100644
--- a/application/FiberPlanPipeEndpoint/FiberPlanPipeEndpointModel.php
+++ b/application/FiberPlanPipeEndpoint/FiberPlanPipeEndpointModel.php
@@ -7,7 +7,7 @@ class FiberPlanPipeEndpointModel
private $fiberPlanDispatcher_id;
private $building_id;
private $sort;
-
+
public static function find($data)
{
@@ -95,6 +95,33 @@ class FiberPlanPipeEndpointModel
return null;
}
+ public static function searchNetworks($filter)
+ {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("FiberPlanPipeEndpoint", "*", "$where ORDER by sort LIMIT 1");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $FiberplanPipeEndpoint = new FiberPlanPipeEndpoint($data);
+ if ($data->pop_id) {
+
+ $sql = "SELECT network_id FROM PopNetwork WHERE pop_id='" . $data->pop_id . "' LIMIT 1";
+ $result = $db->query($sql);
+ $fetch = $db->fetch_object($result);
+ $item = (string) $fetch->network_id;
+ }
+ if ($data->fiberPlanDispatcher_id) {
+ $item = (string) $FiberplanPipeEndpoint->fiberPlanDispatcher->network_id;
+ }
+ if ($data->building_id) {
+ $item = (string) $FiberplanPipeEndpoint->building->network_id;
+ }
+ }
+ }
+ return $item;
+ }
+
public static function search($filter)
{
$items = [];
diff --git a/application/FiberPlanPipeManufacturer/FiberPlanPipeManufacturerModel.php b/application/FiberPlanPipeManufacturer/FiberPlanPipeManufacturerModel.php
index 09556f05f..9069f550c 100644
--- a/application/FiberPlanPipeManufacturer/FiberPlanPipeManufacturerModel.php
+++ b/application/FiberPlanPipeManufacturer/FiberPlanPipeManufacturerModel.php
@@ -53,6 +53,8 @@ class FiberPlanPipeManufacturerModel
$res = $db->select("FiberPlanPipeManufacturer", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
+ $colors=json_decode($data->colors);
+ $data->colors=$colors;
$item = new FiberPlanPipeManufacturer($data);
}
return $item;
diff --git a/application/FiberPlanPipeTemplate/FiberPlanPipeTemplateModel.php b/application/FiberPlanPipeTemplate/FiberPlanPipeTemplateModel.php
index fec7e6ae4..bafd18562 100644
--- a/application/FiberPlanPipeTemplate/FiberPlanPipeTemplateModel.php
+++ b/application/FiberPlanPipeTemplate/FiberPlanPipeTemplateModel.php
@@ -102,7 +102,7 @@ class FiberPlanPipeTemplateModel
$res = $db->select("FiberPlanPipeTemplate", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
- $items[] = new FiberPlanPipeTemplate($data);
+ $items[$data->id] = new FiberPlanPipeTemplate($data);
}
}
return $items;
diff --git a/application/Poprackmodule/PoprackmoduleModel.php b/application/Poprackmodule/PoprackmoduleModel.php
index ba1b38a77..91e64be1f 100644
--- a/application/Poprackmodule/PoprackmoduleModel.php
+++ b/application/Poprackmodule/PoprackmoduleModel.php
@@ -73,5 +73,30 @@ class PoprackmoduleModel
exit;
}
+ public static function getpoprackmoduleall($pop_id)
+ {
+ $items = [];
+ $db = FronkDB::singleton();
+ $sql = "SELECT `Poprackmodule`.`id`, `Poprackmodule`.`name`, `Poprackmodule`.`start_he`,`Poprackmodule`.`end_he`,`Poprackmodule`.`plug`,`Poprackmodule`.`ports`,`Poprack`.id poprackid ,`Poprack`.name poprackname FROM `Poprackmodule` INNER JOIN
+ `Poprack` ON (`Poprack`.`id` = `Poprackmodule`.`poprack_id`)
+ WHERE `Poprack`.`pop_id`='" . $pop_id . "' AND `Poprackmodule`.`type` ='0' ORDER by `Poprack`.`sort`,`Poprackmodule`.`start_he`,`Poprackmodule`.`position`";
+
+ $res = $db->query($sql);
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_array($res)) {
+ $items[$data['poprackname']][] = $data;
+ }
+
+ $response['data'] = $items;
+ $response['success'] = true;
+
+
+ } else {
+ $response['success'] = false;
+ }
+ echo json_encode($response);
+ exit;
+ }
+
}
\ No newline at end of file
diff --git a/db/migrations/20240624123822_fiber_plan_cable.php b/db/migrations/20240624123822_fiber_plan_cable.php
index 5d367d355..01b63956e 100644
--- a/db/migrations/20240624123822_fiber_plan_cable.php
+++ b/db/migrations/20240624123822_fiber_plan_cable.php
@@ -8,7 +8,6 @@ final class FiberPlanCable extends AbstractMigration
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("FiberPlanCable", ["signed" => true]);
-
$table->addColumn("description", "text", ["null" => false]);
$table->addColumn("fibers", "integer", ["null" => false]);
$table->addColumn("diameter", "integer", ["null" => false]);
diff --git a/public/js/pages/FiberPlanCable/Form.js b/public/js/pages/FiberPlanCable/Form.js
new file mode 100644
index 000000000..5c7499130
--- /dev/null
+++ b/public/js/pages/FiberPlanCable/Form.js
@@ -0,0 +1,960 @@
+const poprackmodulesoption = {};
+
+function checkendpoints() {
+ let endpointcounter = $('.fiberplanpipe-label').length;
+ let endpointtext;
+ $('.fiberplanpipe-label').each(function (index) {
+ $(this).find('.move-endpoint-up').remove();
+ $(this).find('.move-endpoint-down').remove();
+ $(this).find('.remove-endpoint').remove();
+ if (index == 0 && endpointcounter - 1 == 0) {
+ // endpointtext = "Startpunkt";
+ } else if (index == 0) {
+ $(this).closest('.fiberplanpipe-label').find('.label-text').after('');
+
+ } else if (endpointcounter == 2) {
+ endpointtext = 'Standort ' + index;
+ $(this).closest('.fiberplanpipe-label').find('.label-text').after('');
+ $(this).find('.endpointsymbol').html('');
+ } else if (endpointcounter - 1 == index) {
+ endpointtext = 'Standort ' + index;
+ $(this).closest('.fiberplanpipe-label').find('.label-text').after('');
+ $(this).find('.endpointsymbol').html('');
+ } else if (index > 0) {
+ endpointtext = 'Standort ' + index;
+ $(this).closest('.fiberplanpipe-label').find('.label-text').after('');
+ $(this).find('.endpointsymbol').html('');
+ }
+
+ // $(this).find('.label-text').text(endpointtext + ' *');
+ });
+}
+
+function checkracks() {
+ $.each($('.fiberplanpipe-pop-racks'), function (index, value) {
+ var option = "";
+ var thisis = $(this);
+ $.getJSON(poprackmoduleallUrl + "&pop_id=" + $(this).data('popid'), {})
+ .done(function (data) {
+ if (data.success) {
+ var plug;
+ $.each(data.data, function (k, val) {
+ option = option + '";
+ });
+ }
+ thisis.closest('.fiberplancableendpoint-div').find('.poprackmodule_id').html(option);
+ $.each(thisis.closest('.fiberplancableendpoint-div').find('.poprackmodule_id'), function (index, value) {
+ if ($(this).data('poprackmodule_id') != "undefined") {
+ $(this).val($(this).data('poprackmodule_id'));
+ $(this).trigger("change", "1");
+ }
+
+ });
+
+
+ }
+ )
+ .done(function (data) {
+
+ });
+ });
+}
+
+function checksleeves() {
+
+ $.each($('.fiberplanpipe-dispatcher-sleeves'), function (index, value) {
+ var option = "";
+ var thisis = $(this);
+ $.getJSON(dispatchersleeveUrl + "&dispatcher_id=" + $(this).data('id'), {})
+ .done(function (data) {
+ if (data.success) {
+ $.each(data.data, function (k, val) {
+ option = option + '';
+ });
+
+ thisis.closest('.fiberplancableendpoint-div').find('.sleeveid').html(option);
+ $.each(thisis.closest('.fiberplancableendpoint-div').find('.fiberplandispatcher_id'), function (index, value) {
+ if ($(this).data('id') != "undefined") {
+ $(this).val($(this).data('id'));
+ $(this).trigger("change", "1");
+ }
+
+ });
+ }
+
+ });
+ });
+}
+
+function checkusedfibers(trigger) {
+ var destination = trigger.closest('.fiberplanpipe-body-div').find('.module-row');
+ var fibercounter = 0;
+ var sumstart;
+ var sumend;
+ destination.each(function (index) {
+ sumstart = fibercounter + 1;
+ if (parseInt($(this).find('.ports-end').val()) && parseInt($(this).find('.ports-start').val())) {
+ fibercounter = fibercounter + parseInt($(this).find('.ports-end').val()) - parseInt($(this).find('.ports-start').val()) + 1;
+ sumend = fibercounter;
+ $(this).find('.fibersum').text('(' + sumstart + '-' + sumend + ')');
+ }
+
+ });
+ trigger.closest('.destinationpoint').find('.fiber-used').text(fibercounter);
+}
+
+function checkusedpipes() {
+ var counter = 0;
+ $.each($('.fiberplanpipesub'), function (index, value) {
+ $('.fiberplanpipe-subpipe').eq(counter).html($(this).next('span').find('.select2-selection__rendered').html());
+ counter++;
+ });
+}
+
+function formatState(state) {
+ if (!state.id || !state.title) {
+ return state.text;
+ }
+ const titleArray = state.title.split(";");
+ var title = titleArray[0];
+ var titlestripe = titleArray[1];
+ var border = 'border:none;'
+ if (title == "#ffffff" || title == "#ffff01" || title == "#01ffff") {
+ border = 'border:1px solid #9d9d9d;';
+ }
+ var height = '10px';
+ var striped = '';
+ if (titlestripe == 1) {
+ striped = 'style="background-color: #000;height: 100%;width: 45%;text-align: center;margin-left: auto;margin-right: auto;"';
+ }
+ if (state.text.indexOf("14x10") != -1) {
+ height = "12px";
+ }
+ var returnstate = $(
+ '' + state.text + ' '
+ );
+ return returnstate;
+};
+
+function generateDestinationmid(destinations, destinationtype, destinationdiv, param = 0, append = 0) {
+ var destination_typename = "Schächte/Verteiler";
+ var randid;
+ $('#' + destinationdiv).append(`
+ ` + destinationtype + ` (` + destination_typename + `)
+ `);
+ console.log(destinations);
+ $.each(destinations, function (index, destination) {
+
+
+ var destination_typename = destination.typename;
+ var destination_type = destination.type;
+ if (destination.typename === undefined) {
+ destination_type = "4";
+ }
+ if (append === 0) {
+ var addsleevebutton = "";
+ if (destination_type == "4") {
+ addsleevebutton = '';
+ }
+
+ }
+ if (destination_type == "4") {
+
+ randid = Math.floor(Math.random() * 10000);
+ $('#' + destinationdiv).append(`
+
+
+
+
+ `);
+ console.log(randid);
+ var sleeveoptions = '';
+ $.each(destination.sleeves, function (k, val) {
+ console.log(val);
+ sleeveoptions = sleeveoptions + '';
+ });
+ $('#' + randid + '_sleeves_div').append(`
+`);
+
+
+ }
+ });
+};
+
+function generateDestination(destination, destinationtype, destinationdiv, param = 0, append = 0) {
+ var destination_typename = destination.typename;
+ var destination_type = destination.type;
+ if (destination.typename === undefined) {
+ destination_typename = "Schächte";
+ destination_type = "4";
+ }
+ if (append === 0) {
+ var addsleevebutton = "";
+ if (destination_type == "4") {
+ addsleevebutton = '';
+ }
+ $('#' + destinationdiv).append(`
+
+ ` + destinationtype + ` (` + destination_typename + `)
+
+
+
+ `);
+ }
+ if (destination_type == "4") {
+ $.getJSON(dispatchersleeveUrl + "&dispatcher_id=" + destination.id, {})
+ .done(function (data) {
+ if (data.success) {
+ var sleeveoptions = '';
+ $.each(data.data, function (k, val) {
+ sleeveoptions = sleeveoptions + '';
+ });
+ console.log(destinationdiv);
+ $('#' + destinationdiv).append(`
+`);
+ }
+ })
+
+
+ }
+ if (destination_type == "2") {
+ destinationname = destination.name;
+ var popid = destination.id;
+ $.getJSON(poprackUrl + "&pop_id=" + destination.id, {})
+ .done(function (data) {
+ if (data.success) {
+ var fibers = $('#fibers').find(':selected').data('fibers');
+
+ if (fibers === undefined) {
+ fibers = 0;
+ }
+ var rackoptions = '';
+ $.each(data.data, function (k, val) {
+ rackoptions = rackoptions + '';
+ });
+ if (append === 0) {
+ $('#' + destinationdiv).append(``);
+
+ if (param == 0) {
+
+ $('#' + destinationdiv).append(``);
+ } else if (param == 1) {
+ if (destinationdiv == 'destinationendpoint') {
+ var dest = destinationendpoint;
+ }
+ if (destinationdiv == 'destinationstartpoint') {
+ var dest = destinationstartpoint;
+ }
+ $('#' + destinationdiv).append(dest);
+ checkusedfibers($('#' + destinationdiv));
+ }
+ } else if (append === 1) {
+ console.log('cool');
+ $('#' + destinationdiv).append(``);
+ }
+ } else {
+ $('#' + destinationdiv).append(`
+ `);
+ }
+
+ }
+ )
+ .done(function (data) {
+ $('#' + destinationdiv).append(``);
+ });
+
+
+ }
+
+}
+
+function addModule(thistrigger, poprackid, append = 0, param = 0, selected = null, startport = null, endport = null, popid = null) {
+ if (popid) {
+ $.getJSON(poprackUrl + "&pop_id=" + popid, {})
+ .done(function (data) {
+
+ if (data.success) {
+ var rackoptions = '';
+ $.each(data.data, function (k, val) {
+ rackoptions = rackoptions + '';
+ });
+ console.log('cool1');
+ $('#destinationstartpoint').append(``);
+ $('#destinationstartpoint').append(``);
+
+ thistrigger = thistrigger.nextAll().eq(1);
+ }
+ });
+
+ }
+ $.getJSON(poprackmoduleUrl + "&poprack_id=" + poprackid, {})
+ .done(function (data) {
+ if (data.success) {
+ var options = "";
+ var rackoptions = '';
+ var systemoption;
+ var plug;
+ var portsstart = 1;
+ var portsend;
+ var counter = 1;
+ $.each(data.data, function (k, val) {
+ if (counter == 1) {
+ portsend = val.ports;
+ }
+
+ if (val.plug == "1") {
+ systemoption = " (LC/APC " + val.ports + "p)";
+ } else if (val.plug == "2") {
+ systemoption = " (SC/APC " + val.ports + "p)";
+ } else if (val.plug == "3") {
+ systemoption = " (E2000/APC " + val.ports + "p)";
+ } else {
+ systemoption = "";
+ }
+ if (selected && selected == val.id) {
+
+ options = options + '';
+ } else {
+ options = options + '';
+ }
+ counter++;
+ });
+ if (startport) {
+ portsstart = startport;
+ }
+ if (endport) {
+ portsend = endport;
+ }
+ var destinationpoint = thistrigger.closest('.destinationpoint').attr('id');
+ var html;
+ if (append === 0) {
+ html = `
+ `;
+ } else if (append === 1) {
+ html = ` `;
+
+ if (append === 0) {
+ thistrigger.closest('.form-group').next().html(html);
+ } else if (append === 1) {
+ thistrigger.append(html);
+ }
+
+ } else {
+ thistrigger.closest('.form-group').next().html(`
+ `);
+ }
+ checkusedfibers(thistrigger);
+ })
+
+}
+
+
+$(document).ready(function () {
+ $(".select2").select2({placeholder: ""});
+ $(".select2select").select2({placeholder: ""});
+ $("#fiberplanpipesub").select2({
+ placeholder: "",
+ templateResult: formatState,
+ templateSelection: formatState
+ });
+ // disable mousewheel on a input number field when in focus
+ $('form').on('focus', 'input[type=number]', function (e) {
+ $(this).on('wheel.disableScroll', function (e) {
+ e.preventDefault()
+ })
+ });
+ $('form').on('blur', 'input[type=number]', function (e) {
+ $(this).off('wheel.disableScroll')
+ });
+
+
+ $("body").on("change", ".pipe-network", function (event, param = 0) {
+ var thisis = $(this);
+ var options = ' ';
+ $.getJSON(fiberPlanPipeUrl + "&network_id=" + $.trim($(this).val()), {})
+ .done(function (data) {
+ if (data.success) {
+ $.each(data.data, function (k, val) {
+ options = options + ' ';
+ });
+
+ $(thisis).closest(".form-group").find('.pipe-div').html(' ');
+ if (param == 1 && pipes.length == $('.fiberPlanPipe_id').length) {
+ var counter = 0;
+ pipes.forEach(function (value, index) {
+ $('.fiberPlanPipe_id').eq(counter).val(value);
+ $('.fiberplanpipe_id').eq(counter).val(pipesid[counter]);
+
+ $('.fiberPlanPipe_id').eq(counter).trigger("change", "1");
+ checkendpoints();
+ counter++;
+ });
+ }
+ $(".select2select").select2({placeholder: ""});
+ }
+
+ });
+ });
+
+
+ $("body").on("change", "#network_id", function (event, param = 0) {
+ var options = ' ';
+ $('#destination-div').empty();
+ $('#destination-div').append(' ');
+ $.getJSON(fiberPlanPipeUrl + "&network_id=" + $.trim($(this).val()), {})
+ .done(function (data) {
+ if (data.success) {
+ $.each(data.data, function (k, val) {
+ options = options + ' ';
+ });
+ $('#subpipe-div').empty();
+ $('#pipe-div').empty();
+ $('#pipe-div').append(' ');
+
+ if (param == 1) {
+ // $("#fiberPlanPipe_id option[value=fiberPlanPipe_id; ?>]").attr('selected', 'selected');
+ if ($('#fiberPlanPipe_id').val()) {
+ $("#fiberPlanPipe_id").trigger("change", "1")
+ }
+ }
+ $(".select2").select2({placeholder: ""});
+ $("#fiberplanpipesub").select2({
+ placeholder: "",
+ templateResult: formatState,
+ templateSelection: formatState
+ });
+ } else {
+ $('#subpipe-div').empty();
+ $('#pipe-div').html(' Keine Rohre in diesem Netzgebiet vorhanden. ');
+ }
+ });
+ });
+
+ $("body").on("change", ".fiberPlanPipe_id", function (event, param = 0) {
+ // console.log(param);
+ var options = ' ';
+ var thisis = $(this);
+ $('#destination-div').empty();
+ $('#destination-div').append(' ');
+ $.getJSON(fiberPlanPipeSubUrl + "&fiberplanpipe_id=" + $.trim($(thisis).val()), {})
+ .done(function (data) {
+ if (data.success) {
+ $.each(data.data, function (k, val) {
+ var idcounter = 0;
+ var color;
+ // generateDestination(val.startpointname, "Startpunkt", "destinationstartpoint", param);
+ // generateDestinationmid(val.midpointname, "Zwischenpunkte", "destinationmidpoint", param);
+ //generateDestination(val.endpointname, "Endpunkt", "destinationendpoint", param);
+ if (val.fiberPlanPipeTemplate_id != null) {
+
+ var obj = jQuery.parseJSON(val.colors);
+ if (val.pipe7x4 != "0" && val.pipe7x4 != null) {
+ var counter = val.pipe7x4;
+ }
+ $.each(obj, function (key, col) {
+ if (counter == 0) {
+ return true;
+ }
+ color = col.color + ';0';
+
+ idcounter++;
+ options = options + ' ';
+ counter--;
+
+ });
+ if (counter != 0) {
+ $.each(obj, function (key, col) {
+ if (counter == 0) {
+ return true;
+ }
+ color = col.color + ';1';
+ idcounter++;
+ options = options + ' ';
+ counter--;
+
+ });
+ }
+ if (val.pipe14x10 != "0" && val.pipe14x10 != null) {
+ var counter = val.pipe14x10;
+ }
+ $.each(obj, function (key, col) {
+ if (counter == 0) {
+ return true;
+ }
+ color = col.color + ';0';
+ idcounter++;
+ options = options + ' ';
+ counter--;
+
+ });
+ if (counter != 0) {
+ $.each(obj, function (key, col) {
+ if (counter == 0) {
+ return true;
+ }
+ color = col.color + ';1';
+ idcounter++;
+ options = options + ' ';
+ counter--;
+
+ });
+ }
+ } else {
+ options = options + ' ';
+ }
+
+ }
+ )
+ ;
+
+ $(thisis).closest(".form-group").next().find('.subpipe-div').html(' ');
+ $(".fiberplanpipesub").select2({
+ placeholder: "",
+ templateResult: formatState,
+ templateSelection: formatState
+ });
+ if (param == 1 && subpipes.length == $('.fiberplanpipesub').length) {
+ var counter = 0;
+ subpipes.forEach(function (value, index) {
+ $('.fiberplanpipesub').eq(counter).val(value);
+ $('.fiberplanpipesub').eq(counter).trigger("change", "1");
+ counter++;
+ });
+ checkusedpipes();
+ checkracks();
+ // $("#fiberplanpipesub option[value=fiberPlanPipe_sub; ?>]").attr('selected', 'selected');
+
+ }
+
+ }
+ }
+ )
+ ;
+ });
+
+ $('#rackModal').on('show.bs.modal', function (event) {
+ var button = $(event.relatedTarget);
+ var recipient = button.data('mdtype');
+ var destinationname = button.data('name');
+ var modal = $(this);
+ if (recipient == "rack") {
+ modal.find('.modal-title').text('Neuer Schrank (' + destinationname + ')');
+ }
+
+ })
+
+
+ if ($('#network_id').val()) {
+ $("#network_id").trigger("change", "1")
+ }
+
+ $("body").on("change", ".poprack_id", function (event, param = 0) {
+ var thistrigger = $(this);
+ var poprackid = $(this).val();
+ // console.log(param);
+ if (param == 0) {
+ addModule(thistrigger, poprackid);
+ }
+ });
+
+ $("body").on("click", ".add-module", function () {
+ var thistrigger = $(this);
+
+ thistrigger.closest('h5').next('div').append(` `);
+ checkracks();
+ $(".select2select").select2({placeholder: ""});
+ if (thistrigger.closest('h5').next('div').length < 6) {
+
+ }
+ });
+
+ $("body").on("click", ".add-rack", function () {
+ var thistrigger = $(this);
+ var poprackid = $(this).data('poprackid');
+ // console.log(thistrigger);
+ var destinationpoint = $(this).closest('.destinationpoint').attr('id');
+ $.getJSON(fiberPlanPipeSubUrl + "&fiberplanpipe_id=" + $.trim($("#fiberPlanPipe_id").val()), {})
+ .done(function (data) {
+ if (data.success) {
+ $.each(data.data, function (k, val) {
+
+ var idcounter = 0;
+ var color;
+ if (destinationpoint == "destinationstartpoint") {
+ generateDestination(val.startpointname, "Startpunkt", "destinationstartpoint", 0, 1);
+ } else if (destinationpoint == "destinationendpoint") {
+ generateDestination(val.endpointname, "Endpunkt", "destinationendpoint", 0, 1);
+ }
+ })
+ }
+ });
+ });
+ $("body").on("click", ".add-sleeve", function () {
+ var thistrigger = $(this);
+
+ thistrigger.closest('h5').next('div').append(` `);
+ checksleeves();
+ // checkusedfibers();
+ $(".select2select").select2({placeholder: ""});
+ if (thistrigger.closest('h5').next('div').length < 6) {
+
+ }
+ });
+
+ $("body").on("click", ".remove-module", function () {
+ var trigger = $(this).closest('.destinationmodules');
+ $(this).closest('div').remove();
+ checkusedfibers(trigger);
+
+
+ });
+ $("body").on("click", ".remove-rack", function () {
+ var trigger = $(this);
+ $(this).closest('.form-group').next().remove();
+ checkusedfibers(trigger);
+ $(this).closest('.form-group').remove();
+ });
+ $("body").on("change", "#responsible", function () {
+ if ($(this).val() == 1) {
+ $('#responsible-div').show();
+ $('#responsible-row').show();
+ $("#address_id").prop("disabled", false);
+ $(".select2select").select2({placeholder: ""});
+ } else {
+ $('#responsible-div').hide();
+ $('#responsible-row').hide();
+ $("#address_id").prop("disabled", true);
+ $(".select2select").select2({placeholder: ""});
+ }
+ });
+
+ $("body").on("change", ".poprackmodule_id", function (event, param = 0) {
+ // console.log('param'+param);
+ var portsend = $(this).closest('.module-row').find('.ports-end').val();
+ // console.log(portsend);
+ //Immer Ändern
+ if (param == 0) {
+ if ($(this).find(':selected').data('ports') != $(this).closest('.module-row').find('.ports-end').val()) {
+ $(this).closest('.module-row').find('.ports-end').val($(this).find(':selected').data('ports'));
+ $(this).closest('.module-row').find('.ports-start').val('1');
+ }
+ }
+ checkusedfibers($(this).closest('.module-row'));
+
+ });
+ $("body").on("change blur", ".ports-end", function () {
+ var maxports = $(this).closest('.module-row').find('.poprackmodule_id').find(':selected').data('ports');
+ var endports = $(this).val();
+ var startports = $(this).closest('.module-row').find('.ports-start').val();
+ if (!parseInt(endports) || endports > maxports) {
+ $(this).val(maxports);
+ } else if (parseInt(endports) < parseInt(startports)) {
+ $(this).val(startports);
+ }
+ checkusedfibers($(this).closest('.module-row'));
+ });
+ $("body").on("change", "#fibers", function () {
+ $('.fiber-counter').text($('#fibers').find(':selected').data('fibers'));
+ })
+
+ $("body").on("change blur", ".ports-start", function () {
+ var startports = $(this).val();
+ var endports = $(this).closest('.module-row').find('.ports-end').val();
+ if (!parseInt(startports) || startports < 1) {
+ $(this).val('1');
+ } else if (parseInt(startports) > parseInt(endports)) {
+ $(this).val(endports);
+ }
+ checkusedfibers($(this).closest('.module-row'));
+ });
+
+ $("body").on("click", ".destination-dropdown", function () {
+ if ($(this).find('i').hasClass('fa-square-caret-down')) {
+ $(this).find('i').removeClass('fa-square-caret-down');
+ $(this).find('i').addClass('fa-square-caret-up');
+ $(this).closest('.destinationpoint').find('.form-group').show();
+ } else {
+ $(this).find('i').addClass('fa-square-caret-down');
+ $(this).find('i').removeClass('fa-square-caret-up');
+ $(this).closest('.destinationpoint').find('.form-group').hide();
+ }
+ });
+ $.each($('.pipe-network'), function (index, value) {
+ var thisis = $(this);
+ $(this).trigger('change', '1')
+ })
+ $('body').on('click', '.add-pipe', function () {
+ $('#fiberplancablepipes-div').append(` `);
+
+ $('#fiberplancableendpoints').append(` `);
+
+ var fiberplancablepipelength = $('.fiberplancablepipe-div').length;
+ $('.fiberplancablepipe-div').eq(fiberplancablepipelength - 1).find('.pipe-network').html($('.fiberplancablepipe-div').eq(fiberplancablepipelength - 2).find('.pipe-network').html());
+
+
+ $('.fiberplancablepipe-div').eq(fiberplancablepipelength - 1).find('.pipe-network').trigger('change');
+
+
+
+
+ $('.select2select').select2({placeholder: ""});
+ checkendpoints();
+
+ });
+
+ $("body").on("click", ".remove-endpoint", function () {
+ let endpointcounter;
+ $(this).closest('.fiberplancablepipe-div').remove();
+ $('.fiberplanpipe-main-div').eq($(this).data('index')).remove();
+ checkendpoints();
+ });
+
+ $("body").on("click", ".move-endpoint-up", function () {
+ $(this).closest('.fiberplancablepipe-div').insertBefore($(this).closest('.fiberplancablepipe-div').prev());
+ $('.fiberplanpipe-main-div').eq($(this).data('index')).insertBefore($('.fiberplanpipe-main-div').eq($(this).data('index')).prev());
+ checkendpoints();
+ });
+
+ $("body").on("click", ".move-endpoint-down", function () {
+ $(this).closest('.fiberplancablepipe-div').insertAfter($(this).closest('.fiberplancablepipe-div').next());
+ $('.fiberplanpipe-main-div').eq($(this).data('index')).insertAfter($('.fiberplanpipe-main-div').eq($(this).data('index')).next());
+ checkendpoints();
+ });
+
+ $("body").on("click", ".change-fiberplanpipe-body", function () {
+ if ($(this).hasClass('fa-square-chevron-down')) {
+ $(this).removeClass('fa-square-chevron-down');
+ $(this).addClass('fa-square-chevron-up');
+ $(this).closest('.fiberplanpipe-main-div').find('.fiberplanpipe-body-div').hide();
+ } else if ($(this).hasClass('fa-square-chevron-up')) {
+ $(this).removeClass('fa-square-chevron-up');
+ $(this).addClass('fa-square-chevron-down');
+ $(this).closest('.fiberplanpipe-main-div').find('.fiberplanpipe-body-div').show();
+ }
+ });
+
+ $("body").on("click", ".up-module", function () {
+ $(this).closest('.module-row').insertBefore($(this).closest('.module-row').prev());
+ checkusedfibers($(this).closest('.module-row'));
+ });
+
+ $("body").on("change", ".fiberplanpipesub", function () {
+ checkusedpipes();
+ });
+
+
+ $("body").on("click", ".change-fiberplanpipe-main", function () {
+ if ($(this).hasClass('fa-square-chevron-down')) {
+ $(this).removeClass('fa-square-chevron-down');
+ $(this).addClass('fa-square-chevron-up');
+ $.each($('.change-fiberplanpipe-body'), function (index, value) {
+ $(this).removeClass('fa-square-chevron-down');
+ $(this).addClass('fa-square-chevron-up');
+ });
+ $('.fiberplanpipe-body-div').hide();
+ } else if ($(this).hasClass('fa-square-chevron-up')) {
+ $.each($('.change-fiberplanpipe-body'), function (index, value) {
+ $(this).removeClass('fa-square-chevron-up');
+ $(this).addClass('fa-square-chevron-down');
+ });
+ $(this).removeClass('fa-square-chevron-up');
+ $(this).addClass('fa-square-chevron-down');
+ $('.fiberplanpipe-body-div').show();
+ }
+ });
+
+ checksleeves();
+});
\ No newline at end of file
|