Faserplanung

* Rohrplanung Updates
 * Migrations
This commit is contained in:
Spitzer Daniel
2024-04-23 17:09:36 +02:00
parent 1db1d583da
commit 6310e2446e
12 changed files with 613 additions and 375 deletions

View File

@@ -18,13 +18,12 @@ class FiberPlanPipeController extends mfBaseController
protected function indexAction()
{
$networks = NetworkModel::getAll();
$this->layout()->setTemplate("FiberPlanPipe/Index");
$fiberplanpipes = FiberPlanPipeModel::getAll();
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
$this->layout()->set("networks", $networks);
$this->layout()->set("buildings", $buildings);
$fiberplanpipeEndpoints = FiberPlanPipeEndpointModel::getAll();
$this->layout()->set("fiberplanpipeEndpoints", $fiberplanpipeEndpoints);
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
@@ -66,7 +65,6 @@ class FiberPlanPipeController extends mfBaseController
protected function detailAction()
{
$id = $this->request->id;
$networks = NetworkModel::getAll();
$this->layout()->setTemplate("FiberPlanPipe/Detail");
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
@@ -77,12 +75,9 @@ class FiberPlanPipeController extends mfBaseController
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
$this->layout()->set("networks", $networks);
$this->layout()->set("buildings", $buildings);
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
}
@@ -111,8 +106,6 @@ class FiberPlanPipeController extends mfBaseController
{
$r = $this->request;
$id = $r->id;
var_dump($r->get());
die();
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$fiberplanpipes = new FiberPlanPipe($id);
@@ -189,12 +182,6 @@ class FiberPlanPipeController extends mfBaseController
if (!$data['length']) {
$data['length'] = NULL;
}
if (!$data['startpoint']) {
$data['startpoint'] = NULL;
}
if (!$data['endpoint']) {
$data['endpoint'] = NULL;
}
if (!$data['status']) {
$data['status'] = NULL;
}
@@ -226,24 +213,42 @@ class FiberPlanPipeController extends mfBaseController
$endpoint = $r->endpoint;
if (!empty($endpoint)) {
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
foreach ($fiberplanpipeendpoints as $fiberplanpipeendpoint) {
if (!in_array($fiberplanpipeendpoint->id, $endpoint_id)) {
$fiberplanpipeendpoint->delete();
}
}
$counter = 1;
foreach ($endpoint as $key => $Endpoint) {
if ($endpoint_type[$key] == 4) {
unset($endpointarray);
$endpointarray = [];
$endpointarray['fiberPlanDispatcher_id'] = null;
$endpointarray['pop_id'] = null;
$endpointarray['building_id'] = null;
if ($endpoint_type[$key] == 4 || $endpoint_type[$key] == 1) {
$endpointarray['fiberPlanDispatcher_id'] = $Endpoint;
} else if ($endpoint_type[$key] == 2) {
$endpointarray['pop_id'] = $Endpoint;
} else if ($endpoint_type[$key] == 3) {
$endpointarray['building_id'] = $Endpoint;
}
$endpointarray['fiberPlanPipe_id'] = $id;
$endpointarray['sort'] = $counter;
// print_r($endpointarray);
// var_dump($endpoint_id[$key]);
// die();
if ($endpoint_id[$key]) {
$fiberplanpipeendpoint = new FiberPlanPipeEndpoint($id);
$fiberplanpipeendpoint = new FiberPlanPipeEndpoint($endpoint_id[$key]);
$fiberplanpipeendpoint->update($endpointarray);
unset($endpoint_id[$key]);
} else {
$fiberplanpipeendpoint = FiberPlanPipeEndpointModel::create($endpointarray);
}
$fiberplanpipeendpoint->save();
$counter++;
}
}

View File

@@ -9,13 +9,6 @@ class FiberPlanPipeModel
private $type_description;
private $fiberplanpipetemplate_id;
private $length;
private $startpoint_type;
private $startpoint_network_id;
private $startpoint;
private $midpoint;
private $endpoint_network_id;
private $entpoint_type;
private $endpoint;
private $status;
private $responsible;
private $responsible_text;
@@ -212,15 +205,15 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
$items = [];
$db = FronkDB::singleton();
if ($bdtype == "1") {
$sql = "SELECT `id`,`description` `name` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND `object_type`='3' ";
$sql = "SELECT `id`,`description` `name`,`gps_lat`,`gps_long` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND `object_type`='3' ";
} else if ($bdtype == "2") {
$sql = "SELECT `Pop`.`id`,`Pop`.`name` FROM `PopNetwork`
$sql = "SELECT `Pop`.`id`,`Pop`.`name`,`gps_lat`,`gps_long` FROM `PopNetwork`
INNER JOIN `Pop` ON (`Pop`.`id`=`PopNetwork`.`pop_id`)
WHERE `PopNetwork`.`network_id`='" . $network . "'";
} else if ($bdtype == "3") {
$sql = "SELECT `id`,`code` ,`street`, `zip`, `city` name FROM Building WHERE network_id='" . $network . "' ORDER by street";
$sql = "SELECT `id`,`code` ,`street`, `zip`, `city` name ,`gps_lat`,`gps_long` FROM Building WHERE network_id='" . $network . "' ORDER by street";
} else if ($bdtype == "4") {
$sql = "SELECT `id`,`description` `name` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND (`object_type`='1' OR `object_type`='2') ";
$sql = "SELECT `id`,`description` `name`,`gps_lat`,`gps_long` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND (`object_type`='1' OR `object_type`='2') ";
}
$res = $db->query($sql);
@@ -229,6 +222,8 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
$counter = 0;
while ($data = $db->fetch_array($res)) {
$items[$counter]['id'] = $data['id'];
$items[$counter]['gps_lat'] = $data['gps_lat'];
$items[$counter]['gps_long'] = $data['gps_long'];
if ($bdtype == "3") {
$items[$counter]['name'] = $data['street'] . " " . $data['zip'] . " " . $data['city'];
} else {
@@ -285,6 +280,7 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
}
$counter = 1;
$endpointuparrow = "";
$Endpointdownarrow = "";
$typeArray[1] = 'Greenfield';
$typeArray[2] = 'POP';
$typeArray[3] = 'Building';
@@ -293,7 +289,8 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
// print_r($buildings);
$counter = 1;
foreach ($endpoints as $Endpoint) {
$endpointuparrow = "";
$Endpointdownarrow = "";
if ($Endpoint->pop_id) {
$networkid = $Endpoint->pop->network_id;
$endpointid = $Endpoint->pop->id;
@@ -312,27 +309,28 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
$endpointtype = 3;
}
$randid = rand(1000, 10000);
if ($counter > 1) {
if (count($endpoints) == $counter) {
$Endpointuparrow = '<i title="nach oben verschieben" style="margin-right:22px;" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>';
} else if ($counter > 1) {
$Endpointuparrow = '<i title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>';
$Endpointdownarrow = '<i title="nach unten verschieben" class="fa-sharp fa-solid fa-down move-endpoint-down"></i>';
}
if ($counter == 1) {
$endpointType = "Startpunkt";
$endpointsymbol = '<span class="endpointsymbol"><i id="add-endpoint" class="fa-regular fa-circle-plus"></i></span>';
}
else if (count($endpoints)==2)
{
} else if (count($endpoints) == 2) {
$endpointcount = $counter - 1;
$endpointType = "Standort " . $endpointcount;
$endpointsymbol='<span class="endpointsymbol">';
}
else {
$endpointsymbol = '<span class="endpointsymbol">';
} else {
$endpointcount = $counter - 1;
$endpointType = "Standort " . $endpointcount;
$endpointsymbol = '<span class="endpointsymbol"><i class="fa-regular fa-circle-minus remove-endpoint"></i></span>';
}
$html = '<div class="form-group row endpoint-maindiv">
<label class="col-lg-2 col-form-label endpoint-label" for="' . $randid . '_endpoint_network_id"><span class="label-text">' . $endpointType . ' * </span>' . $Endpointuparrow . $endpointsymbol . '</label>
<div class="col-lg-2"><select id="' . $randid . '_endpoint_network_id" required="required" name="endpoint_network_id[]" class="select2 form-control endpoint_network_id">';
<label class="col-lg-2 col-form-label endpoint-label" for="' . $randid . '_endpoint_network_id"><span class="label-text">' . $endpointType . ' * </span>' . $Endpointdownarrow . $Endpointuparrow . $endpointsymbol . '</label>
<div class="col-lg-3"><select id="' . $randid . '_endpoint_network_id" required="required" name="endpoint_network_id[]" class="select2 form-control endpoint_network_id">';
foreach ($networks as $network) {
if ($network->id == $networkid) {
$html .= '<option selected="selected" value="' . $network->id . '">' . $network->name . '</option>';
@@ -354,19 +352,19 @@ INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
}
$html .= '</select></div>
<div class="col-lg-2" id="' . $randid . '_end-point-building">
<select id=' . $randid . '_endpoint" required="required" name="endpoint[]" class="select2 form-control">';
<div class="col-lg-3" id="' . $randid . '_end-point-building">
<select id="' . $randid . '_endpoint" required="required" name="endpoint[]" class="select2 form-control endpoint_endpoint">';
$buildings = FiberPlanPipeModel::getBuildingInfo($networkid, $endpointtype, 0);
foreach ($buildings as $key => $building) {
if ($building['id'] == $endpointid) {
$html .= '<option selected="selected" value="' . $building['id'] . '">' . $building['name'] . '</option>';
$html .= '<option data-gpslat="' . $building['gps_lat'] . '" data-gpslong="' . $building['gps_long'] . '" selected="selected" value="' . $building['id'] . '">' . $building['name'] . '</option>';
} else {
$html .= '<option value="' . $building['id'] . '">' . $building['name'] . '</option>';
$html .= '<option data-gpslat="' . $building['gps_lat'] . '" data-gpslong="' . $building['gps_long'] . '" value="' . $building['id'] . '">' . $building['name'] . '</option>';
}
}
$html .= '</select><input type="hidden" name="endpointid[]" value="' . $Endpoint->id . '" ></div></div>';
$html .= '</select></div><div class="col-lg-2"><input type="hidden" name="endpointid[]" value="' . $Endpoint->id . '" ></div></div>';
echo $html;
$counter++;
}