Switched Preorder building source to AddressDB
This commit is contained in:
@@ -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() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user