diff --git a/APPL/PDA/iface.inc b/APPL/PDA/iface.inc index a273da9831..dac285ef39 100644 --- a/APPL/PDA/iface.inc +++ b/APPL/PDA/iface.inc @@ -25,17 +25,17 @@ FCLTMHeader = if (!params) params = {}; params.mobile = true; FCLTHeader.Requires({ plugins: ["jQuery"], - js: ["../pda/mobile.js"], - css: ["../pda/default.css"] + js: [rooturl + "/appl/pda/mobile.js"], + css: [rooturl + "/appl/pda/default.css"] }) if (typeof Session("Logging")=="undefined" || Session("Logging") == 0) FCLTHeader.Requires({ js: ["jquery.mobile-1.4.2.min.js"] }) else FCLTHeader.Requires({ js: ["jquery.mobile-1.4.2.js"] }); - var theme = S("cssformobile") || "../localscripts/theme/cust.mobile-1.4.2.min.css"; + var theme = S("cssformobile") || rooturl + "/appl/localscripts/theme/cust.mobile-1.4.2.min.css"; FCLTHeader.Requires({ css: [theme, - "../localscripts/theme/jquery.mobile.icons-1.4.2.min.css", - "../localscripts/theme/jquery.mobile.structure-1.4.2.min.css" + rooturl + "/appl/localscripts/theme/jquery.mobile.icons-1.4.2.min.css", + rooturl + "/appl/localscripts/theme/jquery.mobile.structure-1.4.2.min.css" ] }) diff --git a/APPL/PDA/reports.asp b/APPL/PDA/reports.asp new file mode 100644 index 0000000000..9364bdb2b6 --- /dev/null +++ b/APPL/PDA/reports.asp @@ -0,0 +1,33 @@ +<%@language = 'javascript' %> + + + +<% + params = { list: {}, + filter: {} + }; + model = model_reportsx; + var usrrap_key = getQParamInt("usrrap_key", -1); + if (mode == "list" && usrrap_key > 0) + { + // Let op: mobile zijn we nog veel strengen dan volledige 3D autorisatie! + params.filter.fclt_3d_locatie_key = user.alg_locatie_key({withcurrent:true}); + params.filter.fclt_3d_gebouw_key = user.alg_gebouw_key({withcurrent:true}); + params.filter.fclt_3d_verdieping_key = user.alg_verdieping_key({withcurrent:true}); + params.filter.fclt_3d_user_key = user_key; + + params.list.fncolLink = null; + var model = model_reports(usrrap_key); + } + else + { + params.list.fncolLink = function (oRs, processParams) + { + var url = "../../" + params.this_path + "?mode=list" + "&usrrap_key=" + oRs.Fields("id").Value; + return url; + }; + // TODO: params.filter mobile only? + } + + scaffolding(model, params); +%> diff --git a/APPL/SCF/scaffolding_common.inc b/APPL/SCF/scaffolding_common.inc new file mode 100644 index 0000000000..56e44d200f --- /dev/null +++ b/APPL/SCF/scaffolding_common.inc @@ -0,0 +1,16 @@ +<% /* + $Revision$ + $Id$ + + File: scaffolding_common.inc + + Description: + Parameters: + Context: + */ + +var scf = + { + } + +%> \ No newline at end of file diff --git a/APPL/SCF/scaffolding_m.inc b/APPL/SCF/scaffolding_m.inc new file mode 100644 index 0000000000..59f4b6ab7f --- /dev/null +++ b/APPL/SCF/scaffolding_m.inc @@ -0,0 +1,214 @@ +<% /* + $Revision$ + $Id$ + + File: scaffolding_m.inc + + Description: Als scaffolding maar dan voor mobile + Parameters: + Context: + Notes: Ondersteunt list, edit en save + Heeft geen search, wrap of show +*/ + +var mode = getQParamSafe("mode", getQParam("id","")!=""?"edit":"list"); +if (mode == "save") + var JSON_Result = true; +%> + + +<% if (mode != "save") { %> +<% if (mode != "list") { %> + + + + + +<% } %> + + + + +<% } %> + + + + + +<% +function scaffolding(model, scf_params) +{ + scf_params = scf_params || {}; + + var imodel = getQParam("model", ""); // include model + if (model.includes && imodel in model.includes) + { + model = model.includes[imodel].model; + scf_params.transit = { name: "model", val: imodel }; + } + + // Originele URL voor IIRF rewrite + var orgurl = Request.ServerVariables("HTTP_X_REWRITE_URL"); + if (orgurl.Count) + scf_params.this_fullpath = String(orgurl).split("?")[0]; + else + scf_params.this_fullpath = String(Request.ServerVariables("SCRIPT_NAME")); + scf_params.this_path = scf_params.this_fullpath.substring(rooturl.length + 1); + + // Algemene normalizing + function def(hash, fld, val) + { + if (!(fld in hash)) + hash[fld] = val; + } + def(model, "record_title", model.record_name); + def(model, "records_title", model.records_name); + for (var fld in model.fields) + def(model.fields[fld], "label", fld) + + if ("includes" in model) + { + for (var inc in model.includes) + def(model.includes[inc], "joinfield", model.fields.id.dbs); + } + + def(model, "list", {}); + if ("id" in model.fields && "name" in model.fields) + def(model.list, "columns", ["id", "name"]); + else + def(model.list, "columns", []); + + def(model, "search", {}); + + switch (mode) + { + case "search": + scaffolding_m_search(model, scf_params); + break; + case "list": + scaffolding_m_list(model, scf_params); + break; + case "edit": + scaffolding_m_edit(model, scf_params); + break; + case "save": + scaffolding_save(model, scf_params); + break; + } +} + +function scf_ROFIELDTR(field, fld, val, key) +{ + var txt = val; + if (txt === null) + { + if (field.typ == "check") + txt = "0"; + else + return; // Altijd suppressEmpty + } + var title = ""; + if (typeof txt == "object") + { + if ("name" in txt) // Foreigns + { + title = "Key: " + txt["id"]; + txt = txt["name"]; + } + else + if (field.typ == "datetime") + txt = toDateTimeString(txt); + else if (typeof txt == "date" || txt instanceof Date) + txt = toDateString(txt); + } + params = { title: title }; + if (field.translate && key) + params.translate = { fld: fld.dbs, key: key } + + if (field.typ == "check") + ROCHECKBOXTR("fldtxt", field.label, txt, params); + else + ROFIELDTR("fldtxt", field.label, txt, params); +} +function scf_RWFIELDTR(field, fld, val) +{ + if (field.foreign && typeof field.foreign == 'string') // TODO: foreign functie en foreignsql ondersteunen + { + var foreign = foreignKeyTable(field.foreign); + + var fupper = field.foreign.toUpperCase(); + if (fupper == "PRS_KOSTENPLAATS") + { + FCLTkostenplaatsselector(fld, + "sg" + fld, + user_key, + { label: field.label, + kostenplaatsKey: val?val.id:null, + filtercode: "AA" + }); + } + else if (fupper == "PRS_PERSLID") + { + FCLTpersoonselector(fld, + "sg" + fld, + { label: field.label, + perslidKey: val?val.id:null + }); + } + else if (fupper == "PRS_AFDELING") + { + FCLTafdelingselector(fld, + "sg" + fld, + { label: field.label, + departmentKey: val?val.id:null + }); + } + else if (fupper.match(/ALG_RUIMTE|ALG_VERDIEPING|RES_RSV_RUIMTE|MLD_UITVOERENDE|CNT_CONTRACT/) || !foreign) + { + ROFIELDTR("fldtxt", field.label, "TODO: suggest met " + field.foreign); + } + else + { + var sql = "SELECT " + foreign.key + + " , " + foreign.desc + + " FROM " + foreign.tbl + " " + (foreign.alias||"") + + " ORDER BY 2"; + FCLTselector(fld, sql, { label: field.label, + initKey: val?val.id:null, + emptyOption: field.required?null:"" + }); + } + } + else if (field.LOV) + { + var sql = api2.splitLOV2sql(field.LOV); + FCLTselector(fld, sql, { label: field.label, + initKey: val?val.id:null, + emptyOption: field.required?null:"" + }); + } + else if (field.typ == "check") + RWCHECKBOXTR(fld, "fldcheck", field.label, val); + else if (field.typ == "date") + FCLTcalendar(fld, { label : field.label, + datum : val, + timeField: false, + initEmpty: !val, + initTimeEmpty: !val, + volgnr : 1 + }); + else if (field.typ == "datetime") + FCLTcalendar(fld, { label : field.label, + datum : val, + timeField: true, + initEmpty: !val, + initTimeEmpty: !val, + timeStep : S("res_h")*60, + startTime: S("res_t1"), + endTime : S("res_t2"), + volgnr : 1 + }); + else + RWFIELDTR(fld, "fld", field.label, val); +} +%> diff --git a/APPL/SCF/scaffolding_m_edit.inc b/APPL/SCF/scaffolding_m_edit.inc new file mode 100644 index 0000000000..826b0c74e6 --- /dev/null +++ b/APPL/SCF/scaffolding_m_edit.inc @@ -0,0 +1,97 @@ +<% /* + $Revision$ + $Id$ + + File: scaffolding_m_edit.asp + Description: show detailed information of a model + + Parameters: + + Context: + Note: + +*/ %> +<% +function scaffolding_m_edit(model, scf_params) +{ + FCLTHeader.Requires({ plugins: ["jQuery"], + js: ["jquery-ui.js", "jquery.timepicker-table.js"], + css: ["timePicker-table.css"]}) + + var transit = ""; + if ("transit" in scf_params) + transit = "&" + scf_params.transit.name + "=" + safe.url(scf_params.transit.val); + + var key = getQParamInt("id", -1); + if (key > 0) + { + user.auth_required_or_abort(model.REST_PUT); + var xxx_params = { filter: { id: key } }; + var xxx_array = model.REST_GET(xxx_params); + + if (!xxx_array.length) + shared.record_not_found(); + var xxx_data = xxx_array[0]; + } + else + { + user.auth_required_or_abort(model.REST_POST); + xxx_data = {}; + } + if ("hook_pre_edit" in model) + model.hook_pre_edit(xxx_data); + + var modal = (model.parent_key != null); // dan doen we een detailrecord altijd modal + %> + + +
+ <% FCLTHeader.Generate(); %> + + + " <%=modal?"class='modal scaffolding'":""%>> + <% + var buttons = [ {title: L("lcl_submit"), action:"scf_submit()", icon: "opslaan.png", singlepress: true }, + {title: L("lcl_cancel"), action:"scf_cancel()", icon: "undo.png" }]; + if (!modal) + IFRAMER_HEADER(model.record_title, buttons); + %> +