Merge branch 'master' into fronkdev

This commit is contained in:
Frank Schubert
2023-04-20 12:13:07 +02:00
92 changed files with 31303 additions and 1238 deletions

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1 @@
<?php

View File

@@ -175,6 +175,50 @@
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gdaeigenschaft">GDA-Eigenschaft</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("gdaeigenschaft", $save_data)): ?>
<input type="text" class="form-control" name="gdaeigenschaft" id="gdaeigenschaft" value="<?=$save_data['gdaeigenschaft']?>">
<?php else: ?>
<input type="text" class="form-control" name="gdaeigenschaft" id="gdaeigenschaft" value="<?=$address->gdaeigenschaft?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="meridian">Meridian</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("meridian", $save_data)): ?>
<input type="text" class="form-control" name="meridian" id="meridian" value="<?=$save_data['meridian']?>">
<?php else: ?>
<input type="text" class="form-control" name="meridian" id="meridian" value="<?=$address->meridian?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="rw">RW</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("rw", $save_data)): ?>
<input type="text" class="form-control" name="rw" id="rw" value="<?=$save_data['rw']?>">
<?php else: ?>
<input type="text" class="form-control" name="rw" id="rw" value="<?=$address->rw?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="hw">HW</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("hw", $save_data)): ?>
<input type="text" class="form-control" name="hw" id="hw" value="<?=$save_data['hw']?>">
<?php else: ?>
<input type="text" class="form-control" name="hw" id="hw" value="<?=$address->hw?>">
<?php endif; ?>
</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">
@@ -240,7 +284,6 @@
</div>
</div>
<?php if(!$address->id): ?>
<hr />
<div class="form-group row">
@@ -249,12 +292,11 @@
<?php if(is_array($save_data) && array_key_exists("unit_count", $save_data)): ?>
<input type="text" class="form-control" name="unit_count" id="unit_count" value="<?=$save_data['unit_count']?>">
<?php else: ?>
<input type="text" class="form-control" name="unit_count" id="unit_count" value="">
<input type="text" class="form-control" name="unit_count" id="unit_count" value="<?=$address->unit_count?>">
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
@@ -277,7 +319,7 @@
</div>
<script>
$(".select2").select2();
$(".select2").select2({closeOnSelect: false});
$('#strasse').autoComplete({minLength: 2}).keydown(preventEnter);
$('#plz').autoComplete({minLength: 1}).keydown(preventEnter);

View File

@@ -84,6 +84,11 @@
<label class="form-label" for="filter_street">Strasse</label>
<input type="text" class="form-control" name="filter[street]" id="filter_street" value="<?=$filter['street']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_hausnummer">Hausnummer</label>
<input type="text" class="form-control" name="filter[hausnummer]" id="filter_street" value="<?=$filter['hausnummer']?>" />
</div>
</div>
<div class="row mt-2">
@@ -120,7 +125,7 @@
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("AddressDB")?>">Filter zurücksetzen</a>
<a class="btn btn-secondary" href="<?=self::getUrl("AddressDB", "", ["resetFilter" => 1])?>">Filter zurücksetzen</a>
<button type="submit" formaction="<?=self::getUrl("AddressDB", "export")?>" id="export-button" class="btn btn-outline-success ml-2"><i class="fas fa-download"></i> CSV-Export</button>
</div>
</div>
@@ -158,6 +163,7 @@
<th>Straße</th>
<th>Hausnummer</th>
<th>Wohneinheiten</th>
<th>GDA-Eigenschaft</th>
<th>Rollout Jahr</th>
<th>Rollout Info</th>
<th></th>
@@ -174,6 +180,7 @@
<td><?=$address->strasse->name?></td>
<td><?=$address->hausnummer?></td>
<td><?=count($address->wohneinheiten)?></td>
<td><?=$address->gdaeigenschaft?></td>
<td><?=$address->rollout?></td>
<td><?=$address->rollout_info?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">

View File

@@ -3,7 +3,7 @@ ob_end_flush();
header("Content-type: text/csv");
header('Content-disposition: attachment; filename="addressdb-export-'.date('Y-m-d_H-i-s').'.csv"');
?>
AddressDB_ID;Extref;Adrcd;OAID;Netzgebiet_Extref;Netzgebiet;GKZ;Gemeinde;OKZ;Ortschaft;PLZ;SKZ;Strasse;Hausnummer;Grundstueck;GPS Breite; GPS Laenge;Rollout;Rollout_Info;Freigabe;Nutzungseinheiten
AddressDB_ID;Extref;Adrcd;OAID;Netzgebiet_Extref;Netzgebiet;GKZ;Gemeinde;OKZ;Ortschaft;PLZ;SKZ;Strasse;Hausnummer;Grundstueck;GPS Breite; GPS Laenge;Rollout;Rollout_Info;Freigabe;Nutzungseinheiten;GDA-Eigenschaft;Meridian;RW;HW
<?php
$line = 0;
@@ -21,7 +21,8 @@ while($data = mysqli_fetch_object($res)):
}
$unit_count = $data->unit_count;
?>
<?=$data->id?>;"<?=$data->extref?>";<?=$data->adrcd?>;"<?=$data->oaid?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";<?=$gemeinde->kennziffer?>;"<?=$gemeinde->name?>";<?=$ortschaft->kennziffer?>;"<?=$ortschaft->name?>";"<?=$plz->plz?>";<?=$strasse->kennziffer?>;"<?=$strasse->name?>";"<?=$data->hausnummer?>";"<?=$data->grund_nr?>";<?=$data->gps_lat?>;<?=$data->gps_long?>;<?=$data->rollout?>;"<?=$data->rollout_info?>";"<?=$freigabe?>";<?=$unit_count?>;
<?=$data->id?>;"<?=$data->extref?>";<?=$data->adrcd?>;"<?=$data->oaid?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";<?=$gemeinde->kennziffer?>;"<?=$gemeinde->name?>";<?=$ortschaft->kennziffer?>;"<?=$ortschaft->name?>";"<?=$plz->plz?>";<?=$strasse->kennziffer?>;"<?=$strasse->name?>";"<?=$data->hausnummer?>";"<?=$data->grund_nr?>";<?=$data->gps_lat?>;<?=$data->gps_long?>;<?=$data->rollout?>;"<?=$data->rollout_info?>";"<?=$freigabe?>";<?=$unit_count?>;"<?=$data->gdaeigenschaft?>";"<?=$data->meridian?>";<?=$data->rw?>;<?=$data->hw?>
<?php
$i++;
if($line % 1000 === 0) {

View File

@@ -110,9 +110,12 @@
<a href="#" class="btn btn-success" onclick="refreshMap()"><i class="far fa-map"></i> Übersichtskarte einblenden</a>
</div>
<div class="row hidden" id="map-row">
<div id="building-map" style="height:50vh; width: 100%"></div>
<div class="mt-1">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle"></i> Zentrieren</button>
<div id="building-map" style="height:70vh; width: 100%"></div>
<div class="row mt-1">
<div class="col">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle fa-fw"></i> Zentrieren</button>
<button type="button" class="btn btn-sm btn-outline-success" onclick="toggleTileset()" title="Zwischen Karte und Satellitenbild umschalten"><i class="far fa-arrow-right-arrow-left fa-fw"></i> Karte/Satellit</button>
</div>
</div>
</div>
</div>
@@ -359,34 +362,66 @@
var markers = [];
var markerState = true;
var mapCenterPos = [<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>];
var tileLayers = [];
var tilesets = ["mapbox/streets-v12", "mapbox/satellite-streets-v12"];
var currentTileset = "mapbox/streets-v12";
function toggleTileset() {
if(currentTileset == "mapbox/streets-v12") {
currentTileset = "mapbox/satellite-streets-v12";
} else {
currentTileset = "mapbox/streets-v12";
}
console.log("renderMap");
renderMap(true);
}
function refreshMap() {
// get buildings and render map
$('#map-link').hide();
$('#map-row').show();
getMapdata();
$([document.documentElement, document.body]).animate({
scrollTop: $("#building-map").offset().top - 150
}, 500);
}
function renderMap() {
function renderMap(tilesetChangeOnly = false) {
if(buildingMap) {
markers.forEach(function(m) {
buildingMap.removeLayer(m);
});
if(!tilesetChangeOnly) {
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);
if(!(currentTileset in tileLayers)) {
tileLayers[currentTileset] = 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: 6,
maxZoom: 22,
id: currentTileset,
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
});
}
tileLayers[currentTileset].addTo(buildingMap);
// remove all tilesets not currently wanted
tilesets.forEach(function(t) {
if(t != currentTileset && buildingMap.hasLayer(tileLayers[t])) {
buildingMap.removeLayer(tileLayers[t]);
}
});
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
addMarkers();
if(!tilesetChangeOnly) {
addMarkers();
}
}
@@ -404,13 +439,13 @@
var gps = [building.gps_lat, building.gps_long];
all_coords.push(gps);
var icon_color = "#CB2B3E";
var icon_color = "#ec98a2";
var icon_name = "home";
if(building.status == "connected") {
icon_color = "#2AAD27";
icon_color = "#acf0ab";
} else if(building.status == "pipework-done") {
icon_color = "#CB8427";
icon_color = "#ffcd8b";
}
if(building.type.match(/^(Zwei)/i)) {

View File

@@ -200,7 +200,6 @@
<th>Kunde</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th></th>
</tr>
<?php foreach($contract->links as $link): ?>
@@ -208,8 +207,7 @@
<td><?=__($link->type, "contract")?></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $link->contract->owner_id])?>"><?=$link->contract->owner->getCompanyOrName()?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract_id?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->matchcode?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?> [<?=$link->contract->matchcode?>]</a></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>

View File

@@ -91,7 +91,7 @@
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<table class="table table-striped table-hover table-sm">
<tr>
<th>Contract ID</th>
<th>Inhaber</th>
@@ -109,7 +109,7 @@
<?php foreach($contracts as $contract): ?>
<tr>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->id?></a></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</td>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
<!--<td>

View File

@@ -322,7 +322,6 @@
<th>Contract ID</th>
<th>Typ</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
@@ -350,8 +349,7 @@
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->matchcode?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$linkcontract->matchcode?>]</a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>

View File

@@ -57,30 +57,73 @@
<div class="card-body">
<h4 class="text-center mb-3">Konfiguration bearbeiten</h4>
<?php if(is_array($groups) && count($groups)): ?>
<form method="post" action="<?=self::getUrl("Contractconfig", "Save")?>">
<form id="contract-config-form" method="post" action="<?=self::getUrl("Contractconfig", "Save")?>">
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
<table class="table table-sm table-borderless view-table">
<?php foreach($groups as $group): ?>
<tr class="bg-light">
<th><h4><u><?=$group->name?></u></h4></td>
<td></td>
</tr>
<?php foreach($group->items as $item): ?>
<tr>
<th style="max-width: 50vw;"><?=$item->displayname?>:</th>
<td style="width: 50vw;">
<?php if($item->type == "enum"): ?>
<select class="form-control" name="itemvalues[<?=$item->id?>]">
<?php foreach($item->getTypedataArray() as $option): ?>
<option value="<?=htmlentities($option)?>" <?=($item->getValue() == $option) ? "selected='selected'" : ""?>><?=htmlentities($option)?></option>
<?php endforeach; ?>
</select>
<?php else: ?>
<input type="text" class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>" name="itemvalues[<?=$item->id?>]" value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id]) : htmlentities($item->getValue())?>" />
<?php endif; ?>
<small><?=$item->description?></small>
</td>
<tr class="bg-light">
<th><h4><u><?=$group->name?></u></h4></td>
<td></td>
</tr>
<?php foreach($group->items as $item): ?>
<?php
$inputname = "itemvalues[".$item->id."]";
if($item->multiple) {
$inputname .= "[]";
}
$inputid = "itemvalues_".$item->id;
$array_count = 0;
?>
<?php if($item->multiple): ?>
<?php foreach($item->getValue() as $item_value): ?>
<tr id="tr-<?=$inputid?>_<?=$array_count?>">
<th style="max-width: 50vw;"><?=$item->displayname?><span class="array_counter"> (<?=$array_count + 1?>)</span>:</th>
<td style="width: 50vw;">
<input type="text"
class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>"
name="<?=$inputname?>"
id="<?=$inputid?>_<?=$array_count?>"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id][$array_count]) : htmlentities($item_value)?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<small><?=$item->description?></small>
</td>
</tr>
<?php $array_count++; ?>
<?php endforeach; ?>
<tr id="tr-<?=$inputid?>_<?=$array_count?>">
<th style="max-width: 50vw;"><?=$item->displayname?><span class="array_counter"> (<?=$array_count + 1?>)</span>:</th>
<td style="width: 50vw;">
<input type="text"
class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>"
name="<?=$inputname?>"
id="<?=$inputid?>_<?=$array_count?>"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id][$array_count]) : ""?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<small><?=$item->description?></small>
</td>
</tr>
<?php else: ?>
<tr id="tr-<?=$inputid?>_0">
<th style="max-width: 50vw;"><?=$item->displayname?>:</th>
<td style="width: 50vw;">
<?php if($item->type == "enum"): ?>
<select class="form-control" name="<?=$inputname?>" id="<?=$inputid?>" <?=($item->multiple) ? "data-item-multiple='true'" : ""?>>
<?php foreach($item->getTypedataArray() as $option): ?>
<option value="<?=htmlentities($option)?>" <?=($item->getValue() == $option) ? "selected='selected'" : ""?>><?=htmlentities($option)?></option>
<?php endforeach; ?>
</select>
<?php else: ?>
<input type="text"
class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>"
name="<?=$inputname?>"
id="<?=$inputid?>_0"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id]) : htmlentities($item->getValue())?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<?php endif; ?>
<small><?=$item->description?></small>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
@@ -105,4 +148,73 @@
</div>
</div>
<script>
$(document).ready(function() {
$("#contract-config-form input").each(function() {
var input = this;
if(!$(input).attr("name")) return;
//console.log(this);
console.log($(input).attr("name"));
if($(input).data("item-multiple")) {
$(input).change(function() {
addMultipleValueField($(this).prop("id"));
});
}
});
});
function addMultipleValueField(id) {
console.log(id);
var id_match = id.match(/^itemvalues_(\d+)_(\d+)$/);
var elem_id = id_match[1];
var last_elem_count = 0;
var stop = false;
// find last input
$("input[id^=itemvalues_" + elem_id + "_").each(function() {
console.log("input id: " + this.id)
console.log("value: " + $(this).val());
if(!$(this).val()) {
stop = true;
return false;
}
var this_count_match = this.id.match(/^itemvalues_\d+_(\d+)$/);
var this_count = this_count_match[1]
if(this_count.length) {
console.log("last_elem_count: " + last_elem_count);
console.log("this count: " + this_count)
last_elem_count = Math.max(this_count, last_elem_count);
}
});
if(stop) {
return;
}
if(!elem_id.length && !last_elem_count.length) {
return;
}
var new_tr = $("#tr-" + id).clone();
console.log(new_tr);
var new_count = parseInt(last_elem_count) + 1;
new_tr.prop("id", "tr-itemvalues_" + elem_id + "_" + new_count);
new_tr.find("td input[type=text]").prop("id", "itemvalues_" + elem_id + "_" + new_count);
new_tr.find("td input[type=text]").val("");
new_tr.find("td input[type=text]").change(function() {
addMultipleValueField($(this).prop("id"));
});
new_tr.find("span.array_counter").text(" (" + (parseInt(new_count) + 1) + ")");
$(new_tr).insertAfter($("#tr-" + id));
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -34,7 +34,7 @@
<div class="input-group mb-3">
<input type="text" class="form-control" name="name" placeholder="Gruppenname..." />
<div class="input-group-append">
<button type="submit" class="btn btn-primary"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
<button type="submit" class="btn btn-purple"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
</div>
</div>
</form>
@@ -63,7 +63,7 @@
<div class="row">
<div class="col-md-1">
<div class="form-group">
<label for="item_new_<?=$item->id?>_order">Sortierung</label>
<label for="item_new_<?=$item->id?>_order">Sort</label>
<input type="text" class="form-control" id="item_new_<?=$item->id?>_order" name="order" value="" />
</div>
</div>
@@ -113,11 +113,18 @@
<input type="text" class="form-control" id="item_new_<?=$group->id?>_description" name="description" value="" />
</div>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<label for="item_new_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
<input type="checkbox" class="form-control" id="item_new_<?=$item->id?>_multiple" name="multiple" value="1" />
</div>
</div>
</div>
<div class="form-group row">
<div class="col">
<input type="submit" class="btn btn-primary" value="Speichern" />
<input type="submit" class="btn btn-purple" value="Speichern" />
</div>
</div>
@@ -131,7 +138,7 @@
<?php $i = 0; foreach($group->items as $item): ?>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action bg-soft-warning" onclick="$('#item-edit-<?=$item->id?>').toggle(); return false;"><i class="fas fa-caret-right pr-1"></i> <?=($item->order) ? $item->order : ""?> <span class="text-monospace bg-purple text-white ml-1 p-1"><?=$item->name?></span> - <?=$item->displayname?> [<?=$item->type?>]</a>
<a href="#" class="list-group-item list-group-item-action bg-soft-warning" onclick="$('#item-edit-<?=$item->id?>').toggle(); return false;"><i class="fas fa-caret-right pr-1"></i> <span class="text-monospace"><?=($item->order) ? str_pad($item->order, 2, "0", STR_PAD_LEFT) : ""?></span> <span class="text-monospace bg-purple text-white ml-1 p-1"><?=$item->name?></span> - <?=$item->displayname?> [<?=$item->type?>]</a>
<div class="card hidden" id="item-edit-<?=$item->id?>">
<div class="card-body">
@@ -146,7 +153,7 @@
<div class="row">
<div class="col-md-1">
<div class="form-group">
<label for="item_<?=$item->id?>_order">Sortierung</label>
<label for="item_<?=$item->id?>_order">Sort</label>
<input type="text" class="form-control" id="item_<?=$item->id?>_order" name="order" value="<?=$item->order?>" />
</div>
</div>
@@ -197,14 +204,22 @@
<input type="text" class="form-control" id="item_<?=$item->id?>_description" name="description" value="<?=$item->description?>" />
</div>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<label for="item_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
<input type="checkbox" class="form-control" id="item_<?=$item->id?>_multiple" name="multiple" value="1" <?=($item->multiple) ? "checked='checked'" : ""?> />
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-11 float-left">
<input type="submit" class="btn btn-primary" value="Speichern" />
<div class="col-md-10 float-left">
<input type="submit" class="btn btn-purple" value="Speichern" />
</div>
<div class="col-md-1 float-right">
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "deleteItem", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
<div class="col-md-2 float-right text-right">
<small><a class="text-danger" href="<?=self::getUrl("ContractconfigItem", "delete", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
</div>
</div>

View File

@@ -1,381 +1,476 @@
<?php
if(!is_array($filter)) $filter = [];
if (!is_array($filter)) $filter = [];
$pagination_baseurl = $this->getUrl($Mod, "Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Zu provisionierende CPEs";
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<?php echo $cpecounter; ?>
<!-- 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">CPE Provisioning</li>
</ol>
</div>
<h4 class="page-title">CPE Provisioning</h4>
<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">CPE Provisioning</li>
</ol>
</div>
<h4 class="page-title">CPE Provisioning</h4>
</div>
</div>
</div>
<!-- end page title -->
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?=self::getUrl("Cpeprovisioning")?>">
<div class="row">
<div class="col-1">
<label class="form-label" for="filter_network_id">Netzgebiet</label>
<select name="filter[network_id]" id="filter_network_id" class="form-control">
<option></option>
<?php foreach(NetworkModel::getAll() as $fnet): ?>
<option value="<?=$fnet->id?>" <?=($filter['network_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_routerconfig_finished">Provisioningstatus</label>
<select name="filter[routerconfig_finished]" id="filter_routerconfig_finished" class="form-control">
<option value="0" <?=($filter['routerconfig_finished'] == 0) ? "selected='selected'" : ""?>>Offen</option>
<option value="1" <?=($filter['routerconfig_finished'] == 1) ? "selected='selected'" : ""?>>Abgeschlossen</option>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_hide_delayed_finish">Verzögerte Herstellung</label>
<select name="filter[hide_delayed_finish]" id="filter_hide_delayed_finish" class="form-control">
<option value="0" <?=(array_key_exists("hide_delayed_finish", $filter) &&$filter['hide_delayed_finish'] != 1) ? "selected='selected'" : ""?>>Anzeigen</option>
<option value="1" <?=(!array_key_exists("hide_delayed_finish", $filter) || $filter['hide_delayed_finish'] == 1) ? "selected='selected'" : ""?>>Nicht anzeigen</option>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_owner">Kunde</label>
<input type="text" class="form-control" name="filter[owner]" id="filter_owner" value="<?=$filter['owner']?>" />
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("Cpeprovisioning")?>">Filter zurücksetzen</a>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">CPE Provisioning</h4>
</div>
<div class="pagination justify-content-center">
<?php if(count($products)): ?>
Zu provisionierende CPEs 1 bis <?=count($products)?>
<?php else: ?>
Keine zu provisionierende CPEs gefunden
<?php endif; ?>
</div>
<table class="table">
<?php $prov_count = 0; ?>
<?php foreach($products as $product): ?>
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> bottom-no-border">
<th>Netzgebiet</th>
<th>Service PIN</th>
<th>Kunde</th>
<th>Produkt</th>
<th>Access Type</th>
<th>VLANs</th>
<th></th>
</tr>
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> top-no-border bottom-no-border">
<td class="pb-0">
<?=($product->termination_id) ? $product->termination->building->network->name : $product->order->owner->zip." ".$product->order->owner->city?>
</td>
<td class="text-pink pb-0"><?=$product->order->owner->spin?></td>
<td class="pb-0"><?=$product->order->owner->getCompanyOrName()?></td>
<td class="pb-0"><?=$product->product->name?><?=($product->termination_id) ? " <small class='text-pink'>".$product->termination->code."</small>" : ""?></td>
<td class="pb-0"><?=$product->product->attributes['bras_type']->value?> - Down: <?=$product->product->attributes["bw_down"]->value?> / Up: <?=$product->product->attributes["bw_up"]->value?></td>
<td class="text-monospace pb-0">
<?php if($product->termination_id): ?>
<?php if($product->termination->getPop()->vlan_public): ?>
<label class="order-date-pill active pointer mb-0">
Public: <strong><?=$product->termination->getPop()->vlan_public?></strong>
<input type="checkbox" name="vlan_public" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->getPop()->vlan_public?>" <?=($product->cpeprovisioning->vlan_public) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php if($product->termination->getPop()->vlan_nat): ?>
<label class="order-date-pill active pointer mb-0">
NAT: <strong><?=$product->termination->getPop()->vlan_nat?></strong>
<input type="checkbox" name="vlan_nat" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->getPop()->vlan_nat?>" <?=($product->cpeprovisioning->vlan_nat) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php if($product->termination->getPop()->vlan_ipv6): ?>
<label class="order-date-pill active pointer mb-0">
IPv6: <strong><?=$product->termination->getPop()->vlan_ipv6?></strong>
<input type="checkbox" name="vlan_ipv6" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->getPop()->vlan_ipv6?>" <?=($product->cpeprovisioning->vlan_ipv6) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php else: ?>
<?php if($product->product->attributes['vlan_default_public']->value): ?>
<label class="order-date-pill active pointer mb-0">
Public: <strong><?=$product->product->attributes['vlan_default_public']->value?></strong>
<input type="checkbox" name="vlan_public" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_public']->value?>" <?=($product->cpeprovisioning->vlan_public) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php if($product->product->attributes['vlan_default_nat']->value): ?>
<label class="order-date-pill active pointer mb-0">
NAT: <strong><?=$product->product->attributes['vlan_default_nat']->value?></strong>
<input type="checkbox" name="vlan_nat" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_nat']->value?>" <?=($product->cpeprovisioning->vlan_nat) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php if($product->product->attributes['vlan_default_ipv6']->value): ?>
<label class="order-date-pill active pointer mb-0">
IPv6: <strong><?=$product->product->attributes['vlan_default_ipv6']->value?></strong>
<input type="checkbox" name="vlan_ipv6" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_ipv6']->value?>" <?=($product->cpeprovisioning->vlan_public) ? "checked='checked'" : ""?> />
</label>
<?php endif; ?>
<?php endif; ?>
</td>
<td class="pb-0" style="min-width: 180px; font-size: 1.1em;">
<?php
$vot = false;
$vo_termin = false;
$hw = false;
$voip = false;
foreach($product->order->products as $prod) {
if(is_array($prod->product->attributes) && count($prod->product->attributes)) {
if(array_key_exists("hw_only", $prod->product->attributes)) {
if($prod->product->attributes["hw_only"]->value) {
$hw[] = (int)$prod->amount."x ".$prod->product->name;
}
}
if(array_key_exists("voip_chan", $prod->product->attributes)) {
if($prod->product->attributes["voip_chan"]->value) {
$voip = true;
}
}
if(array_key_exists("vot", $prod->product->attributes)) {
if($prod->product->attributes["vot"]->value) {
$vot = true;
}
}
if($product->order->install_date) {
$vo_termin = $product->order->install_date;
}
if($hw && $voip_chan) {
break;
}
}
}
?>
<?=($vot || $vo_termin) ? "<i class='fas fa-tools text-purple mr-2' data-toggletooltip='tooltip' title='Vorortinstallation'></i>" : ""?>
<?=($hw) ? "<a href='#' class='fas fa-shopping-bag text-purple mr-2' onclick='return false;' title='Hardware' data-toggle='popover' data-placement='top' data-content='".implode("<br />",$hw)."' ></a>" : ""?>
<?=($voip) ? "<i class='fas fa-phone text-purple mr-2' data-toggletooltip='tooltip' title='Voice Produkt vorhanden'></i>" : ""?>
<?=($product->order->note) ? "<a href='#' class='fas fa-clipboard-list text-purple' onclick='return false;' data-toggle='popover' data-placement='top' data-content='".str_replace('"', '&#34;', str_replace("\n",'<br />',$product->order->note))."'></a>" : ""?>
</td>
</tr>
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> bottom-no-border top-no-border">
<td>
<?php if($product->termination_id && $product->termination->getPop()): ?>
<strong>POP</strong>: <?=$product->termination->getPop()->name?>
<?php endif; ?>
</td>
<td><strong>Telefon:</strong> <?=$product->order->owner->phone?></td>
<td><strong>Email:</strong> <?=$product->order->owner->email?></td>
<td><a target="_blank" href="<?=self::getUrl("Order", "Index", ["id" => $product->order_id, "addJournal" => 1])?>"><i class="fas fa-scroll"></i> Bestelljournal</a></td>
<td colspan="3"></td>
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> bottom-no-border">
<td colspan="6">
<form method="post" id="cpeprovform-<?=$product->id?>" action="<?=self::getUrl("Cpeprovisioning", "Save", ["filter" => $filter])?>">
<input type="hidden" name="id" value="<?=$product->cpeprovisioning->id?>" />
<input type="hidden" name="order_id" value="<?=$product->order_id?>" />
<input type="hidden" name="orderproduct_id" value="<?=$product->id?>" />
<input type="hidden" name="termination_id" value="<?=$product->termination_id?>" />
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?= self::getUrl("Cpeprovisioning") ?>">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label for="routertype-<?=$product->id?>">Router</label>
<select class="form-control" name="routertype" id="routertype-<?=$product->id?>">
<option></option>
<option value="eigener Router" <?=($product->cpeprovisioning->routertype == "eigener Router") ? "selected='selected'" : ""?>>Eigener Router</option>
<option value="anderes CPE" <?=($product->cpeprovisioning->routertype == "anderes CPE") ? "selected='selected'" : ""?>>Anderes CPE</option>
<?php if(preg_match('/^(pppoe|dhcp)$/', $product->product->attributes['bras_type']->value)): ?>
<option value="TP-Link Archer C80" <?=($product->cpeprovisioning->routertype == "TP-Link Archer C80") ? "selected='selected'" : ""?>>TP-Link Archer C80 (Inet, IPTV)</option>
<option value="FritzBox 4040" <?=($product->cpeprovisioning->routertype == "FritzBox 4040") ? "selected='selected'" : ""?>>FritzBox 4040 (Inet, IPTV)</option>
<option value="FritzBox 7530" <?=($product->cpeprovisioning->routertype == "FritzBox 7530") ? "selected='selected'" : ""?>>FritzBox 7530 (Inet, Phone, IPTV)</option>
<option value="FritzBox 7590" <?=($product->cpeprovisioning->routertype == "FritzBox 7590") ? "selected='selected'" : ""?>>FritzBox 7590 (Inet, Phone, IPTV)</option>
<?php elseif($product->product->attributes['bras_type']->value = "static"): ?>
<option value="Mikrotik HAP AC" <?=($product->cpeprovisioning->routertype == "Mikrotik HAP AC") ? "selected='selected'" : ""?>>Mikrotik HAP AC (Inet, IPTV)</option>
<option value="Mikrotik HEX S" <?=($product->cpeprovisioning->routertype == "Mikrotik HEX S") ? "selected='selected'" : ""?>>Mikrotik HEX S (Inet, IPTV)</option>
<option value="Mikrotik RB3011" <?=($product->cpeprovisioning->routertype == "Mikrotik RB3011") ? "selected='selected'" : ""?>>Mikrotik RB3011 (Inet, IPTV)</option>
<?php elseif($product->product->attributes['bras_type']->value == "cmts"): ?>
<option value="FritzBox 6490 Cable" <?=($product->cpeprovisioning->routertype == "FritzBox 6490 Cable") ? "selected='selected'" : ""?>>FritzBox 6490 Cable (Inet, Phone, IPTV)</option>
<?php endif; ?>
</select>
<div class="col-1">
<label class="form-label" for="filter_network_id">Netzgebiet</label>
<select name="filter[network_id]" id="filter_network_id" class="form-control">
<option></option>
<?php foreach (NetworkModel::getAll() as $fnet): ?>
<option value="<?= $fnet->id ?>" <?= ($filter['network_id'] == $fnet->id) ? "selected='selected'" : "" ?>><?= $fnet->name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="wifi_ssid-<?=$product->id?>">WLAN SSID</label>
<input class="form-control" type="text" name="wifi_ssid" id="router_wifi_ssid-<?=$product->id?>" value="<?=$product->cpeprovisioning->wifi_ssid?>" />
<div class="col-2">
<label class="form-label" for="filter_routerconfig_finished">Provisioningstatus</label>
<select name="filter[routerconfig_finished]" id="filter_routerconfig_finished"
class="form-control">
<option value="0" <?= ($filter['routerconfig_finished'] == 0) ? "selected='selected'" : "" ?>>
Offen
</option>
<option value="1" <?= ($filter['routerconfig_finished'] == 1) ? "selected='selected'" : "" ?>>
Abgeschlossen
</option>
</select>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="wifi_pass-<?=$product->id?>">WPA Key</label>
<input class="form-control" type="text" name="wifi_pass" id="router_wifi_pass-<?=$product->id?>" value="<?=$product->cpeprovisioning->wifi_pass?>" />
<div class="col-2">
<label class="form-label" for="filter_hide_delayed_finish">Verzögerte Herstellung</label>
<select name="filter[hide_delayed_finish]" id="filter_hide_delayed_finish"
class="form-control">
<option value="0" <?= (array_key_exists("hide_delayed_finish", $filter) && $filter['hide_delayed_finish'] != 1) ? "selected='selected'" : "" ?>>
Anzeigen
</option>
<option value="1" <?= (!array_key_exists("hide_delayed_finish", $filter) || $filter['hide_delayed_finish'] == 1) ? "selected='selected'" : "" ?>>
Nicht anzeigen
</option>
</select>
</div>
</div>
<?php if($vot || $vo_termin): ?>
<div class="col-md-5"></div>
<?php else: ?>
<div class="col-md-1">
<div class="form-group text-center">
<label class="form-label" for="shipping-<?=$product->id?>">Versandauftrag</label>
<input class="form-control" type="checkbox" value="1" name="shipping" id="shipping-<?=$product->id?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> <?=($product->cpeprovisioning->shipping) ? "checked='checked'" : ""?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_weight-<?=$product->id?>">Gewicht</label>
<input class="form-control" type="text" name="ship_weight" id="ship_weight-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_weight?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
<div class="col-2">
<label class="form-label" for="filter_owner">Kunde</label>
<input type="text" class="form-control" name="filter[owner]" id="filter_owner"
value="<?= $filter['owner'] ?>"/>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_length-<?=$product->id?>">Länge</label>
<input class="form-control" type="text" name="ship_length" id="ship_length-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_length?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_width-<?=$product->id?>">Breite</label>
<input class="form-control" type="text" name="ship_width" id="ship_width-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_width?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_height-<?=$product->id?>">Höhe</label>
<input class="form-control" type="text" name="ship_height" id="ship_height-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_height?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
</div>
</div>
<?php endif; ?>
<div class="col-md-1">
<div class="form-group text-center">
<label class="form-label text-success" for="routerconfig_finished-<?=$product->id?>">Routerkonfig <i class="fas fa-check"></i></label>
<input class="form-control" type="checkbox" value="1" name="routerconfig_finished" id="routerconfig_finished-<?=$product->id?>" <?=($product->cpeprovisioning->routerconfig_finished) ? "checked='checked'" : ""?> />
</div>
</div>
</div>
</form>
</td>
<td></td>
</tr>
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> top-no-border">
<td colspan="6">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label class="form-label" for="mac-<?=$product->id?>">Router MAC Adresse</label>
<input class="form-control" form="cpeprovform-<?=$product->id?>" type="text" name="mac" id="mac-<?=$product->id?>" value="<?=$product->cpeprovisioning->mac?>" />
</div>
</div>
<div class="col-md-2">
<?php if($product->termination_id): ?>
<div class="form-group">
<label class="form-label" for="mac-<?=$product->id?>">ONT montiert / ONT SN</label>
<div class="input-group">
<div class="input-group-prepend">
<?php if($product->termination->getWorkflowValue("ont_deployed", "int")): ?>
<button type="button" class="btn btn-outline-success" disabled="disabled"><i class="fas fa-check"></i></button>
<?php else: ?>
<button type="button" class="btn btn-outline-secondary" disabled="disabled"><i class="fas fa-times"></i></button>
<?php endif; ?>
</div>
<input class="form-control" form="cpeprovform-<?=$product->id?>" type="text" name="ont_sn" id="ont_sn-<?=$product->id?>" value="<?=($product->termination_id) ? $product->termination->getWorkflowValue("ont_sn", "string") : ""?>" />
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?= self::getUrl("Cpeprovisioning") ?>">Filter
zurücksetzen</a>
</div>
<?php endif; ?>
</div>
</form>
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="note-<?=$product->id?>">Kommentar</label>
<textarea class="form-control" form="cpeprovform-<?=$product->id?>" name="note" id="note-<?=$product->id?>"><?=htmlentities($product->cpeprovisioning->note)?></textarea>
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-2">
<div class="form-group">
<label class="form-label">&nbsp;</label>
<button class="form-control btn btn-primary" form="cpeprovform-<?=$product->id?>" type="submit"><i class="fas fa-save"></i> Speichern</button>
</div>
</div>
</div>
</td>
<td></td>
</tr>
<?php $prov_count++ ?>
<?php endforeach; ?>
</table>
<div class="pagination justify-content-center">
<?php if(count($products)): ?>
Zu provisionierende CPEs 1 bis <?=count($products)?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
<div class="card">
<div class="card-body mb-3">
<div class="overflow-auto">
<div class="float-left">
<h4 class="header-title">CPE Provisioning</h4>
</div>
</div>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<div class="pagination justify-content-center">
</div>
<table class="table">
<?php $prov_count = 0; ?>
<?php foreach ($products as $product): ?>
<tr class="<?= ($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd" ?> bottom-no-border">
<th>Netzgebiet</th>
<th>Service PIN</th>
<th>Kunde</th>
<th>Produkt</th>
<th>Access Type</th>
<th>VLANs</th>
<th></th>
</tr>
<tr class="<?= ($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd" ?> top-no-border bottom-no-border">
<td class="pb-0">
<?= ($product->termination_id) ? $product->termination->building->network->name : $product->order->owner->zip . " " . $product->order->owner->city ?>
</td>
<td class="text-pink pb-0"><?= $product->order->owner->spin ?></td>
<td class="pb-0"><?= $product->order->owner->getCompanyOrName() ?></td>
<td class="pb-0"><?= $product->product->name ?><?= ($product->termination_id) ? " <small class='text-pink'>" . $product->termination->code . "</small>" : "" ?></td>
<td class="pb-0"><?= $product->product->attributes['bras_type']->value ?> -
Down: <?= $product->product->attributes["bw_down"]->value ?> /
Up: <?= $product->product->attributes["bw_up"]->value ?></td>
<td class="text-monospace pb-0">
<?php if ($product->termination_id): ?>
<?php if ($product->termination->getPop()->vlan_public): ?>
<label class="order-date-pill active pointer mb-0">
Public: <strong><?= $product->termination->getPop()->vlan_public ?></strong>
<input type="checkbox" name="vlan_public"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->termination->getPop()->vlan_public ?>" <?= ($product->cpeprovisioning->vlan_public) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php if ($product->termination->getPop()->vlan_nat): ?>
<label class="order-date-pill active pointer mb-0">
NAT: <strong><?= $product->termination->getPop()->vlan_nat ?></strong>
<input type="checkbox" name="vlan_nat"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->termination->getPop()->vlan_nat ?>" <?= ($product->cpeprovisioning->vlan_nat) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php if ($product->termination->getPop()->vlan_ipv6): ?>
<label class="order-date-pill active pointer mb-0">
IPv6: <strong><?= $product->termination->getPop()->vlan_ipv6 ?></strong>
<input type="checkbox" name="vlan_ipv6"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->termination->getPop()->vlan_ipv6 ?>" <?= ($product->cpeprovisioning->vlan_ipv6) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php else: ?>
<?php if ($product->product->attributes['vlan_default_public']->value): ?>
<label class="order-date-pill active pointer mb-0">
Public:
<strong><?= $product->product->attributes['vlan_default_public']->value ?></strong>
<input type="checkbox" name="vlan_public"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->product->attributes['vlan_default_public']->value ?>" <?= ($product->cpeprovisioning->vlan_public) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php if ($product->product->attributes['vlan_default_nat']->value): ?>
<label class="order-date-pill active pointer mb-0">
NAT:
<strong><?= $product->product->attributes['vlan_default_nat']->value ?></strong>
<input type="checkbox" name="vlan_nat"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->product->attributes['vlan_default_nat']->value ?>" <?= ($product->cpeprovisioning->vlan_nat) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php if ($product->product->attributes['vlan_default_ipv6']->value): ?>
<label class="order-date-pill active pointer mb-0">
IPv6:
<strong><?= $product->product->attributes['vlan_default_ipv6']->value ?></strong>
<input type="checkbox" name="vlan_ipv6"
form="cpeprovform-<?= $product->id ?>"
value="<?= $product->product->attributes['vlan_default_ipv6']->value ?>" <?= ($product->cpeprovisioning->vlan_public) ? "checked='checked'" : "" ?> />
</label>
<?php endif; ?>
<?php endif; ?>
</td>
<td class="pb-0" style="min-width: 180px; font-size: 1.1em;">
<?php
$vot = false;
$vo_termin = false;
$hw = false;
$voip = false;
foreach ($product->order->products as $prod) {
if (is_array($prod->product->attributes) && count($prod->product->attributes)) {
if (array_key_exists("hw_only", $prod->product->attributes)) {
if ($prod->product->attributes["hw_only"]->value) {
$hw[] = (int)$prod->amount . "x " . $prod->product->name;
}
}
if (array_key_exists("voip_chan", $prod->product->attributes)) {
if ($prod->product->attributes["voip_chan"]->value) {
$voip = true;
}
}
if (array_key_exists("vot", $prod->product->attributes)) {
if ($prod->product->attributes["vot"]->value) {
$vot = true;
}
}
if ($product->order->install_date) {
$vo_termin = $product->order->install_date;
}
if ($hw && $voip_chan) {
break;
}
}
}
?>
<?= ($vot || $vo_termin) ? "<i class='fas fa-tools text-purple mr-2' data-toggletooltip='tooltip' title='Vorortinstallation'></i>" : "" ?>
<?= ($hw) ? "<a href='#' class='fas fa-shopping-bag text-purple mr-2' onclick='return false;' title='Hardware' data-toggle='popover' data-placement='top' data-content='" . implode("<br />", $hw) . "' ></a>" : "" ?>
<?= ($voip) ? "<i class='fas fa-phone text-purple mr-2' data-toggletooltip='tooltip' title='Voice Produkt vorhanden'></i>" : "" ?>
<?= ($product->order->note) ? "<a href='#' class='fas fa-clipboard-list text-purple' onclick='return false;' data-toggle='popover' data-placement='top' data-content='" . str_replace('"', '&#34;', str_replace("\n", '<br />', $product->order->note)) . "'></a>" : "" ?>
</td>
</tr>
<tr class="<?= ($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd" ?> bottom-no-border top-no-border">
<td>
<?php if ($product->termination_id && $product->termination->getPop()): ?>
<strong>POP</strong>: <?= $product->termination->getPop()->name ?>
<?php endif; ?>
</td>
<td><strong>Telefon:</strong> <?= $product->order->owner->phone ?></td>
<td><strong>Email:</strong> <?= $product->order->owner->email ?></td>
<td><a target="_blank"
href="<?= self::getUrl("Order", "Index", ["id" => $product->order_id, "addJournal" => 1]) ?>"><i
class="fas fa-scroll"></i> Bestelljournal</a></td>
<td colspan="3"></td>
<tr class="<?= ($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd" ?> bottom-no-border">
<td colspan="6">
<form method="post" id="cpeprovform-<?= $product->id ?>"
action="<?= self::getUrl("Cpeprovisioning", "Save", ["filter" => $filter]) ?>">
<input type="hidden" name="id" value="<?= $product->cpeprovisioning->id ?>"/>
<input type="hidden" name="order_id" value="<?= $product->order_id ?>"/>
<input type="hidden" name="orderproduct_id" value="<?= $product->id ?>"/>
<input type="hidden" name="termination_id" value="<?= $product->termination_id ?>"/>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label for="routertype-<?= $product->id ?>">Router</label>
<select class="form-control" name="routertype"
id="routertype-<?= $product->id ?>">
<option></option>
<option value="eigener Router" <?= ($product->cpeprovisioning->routertype == "eigener Router") ? "selected='selected'" : "" ?>>
Eigener Router
</option>
<option value="anderes CPE" <?= ($product->cpeprovisioning->routertype == "anderes CPE") ? "selected='selected'" : "" ?>>
Anderes CPE
</option>
<?php if (preg_match('/^(pppoe|dhcp)$/', $product->product->attributes['bras_type']->value)): ?>
<option value="TP-Link Archer C80" <?= ($product->cpeprovisioning->routertype == "TP-Link Archer C80") ? "selected='selected'" : "" ?>>
TP-Link Archer C80 (Inet, IPTV)
</option>
<option value="FritzBox 4040" <?= ($product->cpeprovisioning->routertype == "FritzBox 4040") ? "selected='selected'" : "" ?>>
FritzBox 4040 (Inet, IPTV)
</option>
<option value="FritzBox 7530" <?= ($product->cpeprovisioning->routertype == "FritzBox 7530") ? "selected='selected'" : "" ?>>
FritzBox 7530 (Inet, Phone, IPTV)
</option>
<option value="FritzBox 7590" <?= ($product->cpeprovisioning->routertype == "FritzBox 7590") ? "selected='selected'" : "" ?>>
FritzBox 7590 (Inet, Phone, IPTV)
</option>
<?php elseif ($product->product->attributes['bras_type']->value = "static"): ?>
<option value="Mikrotik HAP AC" <?= ($product->cpeprovisioning->routertype == "Mikrotik HAP AC") ? "selected='selected'" : "" ?>>
Mikrotik HAP AC (Inet, IPTV)
</option>
<option value="Mikrotik HEX S" <?= ($product->cpeprovisioning->routertype == "Mikrotik HEX S") ? "selected='selected'" : "" ?>>
Mikrotik HEX S (Inet, IPTV)
</option>
<option value="Mikrotik RB3011" <?= ($product->cpeprovisioning->routertype == "Mikrotik RB3011") ? "selected='selected'" : "" ?>>
Mikrotik RB3011 (Inet, IPTV)
</option>
<?php elseif ($product->product->attributes['bras_type']->value == "cmts"): ?>
<option value="FritzBox 6490 Cable" <?= ($product->cpeprovisioning->routertype == "FritzBox 6490 Cable") ? "selected='selected'" : "" ?>>
FritzBox 6490 Cable (Inet, Phone, IPTV)
</option>
<?php endif; ?>
</select>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="wifi_ssid-<?= $product->id ?>">WLAN
SSID</label>
<input class="form-control" type="text" name="wifi_ssid"
id="router_wifi_ssid-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->wifi_ssid ?>"/>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="wifi_pass-<?= $product->id ?>">WPA
Key</label>
<input class="form-control" type="text" name="wifi_pass"
id="router_wifi_pass-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->wifi_pass ?>"/>
</div>
</div>
<?php if ($vot || $vo_termin): ?>
<div class="col-md-5"></div>
<?php else: ?>
<div class="col-md-1">
<div class="form-group text-center">
<label class="form-label" for="shipping-<?= $product->id ?>">Versandauftrag</label>
<input class="form-control" type="checkbox" value="1"
name="shipping"
id="shipping-<?= $product->id ?>" <?= ($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : "" ?> <?= ($product->cpeprovisioning->shipping) ? "checked='checked'" : "" ?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_weight-<?= $product->id ?>">Gewicht</label>
<input class="form-control" type="text" name="ship_weight"
id="ship_weight-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->ship_weight ?>" <?= ($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : "" ?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_length-<?= $product->id ?>">Länge</label>
<input class="form-control" type="text" name="ship_length"
id="ship_length-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->ship_length ?>" <?= ($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : "" ?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label" for="ship_width-<?= $product->id ?>">Breite</label>
<input class="form-control" type="text" name="ship_width"
id="ship_width-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->ship_width ?>" <?= ($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : "" ?> />
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="form-label"
for="ship_height-<?= $product->id ?>">Höhe</label>
<input class="form-control" type="text" name="ship_height"
id="ship_height-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->ship_height ?>" <?= ($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : "" ?> />
</div>
</div>
<?php endif; ?>
<div class="col-md-1">
<div class="form-group text-center">
<label class="form-label text-success"
for="routerconfig_finished-<?= $product->id ?>">Routerkonfig <i
class="fas fa-check"></i></label>
<input class="form-control" type="checkbox" value="1"
name="routerconfig_finished"
id="routerconfig_finished-<?= $product->id ?>" <?= ($product->cpeprovisioning->routerconfig_finished) ? "checked='checked'" : "" ?> />
</div>
</div>
</div>
</form>
</td>
<td></td>
</tr>
<tr class="<?= ($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd" ?> top-no-border">
<td colspan="6">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label class="form-label" for="mac-<?= $product->id ?>">Router MAC
Adresse</label>
<input class="form-control" form="cpeprovform-<?= $product->id ?>"
type="text" name="mac" id="mac-<?= $product->id ?>"
value="<?= $product->cpeprovisioning->mac ?>"/>
</div>
</div>
<div class="col-md-2">
<?php if ($product->termination_id): ?>
<div class="form-group">
<label class="form-label" for="mac-<?= $product->id ?>">ONT montiert /
ONT SN</label>
<div class="input-group">
<div class="input-group-prepend">
<?php if ($product->termination->getWorkflowValue("ont_deployed", "int")): ?>
<button type="button" class="btn btn-outline-success"
disabled="disabled"><i class="fas fa-check"></i>
</button>
<?php else: ?>
<button type="button" class="btn btn-outline-secondary"
disabled="disabled"><i class="fas fa-times"></i>
</button>
<?php endif; ?>
</div>
<input class="form-control" form="cpeprovform-<?= $product->id ?>"
type="text" name="ont_sn" id="ont_sn-<?= $product->id ?>"
value="<?= ($product->termination_id) ? $product->termination->getWorkflowValue("ont_sn", "string") : "" ?>"/>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="note-<?= $product->id ?>">Kommentar</label>
<textarea class="form-control" form="cpeprovform-<?= $product->id ?>"
name="note"
id="note-<?= $product->id ?>"><?= htmlentities($product->cpeprovisioning->note) ?></textarea>
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-2">
<div class="form-group">
<label class="form-label">&nbsp;</label>
<button class="form-control btn btn-primary"
form="cpeprovform-<?= $product->id ?>" type="submit"><i
class="fas fa-save"></i> Speichern
</button>
</div>
</div>
</div>
</td>
<td></td>
</tr>
<?php $prov_count++ ?>
<?php endforeach; ?>
</table>
<div class="pagination justify-content-center">
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
</div>
<div class="pagination justify-content-center">
<?php if (count($products)): ?>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$(function () {
$('[data-toggle="popover"]').popover({html: true})
$('[data-toggle="popover"]').popover({html: true})
})
});
$(function () {
});
$(function () {
$('[data-toggletooltip="tooltip"]').tooltip({html: true})
})
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
})
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -2,7 +2,8 @@
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.card-border {
@@ -25,7 +26,8 @@
<li class="breadcrumb-item active">Device Detail</li>
</ol>
</div>
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span> <span class="ml-2">
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span>
<span class="ml-2">
<a href="<?= self::getUrl("Device", "edit", ["id" => $devices->id, 'returnto' => "device-detail"]) ?>">
<button class="btn btn-primary">Bearbeiten</button>
</a>
@@ -36,11 +38,17 @@
<!-- end page title -->
<?php
if (!empty($devices->price)) {
if ($devices->price != "0.00") {
$price = $devices->price;
} else {
$price = $devices->devicetype->price;
}
if ($devices->power != "0.0") {
$power = $devices->power;
} else {
$power = $devices->devicetype->power;
}
?>
<div class="row">
<div class="col-12">
@@ -56,7 +64,7 @@ if (!empty($devices->price)) {
<table class="table table-sm">
<tbody>
<tr>
<th>Device Name</th>
<th class="w-30">Device Name</th>
<td><?= $devices->name ?> </td>
</tr>
<tr>
@@ -83,6 +91,10 @@ if (!empty($devices->price)) {
<th>Preis</th>
<td><?= $price ?> €</td>
</tr>
<tr>
<th>Leistung</th>
<td><?= $power ?> Watt</td>
</tr>
<tr>
<th>Bemerkung</th>
<td><?= nl2br($devices->comment) ?> </td>
@@ -93,29 +105,54 @@ if (!empty($devices->price)) {
</div>
<?php
if ((trim($devices->pop->name))) {
$StdHeader = "Pop Informationen";
$vlans = "";
if (!empty(trim($devices->pop->vlan_public)))
$vlans .= '<span class="order-date-pill active mb-0">Public: <span class="font-weight-500">' . $devices->pop->vlan_public . '</span class="font-weight-500"></span>';
if (!empty(trim($devices->pop->vlan_nat)))
$vlans .= '<span class="order-date-pill active mb-0">Nat: <span class="font-weight-500">' . $devices->pop->vlan_nat . '</span></span>';
if (!empty(trim($devices->pop->vlan_ipv6)))
$vlans .= '<span class="order-date-pill active mb-0">IPv6: <span class="font-weight-500">' . $devices->pop->vlan_ipv6 . '</span></span>';
} else if (trim($devices->addr_street)) {
if (trim($devices->addr_extended)) {
$addrExtended = ' / ' . $devices->addr_extended;
} else {
$addrExtended = "";
}
$StdHeader = "Standort Informationen";
$mapsHeader = "Adresse";
$mapsLink = '<a class="mapsLink"
href="http://maps.google.com/?q=' . $devices->addr_street . ' ' . $devices->addr_number . ' ' . $devices->addr_zip . ' ' . $devices->addr_city . '"
target="_blank"><div>' . $devices->addr_street . ' ' . $devices->addr_number . $addrExtended . '</div>
<div>' . $devices->addr_zip . ' ' . $devices->addr_city . '</div></a>';
} else if (trim($devices->gps_lat)) {
$StdHeader = "Standort Informationen";
$mapsHeader = "Koordinaten";
$mapsLink = '<a class="mapsLink"
href="http://maps.google.com/?q=' . $devices->gps_lat . ',' . $devices->gps_long . '"
target="_blank"><div>' . $devices->gps_lat . ' , ' . $devices->gps_long . '</div></a>';
}
?>
<div class="col-4 card-border">
<div>
<h4>Pop Informationen</h4>
<h4><?= $StdHeader ?></h4>
</div>
<?php
if (!empty(trim($devices->pop->name))) {
$vlans = "";
if (!empty(trim($devices->pop->vlan_public)))
$vlans .= '<span class="order-date-pill active mb-0">Public: <span class="font-weight-500">' . $devices->pop->vlan_public . '</span class="font-weight-500"></span>';
if (!empty(trim($devices->pop->vlan_nat)))
$vlans .= '<span class="order-date-pill active mb-0">Nat: <span class="font-weight-500">' . $devices->pop->vlan_nat . '</span></span>';
if (!empty(trim($devices->pop->vlan_ipv6)))
$vlans .= '<span class="order-date-pill active mb-0">IPv6: <span class="font-weight-500">' . $devices->pop->vlan_ipv6 . '</span></span>';
if ((trim($devices->pop->name))) {
?>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Pop Name</th>
<th class="w-30">Pop Name</th>
<td>
<a href="<?= self::getUrl("Pop", "Detail", ["id" => $devices->pop->id]) ?>"><?= $devices->pop->name ?></a>
</td>
@@ -141,6 +178,24 @@ if (!empty($devices->price)) {
</table>
</div>
<?php
} elseif (trim($devices->addr_street) || trim($devices->gps_lat)) {
?>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th class="align-middle w-30"> <?= $mapsHeader ?></th>
<td>
<?= $mapsLink ?>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<?php
} else {
?>
<h5 class="text-center">Keine Standort Informationen vorhanden</h5>
@@ -152,11 +207,21 @@ if (!empty($devices->price)) {
</div>
<div class="col-3 card-border">
<div>
<h4>Config Backups</h4>
<div class="overflow-auto">
<h4 class="float-left">Config Backups</h4>
<?php if ($devices->devicetype->devicemanufactor->config_backup > count()): ?>
<span><i title="Switch config" class="fa-light fa-rectangle-code code-ico"
data-toggle="modal" data-target="#configCode"></i></span>
<?php endif; ?>
<div class="float-right">
<a id="create-backup-href"
href="https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=createconfig&ip=<?= $devices->ip; ?>&id=<?= $devices->id; ?>">
<button class="btn btn-primary "><span id="create-backup-button-text">Backup erstellen</span>
<span id="create-backup-load"></i></span></button>
</a></div>
</div>
<?php
if (!empty($configs)) {
if ($devicesconfig->success == "true" && $devicesconfig->data > count()) {
?>
<div>
<table class="table table-sm">
@@ -164,21 +229,41 @@ if (!empty($devices->price)) {
<tr>
<th>Datum/Uhrzeit</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<?php foreach ($devicesconfig->data as $config) :
$configfileCleartext = trim($config->config_cleartext);
$configfileCompressed = trim($config->config_compressed);
$configid = $config->id;
if ($configfileCleartext && $configfileCompressed) :
$configLinks = '<a href="https://' . $_SERVER['SERVER_NAME'] . '/Device/api?do=getconfig&id='. $configid.'&format=txt&filename=' . $configfileCleartext . '">
TXT</a> / <a
href="https://' . $_SERVER['SERVER_NAME'] . '/Device/api?do=getconfig&id='. $configid.'&format=xml&filename=' . $configfileCompressed . '">
XML</a>';
elseif ($configfileCleartext || $configfileCompressed) :
$configLinks = '<a href="https://' . $_SERVER['SERVER_NAME'] . '/Device/api?do=getconfig&id='. $configid.'&format=txt&filename=' . $configfileCleartext .$configfileCompressed . '">
TXT</a>';
endif;
?>
<tr>
<td><?= date("d.m.Y/H:i", $config->config_timestamp); ?></td>
<td><?= $configLinks; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
} else {
?>
<h5 class="text-center">Keine Configs vorhanden</h5>
<div class="mt-1">
<h5 class="text-center">Keine Configs vorhanden</h5>
</div>
<?php
}
?>
@@ -191,12 +276,49 @@ if (!empty($devices->price)) {
</div>
</div>
</div>
<?php if ($devices->devicetype->devicemanufactor->config_backup > count()):
$year = date("Y", time());
$month = date("n", time());
$day = date("d", time());
$config = $devices->devicetype->devicemanufactor->config_backup;
$config = str_replace("&&YEAR&&", $year, $config);
$config = str_replace("&&MONTH&&", $month, $config);
$config = str_replace("&&DAY&&", $day, $config);
?>
<div class="modal fade" id="configCode" tabindex="-1" role="dialog" aria-labelledby="configCodeLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="configCodeLabel">SwitchConfig Autobackup</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?= nl2br($config) ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/javascript">
$(document).ready(function () {
$('#create-backup-href').click(function () {
$('#create-backup-load').html('<i class="fas fa-spinner fa-spin spinner-ico"></i>');
$('#create-backup-button-text').text('Backup wird erstellt.')
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -1,13 +1,28 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<?php
foreach ($devicetypes as $devicetype) {
$deviceTypes[$devicetype->id]=$devicetype->devicemanufactor->name . " " . $devicetype->name;
$deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name;
}
asort($deviceTypes);
if ($device->price == "0.00") {
$price = "";
} else {
$price = $device->price;
}
if ($device->power == "0.0") {
$power = "";
} else {
$power = $device->power;
}
if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
$cancelUrl = self::getUrl("Device", "Detail", ["id" => $device->id]);
} else {
$cancelUrl = self::getUrl("Device");
}
?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css" rel="stylesheet" type="text/css"/>
<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">
@@ -33,8 +48,7 @@ asort($deviceTypes);
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($device->id) ? "Device bearbeiten" : "Neues Gerät" ?></h4>
<h4 class="header-title mb-2"><?= ($device->id) ? "Device bearbeiten" : "Neues Device" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Device", "save", ["returnto" => $_GET["returnto"]]) ?>">
<div class="card">
@@ -72,6 +86,63 @@ asort($deviceTypes);
</select>
</div>
</div>
<div class="form-group row std-types">
<label class="col-lg-2 col-form-label">Adresse/Koordinaten</label>
<div class="col-lg-2">
<select class="select2 form-control " id="select-std-type">
<option value="0">Adresse</option>
<option
<?php if (trim($device->gps_lat)): ?>selected="selected"<?php endif; ?>
value="1">Koordinaten
</option>
</select>
</div>
</div>
<div class="form-group row addr-fields">
<label class="col-lg-2 col-form-label"
for="addr_street">Straße/Hausnummer/Stock-Tür</label>
<div class="col-lg-3">
<input type="text" class="form-control addr-fields" name="addr_street"
id="addr_street" placeholder="Dr. Auner Straße"
value="<?= $device->addr_street ?>">
</div>
<div class="col-lg-1">
<input type="text" class="form-control addr-fields" name="addr_number"
id="addr_number" placeholder="22"
value="<?= $device->addr_number ?>">
</div>
<div class="col-lg-1">
<input type="text" class="form-control addr-fields" name="addr_extended"
id="addr_extended" placeholder="OG5/1"
value="<?= $device->addr_extended ?>">
</div>
</div>
<div class="form-group row addr-fields">
<label class="col-lg-2 col-form-label" for="addr_zip">PLZ./Ort</label>
<div class="col-lg-1">
<input type="text" class="form-control" name="addr_zip"
id="addr_zip" placeholder="8074"
value="<?= $device->addr_zip ?>">
</div>
<div class="col-lg-4">
<input type="text" class="form-control" name="addr_city"
id="addr_city" placeholder="Raaba"
value="<?= $device->addr_city ?>">
</div>
</div>
<div class="form-group row gps-fields">
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite/GPS Länge</label>
<div class="col-lg-2">
<input type="text" class="form-control " name="gps_lat"
id="gps_lat" placeholder="46.98........"
value="<?= $device->gps_lat ?>">
</div>
<div class="col-lg-2">
<input type="text" class="form-control" name="gps_long"
id="gps_long" placeholder="15.36........"
value="<?= $device->gps_long ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="ip">IP-Adresse *</label>
<div class="col-lg-10">
@@ -93,6 +164,22 @@ asort($deviceTypes);
value="<?= $device->serial ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="serial">Preis</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price" id="price"
placeholder="<?= $device->devicetype->price ?>"
value="<?= $price ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="serial">Leistung</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="power" id="power"
placeholder="<?= $device->devicetype->power ?>"
value="<?= $power ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="comment">Bemerkung</label>
<div class="col-lg-10">
@@ -109,6 +196,10 @@ asort($deviceTypes);
<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>
@@ -136,6 +227,52 @@ asort($deviceTypes);
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
$(document).ready(function () {
if ($("#pop_id").val() != 0) {
$('#select-std-type').val('0');
$('#select-std-type').trigger('change');
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.std-types').hide();
} else if ($("#select-std-type").val() == 0) {
$('.gps-fields').hide();
$('.addr-fields').show();
} else if ($("#select-std-type").val() == 1) {
$('.addr-fields').hide();
$('.gps-fields').show();
}
$("#pop_id").change(function () {
if ($(this).val() != 0) {
$('#select-std-type').val('0');
$('#select-std-type').trigger('change');
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.std-types').hide();
} else {
$('.addr-fields').show();
$('.std-types').show();
}
});
$("#select-std-type").change(function () {
if ($(this).val() == 0) {
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').show();
} else if ($(this).val() == 1) {
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.gps-fields').show();
}
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -4,10 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Device";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css" rel="stylesheet" type="text/css" />
<style>
</style>
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -74,11 +71,16 @@ $pagination_entity_name = "Device";
<?php
foreach ($devices as $device):
if (!empty($device->price)) {
if ($device->price != "0.00") {
$price = $device->price;
} else {
$price = $device->devicetype->price;
}
if ($device->power != "0.0") {
$power = $device->power;
} else {
$power = $device->devicetype->power;
}
?>
<tr>
@@ -94,7 +96,7 @@ $pagination_entity_name = "Device";
<td class="text-center"><?= $device->mac ?></td>
<td class="text-center"><?= $device->serial ?></td>
<td class="text-right"><?= $price ?> €</td>
<td class="text-right"><?= $device->devicetype->power ?> Watt</td>
<td class="text-right"><?= $power ?> Watt</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em; width: 80px">
@@ -125,12 +127,12 @@ $pagination_entity_name = "Device";
<script type="text/javascript">
var hidesearch=[9];
var columndefs={ type: 'ip-address', targets: 4 };
$(document).ready(function () {
});
</script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js?<?=date('U')?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -1,5 +1,4 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -42,6 +41,13 @@
value="<?= $devicemanufactors->name ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="comment">Backup Config</label>
<div class="col-lg-10">
<textarea class="form-control" id="config_backup" name="config_backup"
rows="10"><?= $devicemanufactors->config_backup ?></textarea>
</div>
</div>
</div>

View File

@@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Devicemanufactor";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?=date('U')?>" rel="stylesheet" type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -22,7 +22,6 @@ $pagination_entity_name = "Devicemanufactor";
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
@@ -88,7 +87,7 @@ $pagination_entity_name = "Devicemanufactor";
});
</script>
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js"></script>
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?=date('U')?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -1,5 +1,5 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?=self::getResourcePath()?>assets/css/select2-cstm.css" rel="stylesheet" type="text/css" />
<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">

View File

@@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Devicetype";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -106,7 +106,7 @@ $pagination_entity_name = "Devicetype";
});
</script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js?<?=date('U')?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -8,7 +8,7 @@
<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>
<li class="breadcrumb-item active"><?= ($file->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title">Datei</h4>
@@ -16,6 +16,19 @@
</div>
</div>
<!-- end page title -->
<?php
if (!$me->permissions->isAdmin) {
foreach ($networkaddresses as $networkaddress) {
if ($me->address->id == $networkaddress->address_id) {
$allowedNetworks[$networkaddress->network_id] = "ok";
}
}
}
if (empty($mode) && $filestorehistory) {
$mode = "edit-history";
}
?>
<div class="row">
<div class="col-lg-12">
@@ -23,18 +36,52 @@
<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") ?>">
action="<?= self::getUrl("Filestore", "save", ["mode" => $mode]) ?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?= $file->id ?>"/>
<input type="hidden" name="mode" value="<?= $mode ?>"/>
<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">
<?php if (empty($mode) && !$filestorehistory) : ?>
<input value="<?= $file->name ?>" class="form-control"
name="name"
id="name">
<?php else : ?>
<span><?= $file->name ?></span>
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet *</label>
<div class="col-lg-10">
<?php if (empty($mode) && !$filestorehistory) : ?>
<select class="select2 form-control "
name="network_id" id="network_id">
<option value="">&nbsp;</option>
<?php foreach ($networks as $key => $network):
if (!$me->permissions->isAdmin) {
if (!array_key_exists($network->id, $allowedNetworks)) {
continue;
}
}
?>
<option value="<?= $network->id ?>" <?= ($file->network_id == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
<?php endforeach; ?>
</select>
<?php else :
foreach ($networks as $key => $network):
if (($file->network_id == $network->id)) :
$networkName = $network->name;
endif;
endforeach;
?>
<span class="col-form-label"><?= $networkName ?></span>
<?php endif; ?>
</div>
</div>
<div class="form-group row">
@@ -44,12 +91,15 @@
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">
<?php if (empty($mode) || $mode=="add-version") : ?>
<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>
<?php endif; ?>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">

View File

@@ -1,5 +1,5 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css" rel="stylesheet" type="text/css" />
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
<!-- start page title -->
<div class="row">
@@ -33,17 +33,26 @@
</div>
</div>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
<?php
if (!$me->permissions->isAdmin) {
foreach ($networkaddresses as $networkaddress) {
if ($me->address->id == $networkaddress->address_id) {
$allowedNetworks[$networkaddress->network_id] = "ok";
}
}
}
?>
<table id="datatable" class="table table-striped table-hover">
<thead>
<tr>
<th>Name</th>
<th>Beschreibung</th>
<th>Ersteller</th>
<th>Bearbeiter</th>
<th ></th>
<th>Netzgebiet</th>
<th style="min-width: 270px;">Bearbeiter</th>
<th>Datum/Uhrzeit</th>
<th class="edit-width-large"></th>
</tr>
<tr id="filterrow">
<th></th>
@@ -51,19 +60,48 @@
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($files as $file): ?>
<?php foreach ($files as $file):
if (!$me->permissions->isAdmin) {
if (!array_key_exists($file->networkid, $allowedNetworks)) {
continue;
}
}
?>
<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><?= $file->network ?></td>
<!--<td>--><?php //= $file->creator->name
?><!-- (-->
<?php //= date("d.m.Y , H:i", $file->create)
?><!--)</td>-->
<td><?= $file->editor->name ?></td>
<td><?= 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>
<a href="<?= self::getUrl("File", "download", ["id" => $file->file_id]) ?>"><i
class="far fa-download" title="Download"></i></a>
<a href="<?= self::getUrl("Filestore", "edit", ["id" => $file->id, "mode" => "add-version"]) ?>"><i
class="far fa-file-circle-plus" title="Dateiversion hinzufügen"></i></a>
<?php if (!empty($fileshistory[$file->id])) : ?>
<i data-id="<?= $file->id ?>" title="Versionsverlauf"
class="fa-solid fa-clock-rotate-left history-ico check-history"></i>
<?php endif; ?>
<a href="<?= self::getUrl("Filestore", "edit", ["id" => $file->id]) ?>"><i
class="far fa-edit" title="Bearbeiten"></i></a>
<?php if ($me->permissions->isAdmin) : ?>
<a style="float: right"
href="<?= self::getUrl("Filestore", "delete", ["id" => $file->id]) ?>"
onclick="if(!confirm('Datei wirklich löschen?')) return false;"
class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
<?php endif; ?>
</td>
</tr>
@@ -72,7 +110,6 @@
</table>
</div>
</div>
@@ -81,13 +118,67 @@
<script type="text/javascript">
var hidesearch=[2,3,4];
var hidesearch = [3, 4, 5];
var cstmdom = "flrtip";
$(document).ready(function () {
$(".check-history").click(function () {
let dataobject = $(this);
let fsiid = $(this).data('id');
if ($('.filestore-history-' + fsiid).length) {
$('.filestore-history-' + fsiid).remove();
} else {
$.getJSON("/Filestore/api",
{id: $(this).data('id')},
function (data) {
if (data) {
let expandtr;
expandtr = `<tr class="filestore-history-tr filestore-history-` + fsiid + `">
<td colspan="7" class="filestore-history-td" >
<table class="float-right table table-bordered table-condensed" style="width: 1300px;">
<thead>
<tr style="background-color: #fff">
<th>Beschreibung</th>
<th style="width: 270px;">Bearbeiter</th>
<th style="width: 235px;">Datum/Uhrzeit</th>
<th></th>
</tr>
</thead>
`;
$.each(data, function (i, item) {
let isdelete = '';
var date = new Date(item.edit * 1000);
var day = "0" + date.getDay();
var month = "0" + date.getMonth();
var year = date.getFullYear();
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var formattedTime = day + '.' + month + '.' + year + ', ' + hours + ':' + minutes.substr(-2);
if (item.is_delete == "1") {
isdelete = `<a style="float: right" href="/FilestoreHistory/delete/?id=` + item.id + `&amp;s=0" onclick="if(!confirm('Datei wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>`;
}
expandtr = expandtr + `<tr class="filestore-history">
<td>` + item.description + `</td>
<td>` + item.workername + `</td>
<td>` + formattedTime + `</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;width: 140px;">
<a href="/File/download/?id=` + item.file_id + `&amp;s=0"><i class="far fa-download" title="Download"></i></a>
` + isdelete + `
</td>
</tr>`;
});
expandtr = expandtr + `</table></td></tr>`;
dataobject.closest('tr').after(expandtr);
}
});
}
});
});
</script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js"></script>
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js"></script>
<script>
</script>

View File

@@ -153,7 +153,7 @@
<div class="col-lg-10">
<select class="form-control" name="adb_wohneinheit_id" id="adb_wohneinheit_id" />
<?php if($preorder->adb_wohneinheit_id): ?>
<option value="<?=$preorder->adb_wohneinheit_id?>" selected="selected"><?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?> <?=$preorder->adb_wohneinheit?></option>
<option value="<?=$preorder->adb_wohneinheit_id?>" selected="selected"><?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?> <?=$preorder->adb_wohneinheit?><?=($preorder->adb_wohneinheit->extref) ? " (".$preorder->adb_wohneinheit->extref.")" : ""?></option>
<?php endif; ?>
</select>
</div>
@@ -588,6 +588,7 @@
if(unit.extra) {
opt += " " + unit.extra;
}
if(unit.extref) opt += " (" + unit.extref + ")";
/*let extras = new Array();
if(unit.block) extras.push("Block " + unit.block);
@@ -608,6 +609,7 @@
$('#adb_wohneinheit_id').append(opt);
$('#adb_wohneinheit_id').addClass("is-invalid");
$('#adb_wohneinheit_id')
.data("extref", unit.extref)
.data("zip", unit.zip)
.data("city", unit.city)
.data("street", unit.street)

View File

@@ -31,7 +31,23 @@
<form method="get" action="<?=self::getUrl("Preorder")?>">
<div class="row">
<?php if($me->is("preorderfront")): ?>
<div class="col-2">
<label class="form-label" for="filter_kunde">Kunde (Name oder Adresse)</label>
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_address">Anschlussadresse</label>
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=$filter['address']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_hausnummer">Hausnummer</label>
<input type="text" class="form-control" name="filter[hausnummer]" id="filter_hausnummer" value="<?=$filter['hausnummer']?>" />
</div>
<?php else: ?>
<div class="col-2">
<label class="form-label" for="filter_preordercampaign_id">Kampagne</label>
<select name="filter[preordercampaign_id]" id="filter_preordercampaign_id" class="form-control">
@@ -91,7 +107,39 @@
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_unit_missing">Wohneinheit</label>
<select name="filter[unit_missing]" id="filter_unit_missing" class="form-control">
<option value=""></option>
<option value="yes" <?=(isset($filter) && array_key_exists("unit_missing", $filter) && $filter['unit_missing'] == "yes") ? "selected='selected'" : ""?>>Wohneinheit fehlt</option>
<option value="no" <?=(isset($filter) && array_key_exists("unit_missing", $filter) && $filter['unit_missing'] == "no") ? "selected='selected'" : ""?>>Wohneinheit vorhanden</option>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_connection_count">Anzahl Anschlüsse</label>
<select name="filter[connection_count]" id="filter_connection_count" class="form-control">
<option value=""></option>
<option value="1" <?=(isset($filter) && array_key_exists("connection_count", $filter) && intval($filter['connection_count']) === 1) ? "selected='selected'" : ""?>>1</option>
<option value="2" <?=(isset($filter) && array_key_exists("connection_count", $filter) && intval($filter['connection_count']) === 2) ? "selected='selected'" : ""?>> &gt; 1</option>
</select>
</div>
<?php if($me->is("Admin")): ?>
<div class="col-2">
<label class="form-label" for="filter_unit_count">Anzahl GWR Wohneinheiten</label>
<select name="filter[unit_count]" id="filter_unit_count" class="form-control">
<option value=""></option>
<option value="0" <?=(isset($filter) && array_key_exists("unit_count", $filter) && strlen($filter['unit_count']) && intval($filter['unit_count']) === 0) ? "selected='selected'" : ""?>>0</option>
<option value="1" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 1) ? "selected='selected'" : ""?>>1</option>
<option value="2" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 2) ? "selected='selected'" : ""?>> &gt; 1</option>
</select>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
@@ -100,12 +148,32 @@
<?php else: ?>
<a class="btn btn-secondary" href="<?=self::getUrl("Preorder")?>">Filter zurücksetzen</a>
<?php endif; ?>
<?php if(!$me->is("Preorderfront")): ?>
<button type="submit" formaction="<?=self::getUrl("Preorder", "export")?>" id="export-button" class="btn btn-outline-success ml-2"><i class="fas fa-download"></i> CSV-Export</button>
<?php endif; ?>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="row col" id="map-link">
<a href="#" class="btn btn-success" onclick="refreshMap()"><i class="far fa-map"></i> Übersichtskarte einblenden</a>
</div>
<div class="row hidden" id="map-row">
<div id="preorder-map" style="height:70vh; width: 100%"></div>
<div class="row mt-1">
<div class="col">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle fa-fw"></i> Zentrieren</button>
<button type="button" class="btn btn-sm btn-outline-success" onclick="toggleTileset()" title="Zwischen Karte und Satellitenbild umschalten"><i class="far fa-arrow-right-arrow-left fa-fw"></i> Karte/Satellit</button>
</div>
</div>
</div>
</div>
</div>
<div class="card">
@@ -129,7 +197,7 @@
<table class="table table-striped table-hover">
<tr>
<th>Kampagne</th>
<?php if(!$me->is("preorderfront")): ?><th>Kampagne</th><?php endif; ?>
<th>Bestelltyp</th>
<th>Status</th>
<th>Anschlussadresse</th>
@@ -137,20 +205,20 @@
<th>Kunde</th>
<th>Kontakt</th>
<th>Partner</th>
<th>Anschluss</th>
<th>Attribute</th>
<th>Erstellt</th>
<th>Zuletzt bearbeitet</th>
<th></th>
</tr>
<?php foreach($preorders as $preorder): ?>
<tr>
<td><?=$preorder->campaign->name?></td>
<?php if(!$me->is("preorderfront")): ?><td><?=$preorder->campaign->name?></td><?php endif; ?>
<td><?=__($preorder->type, "preorder")?></td>
<td>Aufgenommen</td>
<?php if($preorder->building_id): ?>
<td><?=$preorder->building->street?><br /><?=$preorder->building->zip?> <?=$preorder->building->city?></td>
<?php elseif($preorder->adb_hausnummer_id): ?>
<td <?=($preorder->address_created) ? "class='alert-warning' title='Manuell angelegt'" : ""?>">
<td <?=($preorder->address_created) ? "class='alert-warning' title='Adresse manuell angelegt'" : ""?>">
<?=$preorder->adb_hausnummer->strasse->name?>
<?=$preorder->adb_hausnummer->hausnummer?><br />
<?=($preorder->adb_wohneinheit_id) ? ((string)$preorder->adb_wohneinheit ? $preorder->adb_wohneinheit."<br />" : "") : "<i class='text-pink'>&lt;keine Wohneinheit&gt;</i><br />"?>
@@ -173,12 +241,17 @@
</td>
<td><?=($preorder->partner_id) ? $preorder->partner->getCompanyOrName() : ""?></td>
<td><?=($preorder->termination) ? $preorder->termination->code : ""?></td>
<td>
<label><input type="checkbox" name="attributes_bep_specified" id="attributes_bep_specified-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("bep_specified", $preorder->attribute) && $preorder->attribute["bep_specified"]) ? "checked='checked'" : ""?> /> Borderpoint festgelegt</label><br />
<label><input type="checkbox" name="attributes_inhouse_cabling_supplied" id="attributes_inhouse_cabling_supplied-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("inhouse_cabling_supplied", $preorder->attribute) && $preorder->attribute["inhouse_cabling_supplied"]) ? "checked='checked'" : ""?> /> Starterpaket erhalten</label>
</td>
<td><?=date('d.m.Y H:i', $preorder->create)?></td>
<td><?=date('d.m.Y H:i', $preorder->edit)?></td>
<td id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<?php if(!$me->is("preorderfront")): ?>
<a href="<?=self::getUrl("Preorder", "edit", ["id" => $preorder->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
<a href="<?=self::getUrl("Preorder", "delete", ["id" => $preorder->id, "filter" => $filter])?>" class="text-danger" onclick="if(!confirm('Vorbestellung wirklich löschen?')) return false;" title="Vorbestellung Löschen"><i class="fas fa-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
@@ -195,7 +268,249 @@
<script type="text/javascript">
$("#filter_type").select2({closeOnSelect: false});
$("#filter_status").select2({closeOnSelect: false});
$(document).ready(function() {
$("#filter_type").select2({closeOnSelect: false});
$("#filter_status").select2({closeOnSelect: false});
var attributes = ["bep_specified", "inhouse_cabling_supplied"];
attributes.forEach(function(attrib) {
$("input[name=attributes_" + attrib + "]").change(function(ev) {
// save new value
var cb = $("#" + ev.currentTarget.id);
var value = $(cb).is(":checked") ? 1 : 0;
var preorder_id = $(cb).data("preorder-id");
$.post("<?=self::getUrl("Preorder", "Api")?>", {
do: "saveAttribute",
id: preorder_id,
attribute: attrib,
value: value
},
function(success) {
if(success.status == "OK") {
attributeSuccess(success.result);
} else {
attributeError(success.result.id, success.result.attribute);
}
},
"json"
);
});
});
});
function attributeSuccess(result) {
var id = result.id
var attribute = result.attribute
var update = result.update
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-danger");
$("#attributes_" + attribute + "-" + id).parent().addClass("text-success");
if(update) {
$("#update-" + id).text(update);
$("#update-" + id).addClass("text-success")
}
setTimeout(function() {
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-success");
$("#update-" + id).removeClass("text-success")
}, 2000, id, attribute);
}
function attributeError(id, attribute) {
$("#attributes_" + attribute + "-" + id).parent().addClass("text-danger");
$("#attributes_" + attribute + "-" + id).prop("checked", !$("#attributes_" + attribute + "-" + id).is(":checked"));
}
/*
* Globals for map display
*/
var preorderMap;
var preorders = [];
var markers = [];
var markerState = true;
var mapCenterPos = [<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>];
var tileLayers = [];
var tilesets = ["mapbox/streets-v12", "mapbox/satellite-streets-v12"];
var currentTileset = "mapbox/streets-v12";
function toggleTileset() {
if(currentTileset == "mapbox/streets-v12") {
currentTileset = "mapbox/satellite-streets-v12";
} else {
currentTileset = "mapbox/streets-v12";
}
console.log("renderMap");
renderMap(true);
}
function refreshMap() {
// get Preorders and render map
$('#map-link').hide();
$('#map-row').show();
getMapdata();
$([document.documentElement, document.body]).animate({
scrollTop: $("#preorder-map").offset().top - 150
}, 500);
}
function renderMap(tilesetChangeOnly = false) {
if(preorderMap) {
if(!tilesetChangeOnly) {
markers.forEach(function(m) {
preorderMap.removeLayer(m);
});
}
} else {
preorderMap = L.map('preorder-map').setView([<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>], 12);
}
if(!(currentTileset in tileLayers)) {
tileLayers[currentTileset] = 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: 6,
maxZoom: 22,
id: currentTileset,
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
});
}
tileLayers[currentTileset].addTo(preorderMap);
// remove all tilesets not currently wanted
tilesets.forEach(function(t) {
if(t != currentTileset && preorderMap.hasLayer(tileLayers[t])) {
preorderMap.removeLayer(tileLayers[t]);
}
});
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
if(!tilesetChangeOnly) {
addMarkers();
}
}
function addMarkers() {
if(!Array.isArray(preorders) | !preorders.length) {
return false;
}
// draw markers and calculate center position
var all_coords = [];
preorders.forEach(function(preorder) {
if(!preorder.gps_lat || !preorder.gps_long) {
return;
}
var gps = [preorder.gps_lat, preorder.gps_long];
all_coords.push(gps);
var icon_color = "#acf0ab";
var icon_name = "home";
if(preorder.type == "interest") {
icon_color = "#ec98a2";
} else if(preorder.type == "provision") {
icon_color = "#ffcd8b";
}
if(preorder.connection_type.match(/^multi/i) || preorder.count > 1) {
icon_name = "town";
} else if(preorder.connection_type.match(/^apartment-building/i)) {
icon_name = "city";
} else if(preorder.connection_type.match(/^business/i)) {
icon_name = "industry";
}
var marker_popup_content = '<?php include(realpath(dirname(__FILE__))."/include/preorder_popup.php");?>';
// popup fields
[
["street", preorder.adb_strasse],
["hausnummer", preorder.adb_hausnummer],
["zip", preorder.adb_plz],
["city", preorder.adb_ort],
["type", preorder.type_label],
["typestyle", "color: #000; background-color: " + icon_color],
["adrcd", preorder.adrcd],
["extref", preorder.extref ? preorder.extref : ""],
["gps", (preorder.gps_lat && preorder.gps_long) ? preorder.gps_lat + ", " + preorder.gps_long : ""],
["contact", (preorder.company ? preorder.company + " " : preorder.firstname + " " + preorder.lastname)],
["phone", preorder.phone ? preorder.phone : ""],
["email", preorder.email ? preorder.email : ""],
["connectiontype", preorder.connection_type_label],
["count", preorder.connection_count]
].forEach(function(item) {
marker_popup_content = marker_popup_content.replaceAll("{{" + item[0].toUpperCase() + "}}", item[1]);
});
var icon = L.MakiMarkers.icon({icon: icon_name, color: icon_color, size: "l"});
var marker = L.marker(gps, {icon: icon}).addTo(preorderMap).bindPopup(marker_popup_content);
markers[preorder.id] = marker;
});
// calculate center position
mapCenterPos = GetCenterFromDegrees(all_coords);
preorderMap.setView(mapCenterPos, 12);
return true;
}
function centerMap() {
preorderMap.setView(mapCenterPos, 12);
}
// gets preorders and calls renderMap()
function getMapdata() {
filter = getFilter();
$.post('<?=self::getUrl("Preorder", "Api")?>', {
'do': "getFilteredPreorders",
filter: filter
},function(success) {
if(success.status == "OK") {
if(Array.isArray(success.result.preorders)) {
preorders = success.result.preorders;
renderMap();
}
}
},
'json'
);
}
function getFilter() {
var fields = ['preordercampaign_id', 'status', 'type', 'address', 'kunde', 'address_source'];
var filter = {};
fields.forEach(function(field) {
if(!field) {
return;
}
if(!$('#filter_' + field).length) {
return;
}
let val = $('#filter_' + field).val();
if(val.length) {
filter[field] = val;
}
});
return filter;
}
<?php if(is_array($filter) && count($filter)): ?>
//refreshMap();
<?php endif; ?>
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -0,0 +1,67 @@
<?php
ob_end_flush();
header("Content-type: text/csv");
header('Content-disposition: attachment; filename="preorder-export-'.date('Y-m-d_H-i-s').'.csv"');
?>
Kampagne;Netzgebiet ID;Netzgebiet;Extref;Bestellcode;OAID;Bestelltyp;Status;Anschlusstyp;GWR Adresscode;Anschluss Strasse;Anschluss Hausnummer;Anschluss PLZ;Anschluss Ort;Anschluss Wohneinheit;GPS Breite;GPS Länge;Anzahl Anschlüsse;Kunde Firma;Kunde UID;Kunde Vorname;Kunde Nachname;Kunde Strasse;Kunde PLZ;Kunde Ort;Kunde Telefon;Kunde Email;Partner;Addon Lehrverrohrung Grundstück;Addon Hausverkabelung;BEP festgelegt;Starterpaket erhalten;Erstellt;Letzte Bearbeitung
<?php
$line = 0;
while($data = mysqli_fetch_object($res)):
$campaign = Layout::getMfValuecacheObject("Preordercampaign", $data->preordercampaign_id);
$status = Layout::getMfValuecacheObject("Preorderstatus", $data->status_id);
$hausnummer = Layout::getMfValuecacheObject("ADBHausnummer", $data->adb_hausnummer_id);
$wohneinheit = Layout::getMfValuecacheObject("ADBWohneinheit", $data->adb_wohneinheit_id);
$netzgebiet = Layout::getMfValuecacheObject("ADBNetzgebiet", $hausnummer->netzgebiet_id);
$strasse = Layout::getMfValuecacheObject("ADBStrasse", $hausnummer->strasse_id);
$gemeinde = Layout::getMfValuecacheObject("ADBGemeinde",$strasse->gemeinde_id);
$ortschaft = Layout::getMfValuecacheObject("ADBOrtschaft", $hausnummer->ortschaft_id);
$plz = Layout::getMfValuecacheObject("ADBPlz", $hausnummer->plz_id);
$partner = Layout::getMfValuecacheObject("Address", $data->partner_id);
$unit_data = "";
if($wohneinheit->block) $unit_data .= "Block ".$wohneinheit->block;
if($wohneinheit->stiege) $unit_data .= "Stiege ".$wohneinheit->stiege;
if($wohneinheit->stock) $unit_data .= "Stock ".$wohneinheit->stock;
if($wohneinheit->tuer) $unit_data .= "Tür ".$wohneinheit->tuer;
if($wohneinheit->unit_string) {
$unit_data = $wohneinheit->unit_string;
}
$bep = false;
$inhouse = false;
if($data->attributes) {
$attribs = json_decode($data->attributes, true);
if($attribs['bep_specified']) $bep = true;
if($attribs['inhouse_cabling_supplied']) $inhouse = true;
}
$addon_property = 0;
$addon_inhouse = 0;
if($data->addon_services) {
$services = json_decode($data->addon_services);
if(is_array($services) && count($services)) {
foreach($services as $service) {
if($service->service == "installation_onproperty" && $service->ordered) {
$addon_property = 1;
}
if($service->service == "installation_inhouse" && $service->ordered) {
$addon_inhouse = 1;
}
}
}
}
if($data->uid == "string") $data->uid = "";
?>
"<?=$campaign->name?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";"<?=$data->extref?>";"<?=$data->ucode?>";"<?=$wohneinheit->oaid?>";"<?=__($data->type,"preorder")?>";"<?=$status->name?>";"<?=__($data->connection_type,"preorder")?>";"<?=$hausnummer->adrcd?>";"<?=$strasse->name?>";"<?=$hausnummer->hausnummer?>";"<?=$plz->plz?>";"<?=$ortschaft->name?>";"<?=$unit_data?>";"<?=$hausnummer->gps_lat?>";"<?=$hausnummer->gps_long?>";<?=$data->connection_count?>;"<?=$data->company?>";"<?=$data->uid?>";"<?=$data->firstname?>";"<?=$data->lastname?>";"<?=$data->street?>";"<?=$data->zip?>";"<?=$data->city?>";"<?=$data->phone?>";"<?=$data->email?>";"<?=$partner->getCompanyOrName()?>";<?=$addon_property?>;<?=$addon_inhouse?>;<?=($bep) ? "1" : "0"?>;<?=($inhouse) ? "1" : "0"?>;"<?=date("Y-m-d H:i:s",$data->create)?>";"<?=date("Y-m-d H:i:s",$data->edit)?>"
<?php
$i++;
if($line % 1000 === 0) {
flush();
}
endwhile;

View File

@@ -0,0 +1,42 @@
<?php
ob_start();
?>
<div class="font-weight-bold">
{{STREET}} {{HAUSNUMMER}}<br />
{{ZIP}} {{CITY}}
</div>
<hr />
<table class="table table-sm table-striped">
<tr>
<th class="font-weight-bold">Bestelltyp:</th>
<td style="{{TYPESTYLE}}">{{TYPE}}</td>
</tr><tr>
<th class="font-weight-bold">Gebäudetyp:</th>
<td>{{CONNECTIONTYPE}}</td>
</tr><tr>
<th class="font-weight-bold">Anschlüsse:</th>
<td>{{COUNT}}</td>
</tr><tr>
<th class="font-weight-bold">GPS:</th>
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}" target="_blank">{{GPS}}</a></td>
</tr><tr>
<th class="font-weight-bold">GWR Adrcd:</th>
<td>{{ADRCD}}</td>
</tr><tr>
<th class="font-weight-bold">Extref:</th>
<td>{{EXTREF}}</td>
</tr><tr>
<th class="font-weight-bold">Kontakt:</th>
<td>{{CONTACT}}</td>
</tr><tr>
<th class="font-weight-bold">Telefon:</th>
<td>{{PHONE}}</td>
</tr><tr>
<th class="font-weight-bold">Email:</th>
<td>{{EMAIL}}</td>
</tr>
</table>
<?=str_replace("\n"," ",ob_get_clean())?>

View File

@@ -64,6 +64,34 @@
<option value="true" <?=(isset($user) && $user->is("Technician")) ? "selected='selected'" : ""?>>Yes</option>
</select>
</div>
<div class="form-group">
<label for="preorderfront">Preorder Frontdesk:</label>
<select name="preorderfront" class="form-control">
<option value="false" <?=(isset($user) && !$user->is("preorderfront")) ? "selected='selected'" : ""?>>No</option>
<option value="true" <?=(isset($user) && $user->is("preorderfront")) ? "selected='selected'" : ""?>>Yes</option>
</select>
</div>
<div class="form-group" id="preorder-network-container">
<label for="preorder_networks">Preorder Netzgebiete:</label>
<?php
$pns = [];
if($user->id) {
$pns = json_decode((new WorkerFlag($user->id,"preorder_networks"))->value());
if(!$pns) {
$pns = [];
}
}
?>
<select name="preorder_networks[]" id="preorder_networks" class="form-control" multiple="multiple">
<?php foreach(NetworkModel::getAll() as $network): ?>
<option value="<?=$network->id?>" <?=(in_array($network->id, $pns)) ? "selected='selected'" : ""?>><?=$network->name?></option>
<?php endforeach; ?>
</select>
<small>Überschreibt Netzgebiete der Firma. Wenn leer werden Netzgebiete der Firma angezeigt</small>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" class="form-control" value="" />
@@ -113,9 +141,30 @@
<?php endif; ?>
<script type="text/javascript">
$("#address_id").select2({
allowClear: true,
placeholder: ""
$(document).ready(function() {
$("#address_id").select2({
allowClear: true,
placeholder: ""
});
$("#preorder_networks").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
<?php if(!$user || !$user->is("preorderfront")): ?>
$("#preorder-network-container").hide();
<?php endif; ?>
$("select[name=preorderfront]").change(function() {
if($("select[name=preorderfront]").val() == "true") {
$("#preorder-network-container").show();
} else {
$("#preorder-network-container").hide();
}
});
});
</script>

View File

@@ -8,6 +8,7 @@
<tr>
<th>Nummer</th>
<th>Aktiv</th>
<th>Contract ID</th>
<th>Routing</th>
<th>Portierungsstatus</th>
<th>Sperre</th>
@@ -26,6 +27,7 @@
<span class="text-danger"><i class="fas fa-times"></i></span>
<?php endif; ?>
</td>
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $num->contract_id])?>"><?=$num->contract_id?></a></td>
<td><?=__($num->routing)?></td>
<td>
<?php if($num->ported_out): ?>

View File

@@ -4,122 +4,135 @@
<!-- Navigation Menu-->
<ul class="navigation-menu">
<?php if(!$me->is("Admin")): ?>
<li class="has-submenu">
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard</a>
</li>
<?php if($me->is("preorderfront")): ?>
<li class="has-submenu">
<a href="#">
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Preorder")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
</ul>
</li>
<?php else: ?>
<?php if(!$me->is("Admin")): ?>
<li class="has-submenu">
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard</a>
</li>
<?php endif; ?>
<?php if($me->is("Admin")): ?>
<li class="has-submenu">
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard <div class="arrow-down"></div></a>
<ul class="submenu">
<li><a href="<?=self::getUrl("News")?>"><i class="far fa-th-list text-info"></i> News</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin", "netowner"])): ?>
<li class="has-submenu">
<a href="#">
<i class="far fa-database"></i>Stammdaten <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin"])): ?>
<li class="has-sub-submenu font-weight-bold"><a>Betriebsstammdaten</a></li>
<li><a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a></li>
<li><a href="<?=self::getUrl("Product")?>"><i class="far fa-rectangle-list text-info"></i> Produkte</a></li>
<li><a href="<?=self::getUrl("Productgroup")?>"><i class="far fa-list-tree text-info"></i> Produktgruppen</a></li>
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
<li class="has-sub-submenu" ><a href="<?=self::getUrl("Pop")?>"><i class="fad fa-house text-info"></i> Pops</a></li>
<li ><a href="<?=self::getUrl("Devicemanufactor")?>"><i class="fad fa-router text-info"></i> Geräte Hersteller</a></li>
<li><a href="<?=self::getUrl("Devicetype")?>"><i class="fad fa-router text-info"></i> Geräte Typen</a></li>
<li class="has-sub-submenu"><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info "></i> Devices</a></li>
<li class="has-sub-submenu"><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
<li class="has-sub-submenu font-weight-bold mt-1"><a>Grundstammdaten</a></li>
<?php endif; ?>
<?php if($me->is(["Admin", "netowner"])): ?>
<li><a href="<?=self::getUrl("AddressDB")?>"><i class="fas fa-city text-info"></i> GWR / AddressDB</a></li>
<?php endif; ?>
<?php if($me->is(["Admin"])): ?>
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
<!--<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fad fa-gear text-info"></i> ContractConfig</a></li>-->
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin","netowner","lineplanner","pipeplanner","pipeworker","lineworker"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fas fa-hard-hat"></i>Netzbau <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin","netowner","pipeplanner"])): ?><li><a href="<?=self::getUrl("Building")?>"><i class="fas fa-city text-info"></i> Objekte & Anschlüsse</a></li><?php endif; ?>
<?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 class="has-sub-submenu"><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; ?>
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fad fa-running"></i>Netzbetrieb <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Cpeprovisioning")?>"><i class="fad fa-hdd text-info"></i> CPE Provisioning</a></li>
<li><a href="<?=self::getUrl("Cpeshipping")?>"><i class="fad fa-shipping-fast text-info"></i> CPE Versand</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fad fa-phone"></i>Telefonie <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Voicenumberblock")?>"><i class="fad fa-blender-phone text-info"></i> Rufnummernblöcke</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
<?php endif; ?>
<?php if($me->is(["Admin","salespartner"])): ?>
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
<!--
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fas fa-shopping-basket"></i>Verträge<div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
<li><hr /></li>
<li><a href="<?=self::getUrl("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
</ul>
</li>
<?php endif; ?>
-->
<?php endif; ?>
<?php if($me->is("Admin")): ?>
<li class="has-submenu">
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard <div class="arrow-down"></div></a>
<ul class="submenu">
<li><a href="<?=self::getUrl("News")?>"><i class="far fa-th-list text-info"></i> News</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin", "netowner"])): ?>
<li class="has-submenu">
<a href="#">
<i class="far fa-database"></i>Stammdaten <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin"])): ?>
<li class="has-sub-submenu font-weight-bold"><a>Betriebsstammdaten</a></li>
<li><a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a></li>
<li><a href="<?=self::getUrl("Product")?>"><i class="far fa-rectangle-list text-info"></i> Produkte</a></li>
<li><a href="<?=self::getUrl("Productgroup")?>"><i class="far fa-list-tree text-info"></i> Produktgruppen</a></li>
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
<li class="has-sub-submenu" ><a href="<?=self::getUrl("Pop")?>"><i class="fad fa-house text-info"></i> Pops</a></li>
<li ><a href="<?=self::getUrl("Devicemanufactor")?>"><i class="fad fa-router text-info"></i> Geräte Hersteller</a></li>
<li><a href="<?=self::getUrl("Devicetype")?>"><i class="fad fa-router text-info"></i> Geräte Typen</a></li>
<li class="has-sub-submenu"><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info "></i> Devices</a></li>
<li class="has-sub-submenu"><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
<li class="has-sub-submenu font-weight-bold mt-1"><a>Grundstammdaten</a></li>
<?php endif; ?>
<?php if($me->is(["Admin", "netowner"])): ?>
<li><a href="<?=self::getUrl("AddressDB")?>"><i class="fas fa-city text-info"></i> GWR / AddressDB</a></li>
<?php endif; ?>
<?php if($me->is(["Admin"])): ?>
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
<!--<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fad fa-gear text-info"></i> ContractConfig</a></li>-->
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin","netowner","lineplanner","pipeplanner","pipeworker","lineworker"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fas fa-hard-hat"></i>Netzbau <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin","netowner","pipeplanner"])): ?><li><a href="<?=self::getUrl("Building")?>"><i class="fas fa-city text-info"></i> Objekte & Anschlüsse</a></li><?php endif; ?>
<?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 class="has-sub-submenu"><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; ?>
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fad fa-running"></i>Netzbetrieb <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Cpeprovisioning")?>"><i class="fad fa-hdd text-info"></i> CPE Provisioning</a></li>
<li><a href="<?=self::getUrl("Cpeshipping")?>"><i class="fad fa-shipping-fast text-info"></i> CPE Versand</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fad fa-phone"></i>Telefonie <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Voicenumberblock")?>"><i class="fad fa-blender-phone text-info"></i> Rufnummernblöcke</a></li>
</ul>
</li>
<?php endif; ?>
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
</a>
<ul class="submenu">
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
<?php endif; ?>
<?php if($me->is(["Admin","salespartner"])): ?>
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
<?php endif; ?>
</ul>
</li>
<?php endif; ?>
<!--
<?php if($me->is(["Admin"])): ?>
<li class="has-submenu">
<a href="#">
<i class="fas fa-shopping-basket"></i>Verträge<div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
<li><hr /></li>
<li><a href="<?=self::getUrl("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
</ul>
</li>
<?php endif; ?>
-->
</ul>
<!-- End navigation menu -->

View File

@@ -1,6 +1,7 @@
<?php
class ADBHausnummer extends mfBaseModel {
protected $forcestr = ["oaid","adrcd","subcd","extref","hausnummer","zusatz","grund_nr","gdaeigenschaft","meridian","rollout_info","rimo_fcp_name"];
private $netzgebiet;
private $ortschaft;
private $strasse;
@@ -85,28 +86,22 @@ class ADBHausnummer extends mfBaseModel {
}
if($name == "netzgebiet") {
$this->netzgebiet = new ADBNetzgebiet($this->netzgebiet_id);
$this->netzgebiet = mfValuecache::singleton()->getMfObject("ADBNetzgebiet", $this->netzgebiet_id);
return $this->netzgebiet;
}
if($name == "ortschaft") {
$this->ortschaft = new ADBOrtschaft($this->ortschaft_id);
$this->ortschaft = mfValuecache::singleton()->getMfObject("ADBOrtschaft", $this->ortschaft_id);
return $this->ortschaft;
}
if($name == "strasse") {
$this->strasse = new ADBStrasse($this->strasse_id);
$this->strasse = mfValuecache::singleton()->getMfObject("ADBStrasse", $this->strasse_id);
return $this->strasse;
}
if($name == "plz") {
$this->plz = mfValuecache::singleton()->get("adbplz-".$this->plz_id);
if($this->plz === null) {
$this->plz = new ADBPlz($this->plz_id);
if($this->plz->id) {
mfValuecache::singleton()->set("adplz-".$this->plz_id, $this->plz);
}
}
$this->plz = mfValuecache::singleton()->getMfObject("ADBPlz", $this->plz_id);
return $this->plz;
}

View File

@@ -71,8 +71,8 @@ class ADBHausnummerModel {
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer
LIMIT 1";
//mfLoghandler::singleton()->debug($where);
$res = $db->select("Hausnummer", "*", "$where ORDER BY strasse_id,hausnummer LIMIT 1");
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ADBHausnummer($data);
@@ -135,7 +135,6 @@ class ADBHausnummerModel {
WHERE $where
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer";
mfLoghandler::singleton()->debug($sql);
if(is_array($limit) && count($limit)) {
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
@@ -312,9 +311,9 @@ class ADBHausnummerModel {
}
if(array_key_exists("hausnummer%", $filter)) {
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer%']);
if($hausnummer) {
$where .= " AND Hausnummer.`hausnummer` like '%$hausnummer%'";
$where .= " AND Hausnummer.`hausnummer` like '$hausnummer%'";
}
}

View File

@@ -75,7 +75,15 @@ class ADBWohneinheit extends mfBaseModel {
$bcode = $this->getProperty("hausnummer")->oaid;
//var_dump($bcode);
if(!$bcode) {
return false;
$hausnummer = $this->getProperty("hausnummer");
$hausnummer->oaid = $hausnummer->getNewOAID();
if(!$hausnummer->oaid) {
return false;
}
if(!$hausnummer->save()) {
return false;
}
$bcode = $hausnummer->oaid;
}
$codes = [];

View File

@@ -0,0 +1,5 @@
<?php
class ADBWohneinheitController extends mfBaseController {
}

View File

@@ -3,6 +3,9 @@
class AddressDB {
private $db;
private $log;
public $validation_error = [];
public static $wohneinheit_query = "select `Netzgebiet`.`id` AS `netzgebiet_id`,
`Netzgebiet`.`name` AS `netzgebiet`,
`Netzgebiet`.`extref` AS `netzgebiet_extref`,
@@ -204,6 +207,20 @@ class AddressDB {
$hausnummer_data['strasse_id'] = $strasse->id;
$hausnummer_data['hausnummer'] = $data['hausnummer'];
$hausnummer_data['grund_nr'] = $data['grund_nr'];
$hausnummer_data['gdaeigenschaft'] = $data['gdaeigenschaft'];
$hausnummer_data['meridian'] = $data['meridian'];
$hausnummer_data['rw'] = ($data['rw']) ? str_replace(",",".", $data['rw']) : null;
$hausnummer_data['hw'] = ($data['hw']) ? str_replace(",",".", $data['hw']) : null;
if($data['rw'] && !is_numeric($hausnummer_data['rw'])) {
$hausnummer_data['rw'] = null;
$this->validation_error[] = "RW nicht gespeichert: Keine Zahl";
}
if($data['hw'] && !is_numeric($hausnummer_data['hw'])) {
$hausnummer_data['hw'] = null;
$this->validation_error[] = "HW nicht gespeichert: Keine Zahl";
}
$hausnummer_data['gps_lat'] = ($data['gps_lat']) ? str_replace(",", ".", $data['gps_lat']) : null;
$hausnummer_data['gps_long'] = ($data['gps_long']) ? str_replace(",", ".", $data['gps_long']) : null;
$hausnummer_data['rollout'] = (trim($data['rollout'])) ? trim($data['rollout']) : null;

View File

@@ -18,14 +18,22 @@ class AddressDBController extends mfBaseController {
protected function indexAction() {
$this->layout()->setTemplate("AddressDB/Index");
$rfilter = $this->request->filter;
iF(!is_array($rfilter)) {
$rfilter = [];
if($this->request->resetFilter) {
unset($_SESSION[MFAPPNAME.'-AddressDB-filter']);
}
$this->layout->set("filter", $rfilter);
$filter = $this->getPreparedFilter($rfilter);
$filter = [];
if(is_array($this->request->filter)) {
$filter = $this->request->filter;
$_SESSION[MFAPPNAME.'-AddressDB-filter'] = $filter;
} else {
if(array_key_exists(MFAPPNAME.'-AddressDB-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-AddressDB-filter'])) {
$filter = $_SESSION[MFAPPNAME.'-AddressDB-filter'];
}
}
$this->layout->set("filter", $filter);
$filter = $this->getPreparedFilter($filter);
// pagination defaults
$pagination = [];
@@ -73,7 +81,7 @@ class AddressDBController extends mfBaseController {
$this->layout()->set("my_networks", ADBNetzgebietModel::getAll());
$this->layout()->set("my_adb_networks", $my_adb_networks);
//var_dump($addressdb_filter);exit;
//var_dump($addressdb_filter);exit;
if($filter['netzgebiet_id'] === "null") {
$addressdb_filter['netzgebiet_id'] = 0;
$pagination['maxItems'] = ADBHausnummerModel::count($addressdb_filter);
@@ -107,13 +115,18 @@ class AddressDBController extends mfBaseController {
unset($filter['street']);
}
if(array_key_exists("hausnummer", $filter) && $filter['hausnummer']) {
$new_filter['hausnummer%'] = $filter['hausnummer'];
unset($filter['hausnummer']);
}
if(array_key_exists("adrcd", $filter) && $filter['adrcd']) {
$new_filter['adrcd%'] = $filter['adrcd'];
unset($filter['adrcd']);
}
if(array_key_exists("oaid", $filter) && $filter['oaid']) {
$new_filter['oaid%'] = $filter['oaid'];
$new_filter['oaid%'] = "%".$filter['oaid'];
unset($filter['oaid']);
}
@@ -149,6 +162,7 @@ class AddressDBController extends mfBaseController {
unset($filter['ortschaft_id']);
}
if(is_array($filter) && count($filter)) {
foreach($filter as $name => $value) {
if(strlen($value) > 0) $new_filter[$name] = $value;
@@ -188,7 +202,6 @@ class AddressDBController extends mfBaseController {
}
protected function editAction() {
$id = $this->request->id;
if(!is_numeric($id) || $id < 1) {
$this->layout()->setFlash("Adresse nicht gefunden", "error");
@@ -231,12 +244,11 @@ class AddressDBController extends mfBaseController {
}
$required = ['netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde'];
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gps_lat','gps_long','unit_count'] as $field) {
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) {
if(in_array($field, $required)) {
if(!trim($r->$field)) {
$this->layout()->setFlash("'".ucfirst($field)."' darf nicht leer sein!", "error");
return $this->addAction();
//$this->redirect("AddressDB", $mode, ['id' => $id]);
}
}
$address_data[$field] = $this->db()->escape(trim($r->$field));
@@ -289,39 +301,61 @@ class AddressDBController extends mfBaseController {
$adb = new AddressDB();
$hausnummer_id = $adb->createUpdateHausnummer($address_data);
if(is_array($adb->validation_error) && count($adb->validation_error)) {
$this->layout()->setFlash(implode("<br />\n",$adb->validation_error), "warning");
}
if(!$hausnummer_id) {
$this->layout()->setFlash("Fehler beim Erstellen der Adresse!", "error");
return $this->addAction();
//$this->redirect("AddressDB");
}
if($mode == "add") {
/*
* Wohneinheiten erstellen
*/
if(is_numeric($r->unit_count) && $r->unit_count) {
$unit_count = $r->unit_count;
$hausnummer = new ADBHausnummer($hausnummer_id);
/*
* Wohneinheiten erstellen
*/
if($r->unit_count > 0) {
for($i = 1; $i <= $r->unit_count; $i++) {
$unit = ADBWohneinheitModel::create([
'hausnummer_id' => $hausnummer_id,
'num' => $i,
]);
$unit_id = $unit->save();
if(!$unit_id) {
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Woneinheit");
continue;
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $hausnummer->id]);
//var_dump($hausnummer,$existing_units_count);exit;
if($existing_units_count < $unit_count) {
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
$unit->oaid = $unit->getNewOAID();
$unit->save();
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
$this->layout()->setFlash("Fehler beim Erstellen einer Wohneinheit!", "warning");
return $this->addAction();
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
$wohneinheit->save();
$w++;
}
}
}
$qs = http_build_query(['filter' => ['oaid' => $hausnummer->oaid]]);
//$qs = http_build_query(['filter' => ['oaid' => $hausnummer->oaid]]);
//var_dump($qs);exit;
$this->layout()->setFlash("Adresse erfolgreich gespeichert", "success");
$this->redirect("AddressDB", "Index", $qs);
$this->redirect("AddressDB");
}
@@ -547,6 +581,7 @@ class AddressDBController extends mfBaseController {
foreach($units as $unit) {
$u = [];
$u['id'] = $unit->id;
$u['extref'] = $unit->extref;
$u['zip'] = $unit->hausnummer->plz->plzstring;
$u['city'] = $unit->hausnummer->ortschaft->name;
$u['street'] = $unit->hausnummer->strasse->name;

View File

@@ -31,6 +31,13 @@ class AddressdbApicontroller extends mfBaseApicontroller {
protected function authenticated() {
$campaignApiusers = PreordercampaignApiuserModel::search(["worker_id" => $this->me->id]);
if(!$campaignApiusers) {
$cau = new PreordercampaignApiuser();
$cau->preordercampaign_id = 1;
$campaignApiusers = [$cau];
}
foreach($campaignApiusers as $campaignApiuser) {
$campaign = new Preordercampaign($campaignApiuser->preordercampaign_id);
if($campaign) {

View File

@@ -0,0 +1,26 @@
<?php
class DeviceApicontroller extends mfBaseApicontroller
{
protected function init()
{
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->addRoute("/device/getDevices", "getDevices", "GET");
}
protected function getDevices()
{
$devices = DeviceModel::getAll();
foreach ($devices as $key => $device) {
$deviceReturn[$key]['id'] = $device->id;
$deviceReturn[$key]['name'] = $device->name;
$deviceReturn[$key]['ip'] = $device->ip;
$deviceReturn[$key]['serial'] = $device->serial;
$deviceReturn[$key]['manufactor'] = $device->devicetype->devicemanufactor->name;
}
return mfResponse::Ok($deviceReturn);
}
}

View File

@@ -311,6 +311,13 @@ class PreorderApicontroller extends mfBaseApicontroller {
$unit_search[$key] = trim($this->post['address']->$key);
}
}
// ignore unit_string if the specific fields were provided
if($unit_search['block'] || $unit_search['stiege'] || $unit_search['stock'] || $unit_search['tuer']) {
unset($unit_search['unit_string']);
}
if($zusatz) {
$unit_search['zusatz'] = $zusatz;
}
@@ -334,6 +341,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
*/
$where = "1=1 ";
foreach($address_search as $field => $value) {
if($field == "ortschaft" || $field == "gemeinde") continue;
$where .= " AND `$field` = '$value'";
}
@@ -346,7 +354,35 @@ class PreorderApicontroller extends mfBaseApicontroller {
$this->log->debug($sql);
$res = $this->db()->query($sql);
if(!$this->db()->num_rows($res)) {
return mfResponse::NotFound(['message' => "Adresse nicht gefunden"]);
// try with Ortschaft in front of strasse (liezen gwr issue)
$where = "1=1 ";
foreach($address_search as $field => $value) {
if($field == "ortschaft" || $field == "gemeinde") continue;
if($field == "strasse") {
$prefix = ($address_search['ortschaft']) ? $address_search['ortschaft'] : $address_search['gemeinde'];
if(strpos($value, "$prefix ") === 0) {
$str = substr($value, strlen($prefix)+1);
} else {
$str = $value;
}
$where .= " AND `strasse` = '$str'";
} else {
$where .= " AND `$field` = '$value'";
}
}
// filter salesclusters
if(count($this->filter_salescluster_ids)) {
$where .= " AND netzgebiet_id IN (".implode(',', $this->filter_salescluster_ids).")";
}
$sql = "SELECT * FROM view_hausnummer WHERE $where";
$this->log->debug($sql);
$res = $this->db()->query($sql);
if(!$this->db()->num_rows($res)) {
return mfResponse::NotFound(['message' => "Adresse nicht gefunden"]);
}
}
$address = $this->db()->fetch_object($res);
@@ -592,6 +628,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
}
}
}
// get units excluding unavailable units
$where = "hausnummer_id=".$address->hausnummer_id;
$where .= " AND ( block = '' OR block IS NULL)";

View File

@@ -411,10 +411,10 @@ class BuildingController extends mfBaseController {
$building_term['status'] = "none";
//$this->log->debug("building status: ".print_r($building->status,true));
if($term->status->code == TT_TERMSTATUS_CONNECTED) {
if($term->status->code >= TT_TERMSTATUS_CONNECTED) {
$building_term['status'] = "connected";
$data->status = "connected";
} elseif($building->status->code == TT_BUILDINGSTATUS_CONNECTED) {
} elseif($building->status->code >= TT_BUILDINGSTATUS_CONNECTED) {
$building_term['status'] = "pipework-done";
if($data->status != "connected") $data->status = "pipework-done";
}

View File

@@ -1,6 +1,8 @@
<?php
class Contract extends mfBaseModel {
protected $forcestr = ["product_name","product_info","matchcode"];
private $owner;
private $billingaddress;
private $product;

View File

@@ -1,6 +1,7 @@
<?php
class ContractconfigController extends mfBaseController {
public $hook_errors;
protected function init() {
$this->needlogin=true;
@@ -68,13 +69,23 @@ class ContractconfigController extends mfBaseController {
$error_items = [];
$old_values = [];
foreach($r->itemvalues as $item_id => $itemvalue) {
//var_dump($item_id, $itemvalue); continue;
$item = new ContractconfigItem($item_id);
if(!$item->id) {
$this->log->warn("Tried to save non-existant ContractconfigItem $item_id");
continue;
}
$item->setContractId($contract_id);
/*if(!array_key_exists($item->name, $old_values)) {
$old_values[$item->name] = [];
}*/
$old_values[$item->name] = $item->getValue();
if(!$item->value->set($itemvalue)) {
$error_items[$item->id] = $item->name;
continue;
@@ -85,6 +96,7 @@ class ContractconfigController extends mfBaseController {
return $this->editAction();
}
}
//exit;
if(count($error_items)) {
$this->layout()->set("error_items", array_keys($error_items));
@@ -94,12 +106,74 @@ class ContractconfigController extends mfBaseController {
}
// run custom productgroup hooks
if(!$this->runAfterSaveHooks($contract)) {
$errors = [];
foreach($this->hook_errors as $item_name => $item_errors) {
if(is_array($item_errors) && count($item_errors)) {
foreach($item_errors as $error_string) {
$errors[] = "[$item_name] $error_string";
}
//var_dump($old_values[$item_name]);
// on error restore old values
if(array_key_exists($item_name, $old_values)) {
$old_item = ContractconfigItemModel::getFirst(["name" => $item_name]);
$old_item->setContractId($contract_id);
$old_item->value->set($old_values[$item_name]);
$old_item->value->save();
//var_dump($old_item->value->json);exit;
}
}
}
//var_dump($errors);exit;
$this->layout()->setFlash(implode("<br />", $errors), "error");
$this->redirect("Contract", "view", ['id' => $contract_id]);
}
$this->layout()->setFlash("Konfiguration gespeichert", "success");
$this->redirect("Contract", "view", ['id' => $contract_id]);
}
private function runAfterSaveHooks(Contract $contract) {
if(!$contract || !$contract->id) {
return false;
}
$folderpath = APPDIR."/Contractconfig/hooks/";
$dir = opendir($folderpath);
while($filename = readdir($dir)) {
if(substr($filename, 0, 1) == ".") {
continue;
}
if($filename == "Contractconfig_Hook.php") continue;
if(substr($filename, -4) != ".php") continue;
$hook_type = basename($filename, ".php");
$classname = "Contractconfig_Hook_$hook_type";
$hook_class_filename = $folderpath.$filename;
require_once $hook_class_filename;
if(!class_exists($classname)) {
continue;
}
$hook = new $classname($contract);
if($hook->isResponsible()) {
$this->log->debug("Running {$classname}->afterSave() for Contract id ".$contract->id);
$hook->afterSave();
if($hook->errors) {
$this->hook_errors = $hook->errors;
return false;
}
}
}
return true;
}
}

View File

@@ -1,6 +1,8 @@
<?php
abstract class Contractconfig_Hook {
protected $log;
protected $required_product_attributes = [];
protected $contract;
protected $items;
@@ -17,11 +19,13 @@ abstract class Contractconfig_Hook {
abstract public function beforeSave();
abstract public function afterSave();
abstract public function beforeDelete();
abstract public function afterDelete();
abstract public function beforeCancel();
abstract public function afterCancel();
public function __construct(Contract $contract) {
$this->log = mfLoghandler::singleton();
$this->contract = $contract;
if($contract->product) {

View File

@@ -1,10 +1,15 @@
<?php
require_once __DIR__."/Contractconfig_Hook.php";
/*
* Contractconfig Hooks for
*/
class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
protected $required_product_attributes = ["needs_number"];
private $voip_routing;
private $create_numbers = [];
/*
* Checks to determine if class needs to work on contract.
*/
@@ -24,101 +29,152 @@ class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
}
public function init() {
$this->errors["voicenumberblock_voicenumber"] = [];
// get voip routing for number
$this->getVoipRouting();
}
private function getVoipRouting() {
if(is_array($this->contract->configvalues)) {
// look in contract config
if(array_key_exists("voip_routing",$this->contract->configvalues) && $this->contract->configvalues['voip_routing']->value->string) {
$this->voip_routing = $this->contract->configvalues['voip_routing']->value->string;
} else {
// else take first value (default)
$typedata = $this->voip_routing = $this->contract->configvalues['voip_routing']->getTypedataArray();
$typedata = $this->contract->configvalues['voip_routing']->getTypedataArray();
$this->voip_routing = $typedata[0];
}
}
return $this->voip_routing;
}
public function beforeSave() {
return $this->checkNewNumbers();
}
public function afterSave() {
// check if number was saved
if(!array_key_exists("voicenumber", $this->configitems)) {
echo "configitem voicenumber does not exists\n";
return true;
}
echo "configitem voicenumber exists\n";
$item = $this->configitems['voicenumber'];
$number = $item->value->string;
if(!$number) {
echo "Keine nummer gespeichert\n";
return true;
}
echo "Nummer: $number\n";
$this->checkNewNumbers();
// load voip routing again, in case it changed with the same config update
$this->getVoipRouting();
// check if Voicenumber exists
$voicenumberblock = Voicenumberblock::findBlock($number);
if(!$voicenumberblock) {
$this->errors[] = "Ungültige Rufnummer: Kein aktiver Rufnummernblock gefunden";
echo "Voicenumberblock für $number nicht gefunden\n";
}
if(!$voicenumberblock->isNumberInBlock($number)) {
$this->errors[] = "Ungültige Rufnummer: Bitte Rufnummernlänge kontrollieren! Block erlaubt ".$voicenumberblock->first ." bis ".$voicenumberblock->last;
echo "Voicenumber $number not in Block ".$voicenumberblock->prefix."\n";
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
if($voicenumber) {
// check if number belongs to another contract
if($voicenumber->contract_id) {
if($voicenumber->contract_id == $this->contract->id) {
// belongs to our contract already => no changes needed
return true;
foreach($this->create_numbers as $voicenumberblock_id => $numbers) {
foreach($numbers as $number){
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
if(!$voicenumber) {
$this->log->debug("creating voicenumber $number in block ".$voicenumberblock->prefix);
$voicenumber = VoicenumberModel::create([
'voicenumberblock_id' => $voicenumberblock_id,
"contract_id" => $this->contract->id,
'active' => 1,
'activated_date' => date('U'),
'routing' => $this->voip_routing,
'number' => $number,
'disabled' => 0
]);
if(!$voicenumber->save()) {
$this->errors["voicenumberblock_voicenumber"][] = "Error saving new number $number";
}
}
$this->errors[] = "Ungültige Rufnummer: Rufnummer gehört zu bestehendem contract ".$voicenumber->contract_id;
return false;
}
// check if number is locked
if($voicenumber->disabled) {
$this->errors[] = "Ungültige Rufnummer: Rufnummer ist gesperrt ".$voicenumber->contract_id;
return false;
}
// check if number was ported out
if($voicenumber->ported_out) {
$this->errors[] = "Ungültige Rufnummer: Rufnummer wurde rausportiert ".$voicenumber->contract_id;
return false;
}
} else {
echo "creating voicenumber $number in block ".$voicenumberblock->prefix."\n";
$voicenumber = VoicenumberModel::create([
'voicenumberblock_id' => $voicenumberblock->id,
"contract_id" => $this->contract->id,
'active' => 1,
'activated_date' => date('U'),
'routing' => $this->voip_routing,
'number' => $number,
'disabled' => 0
]);
if(!$voicenumber->save()) {
echo "Error saving new number\n";
}
}
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
return true;
}
/*
* TODO: Check if contract was canceled, then set lock and lock_reason to reserved
* => should go into beforeCancel event
*/
public function checkNewNumbers() {
$this->log->debug(":: In Contractconfig_Hook_Voicenumberblock->afterSave()");
// check if number was saved
if(!array_key_exists("voicenumber", $this->configitems)) {
$this->log->debug("configitem voicenumber does not exists");
return true;
}
$item = $this->configitems['voicenumber'];
//var_dump($item);exit;
if($item->value->json) {
$numbers = json_decode($item->value->json);
}
if(!is_array($numbers) || !count($numbers)) {
return true;
}
foreach($numbers as $number) {
if(!$number) {
$this->log->debug("Keine nummer gespeichert");
continue;
}
$this->log->debug("Nummer: $number");
// check if Voicenumber exists
$voicenumberblock = Voicenumberblock::findBlock($number);
if(!$voicenumberblock) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Kein aktiver Rufnummernblock gefunden";
continue;
}
if(!$voicenumberblock->isNumberInBlock($number)) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Bitte Rufnummernlänge kontrollieren! Block erlaubt ".$voicenumberblock->first ." bis ".$voicenumberblock->last;
continue;
}
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
if($voicenumber) {
// check if number belongs to another contract
if($voicenumber->contract_id) {
if($voicenumber->contract_id == $this->contract->id) {
// belongs to our contract already => no changes needed
continue;
}
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer gehört zu bestehendem contract ".$voicenumber->contract_id;
continue;
}
// check if number is locked
if($voicenumber->disabled) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer ist gesperrt ".$voicenumber->contract_id;
continue;
}
// check if number was ported out
if($voicenumber->ported_out) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer wurde rausportiert ".$voicenumber->contract_id;
continue;
}
} else {
if(!array_key_exists($voicenumberblock->id, $this->create_numbers)) {
$this->create_numbers[$voicenumberblock->id] = [];
}
$this->create_numbers[$voicenumberblock->id][] = $number;
}
}
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
return true;
}
public function beforeDelete() {
public function beforeCancel() {
}
public function afterDelete() {
public function afterCancel() {
}
}

View File

@@ -18,6 +18,9 @@ class ContractconfigItem extends mfBaseModel {
return null;
}
if($this->multiple) {
return json_decode($value->json);
}
if($this->type == "int") {
return $value->int;
}
@@ -56,7 +59,7 @@ class ContractconfigItem extends mfBaseModel {
$value->contract_id = $this->contract_id;
$value->create_by = $me->id;
}
//var_dump($value);exit;
$this->value = $value;
return $this->value;
}

View File

@@ -34,6 +34,7 @@ class ContractconfigItemController extends mfBaseController {
$item_data['name'] = $r->name;
$item_data['displayname'] = $r->displayname;
$item_data['description'] = $r->description;
$item_data['multiple'] = ($r->multiple) ? 1 : 0;
$item_data['typedata'] = "";
$item_data['pattern'] = "";
@@ -54,7 +55,7 @@ class ContractconfigItemController extends mfBaseController {
$item_data['type'] = "decimal";
break;
default:
$this->layout()->setFlash("Ungültiger Datentyp!");
$this->layout()->setFlash("Ungültiger Datentyp!", "error");
$this->redirect("Contractconfiggroup");
}
@@ -69,7 +70,7 @@ class ContractconfigItemController extends mfBaseController {
$item_id = $item->save();
if(!$item_id) {
$this->layout()->setFlash("Fehler beim Speichern!");
$this->layout()->setFlash("Fehler beim Speichern!", "error");
$this->redirect("Contractconfiggroup");
}
@@ -79,5 +80,35 @@ class ContractconfigItemController extends mfBaseController {
}
protected function deleteAction() {
$r = $this->request;
$id = $r->id;
if(!is_numeric($id) || $id < 1) {
$this->layout()->setFlash("Config Element nicht gefunden!", "error");
$this->redirect("Contractconfiggroup");
}
$item = new ContractconfigItem($id);
if(!$item->id) {
$this->layout()->setFlash("Config Element nicht gefunden!", "error");
$this->redirect("Contractconfiggroup");
}
if(ContractconfigValueModel::getFirst(["item_id" => $id])) {
$this->layout()->setFlash("Config Element kann nicht gelöscht werden, das es in Verwendung ist!", "error");
$this->redirect("Contractconfiggroup");
}
if(!$item->delete()) {
$this->layout()->setFlash("Fehler beim Löschen!", "error");
$this->redirect("Contractconfiggroup");
}
$this->layout()->setFlash("Config Element erfolgreich gelöscht!", "success");
$this->redirect("Contractconfiggroup");
}
}

View File

@@ -4,6 +4,7 @@ class ContractconfigItemModel {
public $order;
public $contractconfiggroup_id;
public $type;
public $multiple;
public $name;
public $displayname;
public $description;
@@ -53,7 +54,7 @@ class ContractconfigItemModel {
}
public static function getFirst() {
public static function getFirst($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);

View File

@@ -4,20 +4,36 @@ class ContractconfigValue extends mfBaseModel {
private $item;
public function set($new_value) {
$item = $this->getProperty("item");
// explicitly load item, because we might not have an id yet
$item = new ContractconfigItem($this->item_id);
$me = new User();
$me->loadMe();
$this->edit_by = $me->id;
if($new_value === null || strlen($new_value) == 0) {
if(!is_array($new_value) && ($new_value === null || strlen($new_value) == 0)) {
$this->int = null;
$this->number = null;
$this->string = null;
return true;
}
if($item->type == "int") {
if($item->multiple) {
if(!is_array($new_value)) {
$new_value = [$new_vale];
}
$json_array = [];
foreach($new_value as $v) {
if($v) {
$json_array[] = $v;
}
}
$this->json = json_encode($json_array);
} elseif($item->type == "int") {
if(!is_numeric($new_value)) return false;
$this->int = $new_value;
} elseif($item->type == "decimal") {

View File

@@ -1,266 +1,290 @@
<?php
class CpeprovisioningController 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"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction() {
$this->layout()->setTemplate("Cpeprovisioning/Index");
$cpeproducts = [];
$this->layout->set("filter", $this->request->filter);
$filter = $this->getPreparedFilter($this->request->filter);
// pagination defaults
$pagination = [];
$pagination['start'] = 0;
$pagination['count'] = 20;
$pagination['maxItems'] = 0;
$order_filter = $filter;
//var_dump($filter);exit;
/*
* Get orderproducts in need of sending a CPE
*/
//var_dump($order_filter);exit;
$orders = OrderModel::search($order_filter);
foreach($orders as $order) {
if($order_filter["hide_delayed_finish"] && $order->finish_after) {
// show at most 4 weeks before finish_after date
//$after_ts = Layout::dateToInt($order->finish_after);
if($order->finish_after > date("U") + (31 * 86400)) {
$this->log->debug("Before 4 weeks before finish_after oid ".$order->id);
continue;
}
}
if(is_array($order->terminations) && count($order->terminations)) {
if(!$order->cpeprovisioning_enabled && $order->terminations[0]->status->code < TT_TERMSTATUS_CONNECTED) {
continue;
}
}
foreach($order->products as $orderproduct) {
if($orderproduct->cpeprovisioning->routerconfig_finished == 1) {
if(!$filter['routerconfig_finished']) continue;
} else {
if($filter['routerconfig_finished']) continue;
}
$product = $orderproduct->product;
if(is_array($product->attributes) && count($product->attributes)) {
// filter out products without bras_type
if(array_key_exists("bras_type", $product->attributes) && $product->attributes['bras_type']->value) {
$cpeproducts[] = $orderproduct;
} else {
$this->log->debug("no bras_type oid ".$order->id);
continue;
}
} else {
// ignore products without attributes
$this->log->debug("no attributes oid ".$order->id);
continue;
}
}
}
$this->layout()->set("products", $cpeproducts);
}
private function getPreparedFilter($filter) {
$new_filter = [];
if(!is_array($filter)) $filter = [];
if(array_key_exists("hide_delayed_finish", $filter)) {
if($filter["hide_delayed_finish"] == "1") {
$new_filter["hide_delayed_finish"] = true;
} else {
$new_filter["hide_delayed_finish"] = false;
}
unset($filter["hide_delayed_finish"]);
} else {
$new_filter["hide_delayed_finish"] = true;
}
if(array_key_exists("routerconfig_finished", $filter)) {
if($filter["routerconfig_finished"] == "1") {
$new_filter["routerconfig_finished"] = true;
$new_filter["hide_delayed_finish"] = false;
} else {
$new_filter["routerconfig_finished"] = false;
$order_filter["finish_date"] = null;
}
unset($filter["routerconfig_finished"]);
} else {
$new_filter["routerconfig_finished"] = false;
$order_filter["finish_date"] = null;
}
$new_filter['upgrade'] = 0;
foreach($filter as $name => $value) {
$new_filter[$name] = $value;
}
//var_dump($new_filter);exit;
return $new_filter;
}
protected function saveAction() {
$r = $this->request;
$id = $r->id;
//var_dump($r);exit;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$cpeprovisioning = new Cpeprovisioning($id);
if(!$cpeprovisioning->id) {
$this->layout()->setFlash("Eintrag nicht gefunden", "error");
$this->redirect("Cpeprovisioning");
}
} else {
$mode = "add";
}
$order_id = $r->order_id;
$termination_id = $r->termination_id;
if(!(is_numeric($termination_id) && $termination_id > 0) && !(is_numeric($order_id) && $order_id > 0)) {
$this->layout()->setFlash("Anschluss oder Bestellung nicht gefunden", "error");
$this->redirect("Cpeprovisioning");
}
$orderproduct = OrderProductModel::getFirst(["order_id" => $order_id, "termination_id" => $termination_id]);
if(!$orderproduct) {
$this->layout()->setFlash("Anschluss gehört nicht zur Bestellung", "error");
$this->redirect("Cpeprovisioning");
}
$prov_data = [];
$prov_data["termination_id"] = ($r->termination_id) ? $r->termination_id : null;
$prov_data["order_id"] = $r->order_id;
$prov_data["orderproduct_id"] = $r->orderproduct_id;
$prov_data["routerconfig_finished"] = ($r->routerconfig_finished) ? 1 : 0;
$prov_data["routertype"] = $r->routertype;
$prov_data["shipping"] = ($r->shipping) ? 1 : 0;
$prov_data["wifi_ssid"] = $r->wifi_ssid;
$prov_data["wifi_pass"] = $r->wifi_pass;
$prov_data["mac"] = $r->mac;
$prov_data["vlan_public"] = (strlen($r->vlan_public)) ? $r->vlan_public : null;
$prov_data["vlan_nat"] = (strlen($r->vlan_nat)) ? $r->vlan_nat : null;
$prov_data["vlan_ipv6"] = (strlen($r->vlan_ipv6)) ? $r->vlan_ipv6 : null;
$prov_data["ship_weight"] = (strlen($r->ship_weight)) ? $r->ship_weight : null;
$prov_data["ship_length"] = (strlen($r->ship_length)) ? $r->ship_length : null;
$prov_data["ship_width"] = (strlen($r->ship_width)) ? $r->ship_width : null;
$prov_data["ship_height"] = (strlen($r->ship_height)) ? $r->ship_height : null;
$prov_data["note"] = $r->note;
$prov_data["edit_by"] = $this->me->id;
if($mode == "add") {
$prov_data["create_by"] = $this->me->id;
$cpeprovisioning = CpeprovisioningModel::create($prov_data);
} else {
$cpeprovisioning->update($prov_data);
}
//var_dump($prov_data);exit;
$new_id = $cpeprovisioning->save();
if(!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->redirect("Cpeprovisioning");
}
// saved successfully, if routerconfig_finished make Journal entry in Order
if($cpeprovisioning->routerconfig_finished) {
$order_product = new OrderProduct($r->orderproduct_id);
if($cpeprovisioning->shipping) {
$text = "CPE zu Produkt \"".$order_product->product->name."\" zum Versand vorbereitet.\n\n";
} else {
$text = "CPE zu Produkt \"".$order_product->product->name."\" vorbereitet für Techniker zur Vorortinstallation.\n\n";
}
$text .= "Router: ".$cpeprovisioning->routertype."\n";
$text .= "Zugangstyp: ".$order_product->product->attributes['bras_type']->value."\n";
if($cpeprovisioning->vlan_public) {
$text .= "Vlan Public: ".$cpeprovisioning->vlan_public."\n";
}
if($cpeprovisioning->vlan_nat) {
$text .= "Vlan NAT: ".$cpeprovisioning->vlan_nat."\n";
}
if($cpeprovisioning->vlan_ipv6) {
$text .= "Vlan IPv6: ".$cpeprovisioning->vlan_ipv6."\n";
}
class CpeprovisioningController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
$journal = new OrderJournal();
$journal->order_id = $order_id;
$journal->text = $text;
$journal->create_by = $this->me->id;
$journal->edit_by = $this->me->id;
$journal_id = $journal->save();
if(!$journal_id) {
$this->layout()->setFlash("Konnte nicht ins Bestelljournal schreiben!", "warning");
} else {
$cpeprovisioning->order_journal_id = $journal_id;
$cpeprovisioning->save();
}
}
// save ONT sn
if($r->ont_sn) {
$termination = new Termination($termination_id);
$orig_sn = $termination->getWorkflowvalue("ont_sn", "string");
if($orig_sn === null) {
$sn_item = WorkflowitemModel::getFirst(["name" => "ont_sn", "object_type" => "termination"]);
//var_dump($sn_item);exit;
//var_dump(mfValuecache::singleton()->get("wfItemvalue-item-".$sn_item->id."-object-".$termination_id));exit;
if(!$sn_item->id) {
$this->log->error("ont_sn workflow item not found");
} else {
$sn_item->setObjectId($termination_id);
$termination->workflowitems["ont_sn"] = $sn_item;
//$sn_item->value->setValue($r->ont_sn);
//$sn_item->value->save();
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
if($r->ont_sn != $orig_sn) {
$termination->workflowitems["ont_sn"]->value->setValue($r->ont_sn);
$termination->workflowitems["ont_sn"]->value->save();
}
}
$query = [];
if(is_numeric($this->request->s) && $this->request->s > 0) {
$query["s"] = $this->request->s;
protected function indexAction()
{
$cpecounter = 0;
$r = $this->request;
$page = $r->s;
$this->layout()->setTemplate("Cpeprovisioning/Index");
$cpeproducts = [];
$this->layout->set("filter", $this->request->filter);
$filter = $this->getPreparedFilter($this->request->filter);
// pagination defaults
$pagination = [];
$pagination['start'] = $page;
$pagination['count'] = 25;
$pagination['maxItems'] = 0;
$order_filter = $filter;
//var_dump($filter);exit;
/*
* Get orderproducts in need of sending a CPE
*/
//var_dump($order_filter);exit;
$orders = OrderModel::search($order_filter);
$orderproductsprefetch = OrderProductModel::precache();
foreach ($orders as $order) {
if ($order_filter["hide_delayed_finish"] && $order->finish_after) {
// show at most 4 weeks before finish_after date
//$after_ts = Layout::dateToInt($order->finish_after);
if ($order->finish_after > date("U") + (31 * 86400)) {
$this->log->debug("Before 4 weeks before finish_after oid " . $order->id);
continue;
}
}
if (is_array($orderproductsprefetch['terminations'][$order->id]) && count($orderproductsprefetch['terminations'][$order->id])) {
if (!$order->cpeprovisioning_enabled && $orderproductsprefetch['terminations'][$order->id][0]['statuscode'] < TT_TERMSTATUS_CONNECTED) {
continue;
}
}
foreach ($orderproductsprefetch[$order->id] as $orderproduct) {
if ($orderproduct['routerconfig_finished'] == 1) {
if (!$filter['routerconfig_finished']) continue;
} else {
if ($filter['routerconfig_finished']) continue;
}
$productattributes = $orderproduct['attributes'];
if (is_array($productattributes) && count($productattributes)) {
// filter out products without bras_type
if (array_key_exists("bras_type", $productattributes) && $productattributes) {
$pagination['maxItems']++;
if ($pagination['maxItems'] >= $pagination['start']+1 && $pagination['maxItems'] <= $pagination['start'] + $pagination['count']) {
$cpeproducts[] = OrderProductModel::getOne($orderproduct['id']);
}
} else {
$this->log->debug("no bras_type oid " . $order->id);
continue;
}
} else {
// ignore products without attributes
$this->log->debug("no attributes oid " . $order->id);
continue;
}
}
}
$this->layout()->set("pagination", $pagination);
$this->layout()->set("products", $cpeproducts);
}
if (is_array($this->request->filter)) {
$query["filter"] = $this->request->filter;
private function getPreparedFilter($filter)
{
$new_filter = [];
if (!is_array($filter)) $filter = [];
if (array_key_exists("hide_delayed_finish", $filter)) {
if ($filter["hide_delayed_finish"] == "1") {
$new_filter["hide_delayed_finish"] = true;
} else {
$new_filter["hide_delayed_finish"] = false;
}
unset($filter["hide_delayed_finish"]);
} else {
$new_filter["hide_delayed_finish"] = true;
}
if (array_key_exists("routerconfig_finished", $filter)) {
if ($filter["routerconfig_finished"] == "1") {
$new_filter["routerconfig_finished"] = true;
$new_filter["hide_delayed_finish"] = false;
} else {
$new_filter["routerconfig_finished"] = false;
$order_filter["finish_date"] = null;
}
unset($filter["routerconfig_finished"]);
} else {
$new_filter["routerconfig_finished"] = false;
$order_filter["finish_date"] = null;
}
$new_filter['upgrade'] = 0;
foreach ($filter as $name => $value) {
$new_filter[$name] = $value;
}
//var_dump($new_filter);exit;
return $new_filter;
}
$qs = http_build_query($query);
$this->layout()->setFlash("Eintrag erfolgreich gespeichert.", "success");
$this->redirect("Cpeprovisioning","Index", $qs);
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r);exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$cpeprovisioning = new Cpeprovisioning($id);
if (!$cpeprovisioning->id) {
$this->layout()->setFlash("Eintrag nicht gefunden", "error");
$this->redirect("Cpeprovisioning");
}
} else {
$mode = "add";
}
$order_id = $r->order_id;
$termination_id = $r->termination_id;
if (!(is_numeric($termination_id) && $termination_id > 0) && !(is_numeric($order_id) && $order_id > 0)) {
$this->layout()->setFlash("Anschluss oder Bestellung nicht gefunden", "error");
$this->redirect("Cpeprovisioning");
}
$orderproduct = OrderProductModel::getFirst(["order_id" => $order_id, "termination_id" => $termination_id]);
if (!$orderproduct) {
$this->layout()->setFlash("Anschluss gehört nicht zur Bestellung", "error");
$this->redirect("Cpeprovisioning");
}
$prov_data = [];
$prov_data["termination_id"] = ($r->termination_id) ? $r->termination_id : null;
$prov_data["order_id"] = $r->order_id;
$prov_data["orderproduct_id"] = $r->orderproduct_id;
$prov_data["routerconfig_finished"] = ($r->routerconfig_finished) ? 1 : 0;
$prov_data["routertype"] = $r->routertype;
$prov_data["shipping"] = ($r->shipping) ? 1 : 0;
$prov_data["wifi_ssid"] = $r->wifi_ssid;
$prov_data["wifi_pass"] = $r->wifi_pass;
$prov_data["mac"] = $r->mac;
$prov_data["vlan_public"] = (strlen($r->vlan_public)) ? $r->vlan_public : null;
$prov_data["vlan_nat"] = (strlen($r->vlan_nat)) ? $r->vlan_nat : null;
$prov_data["vlan_ipv6"] = (strlen($r->vlan_ipv6)) ? $r->vlan_ipv6 : null;
$prov_data["ship_weight"] = (strlen($r->ship_weight)) ? $r->ship_weight : null;
$prov_data["ship_length"] = (strlen($r->ship_length)) ? $r->ship_length : null;
$prov_data["ship_width"] = (strlen($r->ship_width)) ? $r->ship_width : null;
$prov_data["ship_height"] = (strlen($r->ship_height)) ? $r->ship_height : null;
$prov_data["note"] = $r->note;
$prov_data["edit_by"] = $this->me->id;
if ($mode == "add") {
$prov_data["create_by"] = $this->me->id;
$cpeprovisioning = CpeprovisioningModel::create($prov_data);
} else {
$cpeprovisioning->update($prov_data);
}
//var_dump($prov_data);exit;
$new_id = $cpeprovisioning->save();
if (!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->redirect("Cpeprovisioning");
}
// saved successfully, if routerconfig_finished make Journal entry in Order
if ($cpeprovisioning->routerconfig_finished) {
$order_product = new OrderProduct($r->orderproduct_id);
if ($cpeprovisioning->shipping) {
$text = "CPE zu Produkt \"" . $order_product->product->name . "\" zum Versand vorbereitet.\n\n";
} else {
$text = "CPE zu Produkt \"" . $order_product->product->name . "\" vorbereitet für Techniker zur Vorortinstallation.\n\n";
}
$text .= "Router: " . $cpeprovisioning->routertype . "\n";
$text .= "Zugangstyp: " . $order_product->product->attributes['bras_type']->value . "\n";
if ($cpeprovisioning->vlan_public) {
$text .= "Vlan Public: " . $cpeprovisioning->vlan_public . "\n";
}
if ($cpeprovisioning->vlan_nat) {
$text .= "Vlan NAT: " . $cpeprovisioning->vlan_nat . "\n";
}
if ($cpeprovisioning->vlan_ipv6) {
$text .= "Vlan IPv6: " . $cpeprovisioning->vlan_ipv6 . "\n";
}
$journal = new OrderJournal();
$journal->order_id = $order_id;
$journal->text = $text;
$journal->create_by = $this->me->id;
$journal->edit_by = $this->me->id;
$journal_id = $journal->save();
if (!$journal_id) {
$this->layout()->setFlash("Konnte nicht ins Bestelljournal schreiben!", "warning");
} else {
$cpeprovisioning->order_journal_id = $journal_id;
$cpeprovisioning->save();
}
}
// save ONT sn
if ($r->ont_sn) {
$termination = new Termination($termination_id);
$orig_sn = $termination->getWorkflowvalue("ont_sn", "string");
if ($orig_sn === null) {
$sn_item = WorkflowitemModel::getFirst(["name" => "ont_sn", "object_type" => "termination"]);
//var_dump($sn_item);exit;
//var_dump(mfValuecache::singleton()->get("wfItemvalue-item-".$sn_item->id."-object-".$termination_id));exit;
if (!$sn_item->id) {
$this->log->error("ont_sn workflow item not found");
} else {
$sn_item->setObjectId($termination_id);
$termination->workflowitems["ont_sn"] = $sn_item;
//$sn_item->value->setValue($r->ont_sn);
//$sn_item->value->save();
}
}
if ($r->ont_sn != $orig_sn) {
$termination->workflowitems["ont_sn"]->value->setValue($r->ont_sn);
$termination->workflowitems["ont_sn"]->value->save();
}
}
$query = [];
if (is_numeric($this->request->s) && $this->request->s > 0) {
$query["s"] = $this->request->s;
}
if (is_array($this->request->filter)) {
$query["filter"] = $this->request->filter;
}
$qs = http_build_query($query);
$this->layout()->setFlash("Eintrag erfolgreich gespeichert.", "success");
$this->redirect("Cpeprovisioning", "Index", $qs);
}
}

View File

@@ -11,8 +11,13 @@ class DashboardController extends mfBaseController {
}
protected function indexAction() {
if($this->me->is("preorderfront")) {
$this->redirect("Preorder");
}
$newss = NewsModel::getAll();
$this->layout()->set("newss", $newss);
}

View File

@@ -2,7 +2,6 @@
class DeviceController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
@@ -42,7 +41,9 @@ class DeviceController extends mfBaseController
}
$this->layout()->setTemplate("Device/Detail");
$devicesconfig = DeviceModel::getconifg($id);
$devices = DeviceModel::getOne($id);
$this->layout()->set("devicesconfig", $devicesconfig);
$this->layout()->set("devices", $devices);
}
@@ -60,13 +61,13 @@ class DeviceController extends mfBaseController
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Gerät nicht gefunden", "error");
$this->layout()->setFlash("Device nicht gefunden", "error");
$this->redirect("Device");
}
$device = new Device($id);
if ($device->id != $id) {
$this->layout()->setFlash("Gerät nicht gefunden", "error");
$this->layout()->setFlash("Device nicht gefunden", "error");
$this->redirect("Device");
}
@@ -93,14 +94,44 @@ class DeviceController extends mfBaseController
$data = [];
$data['name'] = trim($r->name);
$data['devicetype_id'] = $r->devicetype_id;
if (trim($r->pop_id)=="0") {
if (trim($r->pop_id) == "0") {
$data['pop_id'] = NULL;
} else {
$data['pop_id'] = $r->pop_id;
}
if (!(trim($r->addr_street))) {
$data['addr_street'] = NULL;
$data['addr_number'] = NULL;
$data['addr_extended'] = NULL;
$data['addr_zip'] = NULL;
$data['addr_city'] = NULL;
} else {
$data['addr_street'] = $r->addr_street;
$data['addr_number'] = $r->addr_number;
$data['addr_extended'] = $r->addr_extended;
$data['addr_zip'] = $r->addr_zip;
$data['addr_city'] = $r->addr_city;
}
if (!trim($r->gps_lat) || !trim($r->gps_long)) {
$data['gps_lat'] = NULL;
$data['gps_long'] = NULL;
} else {
$data['gps_lat'] = $r->gps_lat;
$data['gps_long'] = $r->gps_long;
}
$data['ip'] = $r->ip;
$data['mac'] = $r->mac;
$data['serial'] = $r->serial;
if (empty(trim($r->price))) {
$data['price'] = "0.00";
} else {
$data['price'] = $r->price;
}
if (empty(trim($r->power))) {
$data['power'] = "0.0";
} else {
$data['power'] = $r->power;
}
$data['comment'] = $r->comment;
$ipv4_validation_regex = "/^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/";
@@ -133,11 +164,8 @@ class DeviceController extends mfBaseController
// exit;
$id = $device->save();
if (!$id) {
$this->layout()->setFlash("Device konnte nicht angelegt werden", "error");
$this->redirect("Device");
}
$returnUrl="Device";
$returnUrl = "Device";
$returnAction = "Index";
$returnVariables = array();
$returnAnker = "";
@@ -163,6 +191,15 @@ class DeviceController extends mfBaseController
}
}
if (!$id) {
$returnVariables['id'] = $r->id;
if ($mode == "edit") {
$this->layout()->setFlash("Device konnte nicht gespeichert werden", "error");
} else if ($mode = "add") {
$this->layout()->setFlash("Device konnte nicht angelegt werden", "error");
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
if ($mode == "edit") {
$this->layout()->setFlash("Device erfolgreich geändert", "success");
@@ -171,4 +208,75 @@ class DeviceController extends mfBaseController
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
protected function apiAction()
{
if (!$this->me->is(["Admin"])) {
$this->redirect("Dashboard");
}
$do = $this->request->do;
$format = $this->request->format;
$filename = $this->request->filename;
$id = $this->request->id;
$ip = $this->request->ip;
$data = [];
switch ($do) {
case "getconfig":
$return = $this->getConfig($id, $format, $filename);
break;
case "createconfig":
$return = $this->createConfig($ip);
break;
default:
$return = false;
}
}
protected function deleteAction()
{
$id = $this->request->id;
$device = new Device($id);
if (!$device->id || $device->id != $id) {
$this->layout()->setFlash("Gerätetyp nicht gefunden.", "error");
$this->redirect("Device");
}
$device->delete();
$this->redirect("Device");
}
private function getConfig($id, $format, $filename)
{
$configDownload = DeviceModel::getconifgdownload($id, $format);
//
// header('Content-Type: application/octet-stream');
header('Content-Type: text/plain');
header('Content-disposition: attachment; filename="' . $filename . '"');
echo $configDownload;
exit;
}
private function createConfig($ip)
{
$r = $this->request;
$id = $r->id;
$createConfig = DeviceModel::configcreate($ip);
if ($createConfig->success === "true") {
$this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success");
} elseif (!TT_MBI_API_ENABLE) {
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: Schnittstellenserver wurde vom Admin deaktiviert.", "error");
} else {
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: " . $createConfig->error, "error");
}
$returnUrl = "Device";
$returnAction = "Detail";
$returnVariables['id'] = $id;
return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
}

View File

@@ -5,27 +5,34 @@ class DeviceModel
public $name = null;
public $ip = null;
public $mac = null;
public $serial= null;
public $comment= null;
public $serial = null;
public $comment = null;
public $devicetype_id = null;
public $pop_id = null;
public $addr_street = null;
public $addr_number = null;
public $addr_extended = null;
public $addr_zip = null;
public $gps_lat = null;
public $addr_city = null;
public $gps_long = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function find($data) {
public static function find($data)
{
}
public static function create(Array $data) {
public static function create(array $data)
{
$model = new Device();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
if(substr($field, 0, 5) == "vlan_" && !$value) {
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
if (substr($field, 0, 5) == "vlan_" && !$value) {
$model->$field = null;
continue;
}
@@ -34,45 +41,47 @@ class DeviceModel
}
$me = mfValuecache::singleton()->get("me");
if(!$me) {
if (!$me) {
$me = new User();
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if($model->create_by === null) {
if ($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
if ($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Device", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Device($data);
}
return $item;
}
public static function getAll() {
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Device", "*");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Device($data);
}
}
@@ -80,15 +89,16 @@ class DeviceModel
}
public static function getFirst() {
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Device", "*", "$where ORDER BY name, network_id");
if($db->num_rows($res)) {
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Device($data);
if($item->id) {
if ($item->id) {
return $item;
} else {
return null;
@@ -97,26 +107,28 @@ class DeviceModel
return null;
}
public static function search($filter) {
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Device", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Device($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if(array_key_exists("pop_id", $filter)) {
if (array_key_exists("pop_id", $filter)) {
$popid = $filter['pop_id'];
if(is_numeric($popid)) {
if (is_numeric($popid)) {
$where .= " AND pop_id=$popid";
}
}
@@ -124,4 +136,83 @@ class DeviceModel
//var_dump($filter, $where);exit;
return $where;
}
public static function getconifg($id)
{
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigs/' . $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
public static function getconifgdownload($id, $format)
{
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigsdownload/' . $id . '/' . $format,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return ($response);
}
public static function configcreate($ip)
{
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigscreate/' . $ip,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
endif;
return json_decode($response);
}
}

View File

@@ -1,5 +1,4 @@
<?php
class Devicemanufactor extends mfBaseModel
{
private $editor;

View File

@@ -1,5 +1,4 @@
<?php
class DevicemanufactorController extends mfBaseController
{
@@ -68,6 +67,7 @@ class DevicemanufactorController extends mfBaseController
$data = [];
$data['name'] = trim($r->name);
$data['config_backup'] = trim($r->config_backup);
if (!$data['name']) {

View File

@@ -1,5 +1,4 @@
<?php
class DevicemanufactorModel {
public $name = null;

View File

@@ -24,7 +24,7 @@ private $file;
return $this->editor;
}
if($name == "histories") {
$this->histories=FilestoreHistoryModel::search(["filestore_id="=>$this->id]);
$this->histories=FilestoreHistoryModel::search(["filestore_id$filter"=>$this->id]);
return $this->histories;
}

View File

@@ -19,26 +19,21 @@ class FilestoreController extends mfBaseController
{
$this->layout()->setTemplate("Filestore/Index");
$files = FilestoreModel::getAll();
$fileshistory = FilestoreHistoryModel::getAll();
$networkaddress = NetworkAddressModel::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);
$this->layout()->set("fileshistory", $fileshistory);
$this->layout()->set("networkaddresses", $networkaddress);
}
protected function addAction()
{
$this->layout()->set("networks", NetworkModel::getAll());
$this->layout()->set("networkaddresses", NetworkAddressModel::getAll());
$this->layout()->setTemplate("Filestore/Form");
}
@@ -46,9 +41,12 @@ class FilestoreController extends mfBaseController
{
$r = $this->request;
$id = $r->id;
$editmode = $r->mode;
//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");
@@ -59,23 +57,37 @@ class FilestoreController extends mfBaseController
$dataHistory['name'] = $filestore->name;
$dataHistory['description'] = $filestore->description;
$dataHistory['file_id'] = $filestore->file_id;
$dataHistory['network_id'] = $filestore->network_id;
$dataHistory['filestore_id'] = $filestore->id;
$dataHistory['create'] = $filestore->create;
$dataHistory['create_by'] = $filestore->create_by;
$dataHistory['edit'] = date("U");
$dataHistory['edit_by'] = $filestore->edit_by;
// $dataHistory['edit'] = date("U");
$dataHistory['edit'] = $filestore->edit;
} else {
$mode = "add";
}
$data = [];
$data['name'] = trim($r->name);
$data['description'] = trim($r->description);
if ($editmode != "add-version" && $editmode != "edit-history") {
$data['name'] = trim($r->name);
$data['network_id'] = trim($r->network_id);
}
if (!$data['name']) {
$data['description'] = trim($r->description);
$data['edit_by'] = trim($this->me->id);
if (!$data['name'] && $editmode != "add-version" && $editmode != "edit-history") {
$this->layout()->setFlash("Name darf nicht leer sein", "error");
$this->redirect("Filestore");
}
if (!$data['network_id'] && $editmode != "add-version" && $editmode != "edit-history") {
$this->layout()->setFlash("Netzgebiet darf nicht leer sein", "error");
$this->redirect("Filestore");
}
if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) {
$upload_error = false;
@@ -113,14 +125,17 @@ class FilestoreController extends mfBaseController
}
$data['file_id'] = $file_id;
if ($mode == "edit") {
if ($mode == "edit" && $editmode == "add-version") {
$fsh = FilestoreHistoryModel::create($dataHistory);
}
} else {
if ($mode == "add") {
if ($mode == "add" || $editmode == "add-version") {
$this->layout()->setFlash("Keine Datei angegeben", "error");
$this->redirect("Filestore", "add");
if ($editmode == "add-version") {
$this->redirect("Filestore");
} else {
$this->redirect("Filestore", "add");
}
}
}
@@ -141,7 +156,7 @@ class FilestoreController extends mfBaseController
$id = $filestore->save();
if (!$id) {
$this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error");
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
$this->redirect("Filestore");
}
if ($fsh) {
@@ -155,19 +170,28 @@ class FilestoreController extends mfBaseController
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if ($r->mode) {
$mode = $r->mode;
} else {
$mode = "";
}
if (!is_numeric($id) && $id < 1) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
$filestore = new Filestore($id);
$filestore = new Filestore($id);
$filestorehistory = FilestoreHistoryModel::getAllhistory($id);;
if (!$filestore->id) {
$this->layout()->setFlash("Datei nicht gefunden", "error");
$this->redirect("Filestore");
}
if ($mode) {
$this->layout()->set("mode", $mode);
}
$this->layout()->set("filestorehistory", $filestorehistory);
$this->layout()->set("file", $filestore);
return $this->addAction();
@@ -187,11 +211,41 @@ class FilestoreController extends mfBaseController
foreach ($filstore->histories as $h) {
$h->file->delete();
$h->delete();
}
$filstore->file->delete();
// check if Product is unused
$filstore->delete();
$this->redirect("Filestore");
}
protected function apiAction()
{
if (!$this->me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) {
$this->redirect("Dashboard");
}
$id = $this->request->id;
$filestorehistory = FilestoreHistoryModel::getAllhistory($id);
$counter = 0;
foreach ($filestorehistory as $history) {
$data[$counter]['id'] = $history->id;
$data[$counter]['file_id'] = $history->data->file_id;
$data[$counter]['name'] = $history->data->name;
$data[$counter]['description'] = $history->data->description;
$data[$counter]['workername'] = $history->data->workername;
$data[$counter]['workerid'] = $history->data->workerid;
$data[$counter]['edit'] = $history->edit;
if (trim($this->me->id) == $history->data->workerid || $this->me->is(["Admin"])) {
$data[$counter]['is_delete'] = 1;
} else {
$data[$counter]['is_delete'] = 0;
}
$counter++;
}
echo json_encode($data);
exit;
}
}

View File

@@ -4,6 +4,7 @@ class FilestoreModel
{
public $order_id;
public $file_id;
public $network_id;
public $name;
public $description;
@@ -54,11 +55,13 @@ class FilestoreModel
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT Filestore.* FROM Filestore
$sql = "SELECT Filestore.*,Network.name network,Network.id networkid FROM Filestore
LEFT JOIN File ON (Filestore.file_id = File.id)
LEFT JOIN Network ON (Filestore.network_id = Network.id)
ORDER BY name";
$res = $db->query($sql);
if ($db->num_rows($res)) {

View File

@@ -147,5 +147,19 @@ class FilestoreHistoryController extends mfBaseController
return $this->addAction();
}
protected function deleteAction()
{
$id = $this->request->id;
$filstorehistory = new FilestoreHistory($id);
if (!$filstorehistory->id || $filstorehistory->id != $id) {
$this->layout()->setFlash("Datei nicht gefunden.", "error");
$this->redirect("Filestore");
}
$filstorehistory->delete();
$this->redirect("Filestore");
}
}

View File

@@ -58,8 +58,28 @@ class FilestoreHistoryModel
$db = FronkDB::singleton();
$sql = "SELECT FilestoreHistory.* FROM FilestoreHistory
";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$items[$data['filestore_id']] = 1;
}
}
return $items;
}
public static function getAllhistory($id)
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT FilestoreHistory.*,Worker.name workername,Worker.id workerid FROM FilestoreHistory
LEFT JOIN File ON (FilestoreHistory.file_id = File.id)
ORDER BY name";
INNER JOIN Worker ON (FilestoreHistory.edit_by=Worker.id)
WHERE `filestore_id` ='" . $id . "'
ORDER BY edit DESC";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
@@ -94,12 +114,10 @@ class FilestoreHistoryModel
$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)) {

View File

@@ -1,145 +1,204 @@
<?php
class OrderProductModel {
public $order_id;
public $product_id;
public $termination_id;
public $upgrade;
public $amount;
public $pos;
public $description;
public $price;
public $price_setup;
public $price_nne;
public $price_nbe;
public $billing_delay;
public $billing_period;
public $note;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
class OrderProductModel
{
public $order_id;
public $product_id;
public $termination_id;
public $upgrade;
public $amount;
public $pos;
public $description;
public $price;
public $price_setup;
public $price_nne;
public $price_nbe;
public $billing_delay;
public $billing_period;
public $note;
public static function create(Array $data) {
$model = new OrderProduct();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(array $data)
{
$model = new OrderProduct();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
if (!array_key_exists("note", $data)) {
$model->note = "";
}
$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;
}
if(!array_key_exists("note", $data)) {
$model->note = "";
}
$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("OrderProduct", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new OrderProduct($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("OrderProduct", "*", "1=1 ORDER BY order_id, pos, product_id, description");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new OrderProduct($data);
}
}
return $items;
}
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("OrderProduct", "*", "$where ORDER BY order_id, pos, product_id, description");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new OrderProduct($data);
if($item->id) {
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("OrderProduct", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new OrderProduct($data);
}
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM OrderProduct WHERE $where ORDER BY order_id, pos, product_id, description";
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new OrderProduct($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
//var_dump($filter);exit;
if(array_key_exists("order_id", $filter)) {
$order_id = $filter['order_id'];
if(is_numeric($order_id)) {
$where .= " AND order_id=$order_id";
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("OrderProduct", "*", "1=1 ORDER BY order_id, pos, product_id, description");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new OrderProduct($data);
}
}
return $items;
}
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
$where .= " AND order_id=$product_id";
}
public static function getFirst($filter = false)
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("OrderProduct", "*", "$where ORDER BY order_id, pos, product_id, description");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new OrderProduct($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
if(array_key_exists("termination_id", $filter)) {
$termination_id = $filter['termination_id'];
if(is_numeric($termination_id)) {
$where .= " AND termination_id=$termination_id";
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM OrderProduct WHERE $where ORDER BY order_id, pos, product_id, description";
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new OrderProduct($data);
}
}
return $items;
}
//var_dump($filter, $where);exit;
return $where;
}
public static function precache()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `OrderProduct`.`id`, `OrderProduct`.`order_id`, `OrderProduct`.`product_id`, `OrderProduct`.`termination_id`
,`ProducttechAttribute`.`name` ProducttechAttributename,
`routerconfig_finished`,
`Termination`.`id` `terminationid`,
`Terminationstatus`.`code` `statuscode`
FROM `OrderProduct`
INNER JOIN `Product` ON (`OrderProduct`.`product_id`=`Product`.`id`)
INNER JOIN `Producttech` ON (`Producttech`.`id`=`Product`.`producttech_id`)
INNER JOIN `ProductAttribute` ON (`ProductAttribute`.`product_id`=`Product`.`id`)
INNER JOIN `ProducttechAttribute` ON (`ProductAttribute`.`producttechattribute_id`=`ProducttechAttribute`.`id`)
LEFT JOIN `Termination` ON (`OrderProduct`.`termination_id`=`Termination`.`id`)
LEFT JOIN `Terminationstatus` ON (`Terminationstatus`.`id` = `Termination`.`status_id`)
LEFT JOIN `Cpeprovisioning` ON (`Cpeprovisioning`.`orderproduct_id`=`OrderProduct`.`id`)
";
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if ($db->num_rows($res)) {
$oldProduct = "";
$oldOrder = "";
while ($data = $db->fetch_array($res)) {
if ($data['terminationid'])
{
$items['terminations'][$data['order_id']][]['statuscode']=$data['statuscode'];
}
if ($oldOrder != $data['order_id']) {
$items[$data['order_id']]['statuscode'] = $data['statuscode'];
}
if ($oldProduct != $data['id']) {
$items[$data['order_id']][$data['id']]['id'] = $data['id'];
$items[$data['order_id']][$data['id']]['product_id'] = $data['product_id'];
$items[$data['order_id']][$data['id']]['termination_id'] = $data['termination_id'];
$items[$data['order_id']][$data['id']]['routerconfig_finished'] = $data['routerconfig_finished'];
}
if ($data['routerconfig_finished'] == 1) {
$items[$data['order_id']][$data['id']]['routerconfig_finished'] = $data['routerconfig_finished'];
}
$items[$data['order_id']][$data['id']]['attributes'][$data['ProducttechAttributename']] = $data['ProducttechAttributename'];
$oldProduct = $data['id'];
$oldOrder = $data['order_id'];
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("order_id", $filter)) {
$order_id = $filter['order_id'];
if (is_numeric($order_id)) {
$where .= " AND order_id=$order_id";
}
}
if (array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if (is_numeric($product_id)) {
$where .= " AND order_id=$product_id";
}
}
if (array_key_exists("termination_id", $filter)) {
$termination_id = $filter['termination_id'];
if (is_numeric($termination_id)) {
$where .= " AND termination_id=$termination_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -8,6 +8,7 @@ class Preorder extends mfBaseModel {
private $building;
private $adb_hausnummer;
private $adb_wohneinheit;
private $attribute = [];
public function afterLoad() {
@@ -184,6 +185,14 @@ class Preorder extends mfBaseModel {
}
if($name == "attribute") {
if(!$this->attributes) {
return null;
}
$this->attribute = json_decode($this->attributes, true);
return $this->attribute;
}
if($name == "creator") {
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($user) {
@@ -219,4 +228,35 @@ class Preorder extends mfBaseModel {
return $this->$name;
}
public function __clone() {
$me = new User;
$me->loadMe();
$old_id = $this->id;
//$old_ucode = $this->ucode;
$this->id = null;
$this->data = clone($this->data);
$this->_old_data = new StdClass();
$this->status = null;
$this->campaign = null;
$this->partner = null;
$this->building = null;
$this->adb_hausnummer = null;
$this->adb_wohneinheit;
// cleanup Preorder data
$this->create_by = $me->id;
$this->edit_by = $me->id;
$this->create = null;
$this->edit = null;
$this->saved = 0;
$this->mode = "new";
//$this->save();
$this->log->debug("Cloned Preorder $old_id");
}
}

View File

@@ -9,7 +9,7 @@ class PreorderController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin", "netowner", "salespartner"])) {
if(!$me->is(["Admin", "netowner", "salespartner", "preorderfront"])) {
$this->redirect("Dashboard");
}
}
@@ -24,7 +24,6 @@ class PreorderController extends mfBaseController {
$this->layout->set("filter", $rfilter);
$where = "";
$filter = $this->getPreparedFilter($rfilter);
// pagination defaults
@@ -37,7 +36,6 @@ class PreorderController extends mfBaseController {
$pagination['start'] = intval($this->request->s);
}
$preorder_filter = $filter;
$my_campaigns = [];
$my_campaign_ids = [];
@@ -49,7 +47,20 @@ class PreorderController extends mfBaseController {
}
$this->layout()->set("my_campaigns", PreordercampaignModel::getAll());
} else {
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
if($this->me->is("preorderfront")) {
$pns = json_decode($this->me->getFlag("preorder_networks"));
if(is_array($pns) && count($pns)) {
foreach($pns as $pn_id) {
$my_networks[] = new Network($pn_id);
}
} else {
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
}
//var_dump($my_networks);exit;
} else {
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
}
//var_dump($my_networks);exit;
foreach($my_networks as $network) {
@@ -70,6 +81,8 @@ class PreorderController extends mfBaseController {
} else {
$filter['preordercampaign_id'] = $my_campaign_ids;
}
if(!$filter['preordercampaign_id']) $filter['preordercampaign_id'] = 0;
}
if($filter['addon_services']) {
@@ -101,14 +114,19 @@ class PreorderController extends mfBaseController {
$new_filter['add-where'] = "";
if(array_key_exists("address", $filter)) {
if(array_key_exists("address", $filter) && $filter["address"]) {
$address = $this->db()->escape($filter['address']);
$new_filter['add-where'] .= " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%')";
}
if(array_key_exists("kunde", $filter)) {
if(array_key_exists("hausnummer", $filter) && $filter["hausnummer"]) {
$hausnummer = $this->db()->escape($filter['hausnummer']);
$new_filter['hausnummer'] = $hausnummer;
}
if(array_key_exists("kunde", $filter) && $filter["kunde"]) {
$kunde = $this->db()->escape($filter['kunde']);
$new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR street like '%$kunde%' OR zip like '%$kunde%' OR city like '%$kunde%')";
$new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR concat(firstname, ' ', lastname) like '%$kunde%' OR concat(lastname, ' ', firstname) like '%$kunde%' OR street like '%$kunde%' OR zip like '%$kunde%' OR city like '%$kunde%')";
}
@@ -126,6 +144,18 @@ class PreorderController extends mfBaseController {
}
}
if(array_key_exists("unit_missing", $filter)) {
if($filter['unit_missing'] == "yes") {
$new_filter['adb_wohneinheit_id'] = null;
} elseif($filter['unit_missing'] == "no") {
$new_filter['adb_wohneinheit_id'] = true;
}
unset($filter['unit_missing']);
}
if(array_key_exists("attributes", $filter) && count($filter['attributes'])) {
}
if(is_array($filter) && count($filter)) {
foreach($filter as $name => $value) {
@@ -586,4 +616,185 @@ class PreorderController extends mfBaseController {
}
protected function exportAction() {
$rfilter = $this->request->filter;
if(!is_array($rfilter)) {
$rfilter = [];
}
$filter = $this->getPreparedFilter($rfilter);
if($this->me->is("Admin")) {
$my_networks = NetworkModel::getAll();
} else {
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
}
$netzgebiet_ids = [];
$my_adb_networks = [];
foreach($my_networks as $network) {
if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) {
$netzgebiet_ids[] = $network->id;
$my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id);
}
}
unset($filter['network_id']);
$preorder_filter = $filter;
$campaign_ids = [];
foreach(PreordercampaignModel::search(["network_id" => $netzgebiet_ids]) as $campaign) {
if(!in_array($campaign->id, $campaign_ids)) {
$campaign_ids[] = $campaign->id;
}
}
if(array_key_exists("preordercampaign_id", $filter) && in_array($filter['preordercampaign_id'], $campaign_ids)) {
$preorder_filter["preordercampaign_id"] = $filter['preordercampaign_id'];
} else {
$preorder_filter["preordercampaign_id"] = $campaign_ids;
}
$preorder_filter['<status_code'] = 800;
// Get mysqli resource from Model, so layout can output data as it's retrieved
// Works around lousy performance and horrendous memory usage
$res = PreorderModel::search($preorder_filter, [], true);
$this->layout()->setTemplate("Preorder/export.csv");
$this->layout()->set("res", $res);
}
protected function apiAction() {
if(!$this->me->is(["Admin","netowner","salespartner","preorderfront"])) {
$this->redirect("Dashboard");
}
$do = $this->request->do;
$data = [];
switch($do) {
case "saveAttribute":
$return = $this->saveAttributeApi();
break;
case "getFilteredPreorders":
$return = $this->getFilteredPreordersApi();
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);
}
private function getFilteredPreordersApi() {
$preorders = [];
$filter = [];
if(is_array($this->request->filter)) {
$filter = $this->request->filter;
}
$filter = $this->getPreparedFilter($filter);
$my_campaign_ids = [];
if($this->me->is("Admin")) {
$my_networks = NetworkModel::getAll();
} else {
if($this->me->is("preorderfront")) {
$pns = json_decode($this->me->getFlag("preorder_networks"));
if(is_array($pns) && count($pns)) {
foreach($pns as $pn_id) {
$my_networks[] = new Network($pn_id);
}
} else {
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
}
//var_dump($my_networks);exit;
} else {
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
}
foreach($my_networks as $network) {
foreach(PreordercampaignModel::search(['network_id' => $network->id]) as $campaign) {
$my_campaigns[] = $campaign;
if(!in_array($campaign->id, $my_campaign_ids)) $my_campaign_ids[] = $campaign->id;
}
}
if(array_key_exists("preordercampaign_id", $filter)) {
if(!in_array($filter['preordercampaign_id'], $my_campaign_ids)) {
$filter['preordercampaign_id'] = $my_campaign_ids;
}
} else {
$filter['preordercampaign_id'] = $my_campaign_ids;
}
}
if(!$filter['preordercampaign_id']) $filter['preordercampaign_id'] = 0;
//var_dump($filter);exit;
$results = PreorderModel::search($filter);
foreach($results as $preorder) {
//$this->log->debug("building status: ".print_r($building->status,true));
$data = clone($preorder->data);
$data->id = $preorder->id;
$data->status_code = $preorder->status->code;
$data->adrcd = $preorder->adb_hausnummer->adrcd;
$data->extref = $preorder->adb_hausnummer->extref;
$data->adb_strasse = $preorder->adb_hausnummer->strasse->name;
$data->adb_hausnummer = $preorder->adb_hausnummer->hausnummer;
$data->adb_plz = $preorder->adb_hausnummer->plz->plz;
$data->adb_ort = $preorder->adb_hausnummer->ortschaft->name;
$data->adb_gemeinde = $preorder->adb_hausnummer->strasse->gemeinde->name;
$data->gps_lat = $preorder->adb_hausnummer->gps_lat;
$data->gps_long = $preorder->adb_hausnummer->gps_long;
$data->type_label = __($data->type, "preorder");
$data->connection_type_label = __($data->connection_type, "preorder");
$preorders[] = $data;
}
return ["preorders" => $preorders];
}
private function saveAttributeApi() {
$preorder_id = $this->request->id;
if(!is_numeric($preorder_id) || $preorder_id < 1) {
return false;
}
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
return false;
}
$attribute = $this->request->attribute;
if(!$attribute) {
return false;
}
$value = $this->request->value;
$attribs = $preorder->attribute;
if(!$attribs) {
$attribs = [];
}
$attribs[$attribute] = $value ? 1 : 0;
$preorder->attributes = json_encode($attribs);
if($preorder->save()) {
return ["id" => $preorder_id, "attribute" => $attribute, "update" => date("d.m.Y H:i", $preorder->edit)];
} else {
$this->returnJson(["status" => "error", "result" => ["id" => $preorder_id, "attribute" => $attribute]]);
}
}
}

View File

@@ -51,6 +51,7 @@ class PreorderModel {
public $shipping_address;
public $addon_services;
public $addon_data;
public $attributes;
public $submit_type;
public $submit_request;
@@ -216,6 +217,7 @@ class PreorderModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
WHERE $where
";
@@ -230,7 +232,7 @@ class PreorderModel {
return 0;
}
public static function search($filter, $limit = false) {
public static function search($filter, $limit = false, $returnDBRessource = false) {
$items = [];
$db = FronkDB::singleton();
@@ -255,6 +257,12 @@ class PreorderModel {
$res = $db->query($sql);
if($db->num_rows($res)) {
// hack for Preorder::exportAction
if($returnDBRessource) {
return $res;
}
while($data = $db->fetch_object($res)) {
$items[] = new Preorder($data);
}
@@ -364,6 +372,8 @@ class PreorderModel {
$where .= " AND adb_wohneinheit_id IN (".implode(",",$adb_wohneinheit_id).")";
} elseif($adb_wohneinheit_id === null) {
$where .= " AND adb_wohneinheit_id IS NULL";
} elseif($adb_wohneinheit_id === true) {
$where .= " AND adb_wohneinheit_id IS NOT NULL AND adb_wohneinheit_id > 0";
}
}
@@ -400,6 +410,15 @@ class PreorderModel {
}
}
if(array_key_exists("connection_count", $filter)) {
$connection_count = $filter['connection_count'];
if(intval($connection_count) === 1) {
$where .= " AND connection_count = 1";
} elseif(intval($connection_count) === 2) {
$where .= " AND connection_count > 1";
}
}
if(array_key_exists("ucode", $filter)) {
$ucode = FronkDB::singleton()->escape($filter['ucode']);
if($ucode) {
@@ -442,6 +461,41 @@ class PreorderModel {
}
}
if(array_key_exists("hausnummer", $filter)) {
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
if($hausnummer) {
$where .= " AND adb_hausnummer.hausnummer like '%$hausnummer%'";
}
}
if(array_key_exists("unit_count", $filter)) {
$unit_count = $filter['unit_count'];
if(intval($unit_count) === 1) {
$where .= " AND adb_hausnummer.unit_count = 1";
} elseif(intval($unit_count) === 2) {
$where .= " AND adb_hausnummer.unit_count > 1";
} elseif(strlen($unit_count) && intval($unit_count) === 0) {
$where .= " AND adb_hausnummer.unit_count = 0 OR adb_hausnummer.unit_count IS NULL";
}
}
if(array_key_exists("attributes", $filter)) {
$attributes = FronkDB::singleton()->escape($filter['attributes']);
if(is_array($attributes) && count($attributes)) {
if(array_key_exists("bep_specified", $attributes)) {
if($attributes['bep_specified']) {
$where .= " AND JSON_EXTRACT(attributes, \"$.bep_specified\") = 1";
}
}
if(array_key_exists("inhouse_cabling_supplied", $attributes)) {
if($attributes['inhouse_cabling_supplied']) {
$where .= " AND JSON_EXTRACT(attributes, \"$.inhouse_cabling_supplied\") = 1";
}
}
}
}
// custom where clause
if(array_key_exists("add-where", $filter)) {
$where .= " ".$filter['add-where'];

View File

@@ -160,14 +160,14 @@ class PreordernotificationModel {
}
if(array_key_exists("send_finish", $filter)) {
$send_finish = $db->escape($filter['send_finish']);
$send_finish = $filter['send_finish'];
if($send_finish === null) {
$where .= " AND Preordernotification.send_finish IS NULL";
}
}
if(array_key_exists("send_lock", $filter)) {
$send_lock = $db->escape($filter['send_lock']);
$send_lock = $filter['send_lock'];
if($send_lock === null) {
$where .= " AND Preordernotification.send_lock IS NULL";
}

View File

@@ -9,12 +9,12 @@ class Product extends mfBaseModel {
private $attributes;
public function loadAttributes() {
$this->attributes = [];
if(!$this->producttech_id) {
return [];
}
$this->attributes = [];
// get tech attribs
$ptattribs = mfValuecache::singleton()->get("ProducttechAttributes-techid-".$this->producttech_id);
if($ptattribs === null) {

View File

@@ -120,11 +120,12 @@ class User extends mfBaseModel {
//var_dump($m);exit;
$abbr = "$firstname ";
$abbr = substr($firstname, 0, 1). ". ";
if($middlename) {
$abbr .= substr($middlename, 0, 1). ". ";
}
$abbr .= substr($lastname, 0, 1). ". ";
$abbr .= $lastname;
return $abbr;
}

View File

@@ -178,7 +178,22 @@ class UserController extends mfBaseController {
$user->permissions->technician = "false";
}
if($r->preorderfront == "true") {
$user->permissions->preorderfront = "true";
} else {
$user->permissions->preorderfront = "false";
}
$user->permissions->save();
// save networks
$pn = $user->getFlag("preorder_networks");
if($r->preorderfront == "true" && is_array($r->preorder_networks) && count($r->preorder_networks)) {
$pn->value(json_encode($r->preorder_networks));
$pn->save();
} else {
$pn->delete();
}
}
$this->layout()->setFlash("Benutzer gespeichert.", "success");

View File

@@ -0,0 +1,67 @@
<?php
class WorkerFlag {
private $db;
private $id;
private $worker_id = null;
private $name = null;
private $value = null;
private $user = null;
public function __construct($worker_id, $name) {
$this->db = new FronkDB();
$user = new User($worker_id);
$this->user = $user;
$name = $this->db->escape($name);
$this->name = $name;
$res = $this->db->select("WorkerFlag", "*", "worker_id=".$this->user->id." AND name='$name'");
if($this->db->num_rows($res)) {
$data = $this->db->fetch_object($res);
$this->id = $data->id;
$this->value = $data->value;
}
}
public function value($value = null) {
if($value !== null) {
$this->value = $value;
}
return $this->value;
}
public function save() {
$id = $this->id;
$values['worker_id'] = $this->user->id;
$values['name'] = $this->name;
$values['value'] = $this->value;
$values['edit_by'] = $this->user->id;
$values['edit'] = date('U');
if($id) {
// update
$this->db->update("WorkerFlag", $values, "id=$id");
} else {
// insert
$values['create_by'] = $this->user->id;
$values['create'] = date('U');
$id = $this->db->insert("WorkerFlag", $values);
$this->id = $id;
}
}
public function delete() {
if($this->id) {
$this->db->delete("WorkerFlag", "id=".$this->id, 1);
}
return true;
}
public function __toString() {
return (string) $this->value;
}
}

View File

@@ -4,6 +4,7 @@ class WorkerPermission extends mfBaseModel {
public $isAdmin = false;
public $isTicketadmin = false;
public $isTechnician = false;
public $isPreorderfront = false;
public function loadByUserId($userid) {
$res = $this->db->select($this->table,"*","worker_id=$userid");
@@ -29,6 +30,9 @@ class WorkerPermission extends mfBaseModel {
if($this->technician == 'true') {
$this->isTechnician = true;
}
if($this->preorderfront == 'true') {
$this->isPreorderfront= true;
}
}
}

View File

@@ -1,19 +1,41 @@
<?php
require_once(realpath(dirname(__FILE__)."/internals.php"));
define("VCHECK_DEBUG", true);
/*
* Essentials
*/
define("MFAPPNAME","vcheck"); // used for cookie and logfile names
define("MFAPPNAME","thetool"); // used for cookie and logfile names
define("MFAPPNAME_SLUG", "the-tool");
define("MFAPPNAME_FULL", "the tool");
define("MFBASECONTROLLER_INIT_INCLUDE_FILE", APPDIR."Init/Init.php");
// the default Controller to call. Without an action, calls index action.
define("DEFAULT_ROUTE","Dashboard");
define("TT_DISABLE_EMAIL", false);
define("TESTMODE",false);
define("MFVALUECACHE_DEBUG", false);
define("LAYOUT_DEFAULTPACKAGE","default"); // mfLayout looks for templates in this folder
// database configuration
define("FRONKDB_DBHOST","localhost");
define("FRONKDB_DBUSER","vcheck");
define("FRONKDB_DBUSER","thetool");
define("FRONKDB_DBPASS","");
define("FRONKDB_DBNAME","vcheck");
define("FRONKDB_DBNAME","thetool");
// address DB for GWR data
define("ADDRESSDB_DBHOST","localhost");
define("ADDRESSDB_DBUSER","thetool_addressdb");
define("ADDRESSDB_DBPASS","");
define("ADDRESSDB_DBNAME","thetool_addressdb");
define("IVT_DBHOST", "localhost");
define("IVT_DBUSER","ivtuser");
define("IVT_DBPASS","");
define("IVT_DBNAME","ivt");
// Logging configuration
define("LOGTYPE","file"); // can be one of file, mysql, syslog; defaults to "file"
@@ -23,19 +45,613 @@ define("LOGFILENAME",BASEDIR."/var/log/".MFAPPNAME.".log");
* Application-specific settings
*/
// increment when adding new api
// used to route calls without explicit version
define("API_VERSION", "v1");
define("TT_FEATURE_IVT", false);
define("TT_ROLES", ['systemowner','productowner','netowner','salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator','supplier','billing','employee','customer','contact','techcontact']);
define("TT_NETWORK_ROLES", ['salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator']);
define("TT_NETWORK_ROLES_WITH_OWNER", ['netowner','salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator']);
define("TT_ADDRESS_LINK_TYPES", ['billing','employee','customer','contact','techcontact']);
define("TT_ATTRIB_RTRTECHCODE_NAME","rtrcode");
define("TT_ATTRIB_TERMINATION_REQUIRED_NAME", "termination_required");
define("TT_GEOCODING_API_URL", "https://maps.googleapis.com/maps/api/geocode/json");
define("TT_GEOCODING_API_SECRET","");
define("TT_MAPBOX_TILE_API_TOKEN", "");
define("TT_BUILDINGSTATUS_CONNECTED", 50);
define("TT_TERMSTATUS_ASSIGNED", 30);
define("TT_TERMSTATUS_CONNECTED", 50);
define("TT_TERMSTATUS_ACTIVE", 60);
define("TT_PLACEHOLDER_GPS_LAT", "47.082999");
define("TT_PLACEHOLDER_GPS_LONG", "15.425001");
define("TT_FIRST_CUSTNUM", 102030);
define("TT_OUTGOING_EMAIL", "office@xinon.at");
define("TT_OUTGOING_EMAIL_NAME", "XINON Kundenservice");
define("TT_INTERNAL_BILLING_EMAIL_TO", "thetool-tobill@xinon.at");
define("TT_EXTERNAL_BILLING_EMAIL_TO", "energie-billing@xinon.at");
define("TT_CUSTOM_ORDER_PDF_PER_NETOWNER", true);
define("TT_CUSTOM_ORDER_PDF_DEFAULT_OWNER_ID", 1635);
define("TT_PREORDER_DISCOUNT_2", 25);
define("TT_PREORDER_DISCOUNT_3", 33.33);
define("TT_PREORDER_DISCOUNT_APART", 50);
define("TT_PREORDER_DISCOUNT_BUSINESS", 16.667);
/*
* Workflow Settings
*/
define("TT_WORKFLOW_ITEM_STATUS_FIELD", "pipework_finished");
define("TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED", "am Grundstück");
define("TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED", "im Gebäude");
define("TT_WORKFLOW_ITEM_PIPEWORK_DONE", "pipework_finished");
define("TT_WORKFLOW_ITEM_LINEWORK_DONE", "customer_passive_finished");
define("TT_WORKFLOW_BUILDING_FILE_TYPES", [
"Rohrplan",
"Gestattungsvertrag",
"Foto Tiefbau",
"Handskizze",
"Anderes",
]);
define("TT_WORKFLOW_TERMINATION_FILE_TYPES", [
"Spleissplan",
"Foto Leitungsbau",
"Handskizze",
"Anderes",
]);
define("TT_ORDER_FILE_TYPES", [
"order_internet" => "Bestellung Internet & Telefon",
"order_nextv" => "Bestellung nexTV",
"order_general" => "Bestellung Allgemein",
"order_project" => "Bestellung Projekt",
"order_pbx" => "Bestellung Telefonanlage",
"voicenumber_porting" => "Rufnummermitnahme",
"handover_report" => "Übergabe-Protokoll",
"sepa_form" => "Nur Einzugsermächtigung",
"emailjournal_customer" => "Mailverlauf mit Kunde",
"old_phone_contract" => "Telefonvertrag von Voranbieter",
"other" => "Sonstiges Dokument",
]);
define("TT_CABLE_COLORS", [
"rot" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 0,
"mark" => false
],
"gruen" => [
"hex" => "00FF00",
"hexfg" => "000000",
"r" => 0,
"g" => 255,
"b" => 0,
"mark" => false
],
"blau" => [
"hex" => "0000FF",
"hexfg" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 255,
"mark" => false
],
"gelb" => [
"hex" => "FFFF00",
"hexfg" => "000000",
"r" => 255,
"g" => 255,
"b" => 0,
"mark" => false
],
"weiss" => [
"hex" => "FFFFFF",
"hexfg" => "000000",
"r" => 255,
"g" => 255,
"b" => 255,
"mark" => false
],
"natur" => [
"hex" => "FFFFCC",
"hexfg" => "000000",
"r" => 255,
"g" => 255,
"b" => 204,
"mark" => false
],
"grau" => [
"hex" => "888888",
"hexfg" => "FFFFFF",
"r" => 136,
"g" => 136,
"b" => 136,
"mark" => false
],
"braun" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"mark" => false
],
"violett" => [
"hex" => "8800FF",
"hexfg" => "FFFFFF",
"r" => 136,
"g" => 0,
"b" => 255,
"mark" => false
],
"tuerkis" => [
"hex" => "00FFFF",
"hexfg" => "000000",
"r" => 0,
"g" => 255,
"b" => 255,
"mark" => false
],
"schwarz" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"mark" => false
],
"orange" => [
"hex" => "FF8800",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 136,
"b" => 0,
"mark" => false
],
"rosa" => [
"hex" => "FF0088",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 136,
"mark" => false
],
"rot-1R" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 0,
"mark" => true
],
"gruen-1R" => [
"hex" => "00FF00",
"hexfg" => "000000",
"r" => 0,
"g" => 255,
"b" => 0,
"mark" => true
],
"blau-1R" => [
"hex" => "0000FF",
"hexfg" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 255,
"mark" => true
],
"gelb-1R" => [
"hex" => "FFFF00",
"hexfg" => "000000",
"r" => 255,
"g" => 255,
"b" => 0,
"mark" => true
],
"weiss-1R" => [
"hex" => "FFFFFF",
"hexfg" => "000000",
"r" => 255,
"g" => 255,
"b" => 255,
"mark" => true
],
"grau-1R" => [
"hex" => "888888",
"hexfg" => "FFFFFF",
"r" => 136,
"g" => 136,
"b" => 136,
"mark" => true
],
"braun-1R" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"mark" => true
],
"violett-1R" => [
"hex" => "8800FF",
"hexfg" => "FFFFFF",
"r" => 136,
"g" => 0,
"b" => 255,
"mark" => true
],
"tuerkis-1R" => [
"hex" => "00FFFF",
"hexfg" => "000000",
"r" => 0,
"g" => 255,
"b" => 255,
"mark" => true
],
"schwarz-1R" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"mark" => true
],
"orange-1R" => [
"hex" => "FF8800",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 136,
"b" => 0,
"mark" => true
],
"rosa-1R" => [
"hex" => "FF0088",
"hexfg" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 136,
"mark" => true
],
// gabocom colors
"Rot-Gelb" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"hex2" => "FFFF00",
"hexfg2" => "000000",
"r" => 255,
"g" => 0,
"b" => 0,
"r2" => 255,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Rot-Gruen" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"hex2" => "00FF00",
"hexfg2" => "000000",
"r" => 255,
"g" => 0,
"b" => 0,
"r2" => 0,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Rot-Blau" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"hex2" => "0000FF",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 0,
"r2" => 0,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Rot-Violett" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"hex2" => "8800FF",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 0,
"r2" => 136,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Rot-Grau" => [
"hex" => "FF0000",
"hexfg" => "FFFFFF",
"hex2" => "888888",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 0,
"b" => 0,
"r2" => 136,
"g2" => 136,
"b2" => 136,
"two-color" => true
],
"Gelb-Blau" => [
"hex" => "FFFF00",
"hexfg" => "000000",
"hex2" => "0000FF",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 255,
"b" => 0,
"r2" => 0,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Gelb-Violett" => [
"hex" => "FFFF00",
"hexfg" => "000000",
"hex2" => "8800FF",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 255,
"b" => 0,
"r2" => 136,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Gelb-Grau" => [
"hex" => "FFFF00",
"hexfg" => "000000",
"hex2" => "888888",
"hexfg2" => "FFFFFF",
"r" => 255,
"g" => 255,
"b" => 0,
"r2" => 136,
"g2" => 136,
"b2" => 136,
"two-color" => true
],
"Gruen-Blau" => [
"hex" => "00FF00",
"hexfg" => "000000",
"hex2" => "0000FF",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 255,
"b" => 0,
"r2" => 0,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Gruen-Violett" => [
"hex" => "00FF00",
"hexfg" => "000000",
"hex2" => "8800FF",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 255,
"b" => 0,
"r2" => 136,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Gruen-Grau" => [
"hex" => "00FF00",
"hexfg" => "000000",
"hex2" => "888888",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 255,
"b" => 0,
"r2" => 136,
"g2" => 136,
"b2" => 136,
"two-color" => true
],
"Braun-Blau" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "0000FF",
"hexfg2" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 0,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Braun-Violett" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "8800FF",
"hexfg2" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 136,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Braun-Grau" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "888888",
"hexfg2" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 136,
"g2" => 136,
"b2" => 136,
"two-color" => true
],
"Braun-Gruen" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "00FF00",
"hexfg2" => "000000",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 0,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Braun-Gelb" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "FFFF00",
"hexfg2" => "000000",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 255,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Braun-Rot" => [
"hex" => "A52A2A",
"hexfg" => "FFFFFF",
"hex2" => "FF0000",
"hexfg2" => "FFFFFF",
"r" => 165,
"g" => 42,
"b" => 42,
"r2" => 255,
"g2" => 0,
"b2" => 0,
"two-color" => true
],
"Schwarz-Rot" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "FF0000",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 255,
"g2" => 0,
"b2" => 0,
"two-color" => true
],
"Schwarz-Gelb" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "FFFF00",
"hexfg2" => "000000",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 255,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Schwarz-Gruen" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "00FF00",
"hexfg2" => "000000",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 0,
"g2" => 255,
"b2" => 0,
"two-color" => true
],
"Schwarz-Blau" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "0000FF",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 0,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Schwarz-Violett" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "8800FF",
"hexfg2" => "000000",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 136,
"g2" => 0,
"b2" => 255,
"two-color" => true
],
"Schwarz-Grau" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "888888",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 136,
"g2" => 136,
"b2" => 136,
"two-color" => true
],
"Schwarz-Braun" => [
"hex" => "000000",
"hexfg" => "FFFFFF",
"hex2" => "A52A2A",
"hexfg2" => "FFFFFF",
"r" => 0,
"g" => 0,
"b" => 0,
"r2" => 165,
"g2" => 42,
"b2" => 42,
"two-color" => true
]
]);
// Upload settings
define('MFUPLOAD_FILE_SAVE_PATH',BASEDIR.'/files'); // folder where files will be stored
define('MFUPLOAD_ALLOWED_EXTENSIONS', 'jpg|jpeg|gif|png|pdf|doc.?|xls.?'); // allowed file extensions in regex format
define('MFUPLOAD_ALLOWED_EXTENSIONS_STR',"jpg, png, gif, pdf, doc, xls");
define('MFUPLOAD_FILE_MAX_SIZE',8192*1024); // Max filesize (8 MB)
define('MFUPLOAD_ALLOWED_EXTENSIONS', 'jpg|jpeg|gif|png|pdf|doc.?|xls.?|txt|conf|svg|csv'); // allowed file extensions in regex format
define('MFUPLOAD_ALLOWED_EXTENSIONS_STR',"jpg, png, gif, pdf, doc, xls, csv, txt, conf");
define('MFUPLOAD_FILE_MAX_SIZE',128*1024*1024); // Max filesize (128 MB)
define('MFUPLOAD_DIRMODE',0777);
define('MFUPLOAD_FILEMODE',0666);
define("A1VULL_APIURL", '');
define("A1VULL_APIUSER", '');
define("A1VULL_APIPASS", '');
define("HOME_PROVIDER_ID", 1);
define('MFLOCALE_TIME', "de_AT.UTF-8");
define('MFLOCALE_MONETARY', "de_AT.UTF-8");
define('MFLOCALE_NUMERIC', "de_AT.UTF-8");
/*
* Maintainer / developer settings
@@ -45,14 +661,10 @@ define("MFUSEFANCYURLS",true); // to use urls in folder style
// If your database field names start with a prefix (like Customer_id), set this to true.
// Required when extending from mfBase classes (mfBaseController and mfBaseModel).
define("MFMODEL_USEFIELDPREFIX",false);
define("TESTMODE",false);
define("LAYOUT_DEFAULTPACKAGE","default"); // mfLayout looks for templates in this folder
// the default Controller to call. Without an action, calls index action.
define("DEFAULT_ROUTE","Check");
// use mfLogin?
define("MFUSELOGIN",true);
define("MFSESSION",true);
// The name of your users table. Required by stock mfUser and mfLoginController
define("MFUSERTABLE","Worker");
// use mfMenu?
@@ -61,7 +673,17 @@ define("MFUSEMENU",false);
define("MFMENUTABLE","mfMenu");
// change this to wkhtmltopdf-amd64 if your system supports 64 bit binaries
define("WKHTMLTOPDF_BIN",LIBDIR."/mvcfronk/mfWkhtmltopdf/bin/wkhtmltopdf-i386");
define("WKHTMLTOPDF_ARGS",'-q -s A4 --footer-center [page]/[topage]');
define("WKHTMLTOPDF_BIN",LIBDIR."/mvcfronk/mfWkhtmltopdf/bin/wkhtmltopdf-amd64");
//define("WKHTMLTOPDF_ARGS",'-q -s A4 --footer-right [page]/[topage]');
define("WKHTMLTOPDF_ARGS",'-q -s A4 --enable-local-file-access');
// where to save PDF files
define("PDFOUTPUTPATH",BASEDIR."/var/temp");
define("GIT_BIN_PATH", "/usr/bin/git");
define("PDFTOTEXT_BIN_PATH", "/usr/bin/pdftotext");
//MBI-API Server Configuration
define("TT_MBI_API_ENABLE", true); //Enable API Calls
define("TT_MBI_API_URL", "https://x.x.x.x/api/");
define("TT_MBI_API_VERSION", "v01");
define("TT_MBI_API_KEY", "");

View File

@@ -44,6 +44,12 @@ $l['preorder.provision'] = "Vorsorgeanschluss";
$l['preorder.order'] = "Vollanschluss";
$l['preorder.reorder'] = "Nachbestellung";
$l['preorder.single-dwelling'] = "Einfahmilienhaus";
$l['preorder.multi-dwelling'] = "Mehrfamilienhaus";
$l['preorder.apartment-building'] = "Mehrparteienhaus";
$l['preorder.apartment'] = "Wohneinheit in Mehrparteienhaus";
$l['preorder.business'] = "Gewerbebetrieb";
$l['contract.link'] = "Verknüpfung";
$l['contract.upgrade'] = "Upgrade";
$l['contract.downgrade'] = "Downgrade";

View File

@@ -43,12 +43,19 @@ class mfBaseApicontroller {
register_shutdown_function(["mfBaseApicontroller", "return_errors"]);
// allow origins from config file
if(defined("API_CORS_ALLOWED_HOSTNAMES") && is_array(API_CORS_ALLOWED_HOSTNAMES)) {
foreach(API_CORS_ALLOWED_HOSTNAMES as $origin) {
$this->addAllowedOrigin($origin);
}
}
// CORS preflight
// allow all origins
if($this->http_method == "OPTIONS") {
// dont execute route, OPTIONS only requires CORS headers
header("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS");
header("Access-Control-Allow-Headers: X-Api-Key");
header("Access-Control-Allow-Headers: X-Api-Key, accept, Content-Type");
if(preg_match('#^(https?)://([^/:]+)(:\d+)?/?$#i', $this->headers['origin'], $m)) {
$origin_proto = $m[1];
@@ -71,7 +78,7 @@ class mfBaseApicontroller {
if($this->requireAuth) {
$this->authenticateUser();
if(method_exists($this,"authenticated")) {
$this->authenticated();
$this->authenticated(); // event defined in extending class
}
}
@@ -129,7 +136,7 @@ class mfBaseApicontroller {
if(!$me->id) {
header("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS");
header("Access-Control-Allow-Headers: X-Api-Key");
header("Access-Control-Allow-Headers: X-Api-Key, accept, Content-Type");
if(preg_match('#^(https?)://([^/:]+)(:\d+)?/?$#i', $this->headers['origin'], $m)) {
$origin_proto = $m[1];
@@ -326,7 +333,7 @@ class mfBaseApicontroller {
private function createCorsHeaders() {
header("Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS");
header("Access-Control-Allow-Headers: X-Api-Key");
header("Access-Control-Allow-Headers: X-Api-Key, accept, Content-Type");
if(!is_array($this->allowed_origins) || !count($this->allowed_origins)) {
return true;

View File

@@ -12,8 +12,8 @@ class mfBaseController {
private $mfLayout;
private $mfMenu;
private $mfUser;
private $mod;
private $action;
protected $mod;
protected $action;
public function __construct($params = NULL) {
// load logging facility
@@ -235,6 +235,8 @@ class mfBaseController {
$url.="#$anker";
}
$url = preg_replace('#^/+#', "/", $url);
$log->debug("Redirecting to $url");
header("Location: $url");
exit;

View File

@@ -28,4 +28,16 @@ class mfValuecache {
public function getCache() {
return $this->cache;
}
public function getMfObject($objectname, $id) {
$object = $this->get("mfObjectmodel-$objectname-".$id);
if(!$object) {
$object = new $objectname($id);
if($object->id) {
$this->set("mfObjectmodel-$objectname-".$id, $object);
}
}
return $object;
}
}

View File

@@ -32,6 +32,10 @@
width: 50px;
}
.edit-width-large {
width: 128px;
}
.order-date-pill {
margin: 2px;
white-space: nowrap;
@@ -40,3 +44,46 @@
.font-weight-500 {
font-weight: 500;
}
.history-ico {
color: #007bff;
cursor: pointer;
}
.history-ico:hover {
color: #006875;
}
.code-ico {
cursor: pointer;
font-size: 25px;
margin-top: 7px;
margin-left: 10px;
}
.spinner-ico {
margin-left: 5px;
}
.filestore-history {
}
.filestore-history-td {
padding: 0 0px 0 10px !important;
box-shadow: unset;
}
.filestore-history-td:hover {
box-shadow: unset !important;
}
.filestore-history-tr:hover {
color: unset !important;
background-color: #fff !important;
}
.w-30 {
width: 33% !important;
}

View File

@@ -10,6 +10,12 @@ if (typeof cstmdom === "undefined") {
cstmdom = "flBrtip";
}
if (typeof columndefs === "undefined") {
var columndefs;
columndefs = "";
}
$('#filterrow th').each(function (i) {
let title = $('#datatable thead th').eq($(this).index()).text();
@@ -29,6 +35,8 @@ table = $('#datatable').DataTable({
className: 'btn-success margina'
}
], columnDefs: [
columndefs
],
"language": {
"url": "/datatables/json/german.json"

View File

@@ -0,0 +1,265 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$adb_gemeinde_id = 1462;
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "RIMO_230307_Adressen_Cluster_Lieboch.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$l = 0;
$u = 0;
while($csv = fgetcsv($input, 0, ";")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_extref = trim($csv[48]);
$adrcd = trim($csv[65]);
$netzgebiet_extref = trim($csv[55]);
$grund_nr = trim($csv[74]);
//gps_long, gps_lat
//$rollout_time = trim($csv[17]);
//$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[5]);
$gdaeigenschaft = trim($csv[67]);
$fcp_name = trim($csv[50]);
$execution_state = trim($csv[9]);
$btype = trim($csv[31]);
if(!$netzgebiet_extref) {
continue;
}
$netzgebiet = ADBNetzgebietModel::getFirst(["extref" => $netzgebiet_extref]);
if(!$netzgebiet) {
echo "netzgebiet not found\n";
exit;
}
if($execution_state == "Canceled") {
continue;
}
if($btype == "Greenfield") {
continue;
}
$gem_name = trim($csv[60]);
$plz_string = trim($csv[88]);
$ort_name = trim($csv[32]);
$strasse_hausnummer = trim($csv[23]);
$strasse_name = "";
$hausnummer_name = "";
$m = [];
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
$lat = str_replace(",",".",trim($csv[10]));
$long = str_replace(",",".",trim($csv[11]));
if(!$adrcd) {
continue;
}
if(!is_numeric($adrcd)) {
echo "Invalid adrcd ($adrcd)\n";
continue;
}
if(!$hausnummer_extref || !is_numeric($hausnummer_extref)) {
//echo("Keine Hausnummer Extref\n");
continue;
}
if($adrcd == "25023176") continue;
$existing_hausnummer = ADBHausnummerModel::getFirst(["extref" => $hausnummer_extref, "gemeinde_id" => $adb_gemeinde_id]);
if(!$existing_hausnummer) {
$existing_hausnummer = ADBHausnummerModel::getFirst(["adrcd" => $adrcd]);
}
if(!$existing_hausnummer) {
//echo "$hausnummer_extref not found $strasse_name $hausnummer_name\n";
// find hausnummer
//echo "$strasse_name $hausnummer_name\n";
//if($strasse_name == "Toepferring") $strasse_name = "Töpferring";
//if($strasse_name == "Foehrenweg") $strasse_name = "Föhrenweg";
if($strasse_name == "Hans-Thalhammer-Straße") $strasse_name = "H. Thalhammer-Straße";
if($strasse_name == "Packerstraße") $strasse_name = "Packer Straße";
$strasse_name = $db->escape($strasse_name);
$hausnummer_name = $db->escape($hausnummer_name);
$strasse_search = [$strasse_name];
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
foreach($strasse_search as $search) {
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
}
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = $adb_gemeinde_id AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$existing_hausnummer = new ADBHausnummer($data->hausnummer_id);
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
if($lat && $long) {
$existing_hausnummer->gps_lat = $lat;
$existing_hausnummer->gps_long = $long;
}
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
} else {
echo "Address not found (straße: $strasse_name, hausnummer: $hausnummer_name, adrcd: $adrcd, extref: $hausnummer_extref)\n";
continue;
}
} else {
// found hausnummer
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
if($lat && $long) {
$existing_hausnummer->gps_lat = $lat;
$existing_hausnummer->gps_long = $long;
}
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
}
//continue;
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
/*if(($existing_units_count - $unit_count) > 1) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}*/
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
//var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
//echo "$hausnummer_extref: $adrcd, $netzgebiet_extref, $grund_nr, $unit_count, $gdaeigenschaft\n";
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,251 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "GWR_Lieboch_gesamt.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$gem_kz = "";
$gem_name = "";
$ort_kz = "";
$plz_name = "";
$ort_name = "";
$strasse_hausnummer = "";
$strasse_building = "";
$strasse_name = "";
$strasse = "";
$addresszusatz = "";
$adrcd = "";
$hausnummer_name = "";
$hausnummer_extref = "";
// netzgebiet Lieboch
$netzgebiet = new ADBNetzgebiet(30);
$l = 0;
$u = 0;
$i = 0;
while($csv = fgetcsv($input, 0, ",")) {
$i++;
if($i == 1) continue;
//var_dump($csv);exit;
if(trim($csv[0])) {
$gem_kz = trim($csv[0]);
$gem_name = trim($csv[1]);
$ort_kz = "14994";
$plz_name = "8501";
$ort_name = "Lieboch";
$strasse_hausnummer = trim($csv[4]);
//$strasse_name = trim($csv[13]);
$adrcd = trim($csv[8]);
$hausnummer_extref = trim($csv[12]);
//echo "strasse: $strasse\n";
//echo "strasse_building: $strasse_building\n";
$strasse_name = "";
$hausnummer_name = "";
$addresszusatz = "";
//echo $strasse_hausnummer."\n";
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
//echo "$strasse_name $hausnummer_name\n";
}
if(!$strasse_name || !$hausnummer_name) {
echo "no strasse_name ($strasse_name) or hausnummer_name ($hausnummer_name)\n";
continue;
}
$strasse_we = trim($csv[13]);
//$nutzung = trim($csv[8]);
$we_num = trim($csv[17]);
if(!$strasse_we) {
echo "Adresse Wohneinheit fehlt.\n";
continue;
}
//echo "strasse_we: $strasse_we\n";
if($strasse_hausnummer == $strasse_we) {
$addresszusatz = "";
} else {
$addresszusatz = preg_replace('/^'.$strasse_hausnummer.'\s+/', "", $strasse_we);
}
$hausnummer_zusatz = ADBWohneinheit::parseHausnummerZusatz($addresszusatz);
//var_dump($hausnummer_zusatz);
echo "Gemeinde: $gem_name | PLZ: $plz_name | Ort: $ort_name | Strasse: $strasse_name | Hausnummer: $hausnummer_name | Zusatz: ";
foreach($hausnummer_zusatz as $key => $value) {
if($value) {
if($key == "zusatz") {
echo $value;
continue;
}
echo ucfirst($key)." ".$value;
}
}
echo "\n";
//continue;
$gemeinde = ADBGemeindeModel::getFirst(['kennziffer' => $gem_kz]);
if(!$gemeinde) {
die("Gemeinde $gem_kz nicht gefunden\n");
/*$gemeinde = new ADBGemeinde();
$gemeinde->kennziffer = $gem_kz;
$gemeinde->code = $gem_kz;
$gemeinde->name = $gem_name;
$gemeinde_id = $gemeinde->save();
if(!$gemeinde_id) {
}*/
}
$ort = ADBOrtschaftModel::getFirst(['kennziffer' => $ort_kz]);
if(!$ort) {
die("Ortschaft $ort_kz nicht gefunden\n");
/*$ort = new ADBOrtschaft();
$ort->gemeinde_id = $gemeinde->id;
$ort->kennziffer = $ort_kz;
$ort->name = $ort_name;
$ort->plz = $plz_name;
$ort_id = $ort->save();
if(!$ort_id) {
die("Error creating Ortschaft $ort_kz $ort_name!\n");
}*/
}
$plz = ADBPlzModel::getFirst(['plz' => $plz_name]);
if(!$plz) {
die("PLZ $plz_name nicht gefunden\n");
/*$plz = new ADBPlz();
$plz->plz = $plz_name;
$plz->plzstring = $plz_name;
$plz_id = $plz->save();
if(!$plz) {
die("Error creating Plz $plz_name!\n");
}*/
}
//var_dump($plz);exit;
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'name' => $strasse_name]);
if(!$strasse) {
die("Strasse $strasse_name nicht gefunden\n");
/*$strasse = new ADBStrasse();
$strasse->ortschaft_id = $ort->id;
$strasse->gemeinde_id = $gemeinde->id;
$strasse->name = $strasse_name;
$strasse_id = $strasse->save();
if(!$strasse_id) {
die("error creating Strasse $strasse_name (gemeinde ".$gemeinde->id.", ort ".$ort->id.")");
}*/
}
//var_dump($strasse);exit;
$hausnummer = ADBHausnummerModel::getFirst(['adrcd' => $adrcd]);
if(!$hausnummer) {
$hausnummer = ADBHausnummerModel::getFirst(['strasse_id' => $strasse->id, 'hausnummer' => $hausnummer_name]);
}
if(!$hausnummer) {
$hausnummer = new ADBHausnummer();
$hausnummer->adrcd = $adrcd;
$hausnummer->plz_id = $plz->id;
$hausnummer->strasse_id = $strasse->id;
$hausnummer->ortschaft_id = $ort->id;
$hausnummer->hausnummer = $hausnummer_name;
}
$hausnummer->netzgebiet_id = $netzgebiet->id;
$hausnummer->extref = $hausnummer_extref;
$hausnummer->freigabe = $freigabe_default;
$hausnummer_id = $hausnummer->save();
if(!$hausnummer_id) {
die("error creating Hausnummer $strasse_name $hausnummer_name\n");
}
$hausnummer->oaid = $hausnummer->getNewOAID();
if(!$hausnummer->save()) {
die("Cannot save oaid $strasse_name $hausnummer_name\n");
}
//var_dump($hausnummer);exit;
$we_search = [
'hausnummer_id' => $hausnummer->id,
'num' => $we_num,
'block' => $hausnummer_zusatz['block'],
'stiege' => $hausnummer_zusatz['stiege'],
'stock' => $hausnummer_zusatz['stock'],
'tuer' => $hausnummer_zusatz['tuer'],
'zusatz' => $hausnummer_zusatz['zusatz'],
];
$wohneinheit = ADBWohneinheitModel::getFirst($we_search);
if(!$wohneinheit) {
$wohneinheit = new ADBWohneinheit();
$wohneinheit->hausnummer_id = $hausnummer->id;
$wohneinheit->num = $we_num;
$wohneinheit->block = ($hausnummer_zusatz['block']) ? $hausnummer_zusatz['block'] : null;
$wohneinheit->stiege = ($hausnummer_zusatz['stiege']) ? $hausnummer_zusatz['stiege'] : null;
$wohneinheit->stock = ($hausnummer_zusatz['stock']) ? $hausnummer_zusatz['stock'] : null;
$wohneinheit->tuer = ($hausnummer_zusatz['tuer']) ? $hausnummer_zusatz['tuer'] : null;
$wohneinheit->zusatz = ($hausnummer_zusatz['zusatz']) ? $hausnummer_zusatz['zusatz'] : null;
//$wohneinheit->nutzung = $nutzung;
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("error creating Wohneinheit $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz));
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->save()) {
die("cannot save oaid $strasse_name $hausnummer_name\n" . print_r($wohneinheit,true));
}
} else {
echo "XXXX wohneinheit gibts schon: $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz)."\n\n";
}
/*if($i > 10) {
exit;
}*/
}

View File

@@ -0,0 +1,26 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$netzgebiet_name_main = "Liezen";
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$log = mfLoghandler::singleton();
$premstaetten_netzgebiete = [];
foreach(PreorderModel::search([]) as $preorder) {
}

View File

@@ -0,0 +1,356 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "SDIBuilding__Locations_FTTx__Nord-update-2023-03-29.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$c = 0;
$l = 0;
$u = 0;
$w = 0;
while($csv = fgetcsv($input, 0, ";")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_extref = trim($csv[64]);
$adrcd_subcd = trim($csv[46]);
$netzgebiet_extref = trim($csv[54]);
$grund_nr = trim($csv[73]);
$lat = str_replace(",",".",trim($csv[9]));
$long = str_replace(",",".",trim($csv[10]));
//$rollout_time = trim($csv[17]);
//$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[78]);
$gdaeigenschaft = trim($csv[66]);
$fcp_name = trim($csv[49]);
$execution_state = trim($csv[8]);
$btype = trim($csv[30]);
if(!$netzgebiet_extref) {
continue;
}
$netzgebiet = ADBNetzgebietModel::getFirst(["extref" => $netzgebiet_extref]);
if(!$netzgebiet) {
echo "netzgebiet not found\n";
exit;
}
if($execution_state == "Canceled") {
continue;
}
if($btype == "Greenfield") {
continue;
}
$adrcd = false;
if($adrcd_subcd) {
$adrparts = explode("-", $adrcd_subcd);
$adrcd = $adrparts[0];
}
$gem_kz = trim($csv[60]);
$gem_name = trim($csv[59]);
$plz_string = trim($csv[88]);
$ort_name = trim($csv[31]);
$strasse_hausnummer = trim($csv[22]);
$strasse_name = "";
$hausnummer_name = "";
if(!$strasse_hausnummer) {
continue;
}
$m = [];
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
if($strasse_name == "Dr.Karl-Renner-Weg") $strasse_name = "Dr.-Karl-Renner-Weg";
if($strasse_name == "Doktor-Karl-Renner-Weg") $strasse_name = "Dr.-Karl-Renner-Weg";
/*
$adrcd = trim($csv[0]);
$gem_kz = trim($csv[2]);
$gem_name = trim($csv[3]);
$ort_kz = trim($csv[5]);
$plz_string = trim($csv[4]);
$ort_name = trim($csv[6]);
$skz = trim($csv[7]);
$strasse_name = trim($csv[8]);
$hausnummer_string = trim($csv[9]);
$hausnummer_extref = trim($csv[0]);
if(in_array($hausnummer_extref, $h_extrefs)) {
die("Hausnummer extref doppelt! $hausnummer_extref\n");
}
$h_extrefs[] = $hausnummer_extref;
*/
//$lat = str_replace(",",".",trim($csv[7]));
//$long = str_replace(",",".",trim($csv[8]));
/*if(!$adrcd) {
continue;
}*/
if($adrcd && !is_numeric($adrcd)) {
echo "Invalid adrcd ($adrcd)\n";
continue;
}
if(!$hausnummer_extref) {
die("!!! Keine Hausnummer Extref\n");
}
if($hausnummer_extref == "25012262") {
$unit_count = 45;
}
if($hausnummer_extref == "25012676") {
continue;
}
if($hausnummer_extref == "25012153" || $hausnummer_extref == "25012155" || $hausnummer_extref == "25012157") {
continue;
}
if($hausnummer_extref == "25012159") {
$unit_count = 61;
}
if($hausnummer_extref == "25010649") {
continue;
}
if($hausnummer_extref == "25010723" || $hausnummer_extref == "25010816") {
continue;
}
$existing_hausnummer = ADBHausnummerModel::getFirst(["extref" => $hausnummer_extref]);
if($adrcd && !$existing_hausnummer) {
$existing_hausnummer = ADBHausnummerModel::getFirst(["adrcd" => $adrcd]);
}
if(!$existing_hausnummer) {
//echo "$hausnummer_extref not found $strasse_name $hausnummer_name\n";
//continue;
// find hausnummer
//echo "$strasse_name $hausnummer_name\n";
if($strasse_name == "Toepferring") $strasse_name = "Töpferring";
if($strasse_name == "Foehrenweg") $strasse_name = "Föhrenweg";
$strasse_name = $db->escape($strasse_name);
$hausnummer_name = $db->escape($hausnummer_name);
$strasse_search = [$strasse_name];
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
foreach($strasse_search as $search) {
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
}
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = 1 AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$existing_hausnummer = new ADBHausnummer($data->hausnummer_id);
if($existing_hausnummer->netzgebiet_id != $netzgebiet->id) {
echo "Updating Netzgebiet from ".$existing_hausnummer->netzgebiet_id." to ".$netzgebiet->id."\n";
}
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
$u++;
} else {
echo "Address not found (straße: $strasse_name ($strasse_hausnummer), hausnummer: $hausnummer_name, adrcd: $adrcd, extref: $hausnummer_extref, unit_count: $unit_count)\n";
// create new adress
$gemeinde = ADBGemeindeModel::getFirst(['kennziffer' => $gem_kz]);
if(!$gemeinde) {
die("Gemeinde nicht gefunden\n");
}
$ort = ADBOrtschaftModel::getFirst(['name' => $ort_name, "gemeinde_id" => $gemeinde->id]);
if(!$ort) {
die("Ort $ort_name nicht gefunden\n");
}
$plz = ADBPlzModel::getFirst(['plz' => $plz_string, 'gemeinde_id' => $gemeinde->id]);
if(!$plz) {
die("PLZ nicht gefunden");
}
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'name' => $strasse_name]);
if(!$strasse) {
if(preg_match('/^(GST\s|L\d+\s)/', $strasse_hausnummer)) {
continue;
}
die("Strase nicht gefunden\n");
}
$hausnummer_data = [
"netzgebiet_id" => $netzgebiet->id,
"extref" => $hausnummer_extref,
"ortschaft_id" => $ort->id,
"plz_id" => $plz->id,
"strasse_id" => $strasse->id,
"hausnummer" => $hausnummer_name,
"zusatz" => ($addresszusatz) ? : null,
"gps_lat" => $lat,
"gps_long" => $long,
"grund_nr" => $grund_nr,
"gdaeigenschaft" => $gdaeigenschaft,
"rimo_fcp_name" => $fcp_name,
"freigabe" => $freigabe_default,
];
$existing_hausnummer = ADBHausnummerModel::create($hausnummer_data);
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
$c++;
}
} else {
// found hausnummer
if($existing_hausnummer->netzgebiet_id != $netzgebiet->id) {
echo "Updating Netzgebiet from ".$existing_hausnummer->netzgebiet_id." to ".$netzgebiet->id."\n";
}
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
$u++;
}
//continue;
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
/*if(($existing_units_count - $unit_count) > 1) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}*/
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
//var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
//echo "$hausnummer_extref: $adrcd, $netzgebiet_extref, $grund_nr, $unit_count, $gdaeigenschaft\n";
}
echo "$c Buildings created, $u Buildings updated, $w Wohneinheiten angelegt\n";

View File

@@ -0,0 +1,287 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "SDIBuilding__Locations__FTTx_premstaetten_2023-03-07.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$l = 0;
$u = 0;
while($csv = fgetcsv($input, 0, ";")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_extref = trim($csv[64]);
$adrcd_subcd = trim($csv[46]);
$netzgebiet_extref = trim($csv[54]);
$grund_nr = trim($csv[73]);
//gps_long, gps_lat
//$rollout_time = trim($csv[17]);
//$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[78]);
$gdaeigenschaft = trim($csv[66]);
$fcp_name = trim($csv[49]);
$execution_state = trim($csv[8]);
$btype = trim($csv[30]);
if(!$netzgebiet_extref) {
continue;
}
$netzgebiet = ADBNetzgebietModel::getFirst(["extref" => $netzgebiet_extref]);
if(!$netzgebiet) {
echo "netzgebiet not found\n";
exit;
}
if($execution_state == "Canceled") {
continue;
}
if($btype == "Greenfield") {
continue;
}
$adrcd = false;
if($adrcd_subcd) {
$adrparts = explode("-", $adrcd_subcd);
$adrcd = $adrparts[0];
}
$gem_name = trim($csv[59]);
$plz_string = trim($csv[88]);
$ort_name = trim($csv[31]);
$strasse_hausnummer = trim($csv[22]);
$strasse_name = "";
$hausnummer_name = "";
$m = [];
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
/*
$adrcd = trim($csv[0]);
$gem_kz = trim($csv[2]);
$gem_name = trim($csv[3]);
$ort_kz = trim($csv[5]);
$plz_string = trim($csv[4]);
$ort_name = trim($csv[6]);
$skz = trim($csv[7]);
$strasse_name = trim($csv[8]);
$hausnummer_string = trim($csv[9]);
$hausnummer_extref = trim($csv[0]);
if(in_array($hausnummer_extref, $h_extrefs)) {
die("Hausnummer extref doppelt! $hausnummer_extref\n");
}
$h_extrefs[] = $hausnummer_extref;
*/
//$lat = str_replace(",",".",trim($csv[7]));
//$long = str_replace(",",".",trim($csv[8]));
if(!$adrcd) {
continue;
}
if(!is_numeric($adrcd)) {
echo "Invalid adrcd ($adrcd)\n";
continue;
}
if(!$hausnummer_extref) {
die("!!! Keine Hausnummer Extref\n");
}
if($hausnummer_extref == "25012262") {
$unit_count = 45;
}
if($hausnummer_extref == "25012676") {
continue;
}
if($hausnummer_extref == "25012153" || $hausnummer_extref == "25012155" || $hausnummer_extref == "25012157") {
continue;
}
if($hausnummer_extref == "25012159") {
$unit_count = 61;
}
if($hausnummer_extref == "25010649") {
continue;
}
if($hausnummer_extref == "25010723" || $hausnummer_extref == "25010816") {
continue;
}
$existing_hausnummer = ADBHausnummerModel::getFirst(["extref" => $hausnummer_extref]);
if(!$existing_hausnummer) {
$existing_hausnummer = ADBHausnummerModel::getFirst(["adrcd" => $adrcd]);
}
if(!$existing_hausnummer) {
//echo "$hausnummer_extref not found $strasse_name $hausnummer_name\n";
//continue;
// find hausnummer
//echo "$strasse_name $hausnummer_name\n";
if($strasse_name == "Toepferring") $strasse_name = "Töpferring";
if($strasse_name == "Foehrenweg") $strasse_name = "Föhrenweg";
$strasse_name = $db->escape($strasse_name);
$hausnummer_name = $db->escape($hausnummer_name);
$strasse_search = [$strasse_name];
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
foreach($strasse_search as $search) {
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
}
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = 1 AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$existing_hausnummer = new ADBHausnummer($data->hausnummer_id);
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
} else {
echo "Address not found (straße: $strasse_name, hausnummer: $hausnummer_name, adrcd: $adrcd, extref: $hausnummer_extref, unit_count: $unit_count)\n";
}
} else {
// found hausnummer
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
}
continue;
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
/*if(($existing_units_count - $unit_count) > 1) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}*/
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
//var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
//echo "$hausnummer_extref: $adrcd, $netzgebiet_extref, $grund_nr, $unit_count, $gdaeigenschaft\n";
}

View File

@@ -1,2 +0,0 @@
*
!.gitignore

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
define("INTERNAL_USER_USERNAME", $me->username);
$ignore_preorders = [];
$campaign_prem_nord = 5;
$same_unit_count = 0;
$missing_units = [];
$missing_doors = [];
$total = 0;
$c = 0;
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_prem_nord, "connection_count" => 2]) as $preorder) {
// check if we have enough units with extref
$wohneinheiten = ADBWohneinheitModel::search(["hausnummer_id" => $preorder->adb_hausnummer_id]);
$unit_count = count($wohneinheiten);
if($unit_count < $preorder->connection_count) {
$mu = [];
$mu['preorder'] = $preorder;
$mu['unit_count'] = $unit_count;
$missing_units[] = $mu;
//echo "Nicht genug Wohneinheiten - Preorder id ".$preorder->id.": ".count($wohneinheiten)." - need ".$preorder->connection_count."\n";
continue;
}
$available_units = [];
foreach($wohneinheiten as $unit) {
if(!PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
if($unit->tuer || preg_match('/^Top\s+\d+$/', $unit->zusatz)) {
$available_units[] = $unit;
}
}
}
if($preorder->connection_count > count($available_units)) {
$md = [];
$md["unit_count"] = $unit_count;
$md["door_count"] = count($available_units);
$md["preorder"] = $preorder;
$missing_doors[] = $md;
//echo "Not enough units with tuer (hausnummer id ".$preorder->adb_hausnummer_id.") units total: ".count($wohneinheiten)."; units with tuer: ".count($available_units)."; preorder connection count: ".$preorder->connection_count."\n";
continue;
}
// create new Preorders with available units
// then set original Preorder deleted
echo "Creating ".$preorder->connection_count." new preorders\n";
for($i = 0; $i < $preorder->connection_count; $i++) {
if(!$available_units[$i]->oaid) {
$available_units[$i]->oaid = $available_units[$i]->getNewOAID();
$available_units[$i]->save();
}
$new_preorder = clone($preorder);
$new_preorder->ucode = $preorder->ucode.".".($i+1);
$new_preorder->connection_count = 1;
$new_preorder->adb_wohneinheit_id = $available_units[$i]->id;
$new_preorder->oaid = $available_units[$i]->oaid;
//var_dump($new_preorder);exit;
$new_preorder->save();
}
$preorder->deleted = 1;
$preorder->delete_reason = "connection_split";
$preorder->save();
$i++;
}
echo "Adresse;Bestellte Anschlüsse;Vorhandene Wohneinheiten;Vorhanden Wohneinheiten mit Tür/Top Nummer\n";
foreach($missing_units as $mu) {
$preorder = $mu['preorder'];
/*echo "Adresse: ".$preorder->adb_hausnummer->strasse->name." ".$preorder->adb_hausnummer->hausnummer;
echo " | Bestellte Anschlüsse: ".$preorder->connection_count;
echo " | Vorhandene Wohneinheiten: ".$mu['unit_count'];*/
echo '"'.$preorder->adb_hausnummer->strasse->name.'";';
echo $preorder->connection_count.';';
echo $mu['unit_count'].';';
echo ';';
echo "\n";
}
foreach($missing_doors as $md) {
$preorder = $md['preorder'];
/*echo "Adresse: ".$preorder->adb_hausnummer->strasse->name." ".$preorder->adb_hausnummer->hausnummer;
echo " | Bestellte Anschlüsse: ".$preorder->connection_count;
echo " | Vorhandene Wohneinheiten: ".$md['unit_count'];
echo " | Vorhandene Tür/Top Nummern: ".$md["door_count"];*/
echo '"'.$preorder->adb_hausnummer->strasse->name.'";';
echo $preorder->connection_count.';';
echo $md["unit_count"].';';
echo $md["door_count"].';';
echo "\n";
}
echo "Processed $total, created $c preorders\n";

0
scripts/send_preordernotifications.php Normal file → Executable file
View File

View File

@@ -0,0 +1,88 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
define("INTERNAL_USER_USERNAME", $me->username);
$ignore_preorders = [];
$campaign_prem_nord = 5;
$same_unit_count = 0;
$i = 0;
foreach(PreorderModel::search(['preordercampaign_id' => $campaign_prem_nord, 'adb_wohneinheit_id' => null, 'connection_count' => 1, "connection_type" => "single-dwelling", "deleted" => 0]) as $preorder) {
if(in_array($preorder->id, $ignore_preorders)) continue;
//if($preorder->connection_type != "single-dwelling") continue;
if($preorder->adb_wohneinheit_id) {
echo "hat eh a unit\n";
continue;
}
if(!$preorder->adb_hausnummer_id) {
echo "missing hausnummer Preorder ".$preorder->id."\n";
continue;
}
$wohneinheiten = ADBWohneinheitModel::search(['hausnummer_id' => $preorder->adb_hausnummer_id]);
if(!count($wohneinheiten)) {
echo "Keine Wohneinheit gefunden. Preorder ".$preorder->id."\n";
}
$unit_count = count($wohneinheiten);
//echo "$unit_count\n";
if($unit_count === 1) {
$same_unit_count++;
$unit = $wohneinheiten[0];
$preorder->adb_wohneinheit_id = $unit->id;
$preorder->save();
continue;
}
if($unit_count > 1 && $unit_count <= 4) {
// assume its single-dwelling with erroneously high door count
$unit_candidates = [];
foreach($wohneinheiten as $unit) {
if(!$unit->tuer) continue;
if($unit->tuer > 1) {
$unit_candidates[$unit->tuer] = $unit;
}
}
/*if(!count($unit_candidates)) {
foreach($wohneinheiten as $unit) {
if(!$unit->zusatz) continue;
if(preg_match('/Top\s+\d+/i',$unit->zusatz)) {
$unit_candidates[$unit->zusatz] = $unit;
}
}
}*/
if(count($unit_candidates)) {
ksort($unit_candidates, SORT_NUMERIC);
$new_unit = array_shift($unit_candidates);
$preorder->adb_wohneinheit_id = $new_unit->id;
$preorder->save();
echo "$i Wohneinheit saved\n";
continue;
}
}
$i++;
}
echo "Same unit count: $same_unit_count (".$i - $same_unit_count." with different unit count)\n";
echo "Processed $i Preorders\n";