379 lines
18 KiB
PHP
379 lines
18 KiB
PHP
<?php
|
|
$pagination_entity_name = "Adressen";
|
|
?>
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("AddressDB")?>">GWR / AddressDB</a></li>
|
|
<li class="breadcrumb-item active"><?=$address->strasse->name?> <?=$address->hausnummer?>, <?=$address->plz->plz?> <?=$address->ortschaft->name?></li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">GWR / AddressDB</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<a href="<?=self::getUrl("AddressDB")?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
|
<a href="<?=self::getUrl("AddressDB","edit", ['id' => $address->id])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
|
|
<div class="card border-top-primary">
|
|
<div class="card-body">
|
|
<h3 class="text-center mb-3"><?=$address->strasse->name?> <?=$address->hausnummer?>, <?=$address->plz->plz?> <?=$address->ortschaft->name?></h3>
|
|
|
|
<table class="table table-sm table-striped view-table">
|
|
<tr>
|
|
<th>OAID</th>
|
|
<td class="text-monospace text-pink"><?=$address->oaid?></td>
|
|
</tr><tr>
|
|
<th>ADRCD</th>
|
|
<td class="text-monospace"><?=$address->adrcd?><?=($address->subcd) ? "-".$address->subcd : ""?></td>
|
|
</tr><tr>
|
|
<th>Extref</th>
|
|
<td><?=$address->extref?></td>
|
|
</tr><tr>
|
|
<th>Rimo External ID</th>
|
|
<td><?=$address->rimo_id?></td>
|
|
</tr><tr>
|
|
<th>Netzgebiet</th>
|
|
<td><?=$address->netzgebiet->name?></td>
|
|
</tr><tr>
|
|
<th>Wohneinheiten</th>
|
|
<td><?=count($address->wohneinheiten)?></td>
|
|
</tr><tr>
|
|
<th>Tool-Gebäudetyp</th>
|
|
<td><?= $address->tool_building_type == 0 ? "Unbekannt" : ($address->tool_building_type == 1 ? "EFH" : "MPH") ?></td>
|
|
</tr><tr>
|
|
<th>GPS Koordinaten</th>
|
|
<td>
|
|
<?php if($address->gps_lat && $address->gps_long): ?>
|
|
<a href="https://maps.google.com/maps?t=k&q=loc:<?=$address->gps_lat?>+<?=$address->gps_long?>" target="_blank"><i class="fas fa-fw fa-globe"></i> <?=$address->gps_lat?>, <?=$address->gps_long?></a>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr><tr>
|
|
<th>Rimo Execution State</th>
|
|
<td><?=$address->rimo_ex_state?></td>
|
|
</tr><tr>
|
|
<th>Rimo Operational State</th>
|
|
<td><?=$address->rimo_op_state?></td>
|
|
</tr><tr>
|
|
<td colspan="2"><h4>Status</h4></td>
|
|
</tr><tr>
|
|
<th>Status</th>
|
|
<td class="text-monospace">
|
|
<span id="addressstatus-<?=$address->id?>-text" data-status-id="<?=$address->status_id?>"><span id="addressstatus-<?=$address->id?>-statustext"><?=$address->status->code?> - <?=$address->status->name?></span> <a href="#" onclick="return toggleAddressStatusControl(<?=$address->id?>)"><i class="fas fa-fw fa-edit"></i></a></span>
|
|
<div class="input-group" id="addressstatus-<?=$address->id?>-input" style="display:none">
|
|
<select class="form-control">
|
|
<?php foreach(ADBStatusModel::search(["!type" => "wohneinheit"]) as $status): ?>
|
|
<option value="<?=$status->id?>" <?=($address->status_id == $status->id) ? "selected='selected'" : ""?>><?=$status->code?> - <?=$status->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<div class="input-group-append">
|
|
<button type="button" class="btn btn-primary" title="Speichern" onclick="saveAddressStatusControl(<?=$address->id?>)"><i class="fas fa-check"></i></button>
|
|
<button type="button" class="btn btn-secondary" title="Abbrechen" onclick="toggleAddressStatusControl(<?=$address->id?>)"><i class="fas fa-times"></i></button>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr><tr>
|
|
<th>Statusflags</th>
|
|
<td>
|
|
<table class="table table-sm table-bordered table-striped bg-white">
|
|
<tr>
|
|
<th class="text-left"></th>
|
|
<th class="text-left">Code</th>
|
|
<th class="text-left">Text</th>
|
|
</tr>
|
|
<?php foreach($address->statusflags as $flag): ?>
|
|
<tr>
|
|
<td class="text-center"><?=($flag->value->value) ? "<i class='fas fa-check text-success'></i>" : ""?></td>
|
|
<td><?=$flag->code?></td>
|
|
<td><?=$flag->name?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</td>
|
|
</tr><tr>
|
|
<td colspan="2"><h4>Adresse</h4></td>
|
|
</tr><tr>
|
|
<th>Straße / Hausnummer</th>
|
|
<td><?=$address->strasse->name?> <?=$address->hausnummer?></td>
|
|
</tr><tr>
|
|
<th>Adresszusatz</th>
|
|
<td><?=$address->zusatz?></td>
|
|
</tr><tr>
|
|
<th>PLZ / Ort</th>
|
|
<td><?=$address->plz->plz?> <?=$address->ortschaft->name?></td>
|
|
</tr><tr>
|
|
<th>Gemeinde</th>
|
|
<td><?=$address->strasse->gemeinde->name?></td>
|
|
</tr><tr>
|
|
<td colspan="2"><h4>GWR Daten</h4></td>
|
|
</tr><tr>
|
|
<th>GDA Eigenschaft.</th>
|
|
<td><?=$address->gdaeigenschaft?></td>
|
|
</tr><tr>
|
|
<th>Meridian</th>
|
|
<td><?=$address->meridian?></td>
|
|
</tr><tr>
|
|
<th>RW</th>
|
|
<td><?=$address->rw?></td>
|
|
</tr><tr>
|
|
<th>HW</th>
|
|
<td><?=$address->hw?></td>
|
|
</tr><tr>
|
|
<th>Grundstücksnr.</th>
|
|
<td><?=$address->grund_nr?></td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
|
|
<div class="card border-top-success pl-2 pr-2">
|
|
<div class="card-header">
|
|
<h4>Wohneinheiten</h4>
|
|
</div>
|
|
<?php if(is_array($address->wohneinheiten) && count($address->wohneinheiten)): ?>
|
|
<table class="table table-sm table-striped table-hover">
|
|
<tr>
|
|
<th></th>
|
|
<th>ID</th>
|
|
<th>OAID</th>
|
|
<th>Status</th>
|
|
<th>Beschreibung</th>
|
|
<th>Extref</th>
|
|
<th></th>
|
|
<th title="Anzahl Bestellungen">Best.</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php foreach($address->wohneinheiten as $unit): ?>
|
|
<tr>
|
|
<td><a href="<?=self::getUrl("ADBWohneinheit", "edit", ["id" => $unit->id])?>"><i class="fas fa-edit"></i></a></td>
|
|
<td><?=$unit->id?></td>
|
|
<td class="text-pink">
|
|
<?php if($unit->oaid): ?>
|
|
<?php if(OpenAccessIdModel::getFirst(["oaid" => $unit->oaid])): ?>
|
|
<a href="<?=self::getUrl("OpenAccessId", "", ["filter" => ["oaid" => $unit->oaid]])?>" class="text-pink" target="_blank"><?=$unit->oaid?></a>
|
|
<?php else: ?>
|
|
<?=$unit->oaid?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td id="unit-<?=$unit->id?>-status" class="text-monospace">
|
|
<span id="unitstatus-<?=$unit->id?>-text" data-status-id="<?=$unit->status_id?>"><span id="unitstatus-<?=$unit->id?>-statustext"><?=$unit->status->code?> - <?=$unit->status->name?></span> <a href="#" onclick="return toggleUnitStatusControl(<?=$unit->id?>)"><i class="fas fa-fw fa-edit"></i></a></span>
|
|
<div class="input-group" id="unitstatus-<?=$unit->id?>-input" style="display:none">
|
|
<select class="form-control">
|
|
<?php foreach(ADBStatusModel::search(["!type" => "hausnummer"]) as $status): ?>
|
|
<option value="<?=$status->id?>" <?=($unit->status_id == $status->id) ? "selected='selected'" : ""?>><?=$status->code?> - <?=$status->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<div class="input-group-append">
|
|
<button type="button" class="btn btn-primary" title="Speichern" onclick="saveUnitStatusControl(<?=$unit->id?>)"><i class="fas fa-check"></i></button>
|
|
<button type="button" class="btn btn-secondary" title="Abbrechen" onclick="toggleUnitStatusControl(<?=$unit->id?>)"><i class="fas fa-times"></i></button>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td><?=((string)$unit) ? "<strong>".(string)$unit."</strong>" : ""?></td>
|
|
<td><?=($unit->extref) ? "[".$unit->extref."]" : ""?></td>
|
|
<td>
|
|
<?php if($unit->rimo_deleted): ?>
|
|
<span class="fa-stack" style="width: 26px;" title="Home nicht (mehr) in Rimo vorhanden">
|
|
<i class="fas fa-stack-1x text-dark">R</i>
|
|
<i class="fas fa-slash fa-stack-1x fa-rotate-90 text-danger"></i>
|
|
</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td title="Anzahl Bestellungen">
|
|
<?php if(is_array($unit->active_preorders) && count($unit->active_preorders)): ?>
|
|
<a href="<?=self::getUrl("Preorder", "", [ "filter" => ["adb_wohneinheit_id" => $unit->id]])?>" target="_blank"><?=count($unit->preorders)?></a>
|
|
<?php else: ?>
|
|
0
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><a href="<?=self::getUrl("ADBWohneinheit", "delete", ["id" => $unit->id])?>" onclick="if(!confirm('Wohneinheit wirklich löschen?')) return false"><i class="fas fa-trash-alt text-danger"></i></a></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<a href="<?=self::getUrl("AddressDB")?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
|
<a href="<?=self::getUrl("AddressDB","edit", ['id' => $address->id])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Adresse bearbeiten</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
function toggleAddressStatusControl(pid) {
|
|
// set select to current status id
|
|
$("#addressstatus-" + pid + "-input select").val($("#addressstatus-" + pid + "-text").data("status-id"));
|
|
|
|
// toggle controls
|
|
$("#addressstatus-" + pid + "-text").toggle();
|
|
$("#addressstatus-" + pid + "-input").toggle();
|
|
|
|
return false;
|
|
}
|
|
|
|
function toggleUnitStatusControl(pid) {
|
|
// set select to current status id
|
|
$("#unitstatus-" + pid + "-input select").val($("#unitstatus-" + pid + "-text").data("status-id"));
|
|
|
|
// toggle controls
|
|
$("#unitstatus-" + pid + "-text").toggle();
|
|
$("#unitstatus-" + pid + "-input").toggle();
|
|
|
|
return false;
|
|
}
|
|
|
|
function saveAddressStatusControl(aid) {
|
|
if(!Number.isInteger(aid) || aid < 1) {
|
|
return false;
|
|
}
|
|
|
|
var value = $("#addressstatus-" + aid + "-input select").val();
|
|
|
|
$.post("<?=self::getUrl("AddressDB","Api")?>",
|
|
{
|
|
'do': "updateAddressStatus",
|
|
id: aid,
|
|
status_id: value
|
|
},
|
|
function(success) {
|
|
if(success.status == "OK") {
|
|
var updates = success.result.updates;
|
|
//console.log(updates);
|
|
|
|
$("#addressstatus-" + updates.id + "-statustext").text(updates.status_code + " - " + updates.status_text);
|
|
$("#addressstatus-" + updates.id + "-text")
|
|
.addClass("text-success")
|
|
.data("status-id", updates.status_id);
|
|
|
|
setTimeout(() => {
|
|
$("#addressstatus-" + updates.id + "-text").removeClass("text-success")
|
|
}, 1500);
|
|
|
|
if("units" in updates && updates.units.length) {
|
|
updates.units.forEach(function (u) {
|
|
//console.log(u);
|
|
// update detail status text
|
|
|
|
|
|
/*// update list status text
|
|
$("#addressstatus-" + u.id + " .status").text(u.code + " - " + u.text);
|
|
$("#addressstatus-" + u.id + " .status").addClass("text-success");
|
|
setTimeout(() => { $("#preorder-" + u.id + " .status").removeClass("text-success") }, 1500);
|
|
*/
|
|
|
|
|
|
if (u.status_code) {
|
|
// update units
|
|
$("#unitstatus-" + u.id + "-statustext").text(u.status_code + " - " + u.status_text);
|
|
$("#unitstatus-" + u.id + "-text").addClass("text-success");
|
|
setTimeout(() => {
|
|
$("#unitstatus-" + u.id + "-text").removeClass("text-success")
|
|
}, 1500);
|
|
}
|
|
});
|
|
}
|
|
toggleAddressStatusControl(aid);
|
|
|
|
}
|
|
|
|
},
|
|
'json');
|
|
}
|
|
|
|
function saveUnitStatusControl(aid) {
|
|
if(!Number.isInteger(aid) || aid < 1) {
|
|
return false;
|
|
}
|
|
|
|
var value = $("#unitstatus-" + aid + "-input select").val();
|
|
|
|
$.post("<?=self::getUrl("AddressDB","Api")?>",
|
|
{
|
|
'do': "updateUnitStatus",
|
|
id: aid,
|
|
status_id: value
|
|
},
|
|
function(success) {
|
|
if(success.status == "OK") {
|
|
var updates = success.result.updates;
|
|
//console.log(updates);
|
|
|
|
/*$("#unitstatus-" + updates.id + "-statustext")
|
|
.text(updates.status_code + " - " + updates.status_text)
|
|
.addClass("text-success")
|
|
$("#unitstatus-" + updates.id + "-text").data("status-id", updates.status_id);
|
|
|
|
setTimeout(() => {
|
|
$("#unitstatus-" + updates.id + "-text").removeClass("text-success")
|
|
}, 1500);
|
|
*/
|
|
|
|
//console.log(updates.units.length);
|
|
if("units" in updates && updates.units.length) {
|
|
updates.units.forEach(function (u) {
|
|
//console.log(u);
|
|
// update detail status text
|
|
|
|
|
|
/*// update list status text
|
|
$("#unitstatus-" + u.id + " .status").text(u.code + " - " + u.text);
|
|
$("#unitstatus-" + u.id + " .status").addClass("text-success");
|
|
setTimeout(() => { $("#preorder-" + u.id + " .status").removeClass("text-success") }, 1500);
|
|
*/
|
|
|
|
//console.log(u.status_code);
|
|
//console.log((u.status_code));
|
|
if(u.status_code) {
|
|
// update units
|
|
$("#unitstatus-" + u.id + "-statustext").text(u.status_code + " - " + u.status_text);
|
|
$("#unitstatus-" + u.id + "-text").data("status-id", updates.status_id);
|
|
$("#unit-" + u.id + "-status").addClass("text-success");
|
|
setTimeout(() => {
|
|
$("#unit-" + u.id + "-status").removeClass("text-success")
|
|
}, 1500);
|
|
}
|
|
});
|
|
}
|
|
toggleUnitStatusControl(aid);
|
|
|
|
}
|
|
|
|
},
|
|
'json');
|
|
}
|
|
</script>
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|