Files
thetool/Layout/default/FiberPlanPipe/Form.php
Spitzer Daniel e3f8c2326e Faserplanung
* Schächte/Verteiler
 * Rohrplanung
2024-04-16 16:55:16 +02:00

469 lines
28 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>
.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;
}
</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">
<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-2">
<input required="required" type="text" id="description" name="description"
class="form-control"
value="<?= $fiberplanpipes->description ?>"/>
</div>
<div class="col-lg-1">
<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-1">
<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);
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">
<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>
<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">
function checkendpoints() {
let endpointcounter = $('.endpoint-label').length;
let endpointtext;
$('.endpoint-label').each(function (index) {
$(this).find('.move-endpoint-up').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 (index > 0) {
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('<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 value="' + val.id + '">' + val.name + '</option>';
});
$("#" + thisid + "_mid-point-building").empty();
$("#" + thisid + "_mid-point-building").append('<select id=' + thisid + '_endpoint" required="required" name="endpoint[]" class="select2 form-control">' + options + '</select>');
$(".select2").select2({placeholder: ""});
});
}
});
$("body").on("click", ".move-endpoint-up", function () {
$(this).closest('.endpoint-maindiv').insertBefore($(this).closest('.endpoint-maindiv').prev());
checkendpoints();
});
$("body").on("click", ".remove-endpoint", function () {
let endpointcounter;
$(this).closest('.endpoint-maindiv').remove();
checkendpoints();
});
$("body").on("change", "#startpoint_type,#network_id", function () {
var options;
if ($.trim($("#network_id").val()) != "" && $.trim($("#startpoint_type").val())) {
$.getJSON("<?= self::getUrl("FiberPlanPipe", "api", ['do' => 'getBuildingInfo']) ?>&network_id=" + $.trim($("#network_id").val()) + "&bdtype=" + $.trim($("#startpoint_type").val()), {})
.done(function (data) {
$.each(data, function (k, val) {
options = options + '<option value="' + val.id + '">' + val.name + '</option>';
});
$('#starting-point-building').empty();
$('#starting-point-building').append('<select id="startpoint" required="required" name="startpoint" class="select2 form-control">' + options + '</select>');
$(".select2").select2({placeholder: ""});
});
}
});
$("body").on("change", "#entpoint_type,#network_id2", function () {
var options;
if ($.trim($("#network_id2").val()) != "" && $.trim($("#entpoint_type").val())) {
$.getJSON("<?= self::getUrl("FiberPlanPipe", "api", ['do' => 'getBuildingInfo']) ?>&network_id=" + $.trim($("#network_id2").val()) + "&bdtype=" + $.trim($("#entpoint_type").val()), {})
.done(function (data) {
$.each(data, function (k, val) {
options = options + '<option value="' + val.id + '">' + val.name + '</option>';
});
$('#end-point-building').empty();
$('#end-point-building').append('<select id="endpoint" name="endpoint" required="required" class="select2 form-control">' + options + '</select><input type="hidden" name="endpointid[]" value="">');
$(".select2").select2({placeholder: ""});
});
}
});
$("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')
});
$(document).ready(function () {
$(".select2").select2({placeholder: ""});
if ($.trim($("#network_id").val()) != "" && $.trim($("#startpoint_type").val())) {
$.getJSON("<?= self::getUrl("FiberPlanPipe", "api", ['do' => 'getBuildingInfo']) ?>&network_id=" + $.trim($("#network_id").val()) + "&bdtype=" + $.trim($("#startpoint_type").val()), {})
.done(function (data) {
var options;
$.each(data, function (k, val) {
if ($('#startpoint_type').data('startpoint') == val.id) {
options = options + '<option selected="selected" value="' + val.id + '">' + val.name + '</option>';
} else {
options = options + '<option value="' + val.id + '">' + val.name + '</option>';
}
});
$('#starting-point-building').empty();
$('#starting-point-building').append('<select id="startpoint" name="startpoint" required="required" class="select2 form-control">' + options + '</select>');
$(".select2").select2({placeholder: ""});
});
}
if ($.trim($("#network_id2").val()) != "" && $.trim($("#entpoint_type").val())) {
$.getJSON("<?= self::getUrl("FiberPlanPipe", "api", ['do' => 'getBuildingInfo']) ?>&network_id=" + $.trim($("#network_id2").val()) + "&bdtype=" + $.trim($("#entpoint_type").val()), {})
.done(function (data) {
var options;
$.each(data, function (k, val) {
if ($('#entpoint_type').data('endpoint') == val.id) {
options = options + '<option selected="selected" value="' + val.id + '">' + val.name + '</option>';
} else {
options = options + '<option value="' + val.id + '">' + val.name + '</option>';
}
});
$('#end-point-building').empty();
$('#end-point-building').append('<select id="endpoint" name="endpoint" required="required" class="select2 form-control">' + options + '</select>');
$(".select2").select2({placeholder: ""});
});
}
$("body").on("click", "#add-endpoint", function (event) {
let randid = Math.floor(Math.random() * 10000);
let endpointtype = $('#startpoint_type').html();
let endpointcounter = $('.endpoint-maindiv').length + 1;
let endpointuparrow = "";
let standorttext = "";
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-2"><select id="` + randid + `_endpoint_network_id" required="required" name="endpoint_network_id[]"
class="select2 form-control endpoint_network_id">` + $('#network_id').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="" : "" >
<option value=""></option>
<option value="4">
Schacht-Verteiler
</option>
</select>
</div>
<div class="col-lg-2" id="` + randid + `_mid-point-building">
</div>
</div>`);
$('#' + randid + '_endpoint_network_id').val($('#network_id').val());
checkendpoints();
$(".select2").select2({placeholder: ""});
}
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>