479 lines
22 KiB
PHP
479 lines
22 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("Preorder", "save", ['preordercampaign_id' => $campaign->id])?>">
|
|
<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">Vorbestellkampagne</label>
|
|
<div class="col-lg-10">
|
|
<input type="hidden" name="campaign_id" id="campaign_id" value="<?=$campaign->id?>" />
|
|
<input type="text" class="form-control" value="<?=$campaign->name?>" readonly="readonly"/>
|
|
</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">
|
|
<input type="hidden" name="network_id" id="network_id" value="<?=$campaign->network_id?>" />
|
|
<input type="text" class="form-control" value="<?=$campaign->network->name?>" readonly="readonly" />
|
|
</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>
|
|
|
|
</div>
|
|
|
|
<div id="preorder-form" class="mt-4">
|
|
<h4>Vorbestellung & Produkt</h4>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="type">Vorbestelltyp *</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control" name="type" id="type">
|
|
<option value="interest" <?=($preorder->type == "interest") ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
|
<option value="provision" <?=($preorder->type == "provision") ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
|
<option value="order" <?=($preorder->type == "order") ? "selected='selected'" : ""?>>Vollanschluss</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="product_id">Vertriebspartner</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control" name="partner_id" id="partner_id">
|
|
<option value=""></option>
|
|
<?php foreach($partners as $partner): ?>
|
|
<option value="<?=$partner->id?>" <?=($preorder->partner_id == $partner->id) ? "selected='selected'" : ""?>><?=$partner->getCompanyOrName()?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="product_id">Produkt *</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control" name="product_id" id="product_id" onchange="updateProduct()">
|
|
<option value=""></option>
|
|
<?php foreach($products as $product): ?>
|
|
<option value="<?=$product->id?>" <?=($preorder->product_id == $product->id) ? "selected='selected'" : ""?>><?=$product->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price_setup">Netto Preis Setup *</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$preorder->price_setup?>" />
|
|
</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?>" />
|
|
</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?>" />
|
|
</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>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="company" id="company" value="<?=$preorder->company?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="uid">UID</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="uid" id="uid" value="<?=$preorder->uid?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="firstname">Vorname *</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="firstname" id="firstname" value="<?=$preorder->firstname?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="lastname">Nachname *</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="lastname" id="lastname" value="<?=$preorder->lastname?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="street">Straße *</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="street" id="street" value="<?=$preorder->street?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="zip">PLZ / Ort *</label>
|
|
<div class="col-lg-3">
|
|
<input type="text" class="form-control" name="zip" id="zip" value="<?=$preorder->zip?>" />
|
|
</div>
|
|
<div class="col-lg-7">
|
|
<input type="text" class="form-control" name="city" id="city" value="<?=$preorder->city?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="phone">Telefon</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="phone" id="phone" value="<?=$preorder->phone?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="email">Email</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="email" id="email" value="<?=$preorder->email?>" />
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
|
<div class="col-lg-10">
|
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$preorder->note?></textarea>
|
|
</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();
|
|
<?php if(!$preorder->building_id): ?>
|
|
$('#building-search-selected').hide();
|
|
<?php endif; ?>
|
|
|
|
$("#product_id").select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
$("#partner_id").select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
|
|
/**********************
|
|
* 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_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() {
|
|
|
|
}
|
|
|
|
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");
|
|
}
|
|
|
|
function refreshBuildingSearch() {
|
|
resetBuildingSearch();
|
|
$('#building_id_search').keyup();
|
|
}
|
|
|
|
|
|
function updateProduct() {
|
|
var pid = $('#product_id').val();
|
|
if(!pid) {
|
|
return false;
|
|
}
|
|
|
|
$.get("<?=self::getUrl("Product", "Api")?>",
|
|
{
|
|
"do": "getProduct",
|
|
product_id: pid,
|
|
form_id: 0
|
|
},
|
|
function (success) {
|
|
//console.log(success);
|
|
p = success.result.product;
|
|
|
|
$('#billing_delay').val(p.billing_delay);
|
|
$('#billing_period').val(p.billing_period);
|
|
$('#price').val(p.price);
|
|
//$('#price_setup').val(p.price_setup);
|
|
$('#price_nne').val(p.price_nne);
|
|
$('#price_nbe').val(p.price_nbe);
|
|
},
|
|
'json');
|
|
|
|
}
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|