From 44304472b5ebd263cf768e359b3e4e49b8dba920 Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Tue, 10 Mar 2015 16:26:09 +0000 Subject: [PATCH] NYBU#30506 PDA rapportages via scaffolding svn path=/Website/trunk/; revision=24399 --- APPL/PDA/iface.inc | 10 +- APPL/PDA/reports.asp | 33 +++++ APPL/SCF/scaffolding_common.inc | 16 +++ APPL/SCF/scaffolding_m.inc | 214 ++++++++++++++++++++++++++++++++ APPL/SCF/scaffolding_m_edit.inc | 97 +++++++++++++++ APPL/SCF/scaffolding_m_list.inc | 152 +++++++++++++++++++++++ 6 files changed, 517 insertions(+), 5 deletions(-) create mode 100644 APPL/PDA/reports.asp create mode 100644 APPL/SCF/scaffolding_common.inc create mode 100644 APPL/SCF/scaffolding_m.inc create mode 100644 APPL/SCF/scaffolding_m_edit.inc create mode 100644 APPL/SCF/scaffolding_m_list.inc 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); + %> +
+
+ <% + BLOCK_START("facInfo", xxx_data["name"] || model.record_title); + for (var fld in model.fields) + { + var field = model.fields[fld]; + if (field.readonly || fld == "id") + scf_ROFIELDTR(field, fld, xxx_data[fld]); + else if (field.insertonly && key > 0) + scf_ROFIELDTR(field, fld, xxx_data[fld]); + else + scf_RWFIELDTR(field, fld, xxx_data[fld]); + } + BLOCK_END(); + if (modal) + CreateButtons(buttons); + IFACE.FORM_END(); + %> +
+
+ + +<% +} +%> \ No newline at end of file diff --git a/APPL/SCF/scaffolding_m_list.inc b/APPL/SCF/scaffolding_m_list.inc new file mode 100644 index 0000000000..8b839d6436 --- /dev/null +++ b/APPL/SCF/scaffolding_m_list.inc @@ -0,0 +1,152 @@ +<% /* + $Revision$ + $Id$ + + File: scaffolding_list.asp + + Description: Toont een lijst + Parameters: + Context: Vanuit scaffolding.inc + Note: model variabele is globaal beschikbaar + */ +%> +<% +function scaffolding_m_list(model, scf_params) +{ + scf_params.list = scf_params.list || {}; + scf_params.list.columns = scf_params.list.columns || []; + + var transit = ""; + if ("transit" in scf_params) + transit = "&" + scf_params.transit.name + "=" + safe.url(scf_params.transit.val); + + var cols = getQParamArray("columns", []); + if (cols.length && cols[0]) + scf_params.list.columns = cols; + + var grps = getQParamArray("groups", []); + if (grps.length && grps[0]) + scf_params.list.groups = grps; + + if (!scf_params.list.columns.length && "list" in model) + scf_params.list.columns = model.list.columns; + + var modal = (model.parent_key != null); // dan doen we een detailrecord altijd modal + + FCLTHeader.Requires({js: []}); + + if (model.autfunction) + var authparams = user.checkAutorisation(model.autfunction); + else + var authparams = { PRSreadlevel: -1, ALGreadlevel: -1 }; + + var showall = getQParamInt("showall", 0) == 1; + var outputmode = getQParamInt("outputmode", 0) + %> + + + <% FCLTMHeader.Generate({ outputmode: outputmode }); %> + + + + <% + PAGE_START(); + var qrc = false; + HEADER({title: model.records_title, back:!qrc, home: !qrc, datatheme: jQFrontEndTheme }); + CONTENT_START(); + + buttons = []; + buttons.push({ icon: "page_refresh.png", title: L("lcl_refresh"), action: "FcltMgr.reload()" }); + if (model["REST_POST"] && authparams.PRSwritelevel < 9 && authparams.ALGwritelevel < 9) + { + var addurl = scf_params.this_path + "?mode=edit" + transit; + buttons.push({ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openDetail('" + addurl + "', '" + L("lcl_add") + " " + model.record_name + "')" }); + } + + var xxx_params = { filter : scf_params.filter || api2.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups }; + var xxx_array = model.REST_GET(xxx_params); + + function fnSubheader(oRs) + { + var subs = []; + for (var i = 2; i < scf_params.list.columns.length; i++) + { + var fld = scf_params.list.columns[i]; + var field = model.fields[fld]; + subs.push("" + field.label + "" + + ResultsetTable.formatValue(oRs.Fields(fld).Value, { datatype: field.typ}) + + ""); + } + return "
" + subs.join("") + "
"; + }; + + function fncolLink(oRs, processParams) + { + var url = "../" + scf_params.this_path + "?mode=edit" + transit + "&id=" + oRs.Fields("id").Value; + return url; + }; + + var rst = new ResultsetTable({ dataset: xxx_array, + keyColumn: ("id" in model.fields?"id":null), + ID: model.table, + title: model.records_title, + headerColumn: scf_params.list.columns[0], + detailColumn: scf_params.list.columns[1], + subheaderColumn: scf_params.list.columns.length > 2?fnSubheader:null, + //groupColumn: "gebouw", + linkColumn: "fncolLink" in scf_params.list?scf_params.list.fncolLink:fncolLink, + showAll: true, // anders op 30 afgekapt + outputmode: outputmode, + buttons: buttons + }); + if (0) + var rst = new ResultsetTable({sql: modules[module].sql, + keyColumn: "item_key", + linkColumn: fncolLink, + headerColumn: fncolHeader, + detailColumn: "detail", + asideColumn: modules[module].fnStatus, + subheaderColumn: modules[module].fnSubheader || "datum", + ID: "factable", + showAll: true, + noSearch: true + }); + + function fnfncolCheck(fld) + { + return function (oRs) + { + if (oRs.Fields(fld).Value == 1) + return L("lcl_Yes") + else + return L("lcl_No") + } + } + + //if (model["REST_PUT"]) + // rst.addAction({ action: "scf_show", caption: L("lcl_edit"), isDefault: true } ); + + var cnt = rst.processResultset(); + + CONTENT_END(); + FOOTER(); + PAGE_END(); + %> + + +<% +} +%> \ No newline at end of file