Files
Facilitor/APPL/PDA/setlocation.asp
Jos Groot Lipman 241c6d8f7f FSN#51907 iOS Inloggen met de app - wit scherm na kiezen locatie
svn path=/Website/branches/v2017.2/; revision=36758
2018-01-29 13:28:48 +00:00

169 lines
6.9 KiB
Plaintext

<%@ language = "JavaScript" %>
<% /*
$Revision$
$Id$
File: pda/setlocation.asp
Sets or lets the user select a current and global location
Status: 90%
Context:
vanaf smartphone-portal of direct via een QRC of andere plaatsbepalende service
Parameters:
alg_key of loc_key of bld_key of flr_key
*/
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="./mobile.inc" -->
<!-- #include file="./iface.inc" -->
<%
// Als ik een alg_key krijg, is dat altijd van level S("mobile_alg_level")
var alg_key = getFParamInt("alg_key", -1);
// Deze zouden door andere systemen of mechanismes gebruikt kunnen worden FOR FUTURE USE
var loc_key = getFParamInt("loc_key", -1);
var bld_key = getFParamInt("bld_key", -1);
var flr_key = getFParamInt("flr_key", -1);
var qrc = getQParamInt("qrc", 0) != 0;
// Met meegegeven waarden ben ik aan het submitten: zet de gedetailleerdste waarde
if (flr_key > -1) {
mobile.iamhere("V", flr_key);
} else if (bld_key > -1) {
mobile.iamhere("G", bld_key);
} else if (loc_key > -1) {
mobile.iamhere("L", loc_key);
} else if (alg_key > -1) {
mobile.iamhere(S("mobile_alg_level"), alg_key);
}
if (flr_key > -1 || bld_key > -1 || loc_key > -1 || alg_key > -1) {
// Gezet, terug naar portal, wellicht nog parameter om niks te doen (QRC)
// Dit lijkt niet helemaal lekker te gaan zo (na langer rondklikken)
Response.Redirect(rooturl + "/appl/pda/Facilitor.asp");
}
// Kies heel ruim waar je autorisatie op hebt
// Let op dat je hier alleen autorisaties met plaats-component toevoegt (fac_functie_minlevel & 8)
var sql = "SELECT COALESCE(MIN(fac_gebruiker_alg_level_read), 9) readlevel"
+ " FROM fac_v_webgebruiker g, fac_functie f "
+ " WHERE g.fac_functie_key = f.fac_functie_key "
+ " AND f.fac_functie_code IN ('WEB_MLDUSE', 'WEB_INSMAN', 'WEB_INSUSE', 'WEB_ALGMAN', 'WEB_ALGUSE', 'WEB_MLDBO2', 'WEB_ORDBO2', 'WEB_MLDBOF', 'WEB_BEZUSE', 'WEB_RESUSE', 'WEB_MLDUSE')"
+ " AND g.prs_perslid_key = " + user_key;
var oRs = Oracle.Execute(sql);
var autlevel = oRs("readlevel").Value; // Pas op: kan ook '0' zijn (regio)
oRs.Close();
// Als keys meegegeven, dan globallocation zetten op die key en refresh naar Facilitor.asp (die toont de locatie)
// Als geen keys meegegeven, dan plaatsselector met default de huidige globallocation om aan te laten passen
%>
<html><head>
<% FCLTMHeader.Generate({title: L("lcl_mobile_setlocation")}); %>
<script>
function showError(error)
{
var txt;
switch(error.code)
{
case error.PERMISSION_DENIED:
txt = "User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
txt = "Location information is unavailable."
break;
case error.TIMEOUT:
txt = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
txt = "An unknown error occurred."
break;
}
alert(txt);
}
function selectByGPS() {
navigator.geolocation.getCurrentPosition (
function (pos)
{
var lat = pos.coords.latitude;
var lng = pos.coords.longitude;
if (lat == null) {
alert("Cannot access coordinates");
}
$.getJSON("getLocation.asp", {lat: lat, lng: lng },
function (data)
{
//alert(data.alg_key);
$("#alg_key").val(data.alg_key).selectmenu('refresh');
});
}, showError
, {timeout: 15000, enableHighAccuracy: true})
};
</script>
</head>
<body>
<%
PAGE_START();
HEADER ({back: !qrc});
CONTENT_START();
%>
<form id="setloc" name="setloc" action="<%=rooturl + "/appl/pda/"%>setlocation.asp" method="post">
<div class="ui-bar" id="setloctxt"><%= L("lcl_mobile_setlocation_intro")%></div>
<%
CONTROLGROUP_START();
BUTTON(L("lcl_mobile_currentgps"), {click: "selectByGPS()", dataicon: "navigation", id: "gpsbut"});
if (S("mobile_alg_level") == 'L') {
sql = "SELECT alg_locatie_key, alg_locatie_omschrijving"
+ " FROM alg_locatie"
+ " WHERE alg_locatie_verwijder IS NULL"; // in scope
if (autlevel >= 0)
sql += " AND alg_locatie_key IN"
+ " (SELECT alg_locatie_key FROM fac_v_my_locations"
+ " WHERE prs_perslid_key = " + user_key
+ " AND niveau = " + autlevel + ")";
sql += " ORDER BY 2";
FCLTselector("alg_key", sql, {initKey: user.alg_locatie_key({withcurrent:true}), nolabel: L("lcl_location"), mobile:true});
} else if (S("mobile_alg_level") == 'G') {
sql = "SELECT g.alg_gebouw_key, COALESCE(alg_locatie_plaats, alg_locatie_omschrijving)||': '||alg_gebouw_omschrijving"
+ " FROM alg_gebouw g, alg_srtgebouw sg, alg_locatie l"
+ " WHERE sg.alg_srtgebouw_key = g.alg_srtgebouw_key"
+ " AND g.alg_locatie_key = l.alg_locatie_key"
+ " AND sg.alg_srtgebouw_passief IS NULL" // Alleen de facilitair actieve gebouwen
+ " AND g.alg_gebouw_verwijder IS NULL";
if (autlevel >= 0)
sql += " AND g.alg_gebouw_key IN"
+ " (SELECT alg_gebouw_key FROM fac_v_my_buildings"
+ " WHERE prs_perslid_key = " + user_key
+ " AND niveau = " + autlevel + ")";
sql += " ORDER BY 2";
FCLTselector("alg_key", sql, {initKey: user.alg_gebouw_key({withcurrent:true}), nolabel: L("lcl_building"), mobile:true});
} else if (S("mobile_alg_level") == 'V') {
sql = "SELECT v.alg_verdieping_key, alg_gebouw_omschrijving||'/'||v.alg_verdieping_code"
+ " FROM alg_gebouw g, alg_srtgebouw sg, alg_verdieping v"
+ " WHERE g.alg_gebouw_key = v.alg_gebouw_key"
+ " AND sg.alg_srtgebouw_key = g.alg_srtgebouw_key"
+ " AND sg.alg_srtgebouw_passief IS NULL" // Alleen de facilitair actieve gebouwen
+ " AND g.alg_gebouw_verwijder IS NULL"
+ " AND v.alg_verdieping_verwijder IS NULL";
if (autlevel >= 0)
sql += " AND g.alg_gebouw_key IN"
+ " (SELECT alg_gebouw_key FROM fac_v_my_buildings"
+ " WHERE prs_perslid_key = " + user_key
+ " AND niveau = " + autlevel + ")";
sql += " ORDER BY 2";
FCLTselector("alg_key", sql, {initKey: user.alg_verdieping_key({withcurrent:true}), nolabel: L("lcl_floor"), mobile:true});
}
BUTTON(L("lcl_select"), {click: "document.forms.setloc.submit()", dataicon: "check"});
CONTROLGROUP_END();
%>
</form>
<%
CONTENT_END();
FOOTER();
PAGE_END();
%>
</body>
</html>