Features Netzbau-> Dateiablage und Stammdaten->Pops hinzugefügt

This commit is contained in:
Spitzer_Daniel
2022-11-02 13:00:52 +01:00
parent 8d8a0b54ae
commit c5d36132d2
12 changed files with 1669 additions and 269 deletions

View File

@@ -0,0 +1,247 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- 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("Filestore") ?>">Dateiablage</a></li>
<li class="breadcrumb-item active"><?= ($building->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title">Datei</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($file->id) ? "Datei bearbeiten" : "Neue Datei" ?></h4>
<form class="form-horizontal" method="post" enctype="multipart/form-data"
action="<?= self::getUrl("Filestore", "save") ?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?= $file->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name *</label>
<div class="col-lg-10">
<input value="<?= $file->name ?>" class="form-control" name="name" id="name">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Beschreibung</label>
<div class="col-lg-10">
<textarea class="form-control" name="description"
id="description"><?= htmlentities($file->description) ?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="filestore">Datei</label>
<div class="col-lg-10">
<input type="file" class="form-control-file" id="filestore" name="filestore">
</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>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$("#network_id").select2({placeholder: ""});
$("#pop_id").select2({placeholder: "", allowClear: true,});
$("#type_id").select2({placeholder: ""});
$("#networksection_id").select2({placeholder: "", allowClear: true,});
// disable mousewheel on 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 updatePops() {
var network_id = $("#network_id").val();
if (!network_id) {
return true;
}
// get new pops
$.get("<?=self::getUrl("Pop", "Api")?>",
{
"do": "getPops",
network_id: network_id
},
function (success) {
if (success.status == "OK") {
//console.log(success);
var pops = success.result.pops;
if (typeof pops !== 'object' || pops === null) {
return true;
}
var selected = $("#pop_id option:selected").val();
$("#pop_id option:gt(0)").remove();
for (var pop_id in pops) {
$("#pop_id").append($("<option></option>").attr("value", pop_id).text(pops[pop_id]));
}
if (selected) {
$("#pop_id").val(selected);
}
}
},
'json'
);
}
function updateSections() {
var network_id = $("#network_id").val();
if (!network_id) {
return true;
}
$.get("<?=self::getUrl("Networksection", "Api")?>",
{
"do": "getSections",
network_id: network_id
},
function (success) {
if (success.status == "OK") {
var sections = success.result.sections;
if (typeof sections !== 'object' || sections === null) {
return true;
}
var selected = $("#networksection_id option:selected").val();
$("#networksection_id option:gt(0)").remove();
for (var section_id in sections) {
$("#networksection_id").append($("<option></option>").attr("value", section_id).text(sections[section_id]));
}
console.log("selected: " + selected);
if (selected) {
$("#networksection_id").val(selected);
}
}
},
'json'
);
}
function updatePermissions() {
var network_id = $("#network_id").val();
if (!network_id) {
return true;
}
var types = ["lineworker", "pipeworker"];
$.get("<?=self::getUrl("Network", "Api")?>",
{
"do": "getPermissions",
network_id: network_id,
types: types.join('|')
},
function (success) {
if (success.status == "OK") {
var perms = success.result.permissions;
if (typeof perms !== 'object' || perms === null) {
return true;
}
types.forEach(function (type) {
var selected = $("#" + type + "_id option:selected").val();
$("#" + type + "_id").empty();
$("#" + type + "_id").append($("<option></option>"));
for (var perm_id in perms[type]) {
$("#" + type + "_id").append($("<option></option>").attr("value", perm_id).text(perms[type][perm_id]));
}
if (selected) {
$("#" + type + "_id").val(selected);
}
});
}
},
'json'
);
}
function enableGpsInputs() {
$("#gps_lat").removeAttr("readonly");
$("#gps_long").removeAttr("readonly");
$("#edit-gps").remove();
}
function showGpsAgain() {
$("#gps-again").show();
$("#gps-again input[type=checkbox").prop("checked", true);
}
<?php if($building->gps_lat && $building->gps_long): ?>
////////////
// Map
////////////
var gpslat = <?=($building->gps_lat) ? $building->gps_lat : 0?>;
var gpslong = <?=($building->gps_long) ? $building->gps_long : 0?>;
console.log(gpslat + "," + gpslong);
// Building Map
var buildingMap = L.map('building-map').setView([gpslat, gpslong], 18);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
//L.tileLayer('<?=self::getResourcePath()?>assets/map/{id}/{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
minZoom: 12,
maxZoom: 22,
//id: 'OSMPublicTransport',
//id: 'mapbox.streets',
id: 'mapbox/streets-v11',
//id: 'mapbox.pirates',
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
}).addTo(buildingMap);
var marker = L.marker([gpslat, gpslong]).addTo(buildingMap);
<?php endif; ?>
$("#street, #zip, #city").change(function () {
showGpsAgain();
});
$("#edit-gps").click(function () {
enableGpsInputs();
});
$("#network_id").change(function () {
updatePops();
updatePermissions();
updateSections();
});
$(document).ready(function () {
updatePops();
updatePermissions();
updateSections();
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,85 @@
<?php
$pagination_baseurl = $this->getUrl($Mod, "Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Dateien";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- 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 active">Dateiablage</li>
</ol>
</div>
<h4 class="page-title">Dateiablage</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Liste aller Dateien</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?= self::getUrl("Filestore", "add") ?>"><i
class="fas fa-plus"></i> Neue Datei hochladen</a>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th>Name</th>
<th>Beschreibung</th>
<th>Ersteller</th>
<th>Bearbeiter</th>
<th></th>
</tr>
<?php foreach ($files as $file): ?>
<tr>
<td><?= $file->name ?></td>
<td><?= $file->description ?></td>
<td><?= $file->creator->name ?> (<?= date("d.m.Y , H:i", $file->create) ?>)</td>
<td><?= $file->editor->name ?> (<?= date("d.m.Y , H:i", $file->edit) ?>)</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("File", "download", ["id" => $file->file_id, 's' => $pagination['start']])?>"><i class="far fa-download" title="Download"></i></a>
<a href="<?=self::getUrl("Filestore", "edit", ["id" => $file->id, 's' => $pagination['start']])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Filestore", "delete", ["id" => $file->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -1,150 +1,172 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- 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("Network")?>">Netzgebiete</a></li>
<li class="breadcrumb-item">POP</li>
<li class="breadcrumb-item active"><?=($pop->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP" ?></h4>
<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>
<?php if (empty($_GET["returnto"])) {
?>
<li class="breadcrumb-item"><a href="<?= self::getUrl("Network") ?>">Netzgebiete</a></li>
<li class="breadcrumb-item">POP</li>
<?php
} else {
?>
<li class="breadcrumb-item"><a
href="<?= self::getUrl(ucfirst($_GET["returnto"])) ?>"><?= strtoupper($_GET["returnto"]) ?>
></a></li>
<?php
}
?>
<li class="breadcrumb-item active"><?= ($pop->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?= ($pop->id) ? "POP bearbeiten" : "Neuer POP" ?></h4>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP"?></h4>
<form class="form-horizontal" method="post" action="<?=self::getUrl("Pop", "save")?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$pop->id?>" />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet</label>
<div class="col-lg-10">
<select class="select2 form-control " name="network_id" id="owner_id">
<option></option>
<?php foreach($networks as $network): ?>
<option value="<?=$network->id?>" <?=($pop->network_id == $network->id) ? "selected='selected'" : ""?>><?=($network->name)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name" value="<?=$pop->name?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite</label>
<div class="col-lg-10">
<input type="number" step="any" class="form-control" name="gps_lat" id="name" value="<?=$pop->gps_lat?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_long">GPS Länge</label>
<div class="col-lg-10">
<input type="number" step="any" class="form-control" name="gps_long" id="name" value="<?=$pop->gps_long?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="location">Standortinfo</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="location" rows="5"><?=$pop->location?></textarea>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h2 class="header-title mb-2">Access VLANs</h2>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_public">Public</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_public" id="vlan_public" value="<?=$pop->vlan_public?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_nat">NAT</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_nat" id="vlan_nat" value="<?=$pop->vlan_nat?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_ipv6">IPv6</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_ipv6" id="vlan_ipv6" value="<?=$pop->vlan_ipv6?>">
</div>
</div>
</div>
</div>
<div class="card">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note" rows="5"><?=$pop->note?></textarea>
</div>
</div>
<h4 class="header-title mb-2"><?= ($pop->id) ? "POP bearbeiten" : "Neuer POP" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Pop", "save", ["returnto" => $_GET["returnto"]]) ?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?= $pop->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet</label>
<div class="col-lg-10">
<select class="select2 form-control " name="network_id" id="owner_id">
<option></option>
<?php foreach ($networks as $network): ?>
<option value="<?= $network->id ?>" <?= ($pop->network_id == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name"
value="<?= $pop->name ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite</label>
<div class="col-lg-10">
<input type="number" step="any" class="form-control" name="gps_lat" id="name"
value="<?= $pop->gps_lat ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_long">GPS Länge</label>
<div class="col-lg-10">
<input type="number" step="any" class="form-control" name="gps_long" id="name"
value="<?= $pop->gps_long ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="location">Standortinfo</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="location"
rows="5"><?= $pop->location ?></textarea>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h2 class="header-title mb-2">Access VLANs</h2>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_public">Public</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_public" id="vlan_public"
value="<?= $pop->vlan_public ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_nat">NAT</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_nat" id="vlan_nat"
value="<?= $pop->vlan_nat ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vlan_ipv6">IPv6</label>
<div class="col-lg-10">
<input type="number" class="form-control" name="vlan_ipv6" id="vlan_ipv6"
value="<?= $pop->vlan_ipv6 ?>">
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note"
rows="5"><?= $pop->note ?></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>
</div>
</div>
</form>
</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>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$("#parent_id").select2({
allowClear: true,
placeholder: ""
});
$("#addresstypes").select2();
// 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')
});
</script>
<script type="text/javascript">
$("#parent_id").select2({
allowClear: true,
placeholder: ""
});
$("#addresstypes").select2();
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
// 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')
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,249 @@
<?php
$pagination_baseurl = $this->getUrl($Mod, "Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Pops";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- 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 active">Pops</li>
</ol>
</div>
<h4 class="page-title">Pops</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Liste aller Pops</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?= self::getUrl("Pop", "add",['returnto' => "pop"]) ?>"><i
class="fas fa-plus"></i> Neuen Pop anlegen</a>
</div>
</div>
</div>
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th>Name</th>
<th>Netgebiet</th>
<th>Zutritt</th>
<th>Vlan Public/Nat</th>
<th>Koordinaten</th>
<th></th>
<th></th>
</tr>
<?php foreach ($pops as $pop): ?>
<tr>
<td><?= $pop->name ?></td>
<td><?= $pop->network->name ?></td>
<td><?= $pop->location ?></td>
<td class="text-center"><?= $pop->vlan_public ?> / <?= $pop->vlan_nat ?></td>
<td class="text-center"><a title="Google-Maps: <?= rtrim($pop->gps_lat,'0') ?> , <?= $pop->gps_long ?>" class="mapsLink" href="http://maps.google.com/?q=<?= $pop->gps_lat ?> , <?= $pop->gps_long ?>" target="_blank"><?= rtrim($pop->gps_lat,'0') ?> , <?= rtrim($pop->gps_long,0) ?></a></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Pop", "edit", ["id" => $pop->id, 'returnto' => "pop"])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Pop", "index")?>" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
<!---->
</div>
</div>
</div>
</div>
<script type="text/javascript">
function toggleBuilding(id) {
$('#building-detail-' + id).toggle();
if ($('#building-detail-' + id).is(":hidden")) {
$('#building-' + id).removeClass("table-info");
$('#building-' + id).removeClass("text-info");
} else {
$('#building-' + id).addClass("text-info");
$('#building-' + id).addClass("table-info");
}
}
function toggleTerminationControl(id, type) {
$("#term-" + type + "-" + id + "-text").toggle();
$("#term-" + type + "-" + id + "-input").toggle();
$("#term-" + type + "-" + id + "-edit").toggle();
}
function saveTerminationControl(id, type) {
if (!Number.isInteger(id) || id < 1) {
return false;
}
var value = $("#term-" + type + "-" + id + "-input input[type=text]").val();
$.post("<?=self::getUrl("Termination", "Api")?>",
{
'do': "setValue",
id: id,
type: type,
value: value
},
function (success) {
if (success.status == "OK") {
$("#term-" + type + "-" + id + "-text").text(value);
} else {
console.log("error saving (" + type + ", '" + value + "')");
}
toggleTerminationControl(id, type);
},
'json');
}
/*
* Globals for map display
*/
var buildingMap;
var buildings = [];
var markers = [];
var markerState = true;
var mapCenterPos = [<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>];
function refreshMap() {
// get buildings and render map
$('#map-link').hide();
$('#map-row').show();
getMapdata();
}
function renderMap() {
if (buildingMap) {
markers.forEach(function (m) {
buildingMap.removeLayer(m);
});
} else {
buildingMap = L.map('building-map').setView([<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>], 12);
}
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
minZoom: 4,
maxZoom: 22,
id: 'mapbox/streets-v11',
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
}).addTo(buildingMap);
addMarkers();
}
function addMarkers() {
if (!Array.isArray(buildings) | !buildings.length) {
return false;
}
// draw markers and calculate center position
var all_coords = [];
buildings.forEach(function (building) {
if (!building.gps_lat || !building.gps_long) {
return;
}
var gps = [building.gps_lat, building.gps_long];
all_coords.push(gps);
var marker = L.marker(gps).addTo(buildingMap);
markers[building.id] = marker;
});
console.log(all_coords);
// calculate center position
mapCenterPos = GetCenterFromDegrees(all_coords);
console.log(mapCenterPos);
buildingMap.setView(mapCenterPos, 12);
return true;
}
function centerMap() {
buildingMap.setView(mapCenterPos, 12);
}
// gets buildings and calls renderMap()
function getMapdata() {
filter = getFilter();
$.post('<?=self::getUrl("Building", "Api")?>', {
'do': "getFilteredBuildings",
filter: filter
}, function (success) {
if (success.status == "OK") {
console.log(success);
if (Array.isArray(success.result.buildings)) {
buildings = success.result.buildings;
renderMap();
}
}
},
'json'
);
}
function getFilter() {
var fields = ['network_id', 'networksection_id', 'status_id', 'code', 'street'];
var filter = {};
fields.forEach(function (field) {
if (!field) {
return;
}
let val = $('#filter_' + field).val();
if (val.length) {
filter[field] = val;
}
});
return filter;
}
// navigation
var building;
var hash = window.location.hash.substr(1);
var match = hash.match(/building=(\d+)/);
if (match && match[1]) {
building = match[1]
toggleBuilding(building);
//$('body').scrollTop($('#building-' + building).offset() - 50);
}
<?php if(is_array($filter) && count($filter)): ?>
//refreshMap();
<?php endif; ?>
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -35,6 +35,7 @@
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
<li><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
<li><a href="<?=self::getUrl("Pop")?>"><i class="fad fa-house text-info"></i> Pops</a></li>
</ul>
</li>
<?php endif; ?>
@@ -50,6 +51,7 @@
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Pipework")?>"><i class="fad fa-wrench text-info"></i> Tiefbau</a></li><?php endif; ?>
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Linework")?>"><i class="fas fa-ethernet text-info"></i> Leitungsbau</a></li><?php endif; ?>
<?php if($me->is(["Admin", "netowner", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-plug text-info"></i> Patchungen</a></li><?php endif; ?>
<?php if($me->is(["Admin", "netowner","pipeplanner","lineplanner","pipeworker", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Filestore")?>"><i class="fas fa-file text-info"></i> Dateiablage</a></li><?php endif; ?>
</ul>
</li>
<?php endif; ?>

View File

@@ -0,0 +1,46 @@
<?php
class Filestore extends mfBaseModel
{
private $editor;
private $creator;
private $histories;
private $file;
public function getProperty($name) {
if($this->$name == null) {
if(!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
if($name == "histories") {
$this->histories=FilestoreHistoryModel::search(["filestore_id="=>$this->id]);
return $this->histories;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,197 @@
<?php
class FilestoreController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("Filestore/Index");
$files = FilestoreModel::getAll();
// pagination defaults
$pagination = [];
$pagination['start'] = 0;
$pagination['count'] = 25;
$pagination['maxItems'] = 0;
if(is_numeric($this->request->s)) {
$pagination['start'] = intval($this->request->s);
}
$pagination['maxItems'] = FilestoreModel::count();
$this->layout()->set("files", $files);
$this->layout()->set("pagination", $pagination);
}
protected function addAction()
{
$this->layout()->setTemplate("Filestore/Form");
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$filestore = new Filestore($id);
if (!$filestore->id) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$dataHistory = [];
$dataHistory['name'] = $filestore->name;
$dataHistory['description'] = $filestore->description;
$dataHistory['file_id'] = $filestore->file_id;
$dataHistory['filestore_id'] = $filestore->id;
$dataHistory['create'] = $filestore->create;
$dataHistory['create_by'] = $filestore->create_by;
$dataHistory['edit'] = date("U");
} else {
$mode = "add";
}
$data = [];
$data['name'] = trim($r->name);
$data['description'] = trim($r->description);
if (!$data['name']) {
$this->layout()->setFlash("Name darf nicht leer sein", "error");
$this->redirect("Filestore");
}
if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) {
$upload_error = false;
//var_dump($_FILES);exit;
$upload = new mfUpload("filestore");
$upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/netzbetrieb");
if (!$upload->getSize()) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen: Dokument darf nicht leer sein!", "error");
$this->redirect("Filestore");
}
if (substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen: PDF-Validierung fehlgeschlagen!", "error");
$this->redirect("Filestore");
}
try {
$upload->save();
} catch (Exception $e) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen1", "error");
$this->redirect("Filestore");
}
$file_data = [];
$file_data['name'] = $upload->getOriginalFilename();
$file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename();
$file_data['subfolder'] = "netzbetrieb";
$file_data['store_filename'] = $upload->getFilename();
$file_data['orig_filename'] = $upload->getOriginalFilename();
$file = FileModel::create($file_data);
$file_id = $file->save();
if (!$file_id) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen3", "error");
$this->redirect("Filestore");
}
$data['file_id'] = $file_id;
if ($mode == "edit") {
$fsh = FilestoreHistoryModel::create($dataHistory);
}
} else {
if ($mode == "add") {
$this->layout()->setFlash("Keine Datei angegeben", "error");
$this->redirect("Filestore", "add");
}
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$filestore->update($data);
} else {
$filestore = FilestoreModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $filestore->save();
if (!$id) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error");
$this->redirect("Filestore");
}
if ($fsh) {
$fsh->save();
}
$this->layout()->setFlash("Dateiupload erfolgreich hochgeladen", "success");
$this->redirect("Filestore");
}
protected function editAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (!is_numeric($id) && $id < 1) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$filestore = new Filestore($id);
if (!$filestore->id) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$this->layout()->set("file", $filestore);
return $this->addAction();
}
protected function deleteAction()
{
$id = $this->request->id;
$filstore = new Filestore($id);
if (!$filstore->id || $filstore->id != $id) {
$this->layout()->setFlash("Datei nicht gefunden.", "error");
$this->redirect("Filestore");
}
foreach ($filstore->histories as $h) {
$h->file->delete();
$h->delete();
}
$filstore->file->delete();
// check if Product is unused
$filstore->delete();
$this->redirect("Filestore");
}
}

View File

@@ -0,0 +1,168 @@
<?php
class FilestoreModel
{
public $order_id;
public $file_id;
public $name;
public $description;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(array $data)
{
$model = new Filestore();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
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("Filestore", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Filestore($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT Filestore.* FROM Filestore
LEFT JOIN File ON (Filestore.file_id = File.id)
ORDER BY name";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Filestore($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Filestore", "*", "$where ORDER BY name, filename");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Filestore($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function count() {
$db = FronkDB::singleton();
$sql = "
SELECT count(Filestore.id) as cnt
FROM Filestore
";
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT Filestore.* FROM Filestore
LEFT JOIN File ON (Filestore.file_id = File.id)
WHERE $where
ORDER BY name";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Filestore($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
if (array_key_exists("file_id", $filter)) {
$file_id = $filter['file_id'];
if (is_numeric($file_id)) {
$where .= " AND file_id=$file_id";
}
}
//var_dump($filter);exit;
if (array_key_exists("name", $filter)) {
$name = FronkDB::singleton()->escape($filter['name']);
if ($name) {
$where .= " AND name='$name'";
}
}
if (array_key_exists("filename", $filter)) {
$filename = FronkDB::singleton()->escape($filter['filename']);
if ($filename) {
$where .= " AND File.filename='$filename'";
}
}
if (array_key_exists("subfolder", $filter)) {
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
if ($subfolder) {
$where .= " AND File.subfolder='$subfolder'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,41 @@
<?php
class FilestoreHistory extends mfBaseModel
{
private $editor;
private $creator;
private $file;
public function getProperty($name) {
if($this->$name == null) {
if(!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,151 @@
<?php
class FilestoreHistoryController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("Filestore/Index");
$files = FilestoreModel::getAll();
$this->layout()->set("files", $files);
}
protected function addAction()
{
$this->layout()->setTemplate("Filestore/Form");
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$filestore = new Filestore($id);
if (!$filestore->id) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$dataHistory = [];
$dataHistory['name'] = $filestore->name;
$dataHistory['description'] = $filestore->description;
$dataHistory['file_id'] = $filestore->file_id;
$dataHistory['create'] = $filestore->create;
$dataHistory['create_by'] = $filestore->create_by;
$dataHistory['edit'] = date("U");
} else {
$mode = "add";
}
$data = [];
$data['name'] = trim($r->name);
$data['description'] = trim($r->description);
if (!$data['name']) {
$this->layout()->setFlash("Name darf nicht leer sein", "error");
$this->redirect("Filestore");
}
if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) {
$upload_error = false;
//var_dump($_FILES);exit;
$upload = new mfUpload("filestore");
$upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/netzbetrieb");
if (!$upload->getSize()) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen: Dokument darf nicht leer sein!", "error");
$this->redirect("Filestore");
}
if (substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen: PDF-Validierung fehlgeschlagen!", "error");
$this->redirect("Filestore");
}
try {
$upload->save();
} catch (Exception $e) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
$this->redirect("Filestore");
}
$file_data = [];
$file_data['name'] = $upload->getOriginalFilename();
$file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename();
$file_data['subfolder'] = "netzbetrieb";
$file_data['store_filename'] = $upload->getFilename();
$file_data['orig_filename'] = $upload->getOriginalFilename();
$file = FileModel::create($file_data);
$file_id = $file->save();
if (!$file_id) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
$this->redirect("Filestore");
}
$data['file_id'] = $file_id;
$filestore = FilestoreHistoryModel::create($dataHistory);
} else {
if ($mode == "add") {
$this->layout()->setFlash("Keine Datei angegeben", "error");
$this->redirect("Filestore", "add");
}
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$filestore->update($data);
} else {
$filestore = FilestoreModel::create($data);
}
$id = $filestore->save();
if (!$id) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
$this->redirect("Filestore");
}
$this->layout()->setFlash("Dateiupload erfolgreich hochgeladen", "success");
$this->redirect("Filestore");
}
protected function editAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (!is_numeric($id) && $id < 1) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$filestore = new Filestore($id);
if (!$filestore->id) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$this->layout()->set("file", $filestore);
return $this->addAction();
}
}

View File

@@ -0,0 +1,157 @@
<?php
class FilestoreHistoryModel
{
public $filestore_id;
public $file_id;
public $name;
public $description;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(array $data)
{
$model = new FilestoreHistory();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
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("FilestoreHistory", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FilestoreHistory($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT FilestoreHistory.* FROM FilestoreHistory
LEFT JOIN File ON (FilestoreHistory.file_id = File.id)
ORDER BY name";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FilestoreHistory($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FilestoreHistory", "*", "$where ORDER BY name, filename");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FilestoreHistory($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT FilestoreHistory.* FROM FilestoreHistory
LEFT JOIN File ON (FilestoreHistory.file_id = File.id)
WHERE $where
ORDER BY name";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FilestoreHistory($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
if (array_key_exists("file_id", $filter)) {
$file_id = $filter['file_id'];
if (is_numeric($file_id)) {
$where .= " AND file_id=$file_id";
}
}
if (array_key_exists("filestore_id", $filter)) {
$filestore_id = $filter['filestore_id'];
if (is_numeric($filestore_id)) {
$where .= " AND filestore_id=$filestore_id";
}
}
//var_dump($filter);exit;
if (array_key_exists("name", $filter)) {
$name = FronkDB::singleton()->escape($filter['name']);
if ($name) {
$where .= " AND name='$name'";
}
}
if (array_key_exists("filename", $filter)) {
$filename = FronkDB::singleton()->escape($filter['filename']);
if ($filename) {
$where .= " AND File.filename='$filename'";
}
}
if (array_key_exists("subfolder", $filter)) {
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
if ($subfolder) {
$where .= " AND File.subfolder='$subfolder'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -1,144 +1,179 @@
<?php
class PopController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin", "netowner", "pipeplanner"])) {
$this->redirect("Dashboard");
}
}
class PopController extends mfBaseController
{
private $returUrl = "Network";
protected function indexAction() {
}
protected function addAction() {
$this->layout()->setTemplate("Pop/Form");
$this->layout()->set("networks", NetworkModel::getAll());
if($this->request->network_id) {
$pop = new Pop();
$pop->network_id = $this->request->network_id;
$this->layout()->set("pop", $pop);
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin", "netowner", "pipeplanner"])) {
$this->redirect("Dashboard");
}
}
}
protected function editAction() {
$id = $this->request->id;
if(!is_numeric($id) || !$id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
protected function indexAction()
{
$this->layout()->setTemplate("Pop/Index");
$pops = PopModel::getAll();
$this->layout()->set("pops", $pops);
}
$pop = new Pop($id);
if($pop->id != $id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
protected function addAction()
{
$this->layout()->setTemplate("Pop/Form");
$this->layout()->set("networks", NetworkModel::getAll());
if ($this->request->network_id) {
$pop = new Pop();
$pop->network_id = $this->request->network_id;
$this->layout()->set("pop", $pop);
}
}
$this->layout()->set("pop", $pop);
return $this->addAction();
}
protected function saveAction() {
$r = $this->request;
$id = $r->id;
//var_dump($r);exit;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$pop = new Pop($id);
if(!$pop->id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
} else {
$mode = "add";
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
$pop = new Pop($id);
if ($pop->id != $id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
$this->layout()->set("pop", $pop);
return $this->addAction();
}
//var_dump($r->addresstypes);exit;
if(!$r->network_id || !$r->name) {
$this->layout()->setFlash("Bitte Name und Netzgebiet eintragen", "error");
$this->layout()->set("pop", $pop);
unset($r->network_id);
return $this->add();
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r);exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$pop = new Pop($id);
if (!$pop->id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
} else {
$mode = "add";
}
//var_dump($r->addresstypes);exit;
$this->log->debug(print_r($r, true));
if (!$r->network_id || !$r->name) {
$this->layout()->setFlash("Bitte Name und Netzgebiet eintragen", "error");
$this->layout()->set("pop", $pop);
unset($r->network_id);
return $this->add();
}
$data = [];
$data['network_id'] = $r->network_id;
$data['name'] = $r->name;
$data['gps_lat'] = ($r->gps_lat) ? $r->gps_lat : null;
$data['gps_long'] = ($r->gps_long) ? $r->gps_long : null;
$data['location'] = $r->location;
$data['vlan_public'] = ($r->vlan_public) ? $r->vlan_public : null;
$data['vlan_nat'] = ($r->vlan_nat) ? $r->vlan_nat : null;
$data['vlan_ipv6'] = ($r->vlan_ipv6) ? $r->vlan_ipv6 : null;
$data['note'] = $r->note;
$data['edit_by'] = 1;
if ($mode == "add") {
$data['create_by'] = 1;
$pop = PopModel::create($data);
} else {
$pop->update($data);
}
$new_id = $pop->save();
if (!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->layout()->set("network", $network);
return $this->addAction();
}
if ($this->request->returnto) {
$this->returUrl = ucfirst($this->request->returnto);
}
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
$this->redirect($this->returUrl, "Index", [], "view=pops&net=" . $pop->network_id);
}
$data = [];
$data['network_id'] = $r->network_id;
$data['name'] = $r->name;
$data['gps_lat'] = ($r->gps_lat) ? $r->gps_lat : null;
$data['gps_long'] = ($r->gps_long) ? $r->gps_long : null;
$data['location'] = $r->location;
$data['vlan_public'] = ($r->vlan_public) ? $r->vlan_public : null;
$data['vlan_nat'] = ($r->vlan_nat) ? $r->vlan_nat: null;
$data['vlan_ipv6'] = ($r->vlan_ipv6) ? $r->vlan_ipv6: null;
$data['note'] = $r->note;
$data['edit_by'] = 1;
if($mode == "add") {
$data['create_by'] = 1;
$pop = PopModel::create($data);
} else {
$pop->update($data);
protected function apiAction()
{
$do = $this->request->do;
$data = [];
switch ($do) {
case "getPops":
$return = $this->getPopsApi();
break;
default:
$return = false;
}
if (!is_array($return) || !count($return)) {
$data = ["status" => "error"];
$this->returnJson($data);
}
$data['status'] = "OK";
$data['result'] = $return;
$this->returnJson($data);
}
//var_dump($address);exit;
$new_id = $pop->save();
if(!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->layout()->set("network", $network);
return $this->addAction();
private function getPopsApi()
{
$network_id = $this->request->network_id;
if (!is_numeric($network_id) || $network_id < 1) {
return false;
}
$network = new Network($network_id);
if (!$network->id) {
return false;
}
$pops = [];
foreach ($network->pops as $pop) {
$pops[$pop->id] = $pop->name;
}
return ["pops" => $pops];
}
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
$this->redirect("Network", "Index", [], "view=pops&net=".$pop->network_id);
}
protected function apiAction() {
$do = $this->request->do;
$data = [];
switch($do) {
case "getPops":
$return = $this->getPopsApi();
break;
default:
$return = false;
protected function deleteAction()
{
$id = $this->request->id;
$pop = new Pop($id);
if (!$pop->id || $pop->id != $id) {
$this->layout()->setFlash("Datei nicht gefunden.", "error");
$this->redirect("Pop");
}
$pop->delete();
$this->redirect("Pop");
}
if(!is_array($return) || !count($return)) {
$data = ["status" => "error"];
$this->returnJson($data);
}
$data['status'] = "OK";
$data['result'] = $return;
$this->returnJson($data);
}
private function getPopsApi() {
$network_id = $this->request->network_id;
if(!is_numeric($network_id) || $network_id < 1) {
return false;
}
$network = new Network($network_id);
if(!$network->id) {
return false;
}
$pops = [];
foreach($network->pops as $pop) {
$pops[$pop->id] = $pop->name;
}
return ["pops" => $pops];
}
}