275 lines
10 KiB
PHP
275 lines
10 KiB
PHP
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Building")?>">Vorbestellung</a></li>
|
|
<li class="breadcrumb-item active"><?=($campaign->id) ? "bearbeiten" : "Neu" ?></li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Vorbestellung</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="header-title mb-2"><?=($preorder->id) ? "Vorbestellung bearbeiten" : "Neue Vorbestellung"?></h4>
|
|
|
|
<form class="form-horizontal" method="post" action="<?=self::getUrl("Preordercampaign", "save")?>">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<input type="hidden" name="id" value="<?=$preorder->id?>" />
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet *</label>
|
|
<div class="col-lg-10">
|
|
<select class="select2 form-control " name="network_id" id="network_id">
|
|
<option></option>
|
|
<?php foreach($networks as $network): ?>
|
|
<option value="<?=$network->id?>" <?=($campaign->network_id == $network->id) ? "selected='selected'" : ""?>><?=($network->name)?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="building-search" class="hidden">
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="building_units">Gebäude suchen *</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="building_id_search" id="building_id_search" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row" id="building-search-results-section">
|
|
<label class="col-lg-2 col-form-label" for="building_units">Gebäude auswählen *</label>
|
|
<div class="col-lg-10">
|
|
<table class="table table-striped table-hover" id="building-search-results">
|
|
<tr>
|
|
<th></th>
|
|
<th>Straße</th>
|
|
<th>PLZ</th>
|
|
<th>Ort</th>
|
|
<th>Code</th>
|
|
<th>OAN ID</th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row" id="building-search-selected">
|
|
<label class="col-lg-2 col-form-label" for="">Ausgewähltes Gebäude</label>
|
|
<div class="col-lg-10">
|
|
<table>
|
|
<tr>
|
|
<td class="check-mark align-top" style="font-size: 2.5em; width:40px;"><i class="fas fa-question text-warning"></i></td>
|
|
<td class="label">Bitte auswählen...</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="form-group row hidden" id="termination-search-results-section">
|
|
<label class="col-lg-2 col-form-label" for="">Anschluss auswählen *</label>
|
|
<div class="col-lg-10">
|
|
<table class="table table-striped table-hover" id="termination-search-results">
|
|
<tr>
|
|
<th></th>
|
|
<th>Bezeichung</th>
|
|
<th>Kontakt</th>
|
|
<th>Status</th>
|
|
<th>Anschluss ID</th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2"></label>
|
|
<div class="col-lg-10">
|
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
|
$('#building-search-results-section').hide();
|
|
$('#building-search-selected').hide();
|
|
|
|
/**********************
|
|
* Event handler
|
|
**********************/
|
|
// show Building Search when selecting Network
|
|
$('#network_id').change(function() {
|
|
var network_id = $('#network_id').val();
|
|
if(network_id) {
|
|
$('#building-search').show();
|
|
$('#building_id_search').focus();
|
|
} else {
|
|
$('#building-search').hide();
|
|
resetBuildingSearch();
|
|
}
|
|
});
|
|
|
|
$('#building_id_search').keyup(function() {
|
|
var search = $('#building_id_search').val();
|
|
var network_id = $('#network_id').val();
|
|
|
|
if(!network_id || search.length < 3) {
|
|
return;
|
|
}
|
|
|
|
$.post('<?=self::getUrl('Building','api')?>',
|
|
{
|
|
do: 'findBuildings',
|
|
network_id: network_id,
|
|
search: search
|
|
},
|
|
function(success) {
|
|
if(success.status == "OK") {
|
|
listSearchresults(success.result);
|
|
}
|
|
},
|
|
'json');
|
|
});
|
|
|
|
$('#building_id_search').keydown(function() {
|
|
if(event.keyCode == 9 || event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
function listSearchresults(data) {
|
|
resetSearchresults();
|
|
var count = data.buildings.length;
|
|
var count_total = data.count;
|
|
|
|
if(!("buildings" in data) || !count) {
|
|
$('#building-search-results-section').hide();
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#building-search-results-section').show();
|
|
|
|
data.buildings.forEach(function(b) {
|
|
var line = '<tr class="result result-' + b.id + ' pointer" onclick="selectBuilding(' + b.id + ')">';
|
|
line += '<td><input type="checkbox" readonly="readonly" onclick="selectBuilding(' + b.id + ')" name="building_id" value="' + b.id + '" data-zip="' + b.zip + '" data-city="' + b.city + '" data-street="' + b.street + '" data-code="' + b.code + '" data-oanid="' + b.oan_id + '" /></td>';
|
|
line += "<td>" + b.street + "</td>";
|
|
line += "<td>" + b.zip + "</td>";
|
|
line += "<td>" + b.city + "</td>";
|
|
line += "<td>" + b.code + "</td>";
|
|
line += "<td>" + b.oan_id + "</td>";
|
|
|
|
$('#building-search-results').append(line);
|
|
});
|
|
console.log(count);
|
|
console.log(count_total);
|
|
if(count < count_total) {
|
|
$('#building-search-results').append('<tr class="results-more bg-warning"><td><i class="fas fa-warning"></i></td><td colspan="5">Es wurden ' + (count_total - count) + ' weitere Suchergebnisse gefunden. Bitte verfeinern Sie die Suche!</td></tr>');
|
|
} else {
|
|
$('#building-search-results .results-more').remove();
|
|
}
|
|
}
|
|
|
|
function resetSearchresults() {
|
|
$('#building-search-results .result').each(function() {
|
|
this.remove();
|
|
});
|
|
$('#building-search-results .results-more').remove();
|
|
}
|
|
|
|
function selectBuilding(id) {
|
|
if($('input[name=building_id][value=' + id + ']').prop('checked')) {
|
|
$('input[name=building_id][value=' + id + ']').prop('checked', false);
|
|
|
|
$('#building-search-selected .label').removeClass("font-weight-bold").text("Bitte auswählen...");
|
|
$('#building-search-selected .check-mark i').removeClass().addClass("fas fa-question text-warning");
|
|
} else {
|
|
// check selected checkbox and uncheck all others
|
|
$('input[name=building_id][value=' + id + ']').prop('checked', true);
|
|
$('input[name=building_id]').each(function() {
|
|
if($(this).val() != id) {
|
|
$(this).prop('checked', false);
|
|
}
|
|
});
|
|
|
|
// write selected buildings address
|
|
var street = $('input[name=building_id][value=' + id + ']').data("street");
|
|
var zip = $('input[name=building_id][value=' + id + ']').data("zip");
|
|
var city = $('input[name=building_id][value=' + id + ']').data("city");
|
|
var code = $('input[name=building_id][value=' + id + ']').data("code");
|
|
var oan_id = $('input[name=building_id][value=' + id + ']').data("oanid");
|
|
|
|
var label = street + "<br />" + zip + " " + city;
|
|
if(code || oan_id) {
|
|
label += "<br /><div style='font-weight: normal;'>";
|
|
if(code) {
|
|
label += "<br />Code: " + code;
|
|
}
|
|
if(oan_id) {
|
|
label += "<br />OAN ID: " + oan_id;
|
|
}
|
|
label += "</div>";
|
|
}
|
|
$('#building-search-selected .label').addClass("font-weight-bold").html(label);
|
|
$('#building-search-selected .check-mark i').removeClass().addClass("fas fa-check text-success");
|
|
|
|
$('#building-search-selected').show();
|
|
|
|
// get terminatiions
|
|
|
|
}
|
|
}
|
|
|
|
function showTerminationSearch() {
|
|
|
|
}
|
|
|
|
function resetBuildingSearch() {
|
|
resetSearchresults();
|
|
$('#building-search-selected').hide();
|
|
$('#building-search-selected .label').removeClass("font-weight-bold").text("Bitte auswählen...");
|
|
$('#building-search-selected .check-mark i').removeClass().addClass("fas fa-question text-warning");
|
|
}
|
|
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|