Switched Preorder building source to AddressDB
This commit is contained in:
@@ -45,72 +45,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="building-search">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="building_id_search">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">
|
||||
<a href="#" class="text-success" onclick="refreshBuildingSearch()"><i class="fas fa-refresh"></i> Aktualisieren</a>
|
||||
<table class="table table-sm table-striped table-hover mb-0" id="building-search-results">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Straße</th>
|
||||
<th>PLZ</th>
|
||||
<th>Ort</th>
|
||||
<th>Wohneinheiten belegt</th>
|
||||
<th>Code</th>
|
||||
<th>OAN ID</th>
|
||||
</tr>
|
||||
</table>
|
||||
<a href="#" class="text-success" onclick="refreshBuildingSearch()"><i class="fas fa-refresh"></i> Aktualisieren</a>
|
||||
<p class="mt-2"><a class="btn btn-sm btn-outline-primary" href="<?=self::getUrl("Building", "add", ["network_id" => $campaign->network_id])?>" target="_blank"><i class="fas fa-plus"></i> Neues Gebäude anlegen</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row" id="building-search-selected">
|
||||
<input type="hidden" name="building_id" id="building_id" value="<?=$preorder->building_id?>" />
|
||||
<label class="col-lg-2 col-form-label" for="">Ausgewähltes Gebäude</label>
|
||||
<div class="col-lg-10">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if(!$preorder->building_id): ?>
|
||||
<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>
|
||||
<?php else: ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="check-mark align-top" style="font-size: 2.5em; width:40px;"><i class="fas fa-check text-success"></i></td>
|
||||
<td class="label">
|
||||
<strong><?=$preorder->building->street?></strong><br />
|
||||
<strong><?=$preorder->building->zip?> <?=$preorder->building->city?></strong><br />
|
||||
Belegte Wohneinheiten: <?=$preorder->building->getUsedTerminationCount(true)?> von <?=($preorder->building->units) ? $preorder->building->units : 1?>
|
||||
<?php if($preorder->building->code): ?>
|
||||
<br /><?=$preorder->building->code?>
|
||||
<?php endif; ?>
|
||||
<?php if($preorder->building->oan_id): ?>
|
||||
<br /><?=$preorder->building->oan_id?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Adresse *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="adb_hausnummer_id" id="adb_hausnummer_id" />
|
||||
<?php if($preorder->adb_hausnummer_id): ?>
|
||||
<option value="<?=$preorder->adb_hausnummer_id?>" selected="selected"><?=$preorder->adb_hausnummer->plz->plz?> <?=$preorder->adb_hausnummer->strasse->ortschaft->name?>, <?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Wohneinheit *</label>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -198,35 +153,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Netto Preis Periodisch *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price" id="price" value="<?=$preorder->price?>" />
|
||||
<?php if($campaign->product_type != "setup_only"): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Netto Preis Periodisch *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price" id="price" value="<?=$preorder->price?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($me->isAdmin()): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$preorder->price_nne?>" />
|
||||
|
||||
<?php if($me->isAdmin()): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$preorder->price_nne?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$preorder->price_nbe?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="billing_delay" id="billing_delay" placeholder="Freimonate" value="<?=$preorder->billing_delay?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$preorder->price_nbe?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="billing_delay" id="billing_delay" placeholder="Freimonate" value="<?=$preorder->billing_delay?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 class="mt-4">Kundendaten</h4>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="company">Firma</label>
|
||||
@@ -315,11 +271,7 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#building-search-results-section').hide();
|
||||
<?php if(!$preorder->building_id): ?>
|
||||
$('#building-search-selected').hide();
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($preorder->type != "provision"): ?>
|
||||
$('#setup-provision').hide();
|
||||
<?php endif; ?>
|
||||
@@ -374,32 +326,93 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('#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');
|
||||
|
||||
$('#adb_hausnummer_id').select2({
|
||||
ajax: {
|
||||
url: '<?=self::getUrl("AddressDB", "api", ["do" => "findAddress"])?>',
|
||||
delay: 250,
|
||||
dataType: 'json'
|
||||
},
|
||||
minimumInputLength: 3,
|
||||
placeholder: "Suche nach Straße, Hausnummer, Ort"
|
||||
});
|
||||
|
||||
$('#building_id_search').keydown(function() {
|
||||
if(event.keyCode == 9 || event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
$('#adb_hausnummer_id').change(function() {
|
||||
var hausnummer_id = $('#adb_hausnummer_id').val();
|
||||
if(!hausnummer_id) return;
|
||||
|
||||
|
||||
$.get('<?=self::getUrl("AddressDB", "Api")?>',
|
||||
{
|
||||
do: "getUnits",
|
||||
hausnummer_id: hausnummer_id
|
||||
},
|
||||
function(success) {
|
||||
if(success.status != "OK") {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#adb_wohneinheit_id').empty();
|
||||
$('#adb_wohneinheit_id').append("<option></option>")
|
||||
|
||||
success.result.units.forEach(function(unit) {
|
||||
let opt = "<option value='" + unit.id + "'>";
|
||||
opt += unit.zip + " " + unit.city + ", " + unit.street + " " + unit.housenumber;
|
||||
if(unit.extra) {
|
||||
opt += " " + unit.extra;
|
||||
}
|
||||
|
||||
/*let extras = new Array();
|
||||
if(unit.block) extras.push("Block " + unit.block);
|
||||
if(unit.stiege) extras.push("Stiege " + unit.stiege);
|
||||
if(unit.stock) extras.push("Stock " + unit.stock);
|
||||
if(unit.tuer) extras.push("Tür " + unit.tuer);
|
||||
if(unit.zusatz) extras.push(unit.zusatz);
|
||||
|
||||
if(extras.length) {
|
||||
opt += " " + extras.join(", ");
|
||||
}*/
|
||||
|
||||
if(unit.nutzung) {
|
||||
opt += " " + unit.nutzung;
|
||||
}
|
||||
|
||||
opt += "</option>";
|
||||
$('#adb_wohneinheit_id').append(opt);
|
||||
$('#adb_wohneinheit_id').addClass("is-invalid");
|
||||
$('#adb_wohneinheit_id')
|
||||
.data("zip", unit.zip)
|
||||
.data("city", unit.city)
|
||||
.data("street", unit.street)
|
||||
.data("housenumber", unit.housenumber)
|
||||
.data("block", unit.block)
|
||||
.data("stiege", unit.stiege)
|
||||
.data("stock", unit.stock)
|
||||
.data("tuer", unit.tuer)
|
||||
.data("zusatz", unit.zusatz);
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
"json");
|
||||
});
|
||||
|
||||
$('#adb_wohneinheit_id').change(function() {
|
||||
val = $('#adb_wohneinheit_id').val();
|
||||
|
||||
if($('#adb_wohneinheit_id option').length < 2) return;
|
||||
|
||||
if(val) {
|
||||
$('#adb_wohneinheit_id').removeClass("is-invalid");
|
||||
|
||||
$('input[name=street]').val($('#adb_wohneinheit_id').data("street"));
|
||||
$('input[name=zip]').val($('#adb_wohneinheit_id').data("zip"));
|
||||
$('input[name=city]').val($('#adb_wohneinheit_id').data("city"));
|
||||
|
||||
} else {
|
||||
$('#adb_wohneinheit_id').addClass("is-invalid");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -441,6 +454,8 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function updateSetupProduct(type) {
|
||||
if(type == "provision") {
|
||||
@@ -456,98 +471,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
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_result_check" value="' + b.id + '"';
|
||||
line += 'data-zip="' + b.zip + '" data-city="' + b.city + '" data-street="' + b.street + '" data-code="' + b.code + '" data-oanid="' + b.oan_id + '" data-units="' + b.units + '" data-units-used="' + b.units_used + '" /></td>';
|
||||
|
||||
line += "<td>" + b.street + "</td>";
|
||||
line += "<td>" + b.zip + "</td>";
|
||||
line += "<td>" + b.city + "</td>";
|
||||
line += "<td>" + b.units_used + " / " + b.units + "</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_result_check][value=' + id + ']').prop('checked')) {
|
||||
$('input[name=building_result_check][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_result_check][value=' + id + ']').prop('checked', true);
|
||||
$('input[name=building_result_check]').each(function() {
|
||||
if($(this).val() != id) {
|
||||
$(this).prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
// write selected buildings address
|
||||
var street = $('input[name=building_result_check][value=' + id + ']').data("street");
|
||||
var zip = $('input[name=building_result_check][value=' + id + ']').data("zip");
|
||||
var city = $('input[name=building_result_check][value=' + id + ']').data("city");
|
||||
var code = $('input[name=building_result_check][value=' + id + ']').data("code");
|
||||
var oan_id = $('input[name=building_result_check][value=' + id + ']').data("oanid");
|
||||
var units = $('input[name=building_result_check][value=' + id + ']').data("units");
|
||||
var units_used = $('input[name=building_result_check][value=' + id + ']').data("units-used");
|
||||
|
||||
$('input[name=street]').val(street);
|
||||
$('input[name=zip]').val(zip);
|
||||
$('input[name=city]').val(city);
|
||||
|
||||
|
||||
var label = street + "<br />" + zip + " " + city;
|
||||
label += "<br /><div style='font-weight: normal;'>Belegte Wohneinheiten: " + units_used + " von " + units;
|
||||
if(code || oan_id) {
|
||||
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();
|
||||
$('#building_id').val(id);
|
||||
|
||||
showPreorderForm();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function showPreorderForm() {
|
||||
|
||||
@@ -557,18 +480,6 @@
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
function refreshBuildingSearch() {
|
||||
resetBuildingSearch();
|
||||
$('#building_id_search').keyup();
|
||||
}
|
||||
|
||||
|
||||
function updateProduct() {
|
||||
var pid = $('#product_id').val();
|
||||
|
||||
@@ -45,10 +45,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="building-search">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="city_search">Ort *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="hidden" name="adb_ortschaft_id" value="" />
|
||||
<input type="text" class="form-control" name="city_search" id="city_search" placeholder="Suche nach PLZ oder Ort" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="city-search-results-section" class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="building_units">Ortschaft auswählen *</label>
|
||||
<div class="col-lg-10">
|
||||
<table class="table table-sm table-striped table-hover mb-0" id="city-search-results">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Ortschaft</th>
|
||||
<th>Gemeinde</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="building-search" class="hidden">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="building_id_search">Gebäude suchen *</label>
|
||||
<label class="col-lg-2 col-form-label" for="building_id_search">Adresse suchen *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="building_id_search" id="building_id_search" />
|
||||
</div>
|
||||
@@ -56,7 +78,7 @@
|
||||
|
||||
|
||||
<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>
|
||||
<label class="col-lg-2 col-form-label" for="building_units">Adresse auswählen *</label>
|
||||
<div class="col-lg-10">
|
||||
<a href="#" class="text-success" onclick="refreshBuildingSearch()"><i class="fas fa-refresh"></i> Aktualisieren</a>
|
||||
<table class="table table-sm table-striped table-hover mb-0" id="building-search-results">
|
||||
@@ -316,6 +338,7 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#building-search-results-section').hide();
|
||||
$('#city-search-results-section').hide();
|
||||
<?php if(!$preorder->building_id): ?>
|
||||
$('#building-search-selected').hide();
|
||||
<?php endif; ?>
|
||||
@@ -374,15 +397,49 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#city_search').keyup(function() {
|
||||
var search = $('#city_search').val();
|
||||
|
||||
if(search.length < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.post('<?=self::getUrl('AddressDB','api')?>',
|
||||
{
|
||||
do: 'findCities',
|
||||
search: search
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
listCitySearchresults(success.result);
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('#building_id_search').keyup(function() {
|
||||
var search = $('#building_id_search').val();
|
||||
var network_id = $('#network_id').val();
|
||||
var city_id = $("input[name=city_result_check]:checked").val();
|
||||
|
||||
console.log(city_id);
|
||||
|
||||
if(!city_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!network_id || search.length < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.post('<?=self::getUrl('Building','api')?>',
|
||||
/*$.post('<?=self::getUrl('Building','api')?>',
|
||||
{
|
||||
do: 'findBuildings',
|
||||
network_id: network_id,
|
||||
@@ -393,7 +450,31 @@
|
||||
listSearchresults(success.result);
|
||||
}
|
||||
},
|
||||
'json');
|
||||
'json'
|
||||
);*/
|
||||
|
||||
$.post('<?=self::getUrl('AddressDB','api')?>',
|
||||
{
|
||||
do: 'findBuildings',
|
||||
city_id: city_id,
|
||||
search: search
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
listSearchresults(success.result);
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#city_search').keydown(function() {
|
||||
if(event.keyCode == 9 || event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#building_id_search').keydown(function() {
|
||||
@@ -441,6 +522,8 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function updateSetupProduct(type) {
|
||||
if(type == "provision") {
|
||||
@@ -456,6 +539,57 @@
|
||||
}
|
||||
}
|
||||
|
||||
function listCitySearchresults(data) {
|
||||
resetCitySearchresults();
|
||||
var count = data.cities.length;
|
||||
|
||||
if(!("cities" in data) || !count) {
|
||||
$('#city-search-results-section').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#city-search-results-section').show();
|
||||
|
||||
data.cities.forEach(function(b) {
|
||||
console.log(b);
|
||||
var line = '<tr class="result result-' + b.id + ' pointer" onclick="selectCity(' + b.id + ')">';
|
||||
line += '<td><input type="checkbox" readonly="readonly" onclick="selectCity(' + b.id + ')" name="city_result_check" value="' + b.id + '" ';
|
||||
line += ' data-city="' + b.name + '" data-gemeinde_id="' + b.gemeinde_id + '" data-gemeinde="' + b.gemeinde +'" data-kennziffer="' + b.kennziffer + '" /></td>';
|
||||
|
||||
line += "<td>" + b.name + "</td>";
|
||||
line += "<td>" + b.gemeinde + "</td>";
|
||||
line += "</tr>";
|
||||
|
||||
$('#city-search-results').append(line);
|
||||
});
|
||||
}
|
||||
|
||||
function resetCitySearchresults() {
|
||||
$('#city-search-results .result').each(function() {
|
||||
this.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function selectCity(id) {
|
||||
console.log("in selectCity");
|
||||
if($('input[name=city_result_check][value=' + id + ']').prop('checked')) {
|
||||
$('input[name=city_result_check][value=' + id + ']').prop('checked', false);
|
||||
|
||||
$('#city-search-selected .label').removeClass("font-weight-bold").text("Bitte auswählen...");
|
||||
$('#city-search-selected .check-mark i').removeClass().addClass("fas fa-question text-warning");
|
||||
$('#city-search').hide();
|
||||
} else {
|
||||
// check selected checkbox and uncheck all others
|
||||
$('input[name=city_result_check][value=' + id + ']').prop('checked', true);
|
||||
$('input[name=city_result_check]').each(function() {
|
||||
if($(this).val() != id) {
|
||||
$(this).prop('checked', false);
|
||||
}
|
||||
});
|
||||
$('#building-search').show();
|
||||
}
|
||||
}
|
||||
|
||||
function listSearchresults(data) {
|
||||
resetSearchresults();
|
||||
var count = data.buildings.length;
|
||||
@@ -479,6 +613,7 @@
|
||||
line += "<td>" + b.units_used + " / " + b.units + "</td>";
|
||||
line += "<td>" + b.code + "</td>";
|
||||
line += "<td>" + b.oan_id + "</td>";
|
||||
line += "</tr>";
|
||||
|
||||
$('#building-search-results').append(line);
|
||||
});
|
||||
@@ -549,6 +684,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showPreorderForm() {
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,19 @@
|
||||
<td><?=$preorder->campaign->name?></td>
|
||||
<td><?=__($preorder->type, "preorder")?></td>
|
||||
<td><?=($preorder->company) ? $preorder->company : $preorder->firstname." ".$preorder->lastname?></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->adb_hausnummer->strasse->name?>
|
||||
<?=$preorder->adb_hausnummer->hausnummer?><br />
|
||||
<?=($preorder->adb_wohneinheit_id) ? $preorder->adb_wohneinheit."<br />" : ""?>
|
||||
<?=$preorder->adb_hausnummer->plz->plz?>
|
||||
<?=$preorder->adb_hausnummer->strasse->ortschaft->name?>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td></td>
|
||||
<?php endif; ?>
|
||||
<td><?=($preorder->partner_id) ? $preorder->partner->getCompanyOrName() : ""?></td>
|
||||
<td><?=($preorder->termination) ? $preorder->termination->code : ""?></td>
|
||||
<td><?=date('d.m.Y H:i', $preorder->create)?></td>
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ADBHausnummer extends mfBaseModel {
|
||||
public $strasse;
|
||||
public $plz;
|
||||
public $status;
|
||||
public $providers = [];
|
||||
public $providerlist = [];
|
||||
private $strasse;
|
||||
private $plz;
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -13,8 +10,35 @@ class ADBHausnummer extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function afterLoad() {
|
||||
$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
$this->plz = new ADBPlz($this->plz_id);
|
||||
//$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
//$this->plz = new ADBPlz($this->plz_id);
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "strasse") {
|
||||
$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
return $this->strasse;
|
||||
}
|
||||
|
||||
if($name == "plz") {
|
||||
$this->plz = new ADBPlz($this->plz_id);
|
||||
return $this->plz;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ADBOrtschaft extends mfBaseModel {
|
||||
private $gemeinde;
|
||||
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -25,5 +27,27 @@ class ADBOrtschaft extends mfBaseModel {
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "gemeinde") {
|
||||
$this->gemeinde = new ADBGemeinde($this->hausnummer_id);
|
||||
return $this->gemeinde;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ADBStrasse extends mfBaseModel {
|
||||
public $gemeinde = [];
|
||||
private $ortschaft;
|
||||
private $gemeinde;
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -9,7 +10,35 @@ class ADBStrasse extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function afterLoad() {
|
||||
$this->gemeinde = new ADBGemeinde($this->gemeinde_id);
|
||||
//$this->gemeinde = new ADBGemeinde($this->gemeinde_id);
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "ortschaft") {
|
||||
$this->ortschaft = new ADBOrtschaft($this->ortschaft_id);
|
||||
return $this->ortschaft;
|
||||
}
|
||||
|
||||
if($name == "gemeinde") {
|
||||
$this->gemeinde = new ADBGemeinde($this->gemeinde_id);
|
||||
return $this->gemeinde;
|
||||
}
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ADBWohneinheit extends mfBaseModel {
|
||||
public $hausnummer;
|
||||
private $hausnummer;
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -54,7 +54,7 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function afterLoad() {
|
||||
$this->hausnummer = new ADBHausnummer($this->hausnummer_id);
|
||||
//$this->hausnummer = new ADBHausnummer($this->hausnummer_id);
|
||||
//$this->loadStatus();
|
||||
//$this->loadProvider();
|
||||
}
|
||||
@@ -84,4 +84,52 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
return true;
|
||||
}*/
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "hausnummer") {
|
||||
$this->hausnummer = new ADBHausnummer($this->hausnummer_id);
|
||||
return $this->hausnummer;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
$parts = [];
|
||||
if($this->block) {
|
||||
$parts[] = "Block ".$this->block;
|
||||
}
|
||||
if($this->stiege) {
|
||||
$parts[] = "Stiege ".$this->stiege;
|
||||
}
|
||||
if($this->stock) {
|
||||
if(is_numeric($this->stock)) {
|
||||
$parts[] = $this->stock.". Stock";
|
||||
} elseif(preg_match('/^(erdgescho(ss|ß)|parterre)$/i', $this->stock)) {
|
||||
$parts[] = "Erdgeschoss";
|
||||
} else {
|
||||
$parts[] = "Stock ".$this->stock;
|
||||
}
|
||||
}
|
||||
if($this->tuer) {
|
||||
$parts[] = "Tür ".$this->tuer;
|
||||
}
|
||||
if($this->zusatz) {
|
||||
$parts[] = $this->zusatz;
|
||||
}
|
||||
return implode(" ", $parts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class ADBWohneinheitModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Wohneinheit", "*", "$where ORDER BY hausnummer_id,block,stiege,stock,tuer LIMIT 1");
|
||||
$res = $db->select("Wohneinheit", "*", "$where ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBWohneinheit($data);
|
||||
@@ -61,7 +61,7 @@ class ADBWohneinheitModel {
|
||||
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$res = $db->select("Wohneinheit", "*", "1=1 ORDER BY hausnummer_id,block,stiege,stock,tuer");
|
||||
$res = $db->select("Wohneinheit", "*", "1=1 ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ADBWohneinheit($data);
|
||||
@@ -95,7 +95,7 @@ class ADBWohneinheitModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Wohneinheit.* FROM Wohneinheit
|
||||
WHERE $where
|
||||
ORDER BY hausnummer_id,block,stiege,stock,tuer";
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
|
||||
@@ -2,4 +2,261 @@
|
||||
|
||||
class AddressDBController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "netowner", "pipeplanner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "findAddress":
|
||||
$return = $this->findAddressApi();
|
||||
break;
|
||||
case "getFilteredBuildings":
|
||||
$return = $this->getFilteredBuildingsApi();
|
||||
break;
|
||||
case "getUnits":
|
||||
$return = $this->getUnitsApi();
|
||||
break;
|
||||
case "findCities":
|
||||
$return = $this->findCitiesApi();
|
||||
break;
|
||||
case 'findBuildings':
|
||||
$return = $this->findBuildingsApi();
|
||||
break;
|
||||
case "findUnit":
|
||||
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 findAddressApi() {
|
||||
$addresses = [];
|
||||
$search = trim($this->request->q);
|
||||
$results = [];
|
||||
|
||||
$search_parts = explode(" ", $search);
|
||||
|
||||
$ort_search = $strasse_search = $plz_search = $hausnummer_search = [];
|
||||
|
||||
foreach($search_parts as $p) {
|
||||
$p = trim($p);
|
||||
if(!$p) continue;
|
||||
$ort_search[] = "ortschaft like '%$p%'";
|
||||
$strasse_search[] = "strasse like '%$p%'";
|
||||
$plz_search[] = "plz like '%$p%'";
|
||||
$hausnummer_search[] = "hausnummer like '%$p%'";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE (".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")";
|
||||
//echo $sql;exit;
|
||||
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$res = $adb->query($sql);
|
||||
|
||||
if(!$adb->num_rows($res)) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
while($data = $adb->fetch_object($res)) {
|
||||
$address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse." ".$data->hausnummer;
|
||||
|
||||
$address = [];
|
||||
$address['id'] = $data->hausnummer_id;
|
||||
$address["text"] = $address_string;
|
||||
$addresses[] = $address;
|
||||
}
|
||||
|
||||
|
||||
// sort results by most occurences of search strings
|
||||
$sort = [];
|
||||
foreach($addresses as $address) {
|
||||
$count = 0;
|
||||
foreach($search_parts as $p) {
|
||||
$count += substr_count(strtolower($address['text']), strtolower($p));
|
||||
}
|
||||
//echo $address['text']." $p $count<br />\n";
|
||||
if(!array_key_exists($count, $sort)) {
|
||||
$sort[$count] = [];
|
||||
}
|
||||
$sort[$count][] = $address;
|
||||
}
|
||||
|
||||
ksort($sort, SORT_NUMERIC);
|
||||
$sort = array_reverse($sort, true);
|
||||
//var_dump($sort);exit;
|
||||
|
||||
foreach($sort as $res) {
|
||||
foreach($res as $a) {
|
||||
$results[] = $a;
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => $results]);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
private function getUnitsApi() {
|
||||
$results = [];
|
||||
$hausnummer_id = intval($this->request->hausnummer_id);
|
||||
|
||||
if(!$hausnummer_id) {
|
||||
return ['results' => []];
|
||||
}
|
||||
|
||||
$units = ADBWohneinheitModel::search(['hausnummer_id' => $hausnummer_id]);
|
||||
|
||||
foreach($units as $unit) {
|
||||
$u = [];
|
||||
$u['id'] = $unit->id;
|
||||
$u['zip'] = $unit->hausnummer->plz->plzstring;
|
||||
$u['city'] = $unit->hausnummer->strasse->ortschaft->name;
|
||||
$u['street'] = $unit->hausnummer->strasse->name;
|
||||
$u['housenumber'] = $unit->hausnummer->hausnummer;
|
||||
$u['block'] = $unit->block;
|
||||
$u['stiege'] = $unit->stiege;
|
||||
$u['stock'] = $unit->stock;
|
||||
$u['tuer'] = $unit->tuer;
|
||||
$u['extra'] = (string)$unit;
|
||||
$u['zusatz'] = $unit->zusatz;
|
||||
$u['usage'] = $unit->nutzung;
|
||||
$results[] = $u;
|
||||
}
|
||||
|
||||
return ['units' => $results];
|
||||
}
|
||||
|
||||
private function findCitiesApi() {
|
||||
$cities = [];
|
||||
$search = $this->request->search;
|
||||
|
||||
$ort_ids = [];
|
||||
|
||||
if(is_numeric($search)) {
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$sql = "SELECT ortschaft_id from view_wohneinheit WHERE plz like '%$search%' GROUP BY ortschaft_id";
|
||||
$res = $adb->query($sql);
|
||||
|
||||
if($adb->num_rows($res)) {
|
||||
while($data = $adb->fetch_object($res)) {
|
||||
$ort_ids[] = $data->ortschaft_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($ort_ids) {
|
||||
foreach($ort_ids as $oid) {
|
||||
$results[] = new ADBOrtschaft($oid);
|
||||
}
|
||||
} else {
|
||||
$results = ADBOrtschaftModel::search(['name%' => $search]);
|
||||
}
|
||||
|
||||
foreach($results as $city) {
|
||||
$gemeinde = new ADBGemeinde($city->gemeinde_id);
|
||||
|
||||
$data = [];
|
||||
$data['id'] = $city->id;
|
||||
$data['gemeinde_id'] = $city->gemeinde_id;
|
||||
$data['gemeinde'] = $gemeinde->name;
|
||||
$data['kennziffer'] = $city->kennziffer;
|
||||
$data['name'] = $city->name;
|
||||
$cities[] = $data;
|
||||
}
|
||||
|
||||
return ['cities' => $cities];
|
||||
}
|
||||
|
||||
private function getFilteredBuildingsApi() {
|
||||
$buildings = [];
|
||||
$filter = $this->request->filter;
|
||||
|
||||
|
||||
$results = BuildingModel::search($filter);
|
||||
|
||||
foreach($results as $building) {
|
||||
$data = $building->data;
|
||||
$data->id = $building->id;
|
||||
$buildings[] = $data;
|
||||
}
|
||||
|
||||
return ["buildings" => $buildings];
|
||||
}
|
||||
|
||||
private function findBuildingsApi() {
|
||||
$buildings = [];
|
||||
$search = $this->request->search;
|
||||
$city_id = intval($this->request->city_id);
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE (ortschaft like '%$search%' OR strasse like '%$search%' OR plz like '%$search%' OR hausnummer like '%$search%')";
|
||||
if($city_id) {
|
||||
$sql .= " AND ortschaft_id=$city_id";
|
||||
}
|
||||
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$res = $adb->query($sql);
|
||||
if(!$adb->num_rows($res)) {
|
||||
return ["count" => 0, "buildings" => []];
|
||||
}
|
||||
while($data = $adb->fetch_object($res)) {
|
||||
$buildings[$data->hausnummer_id] = $data;
|
||||
}
|
||||
|
||||
$unsorted = [];
|
||||
|
||||
foreach($buildings as $building) {
|
||||
$u = [];
|
||||
$u['id'] = $building->hausnummer_id;
|
||||
$u['street'] = $building->strasse . " ".$building->hausnummer;
|
||||
$u['zip'] = $building->plz;
|
||||
$u['city'] = $building->ortschaft;
|
||||
$u['oan_id'] = ($building->oan_id) ? $building->oan_id : "";
|
||||
$u['code'] = ($building->code) ? $building->code : "";
|
||||
$u['units'] = ($building->units) ? $building->units : 1;
|
||||
//$u['units_used'] = $building->getUsedTerminationCount(true);
|
||||
$u['units_used'] = 1;
|
||||
//$u['status'] = $building->status->name;
|
||||
$u['status'] = "";
|
||||
$unsorted[$building->strasse."-".$building->hausnummer_id] = $u;
|
||||
}
|
||||
|
||||
ksort($unsorted);
|
||||
|
||||
$results = [];
|
||||
foreach($unsorted as $r) {
|
||||
$results[] = $r;
|
||||
/*if(count($results) >= 20) {
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
return ["count" => count($buildings), "buildings" => $results];
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ class Preorder extends mfBaseModel {
|
||||
private $campaign;
|
||||
private $partner;
|
||||
private $building;
|
||||
private $adb_hausnummer;
|
||||
private $adb_wohneinheit;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
@@ -36,6 +38,17 @@ class Preorder extends mfBaseModel {
|
||||
return $this->building;
|
||||
}
|
||||
|
||||
if($name == "adb_hausnummer") {
|
||||
$this->adb_hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
return $this->adb_hausnummer;
|
||||
}
|
||||
|
||||
if($name == "adb_wohneinheit") {
|
||||
$this->adb_wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
||||
return $this->adb_wohneinheit;
|
||||
}
|
||||
|
||||
|
||||
if($name == "creator") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($user) {
|
||||
|
||||
@@ -124,7 +124,7 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
var_dump($r);
|
||||
//var_dump($r);
|
||||
|
||||
/*
|
||||
* add or edit
|
||||
@@ -147,7 +147,9 @@ class PreorderController extends mfBaseController {
|
||||
*/
|
||||
$data = [];
|
||||
$data['preordercampaign_id'] = $r->campaign_id;
|
||||
$data['building_id'] = $r->building_id;
|
||||
$data['building_id'] = ($r->building_id) ? $r->building_id : null;
|
||||
$data['adb_hausnummer_id'] = $r->adb_hausnummer_id;
|
||||
$data['adb_wohneinheit_id'] = ($r->adb_wohneinheit_id) ? $r->adb_wohneinheit_id : null;
|
||||
$data['termination_id'] = ($r->termination_id) ? $r->termination_id : null;
|
||||
|
||||
if($campaign->product_type != "setup_only") {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
class PreorderModel {
|
||||
public $preordercampaign_id;
|
||||
public $adb_hausnummer_id;
|
||||
public $adb_wohneinheit_id;
|
||||
public $building_id;
|
||||
public $termination_id;
|
||||
public $product_id;
|
||||
@@ -131,6 +133,27 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("adb_hausnummer_id", $filter)) {
|
||||
$adb_hausnummer_id = $filter['adb_hausnummer_id'];
|
||||
if(is_numeric($adb_hausnummer_id)) {
|
||||
$where .= " AND adb_hausnummer_id=$adb_hausnummer_id";
|
||||
} elseif(is_array($adb_hausnummer_id)) {
|
||||
$where .= " AND adb_hausnummer_id IN (".implode(",",$adb_hausnummer_id).")";
|
||||
} elseif($adb_hausnummer_id === null) {
|
||||
$where .= " AND adb_hausnummer_id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("adb_wohneinheit_id", $filter)) {
|
||||
$adb_wohneinheit_id = $filter['adb_wohneinheit_id'];
|
||||
if(is_numeric($adb_wohneinheit_id)) {
|
||||
$where .= " AND adb_wohneinheit_id=$adb_wohneinheit_id";
|
||||
} elseif(is_array($adb_wohneinheit_id)) {
|
||||
$where .= " AND adb_wohneinheit_id IN (".implode(",",$adb_wohneinheit_id).")";
|
||||
} elseif($adb_wohneinheit_id === null) {
|
||||
$where .= " AND adb_wohneinheit_id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
|
||||
@@ -107,6 +107,7 @@ class mfBaseApicontroller {
|
||||
// CORS preflight OPTIONS
|
||||
// CORS headers must be correctly set in .htaccess or vhost config
|
||||
if($this->http_method == "OPTIONS") {
|
||||
// XXX TODO: api endpoint should decide if Origin should be allowed access
|
||||
$this->return(mfResponse::Ok());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user