Files
thetool/Layout/default/FiberPlanPipe/Form.php
Spitzer Daniel 1ab898fbce Faserplanung/Zeiterfassung
* Zeiterfassung
 * Faserplanung Koordinatenanzeige bei Rohrverzeichnis bearbeiten hinzugefügt
 * Migrations
2024-04-23 20:30:08 +02:00

593 lines
36 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item"><a
href="<?= self::getUrl("FiberPlanPipe") ?>">Rohrverzeichnisse</a></li>
<li class="breadcrumb-item active"><?= ($fiberplanpipes->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?= ($fiberplanpipes->id) ? "Rohrverzeichnis bearbeiten" : "Neuer Rohrverzeichnis" ?></h4>
</div>
</div>
</div>
<style>
#map {
height: 570px;
width: 100%;
}
.fa-circle-plus {
color: #00b125;
cursor: pointer;
font-size: 17px;
float: right;
}
.remove-endpoint {
cursor: pointer;
color: #ff0606;
font-size: 17px;
float: right;
margin-left: 7px;
}
.fa-up {
color: #0d6efd;
font-size: 17px;
cursor: pointer;
float: right;
margin-left: 10px;
}
.fa-down {
color: #0d6efd;
font-size: 17px;
cursor: pointer;
float: right;
margin-left: 10px;
}
</style>
<?php
if (isset($_GET['returnto']) && $_GET['returnto'] == "fiberplanpipe-detail") {
$cancelUrl = self::getUrl("FiberPlanPipe", "Detail", ["id" => $fiberplanpipes->id]);
} else {
$cancelUrl = self::getUrl("FiberPlanPipe");
}
?>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($fiberplanpipes->id) ? "Rohrverzeichnis bearbeiten" : "Neuer Rohrverzeichnis" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("FiberPlanPipe", "save", ["returnto" => $_GET["returnto"]]) ?>">
<div class="card ">
<div class="card-body">
<div class="row">
<div class="col col-lg-8">
<input type="hidden" name="id" value="<?= $fiberplanpipes->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Bezeichnung * / Gis
Id</label>
<div class="col-lg-3">
<input required="required" type="text" id="description"
name="description"
class="form-control"
value="<?= $fiberplanpipes->description ?>"/>
</div>
<div class="col-lg-2">
<input type="text" id="gisid" name="gisid" placeholder="Gis Id"
class="form-control"
value="<?= $fiberplanpipes->gisid ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="type">Type *</label>
<div class="col-lg-3">
<select required="required" id="type" name="type"
class="select2 form-control">
<option value=""></option>
<option value="1" <?= ($fiberplanpipes->type == "1") ? "selected='selected'" : "" ?>>
Einzel
</option>
<option value="2" <?= ($fiberplanpipes->type == "2") ? "selected='selected'" : "" ?>>
Schutzrohr
</option>
<option value="3" <?= ($fiberplanpipes->type == "3") ? "selected='selected'" : "" ?>>
Verband
</option>
</select>
</div>
</div>
<div class="form-group row" id="dimesion-div"
style="<?= ($fiberplanpipes->type == "3") ? "display:none" : "" ?>">
<label class="col-lg-2 col-form-label" for="type_description">Dimension
*</label>
<div class="col-lg-3">
<select required="required" <?= ($fiberplanpipes->type == "3") ? 'disabled="disabled"' : "" ?>
id="type_description" name="type_description"
class="select2 form-control">
<option value=""></option>
<option value="1" <?= ($fiberplanpipes->type_description == "1") ? "selected='selected'" : "" ?>>
MR7
</option>
<option value="2" <?= ($fiberplanpipes->type_description == "2") ? "selected='selected'" : "" ?>>
MR14
</option>
<option value="3" <?= ($fiberplanpipes->type_description == "3") ? "selected='selected'" : "" ?>>
MR16
</option>
<option value="4" <?= ($fiberplanpipes->type_description == "4") ? "selected='selected'" : "" ?>>
MR20
</option>
<option value="5" <?= ($fiberplanpipes->type_description == "5") ? "selected='selected'" : "" ?>>
PE32
</option>
<option value="6" <?= ($fiberplanpipes->type_description == "6") ? "selected='selected'" : "" ?>>
PE40
</option>
<option value="7" <?= ($fiberplanpipes->type_description == "7") ? "selected='selected'" : "" ?>>
PE50
</option>
<option value="8" <?= ($fiberplanpipes->type_description == "8") ? "selected='selected'" : "" ?>>
KSR50
</option>
<option value="9" <?= ($fiberplanpipes->type_description == "9") ? "selected='selected'" : "" ?>>
KSR80
</option>
<option value="10" <?= ($fiberplanpipes->type_description == "10") ? "selected='selected'" : "" ?>>
KSR100
</option>
</select>
</div>
</div>
<div class="form-group row" id="dimension-bundle-div"
style="<?= ($fiberplanpipes->type < "3" || !$fiberplanpipes->type) ? "display:none" : "" ?>">
<label class="col-lg-2 col-form-label" for="fiberplanpipetemplate_id">Multirohr
*</label>
<div class="col-lg-3">
<select <?= ($fiberplanpipes->type < "3" || !$fiberplanpipes->type) ? 'disabled="disabled"' : "" ?>
required="required" id="fiberplanpipetemplate_id"
name="fiberplanpipetemplate_id"
class="select2 form-control">
<option value=""></option>
<?php foreach ($fiberplanpipetemplates as $fiberplanpipetemplate) :
$name = "";
if ($fiberplanpipetemplate->pipe7x4 && $fiberplanpipetemplate->pipe14x10) {
$name = $fiberplanpipetemplate->name . " " . $fiberplanpipetemplate->pipe7x4 . "*7x4" . "/" . $fiberplanpipetemplate->pipe14x10 . "*14x10";
} else if ($fiberplanpipetemplate->pipe7x4) {
$name = $fiberplanpipetemplate->name . " " . $fiberplanpipetemplate->pipe7x4 . "*7x4";
} else if ($fiberplanpipetemplate->pipe14x10) {
$name = $fiberplanpipetemplate->name . " " . $fiberplanpipetemplate->pipe14x10 . "*14x10";
}
?>
<option <?= ($fiberplanpipetemplate->id == $fiberplanpipes->fiberPlanPipeTemplate_id) ? "selected='selected'" : "" ?>
value="<?= $fiberplanpipetemplate->id ?>"><?= $name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="length">Länge (m) *</label>
<div class="col-lg-2">
<input required="required" type="number" step="any" id="length"
name="length"
class="form-control"
value="<?= $fiberplanpipes->length ?>"/>
</div>
</div>
<div id="endpoints">
<?php if ($fiberplanpipeendpoints) :
FiberPlanPipeModel::generateEndpoints($fiberplanpipeendpoints, $networks);
else :
$randid = rand(1000, 10000);
$typeArray[1] = 'Greenfield';
$typeArray[2] = 'POP';
$typeArray[3] = 'Building';
$typeArray[4] = 'Schacht-Verteiler';
?>
<div class="form-group row endpoint-maindiv">
<label class="col-lg-2 col-form-label endpoint-label"
for="startpoint_network_id"><span
class="label-text">Startpunkt * </span><span
class="endpointsymbol"><i id="add-endpoint"
class="fa-regular fa-circle-plus"></i></span></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 ">
<option value=""></option>
<?php foreach ($networks as $network): ?>
<option value="<?= $network->id ?>"><?= $network->name ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-2">
<select id="<?= $randid ?>_endpoint_type" required="required"
name="endpoint_type[]"
class="select2 form-control endpoint_type">
<option value=""></option>
<?php foreach ($typeArray as $key => $type) : ?>
<option value="<?= $key ?>"><?= $type ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-3" id="<?= $randid ?>_end-point-building"></div>
<div class="col-lg-2 endpoint_coordinates"></div>
</div>
<?php
endif;
?>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="status">Status *</label>
<div class="col-lg-2">
<select id="status" name="status" class="select2 form-control"
required="required">
<option value=""></option>
<option value="10" <?= ($fiberplanpipes->status == "10") ? "selected='selected'" : "" ?>>
Geplant
</option>
<option value="20" <?= ($fiberplanpipes->status == "20") ? "selected='selected'" : "" ?>>
Umsetzung
</option>
<option value="30" <?= ($fiberplanpipes->status == "30") ? "selected='selected'" : "" ?>>
Fertiggestellt
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="responsible">Zuständig *</label>
<div class="col-lg-2">
<select id="responsible" name="responsible" class="select2 form-control"
required="required">
<option value=""></option>
<option value="1" <?= ($fiberplanpipes->responsible == "1") ? "selected='selected'" : "" ?>>
Tiefbaufirma
</option>
<option value="2" <?= ($fiberplanpipes->responsible == "2") ? "selected='selected'" : "" ?>>
Person
</option>
</select>
</div>
<div id="responsible-div" class="col-lg-3"
style="<?= ($fiberplanpipes->responsible != "1") ? "display:none" : "" ?>">
<select id="address_id" name="address_id"
class="select2 form-control" <?= ($fiberplanpipes->responsible != "1") ? 'disabled="disabled"' : "" ?> >
<option value=""></option>
<?php foreach ($pipworkeraddresses as $pipworkeraddress): ?>
<option value="<?= $pipworkeraddress->id ?>" <?= ($fiberplanpipes->address_id == $pipworkeraddress->id) ? "selected='selected'" : "" ?>><?= $pipworkeraddress->company ?></option>
<?php endforeach; ?>
</select>
</div>
<div id="responsible_text-div" class="col-lg-3">
<input id="responsible_text" name="responsible_text"
value="<?= $fiberplanpipes->responsible_text ?>"
placeholder="Ansprechsperson"
class="form-control"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="comment">Kommentar</label>
<div class="col-lg-3">
<textarea id="comment" name="comment"
class="form-control"><?= $fiberplanpipes->comment ?></textarea>
</div>
</div>
</div>
<div class="col col-lg-4 align-self-center">
<div class="row">
<div id="map"></div>
</div>
<div class="row">
<div class="col-lg-6"><h4>Legende:</h4></div>
</div>
<div class="row justify-content-center">
<div class="col-lg-5"><img
src="<?= self::getResourcePath() ?>img/markers/marker-pop.png ">
<label class="font-16"> ... Pop</label></div>
<div class="col-lg-5"><img
src="<?= self::getResourcePath() ?>img/markers/marker-home.png ">
<label class="font-16"> ... Building</label></div>
</div>
<div class="row justify-content-center">
<div class="col-lg-5 justify-content-center"><img
src="<?= self::getResourcePath() ?>img/markers/marker-dispatcher.png ">
<label class="font-16"> ... Schacht/Verteiler</label></div>
<div class="col-lg-5"><img
src="<?= self::getResourcePath() ?>img/markers/marker-greenfield.png ">
<label class="font-16"> ... Greenfield</label></div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="<?= $cancelUrl ?>">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var marker = [];
var polylinec;
var polyline = [];
var fitmap = 0;
var map = L.map('map').setView([47.00525090986838, 15.761075762335581], 13);
L.tileLayer('https://mapsneu.wien.gv.at/basemap/{id}/normal/google3857/{z}/{y}/{x}.{imgtype}', {
maxZoom: 19,
id: "geolandbasemap",
imgtype: "png"
}).addTo(map);
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
function checkendpoints() {
let endpointcounter = $('.endpoint-label').length;
let endpointtext;
$('.endpoint-label').each(function (index) {
$(this).find('.move-endpoint-up').remove();
$(this).find('.move-endpoint-down').remove();
if (index == 0) {
endpointtext = "Startpunkt";
$(this).find('.endpointsymbol').html('<i id="add-endpoint" class="fa-regular fa-circle-plus"></i>');
} else if (endpointcounter == 2) {
endpointtext = 'Standort ' + index;
$(this).closest('.endpoint-maindiv').find('.label-text').after('<i title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>');
$(this).find('.endpointsymbol').html('');
} else if (endpointcounter - 1 == index) {
endpointtext = 'Standort ' + index;
$(this).closest('.endpoint-maindiv').find('.label-text').after('<i style="margin-right:22px;" title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>');
$(this).find('.endpointsymbol').html('<i class="fa-regular fa-circle-minus remove-endpoint"></i>');
} else if (index > 0) {
endpointtext = 'Standort ' + index;
$(this).closest('.endpoint-maindiv').find('.label-text').after('<i title="nach unten verschieben" class="fa-sharp fa-solid fa-down move-endpoint-down"></i><i title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>');
$(this).find('.endpointsymbol').html('<i class="fa-regular fa-circle-minus remove-endpoint"></i>');
}
$(this).find('.label-text').text(endpointtext + ' *');
});
}
$("body").on("change", ".endpoint_type,.endpoint_network_id ", function () {
const splitid = $(this).attr('id').split('_');
let thisid = splitid[0];
var options = "";
if ($.trim($("#" + thisid + "_endpoint_network_id").val()) != "" && $.trim($("#" + thisid + "_endpoint_type").val())) {
$.getJSON("<?= self::getUrl("FiberPlanPipe", "api", ['do' => 'getBuildingInfo']) ?>&network_id=" + $.trim($("#" + thisid + "_endpoint_network_id").val()) + "&bdtype=" + $.trim($("#" + thisid + "_endpoint_type").val()), {})
.done(function (data) {
$.each(data, function (k, val) {
options = options + '<option data-gpslat="' + val.gps_lat + '" data-gpslong="' + val.gps_long + '" value="' + val.id + '">' + val.name + '</option>';
});
$("#" + thisid + "_end-point-building").empty();
$("#" + thisid + "_end-point-building").append('<select id="' + thisid + '_endpoint" required="required" name="endpoint[]" class="select2 form-control endpoint_endpoint">' + options + '</select>');
$(".select2").select2({placeholder: ""});
addMarkers();
});
}
});
$("body").on("change", ".endpoint_endpoint", function () {
addMarkers();
});
$("body").on("click", ".move-endpoint-up", function () {
$(this).closest('.endpoint-maindiv').insertBefore($(this).closest('.endpoint-maindiv').prev());
checkendpoints();
addMarkers();
});
$("body").on("click", ".move-endpoint-down", function () {
$(this).closest('.endpoint-maindiv').insertAfter($(this).closest('.endpoint-maindiv').next());
checkendpoints();
addMarkers();
});
$("body").on("click", ".remove-endpoint", function () {
let endpointcounter;
$(this).closest('.endpoint-maindiv').remove();
checkendpoints();
addMarkers();
});
$("body").on("change", "#type", function () {
if ($(this).val() < 3) {
$('#dimesion-div').show();
$('#dimension-bundle-div').hide();
$("#type_description").prop("disabled", false);
$("#fiberplanpipetemplate_id").prop("disabled", true);
$(".select2").select2({placeholder: ""});
} else {
$('#dimesion-div').hide();
$('#dimension-bundle-div').show();
$("#type_description").prop("disabled", true);
$("#fiberplanpipetemplate_id").prop("disabled", false);
$(".select2").select2({placeholder: ""});
}
});
$("body").on("change", "#responsible", function () {
if ($(this).val() == 1) {
$('#responsible-div').show();
$("#address_id").prop("disabled", false);
$(".select2").select2({placeholder: ""});
} else {
$('#responsible-div').hide();
$("#address_id").prop("disabled", true);
$(".select2").select2({placeholder: ""});
}
});
// 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')
});
function addMarkers() {
removeMarkers();
removePolyline();
var oldlat;
var oldlong;
var gpsconter = 0;
$.each($('.endpoint_endpoint'), function (index, value) {
if ($(this).find('option:selected').data('gpslat')) {
var lat = $(this).find('option:selected').data('gpslat');
var lng = $(this).find('option:selected').data('gpslong');
var name = $(this).find('option:selected').text();
var color = "#acf0ab";
var mapicon = "home";
var endpointtype = $(this).closest('.endpoint-maindiv').find('.endpoint_type ').val();
if (endpointtype == 1) {
color = "#abbaf0";
mapicon = "garden";
} else if (endpointtype == 2) {
color = "#acf0ab";
mapicon = "village";
} else if (endpointtype == 3) {
color = "#f0abab";
mapicon = "home";
} else if (endpointtype == 4) {
color = "#e9f0ab";
mapicon = "home";
}
var icon = L.MakiMarkers.icon({
icon: mapicon,
color: color,
size: "l"
});
var markerid = marker.length;
$(this).data('markerid', markerid);
marker.push(L.marker([lat, lng], {icon: icon}).addTo(map));
if (index == 0 && fitmap == 0) {
map.setView([lat, lng]);
}
fitmap = 1;
if (oldlong) {
polylinec = [
[oldlat, oldlong],
[$(this).find('option:selected').data('gpslat'), $(this).find('option:selected').data('gpslong')]
];
polyline.push(L.polyline(polylinec, {color: '#f00'}).addTo(map));
// polyline.bindTooltip(locations[i][4], {permanent: true});
}
oldlat = $(this).find('option:selected').data('gpslat');
oldlong = $(this).find('option:selected').data('gpslong');
gpsconter++;
lat=String(lat);
lng=String(lng);
$(this).closest('.endpoint-maindiv').find('.endpoint_coordinates').html(`<label class="col-form-label"><a title="Google-Maps: ` + $(this).find('option:selected').data('gpslat') + ` , ` + $(this).find('option:selected').data('gpslong') + `"
class="mapsLink"
href="http://maps.google.com/?q=` + $(this).find('option:selected').data('gpslat') + ` , ` + $(this).find('option:selected').data('gpslong') + `"
target="_blank">` + lat.substring(0, 8) + `
, ` + lng.substring(0, 8) + `</a></label>`);
} else {
$(this).closest('.endpoint-maindiv').find('.endpoint_coordinates').html(`<label class="col-form-label">Keine Koordinaten</label>`);
oldlat = "";
oldlong = "";
}
});
if (gpsconter > 1) {
var group = new L.featureGroup(marker);
map.fitBounds(group.getBounds());
}
}
function removeMarkers() {
$.each(marker, function (index, value) {
map.removeLayer(value);
});
marker.splice(0, marker.length);
}
function removePolyline() {
$.each(polyline, function (index, value) {
map.removeLayer(value);
});
polyline.splice(0, polyline.length);
}
$(document).ready(function () {
// map.invalidateSize();
addMarkers();
$(".select2").select2({placeholder: ""});
$("body").on("click", "#add-endpoint", function (event) {
let randid = Math.floor(Math.random() * 10000);
let endpointcounter = $('.endpoint-maindiv').length + 1;
let endpointuparrow = "";
if (endpointcounter > 1) {
endpointuparrow = '<i title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>';
}
if (endpointcounter <= 7) {
$('#endpoints').append(`<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">Standort ` + $('.endpoint-maindiv').length + ` * </span>` + endpointuparrow + `<span class="endpointsymbol"><i class="fa-regular fa-circle-minus remove-endpoint"></i></span></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">` + $('#endpoints').find('.endpoint_network_id').eq(endpointcounter - 2).html() + `</select></div>
<div class="col-lg-2 ">
<select id="` + randid + `_endpoint_type" name="endpoint_type[]" required="required"
class="select2 form-control endpoint_type" data-startpoint="" : "" >
` + $('#endpoints').find('.endpoint_type').html() + `
</select>
</div>
<div class="col-lg-3" id="` + randid + `_end-point-building"></div>
<div class="col-lg-2 endpoint_coordinates"></div>
</div>`);
$('#' + randid + '_endpoint_network_id').val($('#endpoints').find('.endpoint_network_id').eq(endpointcounter - 2).val());
$('#' + randid + '_endpoint_type').val('');
checkendpoints();
$(".select2").select2({placeholder: ""});
}
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>