517 lines
25 KiB
PHP
517 lines
25 KiB
PHP
<?php
|
|
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
|
$pagination_baseurl_params = ["filter" => $filter];
|
|
$pagination_entity_name = "Vorbestellungen";
|
|
?>
|
|
<?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("Preordercampaign")?>">Vorbestellkampagnen</a></li>
|
|
<li class="breadcrumb-item active">Vorbestellungen</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Vorbestellungen<?=(isset($campaign) && $campaign) ? " - ".$campaign->name : ""?></h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<h4 class="header-title mb-3">Filter</h4>
|
|
|
|
<form method="get" action="<?=self::getUrl("Preorder")?>">
|
|
<div class="row">
|
|
|
|
<?php if($me->is("preorderfront")): ?>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_kunde">Kunde (Name oder Adresse)</label>
|
|
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde']?>" />
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_address">Anschlussadresse</label>
|
|
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=$filter['address']?>" />
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_hausnummer">Hausnummer</label>
|
|
<input type="text" class="form-control" name="filter[hausnummer]" id="filter_hausnummer" value="<?=$filter['hausnummer']?>" />
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_preordercampaign_id">Kampagne</label>
|
|
<select name="filter[preordercampaign_id]" id="filter_preordercampaign_id" class="form-control">
|
|
<option value="">Alle</option>
|
|
<?php foreach($my_campaigns as $c): ?>
|
|
<option value="<?=$c->id?>" <?=(isset($campaign) && $c->id == $campaign->id) ? "selected='selected'" : ""?>><?=$c->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_status">Status</label>
|
|
<select name="filter[status][]" id="filter_status" class="form-control" multiple="multiple">
|
|
<option value="new" <?=(isset($filter) && array_key_exists("status", $filter) && in_array("new", $filter['status'])) ? "selected='selected'" : ""?>>Aufgenommen</option>
|
|
<option value="approved" <?=(isset($filter) && array_key_exists("status", $filter) && in_array("approved", $filter['status'])) ? "selected='selected'" : ""?>>Freigegeben</option>
|
|
<option value="pipework" <?=(isset($filter) && array_key_exists("status", $filter) && in_array("pipework", $filter['status'])) ? "selected='selected'" : ""?>>Tiefbau</option>
|
|
<option value="linework" <?=(isset($filter) && array_key_exists("status", $filter) && in_array("linework", $filter['status'])) ? "selected='selected'" : ""?>>Leitungsbau</option>
|
|
<option value="finished" <?=(isset($filter) && array_key_exists("status", $filter) && in_array("finished", $filter['status'])) ? "selected='selected'" : ""?>>Hergestellt</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_type">Bestelltyp</label>
|
|
<select name="filter[type][]" id="filter_type" class="form-control" multiple="multiple">
|
|
<option value="interest" <?=(isset($filter) && array_key_exists("type", $filter) && in_array("interest", $filter['type'])) ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
|
<option value="provision" <?=(isset($filter) && array_key_exists("type", $filter) && in_array("provision", $filter['type'])) ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
|
<option value="order" <?=(isset($filter) && array_key_exists("type", $filter) && in_array("order", $filter['type'])) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_addon_services">Zusatzdienste</label>
|
|
<select name="filter[addon_services]" id="filter_addon_services" class="form-control">
|
|
<option></option>
|
|
<option value="1" <?=(array_key_exists("addon_services", $filter) && $filter['addon_services'] == 1) ? "selected='selected'" : ""?>>Nur mit Zusatzdiensten</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_address">Anschlussadresse</label>
|
|
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=$filter['address']?>" />
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_kunde">Kunde</label>
|
|
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde']?>" />
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_address_source">Adressherkunft</label>
|
|
<select name="filter[address_source]" id="filter_address_source" class="form-control">
|
|
<option value=""></option>
|
|
<option value="addressdb" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "addressdb") ? "selected='selected'" : ""?>>thetool AddressDB</option>
|
|
<option value="manual" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "manual") ? "selected='selected'" : ""?>>manuelle Eingabe</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_unit_missing">Wohneinheit</label>
|
|
<select name="filter[unit_missing]" id="filter_unit_missing" class="form-control">
|
|
<option value=""></option>
|
|
<option value="yes" <?=(isset($filter) && array_key_exists("unit_missing", $filter) && $filter['unit_missing'] == "yes") ? "selected='selected'" : ""?>>Wohneinheit fehlt</option>
|
|
<option value="no" <?=(isset($filter) && array_key_exists("unit_missing", $filter) && $filter['unit_missing'] == "no") ? "selected='selected'" : ""?>>Wohneinheit vorhanden</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_connection_count">Anzahl Anschlüsse</label>
|
|
<select name="filter[connection_count]" id="filter_connection_count" class="form-control">
|
|
<option value=""></option>
|
|
<option value="1" <?=(isset($filter) && array_key_exists("connection_count", $filter) && intval($filter['connection_count']) === 1) ? "selected='selected'" : ""?>>1</option>
|
|
<option value="2" <?=(isset($filter) && array_key_exists("connection_count", $filter) && intval($filter['connection_count']) === 2) ? "selected='selected'" : ""?>> > 1</option>
|
|
</select>
|
|
</div>
|
|
|
|
<?php if($me->is("Admin")): ?>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_unit_count">Anzahl GWR Wohneinheiten</label>
|
|
<select name="filter[unit_count]" id="filter_unit_count" class="form-control">
|
|
<option value=""></option>
|
|
<option value="0" <?=(isset($filter) && array_key_exists("unit_count", $filter) && strlen($filter['unit_count']) && intval($filter['unit_count']) === 0) ? "selected='selected'" : ""?>>0</option>
|
|
<option value="1" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 1) ? "selected='selected'" : ""?>>1</option>
|
|
<option value="2" <?=(isset($filter) && array_key_exists("unit_count", $filter) && intval($filter['unit_count']) === 2) ? "selected='selected'" : ""?>> > 1</option>
|
|
</select>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="row mt-2">
|
|
<div class="col">
|
|
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
|
<?php if(isset($campaign) && $campaign->id): ?>
|
|
<a class="btn btn-secondary" href="<?=self::getUrl("Preorder", "Index", ['filter' => ['preordercampaign_id' => $campaign->id]])?>">Filter zurücksetzen</a>
|
|
<?php else: ?>
|
|
<a class="btn btn-secondary" href="<?=self::getUrl("Preorder")?>">Filter zurücksetzen</a>
|
|
<?php endif; ?>
|
|
<?php if(!$me->is("Preorderfront")): ?>
|
|
<button type="submit" formaction="<?=self::getUrl("Preorder", "export")?>" id="export-button" class="btn btn-outline-success ml-2"><i class="fas fa-download"></i> CSV-Export</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<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="row mt-1">
|
|
<div class="col">
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle fa-fw"></i> Zentrieren</button>
|
|
<button type="button" class="btn btn-sm btn-outline-success" onclick="toggleTileset()" title="Zwischen Karte und Satellitenbild umschalten"><i class="far fa-arrow-right-arrow-left fa-fw"></i> Karte/Satellit</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="float-left">
|
|
<h4 class="header-title">Liste aller Vorbestellungen<?=(isset($campaign) && $campaign) ? " - ".$campaign->name : ""?></h4>
|
|
</div>
|
|
<?php if($filter['preordercampaign_id']): ?>
|
|
<div class="float-right">
|
|
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preorder", "add", ["preordercampaign_id" => $filter['preordercampaign_id']])?>"><i class="fas fa-plus"></i> Neue Vorbestellung anlegen</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
|
|
<table class="table table-striped table-hover">
|
|
<tr>
|
|
<?php if(!$me->is("preorderfront")): ?><th>Kampagne</th><?php endif; ?>
|
|
<th>Bestelltyp</th>
|
|
<th>Status</th>
|
|
<th>Anschlussadresse</th>
|
|
<th>Anschlüsse</th>
|
|
<th>Kunde</th>
|
|
<th>Kontakt</th>
|
|
<th>Partner</th>
|
|
<th>Attribute</th>
|
|
<th>Erstellt</th>
|
|
<th>Zuletzt bearbeitet</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php foreach($preorders as $preorder): ?>
|
|
<tr>
|
|
<?php if(!$me->is("preorderfront")): ?><td><?=$preorder->campaign->name?></td><?php endif; ?>
|
|
<td><?=__($preorder->type, "preorder")?></td>
|
|
<td>Aufgenommen</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->address_created) ? "class='alert-warning' title='Adresse manuell angelegt'" : ""?>">
|
|
<?=$preorder->adb_hausnummer->strasse->name?>
|
|
<?=$preorder->adb_hausnummer->hausnummer?><br />
|
|
<?=($preorder->adb_wohneinheit_id) ? ((string)$preorder->adb_wohneinheit ? $preorder->adb_wohneinheit."<br />" : "") : "<i class='text-pink'><keine Wohneinheit></i><br />"?>
|
|
<?=$preorder->adb_hausnummer->plz->plz?>
|
|
<?=$preorder->adb_hausnummer->ortschaft->name?><br />
|
|
<?=$preorder->adb_hausnummer->strasse->gemeinde->name?>
|
|
</td>
|
|
<?php else: ?>
|
|
<td></td>
|
|
<?php endif; ?>
|
|
<td><?=($preorder->connection_count) ? $preorder->connection_count : 1?></td>
|
|
<td>
|
|
<?=($preorder->company) ? $preorder->company : $preorder->firstname." ".$preorder->lastname?><br />
|
|
<?=$preorder->street?><?=($preorder->housenumber) ? " ".$preorder->housenumber : ""?><br />
|
|
<?=$preorder->zip?> <?=$preorder->city?>
|
|
</td>
|
|
<td>
|
|
<?=($preorder->phone) ? $preorder->phone."<br />" : ""?>
|
|
<?=($preorder->email) ? $preorder->email : ""?>
|
|
</td>
|
|
|
|
<td><?=($preorder->partner_id) ? $preorder->partner->getCompanyOrName() : ""?></td>
|
|
<td>
|
|
<label><input type="checkbox" name="attributes_bep_specified" id="attributes_bep_specified-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("bep_specified", $preorder->attribute) && $preorder->attribute["bep_specified"]) ? "checked='checked'" : ""?> /> Borderpoint festgelegt</label><br />
|
|
<label><input type="checkbox" name="attributes_inhouse_cabling_supplied" id="attributes_inhouse_cabling_supplied-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("inhouse_cabling_supplied", $preorder->attribute) && $preorder->attribute["inhouse_cabling_supplied"]) ? "checked='checked'" : ""?> /> Starterpaket erhalten</label>
|
|
</td>
|
|
<td><?=date('d.m.Y H:i', $preorder->create)?></td>
|
|
<td id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></td>
|
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
|
<?php if(!$me->is("preorderfront")): ?>
|
|
<a href="<?=self::getUrl("Preorder", "edit", ["id" => $preorder->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
|
|
<a href="<?=self::getUrl("Preorder", "delete", ["id" => $preorder->id, "filter" => $filter])?>" class="text-danger" onclick="if(!confirm('Vorbestellung wirklich löschen?')) return false;" title="Vorbestellung Löschen"><i class="fas fa-trash"></i></a>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#filter_type").select2({closeOnSelect: false});
|
|
$("#filter_status").select2({closeOnSelect: false});
|
|
|
|
var attributes = ["bep_specified", "inhouse_cabling_supplied"];
|
|
|
|
|
|
|
|
attributes.forEach(function(attrib) {
|
|
$("input[name=attributes_" + attrib + "]").change(function(ev) {
|
|
// save new value
|
|
var cb = $("#" + ev.currentTarget.id);
|
|
var value = $(cb).is(":checked") ? 1 : 0;
|
|
var preorder_id = $(cb).data("preorder-id");
|
|
|
|
$.post("<?=self::getUrl("Preorder", "Api")?>", {
|
|
do: "saveAttribute",
|
|
id: preorder_id,
|
|
attribute: attrib,
|
|
value: value
|
|
},
|
|
function(success) {
|
|
if(success.status == "OK") {
|
|
attributeSuccess(success.result);
|
|
} else {
|
|
attributeError(success.result.id, success.result.attribute);
|
|
}
|
|
},
|
|
"json"
|
|
);
|
|
|
|
});
|
|
});
|
|
});
|
|
|
|
function attributeSuccess(result) {
|
|
var id = result.id
|
|
var attribute = result.attribute
|
|
var update = result.update
|
|
|
|
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-danger");
|
|
$("#attributes_" + attribute + "-" + id).parent().addClass("text-success");
|
|
if(update) {
|
|
$("#update-" + id).text(update);
|
|
$("#update-" + id).addClass("text-success")
|
|
}
|
|
setTimeout(function() {
|
|
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-success");
|
|
$("#update-" + id).removeClass("text-success")
|
|
}, 2000, id, attribute);
|
|
}
|
|
|
|
function attributeError(id, attribute) {
|
|
$("#attributes_" + attribute + "-" + id).parent().addClass("text-danger");
|
|
$("#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?>];
|
|
var tileLayers = [];
|
|
var tilesets = ["mapbox/streets-v12", "mapbox/satellite-streets-v12"];
|
|
var currentTileset = "mapbox/streets-v12";
|
|
|
|
function toggleTileset() {
|
|
if(currentTileset == "mapbox/streets-v12") {
|
|
currentTileset = "mapbox/satellite-streets-v12";
|
|
} else {
|
|
currentTileset = "mapbox/streets-v12";
|
|
}
|
|
|
|
console.log("renderMap");
|
|
renderMap(true);
|
|
}
|
|
|
|
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(tilesetChangeOnly = false) {
|
|
if(preorderMap) {
|
|
if(!tilesetChangeOnly) {
|
|
markers.forEach(function(m) {
|
|
preorderMap.removeLayer(m);
|
|
});
|
|
}
|
|
} else {
|
|
preorderMap = L.map('preorder-map').setView([<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>], 12);
|
|
}
|
|
|
|
if(!(currentTileset in tileLayers)) {
|
|
tileLayers[currentTileset] = 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: 6,
|
|
maxZoom: 22,
|
|
id: currentTileset,
|
|
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
|
|
});
|
|
}
|
|
|
|
|
|
tileLayers[currentTileset].addTo(preorderMap);
|
|
// remove all tilesets not currently wanted
|
|
tilesets.forEach(function(t) {
|
|
if(t != currentTileset && preorderMap.hasLayer(tileLayers[t])) {
|
|
preorderMap.removeLayer(tileLayers[t]);
|
|
}
|
|
});
|
|
|
|
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
|
|
|
|
if(!tilesetChangeOnly) {
|
|
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 = "#acf0ab";
|
|
var icon_name = "home";
|
|
|
|
if(preorder.type == "interest") {
|
|
icon_color = "#ec98a2";
|
|
} else if(preorder.type == "provision") {
|
|
icon_color = "#ffcd8b";
|
|
}
|
|
|
|
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");?>';
|
|
|
|
// popup fields
|
|
[
|
|
["street", preorder.adb_strasse],
|
|
["hausnummer", preorder.adb_hausnummer],
|
|
["zip", preorder.adb_plz],
|
|
["city", preorder.adb_ort],
|
|
["type", preorder.type_label],
|
|
["typestyle", "color: #000; background-color: " + icon_color],
|
|
["adrcd", preorder.adrcd],
|
|
["extref", preorder.extref ? preorder.extref : ""],
|
|
["gps", (preorder.gps_lat && preorder.gps_long) ? preorder.gps_lat + ", " + preorder.gps_long : ""],
|
|
["contact", (preorder.company ? preorder.company + " " : preorder.firstname + " " + preorder.lastname)],
|
|
["phone", preorder.phone ? preorder.phone : ""],
|
|
["email", preorder.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;
|
|
}
|
|
if(!$('#filter_' + field).length) {
|
|
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"); ?>
|