Added preorder map (visible for admins only)
This commit is contained in:
@@ -200,7 +200,6 @@
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
@@ -208,8 +207,7 @@
|
||||
<td><?=__($link->type, "contract")?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $link->contract->owner_id])?>"><?=$link->contract->owner->getCompanyOrName()?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract_id?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->matchcode?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?> [<?=$link->contract->matchcode?>]</a></td>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->id?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<!--<td>
|
||||
|
||||
@@ -322,7 +322,6 @@
|
||||
<th>Contract ID</th>
|
||||
<th>Typ</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
@@ -350,8 +349,7 @@
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->matchcode?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$linkcontract->matchcode?>]</a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
|
||||
|
||||
@@ -128,6 +128,22 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row col" id="map-link">
|
||||
<a href="#" class="btn btn-success" onclick="refreshMap()"><i class="far fa-map"></i> Übersichtskarte einblenden</a>
|
||||
</div>
|
||||
<div class="row hidden" id="map-row">
|
||||
<div id="preorder-map" style="height:70vh; width: 100%"></div>
|
||||
<div class="mt-1">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle"></i> Zentrieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="card">
|
||||
@@ -233,12 +249,9 @@
|
||||
attributes.forEach(function(attrib) {
|
||||
$("input[name=attributes_" + attrib + "]").change(function(ev) {
|
||||
// save new value
|
||||
//console.log(ev);
|
||||
var cb = $("#" + ev.currentTarget.id);
|
||||
//console.log($(cb).is(":checked"));
|
||||
var value = $(cb).is(":checked") ? 1 : 0;
|
||||
var preorder_id = $(cb).data("preorder-id");
|
||||
//console.log(preorder_id);
|
||||
|
||||
$.post("<?=self::getUrl("Preorder", "Api")?>", {
|
||||
do: "saveAttribute",
|
||||
@@ -282,5 +295,146 @@
|
||||
$("#attributes_" + attribute + "-" + id).prop("checked", !$("#attributes_" + attribute + "-" + id).is(":checked"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Globals for map display
|
||||
*/
|
||||
|
||||
var preorderMap;
|
||||
var preorders = [];
|
||||
var markers = [];
|
||||
var markerState = true;
|
||||
var mapCenterPos = [<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>];
|
||||
|
||||
function refreshMap() {
|
||||
// get Preorders and render map
|
||||
$('#map-link').hide();
|
||||
$('#map-row').show();
|
||||
getMapdata();
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $("#preorder-map").offset().top - 150
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function renderMap() {
|
||||
if(preorderMap) {
|
||||
markers.forEach(function(m) {
|
||||
preorderMap.removeLayer(m);
|
||||
});
|
||||
} else {
|
||||
preorderMap = L.map('preorder-map').setView([<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>], 12);
|
||||
}
|
||||
|
||||
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||
minZoom: 4,
|
||||
maxZoom: 22,
|
||||
id: 'mapbox/streets-v11',
|
||||
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
|
||||
}).addTo(preorderMap);
|
||||
|
||||
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
|
||||
|
||||
addMarkers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addMarkers() {
|
||||
if(!Array.isArray(preorders) | !preorders.length) {
|
||||
return false;
|
||||
}
|
||||
// draw markers and calculate center position
|
||||
var all_coords = [];
|
||||
preorders.forEach(function(preorder) {
|
||||
if(!preorder.gps_lat || !preorder.gps_long) {
|
||||
return;
|
||||
}
|
||||
var gps = [preorder.gps_lat, preorder.gps_long];
|
||||
all_coords.push(gps);
|
||||
|
||||
var icon_color = "#2AAD27";
|
||||
var icon_name = "home";
|
||||
|
||||
if(preorder.type == "interest") {
|
||||
icon_color = "#CB2B3E";
|
||||
} else if(preorder.type == "provision") {
|
||||
icon_color = "#CB8427";
|
||||
}
|
||||
|
||||
if(preorder.connection_type.match(/^multi/i) || preorder.count > 1) {
|
||||
icon_name = "town";
|
||||
} else if(preorder.connection_type.match(/^apartment-building/i)) {
|
||||
icon_name = "city";
|
||||
} else if(preorder.connection_type.match(/^business/i)) {
|
||||
icon_name = "industry";
|
||||
}
|
||||
|
||||
var marker_popup_content = '<?php include(realpath(dirname(__FILE__))."/include/preorder_popup.php");?>';
|
||||
|
||||
[["street", preorder.adb_strasse], ["hausnummer", preorder.adb_hausnummer], ["zip", preorder.adb_plz], ["city", preorder.adb_ort], ["type", preorder.type_label], ["adrcd", preorder.adrcd], ["extref", preorder.extref], ["gps", preorder.gps_lat + ", " + preorder.gps_long],
|
||||
["contact", (preorder.company ? preorder.company + " " : preorder.firstname + " " + preorder.lastname)], ["phone", preorder.phone], ["email", preorder.email], ["connectiontype", preorder.connection_type_label], ["count", preorder.connection_count]
|
||||
].forEach(function(item) {
|
||||
marker_popup_content = marker_popup_content.replaceAll("{{" + item[0].toUpperCase() + "}}", item[1]);
|
||||
});
|
||||
|
||||
var icon = L.MakiMarkers.icon({icon: icon_name, color: icon_color, size: "l"});
|
||||
var marker = L.marker(gps, {icon: icon}).addTo(preorderMap).bindPopup(marker_popup_content);
|
||||
markers[preorder.id] = marker;
|
||||
});
|
||||
|
||||
|
||||
// calculate center position
|
||||
mapCenterPos = GetCenterFromDegrees(all_coords);
|
||||
preorderMap.setView(mapCenterPos, 12);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function centerMap() {
|
||||
preorderMap.setView(mapCenterPos, 12);
|
||||
}
|
||||
|
||||
// gets preorders and calls renderMap()
|
||||
function getMapdata() {
|
||||
filter = getFilter();
|
||||
|
||||
$.post('<?=self::getUrl("Preorder", "Api")?>', {
|
||||
'do': "getFilteredPreorders",
|
||||
filter: filter
|
||||
},function(success) {
|
||||
if(success.status == "OK") {
|
||||
|
||||
if(Array.isArray(success.result.preorders)) {
|
||||
preorders = success.result.preorders;
|
||||
renderMap();
|
||||
}
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function getFilter() {
|
||||
var fields = ['preordercampaign_id', 'status', 'type', 'address', 'kunde', 'address_source'];
|
||||
var filter = {};
|
||||
fields.forEach(function(field) {
|
||||
if(!field) {
|
||||
return;
|
||||
}
|
||||
let val = $('#filter_' + field).val();
|
||||
if(val.length) {
|
||||
filter[field] = val;
|
||||
}
|
||||
});
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
<?php if(is_array($filter) && count($filter)): ?>
|
||||
//refreshMap();
|
||||
<?php endif; ?>
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
|
||||
42
Layout/default/Preorder/include/preorder_popup.php
Normal file
42
Layout/default/Preorder/include/preorder_popup.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
<div class="font-weight-bold">
|
||||
{{STREET}} {{HAUSNUMMER}}<br />
|
||||
{{ZIP}} {{CITY}}
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<table class="table table-sm table-striped">
|
||||
<tr>
|
||||
<th class="font-weight-bold">GWR Adrcd:</th>
|
||||
<td>{{ADRCD}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Extref:</th>
|
||||
<td>{{EXTREF}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Gebäudetyp:</th>
|
||||
<td>{{CONNECTIONTYPE}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Bestelltyp:</th>
|
||||
<td>{{TYPE}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Anschlüsse:</th>
|
||||
<td>{{COUNT}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">GPS:</th>
|
||||
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}" target="_blank">{{GPS}}</a></td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Kontakt:</th>
|
||||
<td>{{CONTACT}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Telefon:</th>
|
||||
<td>{{PHONE}}</td>
|
||||
</tr><tr>
|
||||
<th class="font-weight-bold">Email:</th>
|
||||
<td>{{EMAIL}}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<?=str_replace("\n"," ",ob_get_clean())?>
|
||||
Reference in New Issue
Block a user