diff --git a/Layout/default/FiberPlanCable/Detail.php b/Layout/default/FiberPlanCable/Detail.php new file mode 100644 index 000000000..dea675416 --- /dev/null +++ b/Layout/default/FiberPlanCable/Detail.php @@ -0,0 +1,805 @@ + + + +id] = $lineworkeraddress->company; + +endforeach; + +if ($fiberplancables->address_id) { + $responsible = $Lineworker[$fiberplancables->address_id]; +} else { + $responsible = "Person"; +} + +?> + +endport - $destination->startport + 1; + $startport = $sumcounter + 1; + if ($destinationinfo == "pop"): + + if ($oldrack != $destination->poprack_id) { + if ($counter != 1) { + echo ''; + } + $body .= ' + + +
' . $destination->poprack->name . '
+ + '; + } + $body .= ' + +
HE(' . $destination->poprackmodule->start_he . ') ' . $destination->poprackmodule->name . ' (' . $destination->startport . '-' . $destination->endport . ') ' . $plug[$destination->poprackmodule->plug] . ' (' . $startport . '-' . $endport . ') +
+ + '; + + + $counter++; + $oldrack = $destination->poprack_id; + $sumcounter = $sumcounter + $destination->endport - $destination->startport + 1; + endif; + + if ($destinationinfo == "building"): + + $body .= ' + +
' . $destination->fiberPlanDispatchersleeve->name . ' (' . $destination->startport . '-' . $destination->endport . ') +
+ + '; + $sumcounter = $sumcounter + $destination->endport - $destination->startport + 1; + + endif; + + + if ($destinationinfo == "sleeve"): + + + if ($destination->dropout) { + $body .= ' + +
Dropout
+ + '; + + $body .= ' + +
' . $destination->fiberPlanDispatchersleeve->name . ' (' . $destination->startport . '-' . $destination->endport . ') +
+ + '; + $body .= ' + +'; + + $dropcounter = $destination->endport - $destination->startport + 1; + $dropout .= '
+
' . $dropcounter . ' Fasern
'; + } else { + $body .= ' + +
' . $destination->fiberPlanDispatchersleeve->name . ' (' . $destination->startport . '-' . $destination->endport . ') +
+ + '; + $sumcounter = $sumcounter + $destination->endport - $destination->startport + 1; + } + endif; + } + if ($sumcounter==0){ + $sumcounter = $oldsummcounter; + } + return array($body, $sumcounter, $dropout); +} + +function generatedestinationmidpoint($markers, $midpoints, $cableendpoints, $fiberPlanCablePipes, $pipesubs) +{ + $oldendpoint = ""; + $midpointcounter = count($midpoints); + $pipecolorsmanu = FiberPlanPipeManufacturerModel::getAll(); + $pipecolors = json_decode($pipecolorsmanu[0]->colors, true); + + $counter = 0; + $width = 0; + $oldsummcounter = 0; + foreach ($midpoints as $midpoint): + $pipecol = $pipesubs[$counter]['pipecolor']; + $midcounter = 0; + foreach ($midpoint as $endpoint): + + + $pipecolor = $pipecolors[$endpoint->fiberPlanCablePipe->fiberPlanPipe_sub]; + if ($endpoint->pop_id) { + $enpointid = $endpoint->pop_id; + } elseif ($endpoint->fiberPlanDispatcher_id) { + $enpointid = $endpoint->fiberPlanDispatcher_id; + } elseif ($endpoint->building_id) { + $enpointid = $endpoint->building_id; + } + if ($oldendpoint != $enpointid && $width == 0) { + echo '
'; + } + if (($counter != 0 || $midcounter != 0) && $oldendpoint != $enpointid): + echo ' + + + + + + + + + + + + + + + + +
' . $summcounter . '
' . $pipesubs[$counter]['pipsstriped'] . '
'; + $width = $width + 80; +// $summcounter = 0; + endif; + $endpointbody = ""; + if ($endpoint->pop_id) { + $url = mfBaseController::getUrl("Pop", "detail", ["id" => $endpoint->pop->id]); + $endpointname = '' . $endpoint->pop->name . ''; + $endpointtype = "Pop"; + $gps_lat = $endpoint->pop->gps_lat; + $gps_long = $endpoint->pop->gps_long; + $enpointid = $endpoint->pop_id; + if ($cableendpoints[$endpoint->id]) { + list($endpointbody, $summcounter, $dropout) = generateendpointbody($cableendpoints[$endpoint->id], 'pop', $oldsummcounter); + } + $width = $width + 300; + } elseif ($endpoint->fiberPlanDispatcher_id) { + $endpointname = $endpoint->fiberPlanDispatcher->description; + if ($endpoint->fiberPlanDispatcher->object_type == 3) $endpointtype = "Greenfield"; + else if ($endpoint->fiberPlanDispatcher->object_type == 1) $endpointtype = "Verteiler"; + else if ($endpoint->fiberPlanDispatcher->object_type == 2) $endpointtype = "Schacht"; + else $endpointtype = "Schacht/Verteiler"; + $gps_lat = $endpoint->fiberPlanDispatcher->gps_lat; + $gps_long = $endpoint->fiberPlanDispatcher->gps_long; + $enpointid = $endpoint->fiberPlanDispatcher_id; + list($endpointbody, $summcounter, $dropout) = generateendpointbody($cableendpoints[$endpoint->id], 'sleeve', $oldsummcounter); + $width = $width + 150; + } elseif ($endpoint->building_id) { + $endpointname = $endpoint->building->street; + $endpointtype = 'Building'; + $gps_lat = $endpoint->building->gps_lat; + $gps_long = $endpoint->building->gps_long; + $enpointid = $endpoint->fiberPlanDispatcher_id; + list($endpointbody, $summcounter, $dropout) = generateendpointbody($cableendpoints[$endpoint->id], 'building', $oldsummcounter); + $width = $width + 150; + } + + if ($oldendpoint != $enpointid): + + $coordinates = ""; + if ($gps_lat) { + $coordinates = round($gps_lat, 5) . " , " . round($gps_long, 5); + $coordinates = '' . $coordinates . ''; + } + if ($gps_lat) { + $markers[] = array( + "gps_lat" => $gps_lat, + "gps_long" => $gps_long, + "name" => $endpointname, + "color" => $pipecol, + "type" => $endpointtype, + ); + } + + echo '
+ + + + + + + + + + + '; + + echo $endpointbody; + + + echo ' +
+
' . $endpointtype . '
+
+
' . $endpointname . '
+
+
' . $coordinates . '
+
'; + echo $dropout; + echo '
'; + + + endif; + $midcounter++; + $oldendpoint = $enpointid; + if ($width > 1500) { + echo '
'; + echo '
'; + $width = 0; + } + $oldsummcounter = $summcounter; + endforeach; + $counter++; + endforeach; + + return $markers; +} + + +$counter = 0; +foreach ($fiberPlanCablePipes as $fiberPlanCablePipe) { + //var_dump($fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4); + $pipsstriped = ""; + if ($fiberPlanCablePipe->fiberPlanPipe_sub <= $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 && $fiberPlanCablePipe->fiberPlanPipe_sub <= 12) { + $pipesub = "7x4"; + $pipeheight = "7px"; + $pipeheightinfoheight = "12px"; + $pipeheightinfomarge = "4px"; + $pipecolor = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 1]->color; + $pipecolordesc = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 1]->colordescription; + } elseif ($fiberPlanCablePipe->fiberPlanPipe_sub <= $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 && $fiberPlanCablePipe->fiberPlanPipe_sub > 12) { + $pipesub = "7x4"; + $pipeheight = "7px"; + $pipecolor = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 13]->color; + $pipecolordesc = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 13]->colordescstriped; + $pipeheightinfoheight = "12px"; + $pipeheightinfomarge = "4px"; + $pipsstriped = '
'; + } else if ($fiberPlanCablePipe->fiberPlanPipe_sub - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 <= $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe14x10 && $fiberPlanCablePipe->fiberPlanPipe_sub - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 <= 12) { + $pipesub = "14x10"; + $pipeheight = "10px"; + $pipecolor = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 1 - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4]->color; + $pipecolordesc = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 1 - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4]->colordescription; + $pipeheightinfoheight = "15px"; + $pipeheightinfomarge = "3px"; + } else if ($fiberPlanCablePipe->fiberPlanPipe_sub - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 <= $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe14x10 && $fiberPlanCablePipe->fiberPlanPipe_sub - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4 > 12) { + $pipesub = "14x10"; + $pipeheight = "10px"; + $pipecolor = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 13 - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4]->color; + $pipecolordesc = $fiberplanpipemanufacturers->colors[$fiberPlanCablePipe->fiberPlanPipe_sub - 13 - $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4]->colordescstriped; + $pipeheightinfoheight = "15px"; + $pipeheightinfomarge = "3px"; + $pipsstriped = '
'; + } + /* var_dump($fiberPlanCablePipe->fiberPlanpipe->fiberPlanPipeTemplate); + echo $fiberPlanCablePipe->fiberPlanPipe_sub; + echo ".
"; + echo $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe7x4; + echo "
"; + echo $fiberPlanCablePipe->fiberPlanPipe->fiberPlanPipeTemplate->pipe14x10; + echo "
"; + echo $fiberPlanCablePipe->fiberPlanPipe_sub - $fiberPlanCablePipe->fiberPlanpipe->fiberPlanPipeTemplate->pipe7x4;*/ + $pipesubs[$counter]['pipesub'] = $pipesub; + $pipesubs[$counter]['pipeheight'] = $pipeheight; + $pipesubs[$counter]['pipecolor'] = $pipecolor; + $pipesubs[$counter]['pipecolordesc'] = $pipecolordesc; + $pipesubs[$counter]['pipeheightinfoheight'] = $pipeheightinfoheight; + $pipesubs[$counter]['pipeheightinfomarge'] = $pipeheightinfomarge; + $pipesubs[$counter]['pipsstriped'] = $pipsstriped; + $counter++; +} + +foreach ($fiberPlanCableEndpoints as $fiberPlanCableEndpoint) { + $markers = generatedestinationmidpoint($markers, $fiberPlanCableEndpoints, $fiberPlanCableEndpoints, $fiberPlanCablePipes, $pipesubs); +} +?> + +
+
+
+
+ +
+

Kabel: description ?> + + $fiberplancables->id, 'returnto' => "fiberplancable-detail"]) ?>"> + + +

+
+
+
+ +
+
+
+
+
+
+
+

Allgemeine Informationen

+ +
+
+ + + + + + + + + + + + + + + + + + + +
Bezeichnungdescription ?>
Fasern / Länge (m)fibers]['name'] . " (" . $fibers[$fiberplancables->fibers]['fibers'] . ")" ?> + / lenght ?> Meter +
Netzgebietnetwork->name ?>
Verwendete(s) Rohr(e) + + + + + + + +
$fiberPlanCablePipe->fiberPlanPipe->id]) . '" target="_blanc">' . $fiberPlanCablePipe->fiberPlanPipe->description . '' ?>' . $pipesubs[$counter]['pipsstriped'] . '' ?> + + () +
+
+
+ + +
+ +
+
+

 

+
+ + + + + + + + + + + + + + + + + + + +
Statusstate] ?>
Zuständig
Kontaktresponsible_text ?>
Bemerkungcomment) ?>
+
+
+ +
+
+ +
+ +
+
+

Schematische Darstellung +

+ +
+ + + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/Layout/default/FiberPlanCable/Form.php b/Layout/default/FiberPlanCable/Form.php new file mode 100644 index 000000000..6dc214ca7 --- /dev/null +++ b/Layout/default/FiberPlanCable/Form.php @@ -0,0 +1,639 @@ + + + +
+
+
+
+ +
+

id) ? "Kabelverzeichnis bearbeiten" : "Neues Kabel" ?>

+
+
+
+fiberPlanPipe->startpoint_network_id != $fiberplancables->network_id && $fiberplancables->fiberPlanPipe->endpoint_network_id != $fiberplancables->network_id) { + $networkId = $fiberplancables->fiberPlanPipe->startpoint_network_id; +} else { + $networkId = $fiberplancables->network_id; +} +if (isset($_GET['returnto']) && $_GET['returnto'] == "fiberplancable-detail") { + $cancelUrl = self::getUrl("FiberPlanCable", "Detail", ["id" => $fiberplancables->id]); +} else { + $cancelUrl = self::getUrl("FiberPlanCable"); +} +//var_dump($fiberPlanCableEndpoints); +?> + + + +
+
+ +
+
+

id) ? "Kabelverzeichnis bearbeiten" : "Neues Kabel" ?>

+ +
$_GET["returnto"]]) ?>"> +
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+

Rohr(e)

+
+
+
+ + +
+
+ +
+ +
+
+
+
+
+ +
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
"> + +
"> + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+

Verwendete Rohre/Endpunkte +

+ + + + 0) : + ?> +
+
+ +
+

Rohr:fiberPlanPipe->description ?> +

+ 0) : + ?> + + +
+ + pop_id) { + $endpointname = '' . $fiberPlanPipesEndpointdetail->pop->name; + $endpointtype = '(POP)'; + if ($fiberPlanCableEndpoints[$fiberPlanPipesEndpointdetail->id]) { + $endpointcounter = 0; + foreach ($fiberPlanCableEndpoints[$fiberPlanPipesEndpointdetail->id] as $fiberPlanCableEndpoint): + $endpointbody .= '
+ '; + + $endpointbody .= '
+ +
+
+
+
+
+
+
von
+
+ +
+
+
+
+
+
bis
+
+ + +
+
+
+
+
'; + $endpointcounter++; + endforeach; + } + } else if ($fiberPlanPipesEndpointdetail->fiberPlanDispatcher_id) { + + $endpointname = $fiberPlanPipesEndpointdetail->fiberPlanDispatcher->description; + $endpointtype = $fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type; + if ($fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type == 1) { + $endpointtype = '(Verteiler)'; + $endpointname = '' . $endpointname; + } else if ($fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type == 2) { + $endpointtype = '(Schacht)'; + $endpointname = '' . $endpointname; + } else if ($fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type == 3) { + $endpointname = '' . $endpointname; + $endpointtype = "(Greenfield)"; + } + if ($fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type == 1 || $fiberPlanPipesEndpointdetail->fiberPlanDispatcher->object_type == 2) { + if ($fiberPlanCableEndpoints[$fiberPlanPipesEndpointdetail->id]) { + + foreach ($fiberPlanCableEndpoints[$fiberPlanPipesEndpointdetail->id] as $fiberPlanCableEndpoint): + if ($fiberPlanCableEndpoint->dropout == "1") { + $endpointbody .= '
+
+
Dropout
+
+
'; + } + + + $endpointbody .= '
+ +
+ +
+ +
+
+
+
+
+
von
+
+ +
+
+
+
+
+
bis
+
+ + +
+
+
+
+
'; + endforeach; + } + } + } else if ($fiberPlanPipesEndpointdetail->building_id) { + $endpointname = '' . $fiberPlanPipesEndpointdetail->building->street; + $endpointtype = '(Building)'; + } + if ($fiberPlanCableEndpoints[$fiberPlanPipesEndpointdetail->id]) { + } + ?> +
+
+
+
+ + + + +
+
+
+
+
+
+
+ +
+ + + + +
+
+ + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/Layout/default/FiberPlanCable/Index.php b/Layout/default/FiberPlanCable/Index.php new file mode 100644 index 000000000..36fcec88d --- /dev/null +++ b/Layout/default/FiberPlanCable/Index.php @@ -0,0 +1,203 @@ +id] = $lineworkeraddress->company; + +endforeach; + + +foreach ($networks as $network): + $Networks[$network->id] = $network->name; + +endforeach; + +foreach ($fiberplanpipemanufacturers as $fiberplanpipemanufacturer) { + $colors = json_decode($fiberplanpipemanufacturer->colors, true); + $pipemanufacturercolors[$fiberplanpipemanufacturer->id]['colors'] = $colors; +} +foreach ($fiberplanpipes as $fiberplanpipe) { + $fiberPlanPipe[$fiberplanpipe->id]['description'] = $fiberplanpipe->description; + $fiberPlanPipe[$fiberplanpipe->id]['type'] = $fiberplanpipe->type; + $fiberPlanPipe[$fiberplanpipe->id]['type_description'] = $fiberplanpipe->type_description; + $fiberPlanPipe[$fiberplanpipe->id]['startpoint_network_id'] = $fiberplanpipe->startpoint_network_id; + $fiberPlanPipe[$fiberplanpipe->id]['endpoint_network_id'] = $fiberplanpipe->endpoint_network_id; + $fiberPlanPipe[$fiberplanpipe->id]['fiberPlanPipeManufacturer_id'] = $fiberplanpipe->fiberPlanPipeManufacturer_id; + $fiberPlanPipe[$fiberplanpipe->id]['pipe7x4'] = $fiberplanpipe->pipe7x4; + $fiberPlanPipe[$fiberplanpipe->id]['pipe14x10'] = $fiberplanpipe->pipe14x10; +} +?> + + + +
+
+
+
+ +
+

Kabelverzeichnis

+
+
+
+ + +
+
+
+
+
+

Liste aller Kabelverzeichnis

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + fiberPlanPipe_id]['startpoint_network_id'] == $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['endpoint_network_id']) { + $networkName = $Networks[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['startpoint_network_id']]; + } else { + $networkName = $Networks[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['startpoint_network_id']] . " / " . $Networks[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['endpoint_network_id']]; + } + if ($fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['type'] == "3") { + if ($fiberplancable->fiberPlanPipe_sub <= $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] && $fiberplancable->fiberPlanPipe_sub <= 12) { + $color = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 1]['color']; + $striped = ""; + $height = "10px"; + $title = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 1]['colordescription']; + $description = '7x4 '; + } else if ($fiberplancable->fiberPlanPipe_sub <= $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] && $fiberplancable->fiberPlanPipe_sub > 12) { + $striped = 'style="background-color: #000;height: 100%;width: 45%;text-align: center;margin-left: auto;margin-right: auto;"'; + $color = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 13]['color']; + $height = "10px"; + $title = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 13]['colordescstriped']; + $description = '7x4 '; + } else if ($fiberplancable->fiberPlanPipe_sub - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] <= $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe14x10'] && $fiberplancable->fiberPlanPipe_sub - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] <= 12) { + $color = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 1 - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4']]['color']; + $striped = ""; + $height = "12px"; + $title = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 1 - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4']]['colordescription']; + $description = '14x10 '; + } else if ($fiberplancable->fiberPlanPipe_sub - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] <= $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe14x10'] && $fiberplancable->fiberPlanPipe_sub - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4'] > 12) { + $color = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 13 - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4']]['color']; + $striped = 'style="background-color: #000;height: 100%;width: 45%;text-align: center;margin-left: auto;margin-right: auto;"'; + $height = "12px"; + $title = $pipemanufacturercolors[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['fiberPlanPipeManufacturer_id']]['colors'][$fiberplancable->fiberPlanPipe_sub - 13 - $fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['pipe7x4']]['colordescstriped']; + $description = '14x10 '; + } + if ($color == "#ffffff" || $color == "#ffff01" || $color == "#01ffff") { + $border = 'border:1px solid #9d9d9d;'; + } else { + $border = ""; + } + + $subPipe = '
' . $description . '' . $title . '
'; + } else { + $subPipe = '
' . $type_descrition_definition[$fiberPlanPipe[$fiberplancable->fiberPlanPipe_id]['type_description']] . '
'; + } + + + $responsible=$responsibleOption[$fiberplancable->responsible]; + if ($fiberplancable->address_id) + { + $responsible.=" ".$Lineworker[$fiberplancable->address_id]; + if ($fiberplancable->responsible_text) + { + $responsible.=" (".$fiberplancable->responsible_text.")"; + } + } else if ($fiberplancable->responsible_text) + { + $responsible.=" ".$fiberplancable->responsible_text; + } + + ?> + + + + + + + + + + + + + +
BezeichnungFasern / Dm.Netzgebiet(e)Verwendete(s) Rohr(e)Länge (M)ZuständigStatus
$fiberplancable->id]) ?>">description ?>fibers] . " / " . $fiberplancable->diameter." mm" ?> + + fiberPlanPipe_id]['description'] ?>lenght ?>state] ?> + $fiberplancable->id]) ?>"> + $fiberplancable->id]) ?>" + onclick="if(!confirm('Kabelverzeichnis wirklich löschen?')) return false;" + class="text-danger" + title="Löschen"> +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/FiberPlanPipe/Detail.php b/Layout/default/FiberPlanPipe/Detail.php index 6e19af1e5..d25375687 100644 --- a/Layout/default/FiberPlanPipe/Detail.php +++ b/Layout/default/FiberPlanPipe/Detail.php @@ -130,6 +130,7 @@ if ($fiberplanpipes->type == "3") { width: 50px; border-top: 1px solid #000; border-bottom: 1px solid #000; + background-color: #000; } @@ -423,7 +424,7 @@ if ($fiberplanpipes->type == "3") { + style="width: 70px;"> 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) { - - @@ -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 .= '
    + +
    + +
    +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    '; + + + } 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 .= '
    + +
    + +
    +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    '; + } else { + unset($option); + foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) { + if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"'; + else $selected = ""; + $option .= ''; + } + $return .= '
    + +
    + +
    +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    '; + } + + $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 + ''; + $.each(val, function (key, value) { + if (value.plug == "1") { + plug = " (LC/APC)"; + } else if (value.plug == "2") { + plug = " (SC/APC)"; + } else if (value.plug == "3") { + plug = " (E2000/APC)"; + } + + option = option + ''; + }) + 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(` + +
    + +
    ` + destination.name + `
    +
    +
    + + `); + console.log(randid); + var sleeveoptions = ''; + $.each(destination.sleeves, function (k, val) { + console.log(val); + sleeveoptions = sleeveoptions + ''; + }); + $('#' + randid + '_sleeves_div').append(`
    + +
    + +
    + +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +`); + + + } + }); +}; + +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 + `)

    +
    +
    + +
    ` + destination.name + `
    +
    + + `); + } + 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(`
    + +
    + +
    + +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +`); + } + }) + + + } + 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(`
    + +
    0 von ` + fibers + ` Fasern aufgelegt
    +
    `); + + 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(` +
    + +
    +
    Keine Schränke vorhanden.
    +
    +
    `); + } + + } + ) + .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 = `
    + `; + } + + html = html + ` +
    + +
    +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    `; + + if (append === 0) { + thistrigger.closest('.form-group').next().html(html); + } else if (append === 1) { + thistrigger.append(html); + } + + } else { + thistrigger.closest('.form-group').next().html(` +
    + +
    + Keine Einschübe in diesem Schrank vorhanden +
    +
    `); + } + 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(`
    + +
    + +
    +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    +
    `); + 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(`
    + +
    + +
    + +
    +
    +
    +
    +
    +
    von
    +
    + +
    +
    +
    +
    +
    +
    bis
    +
    + + +
    +
    +
    +
    +
    `); + 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
    Bezeichnung Type/BezeichnungLänge (m) Netzgebiet(e) Anfangspunkt