FSN#31698 Rapportgenerator savepoint
svn path=/Website/trunk/; revision=24330
This commit is contained in:
@@ -258,6 +258,9 @@ api2 = {
|
||||
*/
|
||||
normalize: function _normalize(model)
|
||||
{
|
||||
if (model.parent_key in model.fields)
|
||||
abort_with_warning("parent_key '{0}' should not be defined in fields".format(model.parent_key));
|
||||
|
||||
if (!model.fields.length)
|
||||
return; // het is al een hash
|
||||
var newfields = {};
|
||||
@@ -801,7 +804,10 @@ __DoLogj(typeof newval)
|
||||
val = { id: val };
|
||||
val.name = name;
|
||||
}
|
||||
if (val !== null && (field.LOV))
|
||||
// if (field.typ == 'check' && !field.LOV)
|
||||
// field.LOV = "0;" + L("lcl_No") + ";1;" + L("lcl_Yes");
|
||||
|
||||
if (val !== null && field.LOV)
|
||||
{
|
||||
var spl = api2.splitLOV(field.LOV);
|
||||
val = { id: val, name: spl[val] };
|
||||
@@ -831,7 +837,7 @@ __DoLogj(typeof newval)
|
||||
var spl = api2.splitLOV(LOV);
|
||||
var options = [];
|
||||
for (var l in spl)
|
||||
options.push("<option value='" + safe.htmlattr(l) + "'>" + safe.html(spl[l]) + "</option>");
|
||||
options.push("<option value='" + safe.htmlattr(l) + "'" + (l == current?" selected='1'":"") + ">" + safe.html(spl[l]) + "</option>");
|
||||
return "<select>" + options.join("") + "</select>";
|
||||
},
|
||||
sql2jsonfields: function (oRs, model)
|
||||
@@ -1297,6 +1303,11 @@ __DoLogj(typeof newval)
|
||||
value = jsondataobject;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
generic_REST: function(model)
|
||||
{
|
||||
model.REST_GET = generic_REST_GET(model);
|
||||
model.REST_PUT = generic_REST_PUT(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1323,6 +1334,56 @@ function RequestJSON()
|
||||
return { json: vraag };
|
||||
}
|
||||
|
||||
function generic_REST_GET(model)
|
||||
{
|
||||
user.checkAutorisation(model.autfunction); // Als je zelfs geen readrechten hebt ben je heel fout bezig
|
||||
|
||||
return function(params, jsondata)
|
||||
{
|
||||
var query = api2.sqlfields(params, model);
|
||||
|
||||
var wheres = api2.sqlfilter(params, model);
|
||||
query.wheres = query.wheres.concat(wheres);
|
||||
|
||||
if (model.soft_delete && params.filter.show_deleted != "on")
|
||||
query.wheres.push(model.soft_delete + " IS NULL");
|
||||
|
||||
var maxcnt = getQParamInt("showall", 0) == 1?S("qp_maxrows2"):S("qp_maxrows");
|
||||
query.wheres.push("ROWNUM <= " + maxcnt + 1); // Eentje extra om overflow-melding te triggeren in resultsettable
|
||||
|
||||
var sql = "SELECT " + query.selects.join(", ")
|
||||
+ " FROM " + query.tables.join(", ")
|
||||
+ (query.wheres.length ? " WHERE " + query.wheres.join(" AND " ) : "")
|
||||
+ " ORDER BY " + (model.fields.name?model.fields.name.dbs:model.fields.id.dbs);
|
||||
|
||||
var json = api2.sql2json (params, sql, model);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
function generic_REST_PUT(model)
|
||||
{
|
||||
var autparams = user.checkAutorisation(model.autfunction, true);
|
||||
if (!autparams || autparams.PRSwritelevel == 9 || autparams.ALGwritelevel == 9)
|
||||
return false;
|
||||
|
||||
return function(params, jsondata, the_key)
|
||||
{
|
||||
abort_with_warning("generic update not supported yet");
|
||||
|
||||
var fields = api2.update_fields(params, model, jsondata);
|
||||
var wheres = [model.id.dbs + " = " + the_key];
|
||||
var xxxUpd = buildTrackingUpdate(model.table, wheres.join(" AND " ), fields, { noValidateToken: true });
|
||||
// TODO: Generieke tracking?
|
||||
|
||||
var err = Oracle.Execute(xxxUpd.sql, true);
|
||||
if (err.friendlyMsg)
|
||||
abort_with_warning(err.friendlyMsg);
|
||||
|
||||
return { key: the_key, warning: "" };
|
||||
}
|
||||
}
|
||||
|
||||
function RequestXML()
|
||||
{
|
||||
try
|
||||
@@ -1385,4 +1446,15 @@ function _get_ParamISODate(pColl, pName, defVal)
|
||||
// Error message will get to client and/or IIS logfiles
|
||||
eval("INTERNAL_ERROR_PARAMETER_" + pName + "_IS_NOT_ISODATE");
|
||||
}
|
||||
|
||||
// Backwards compatible FACMGT_LCL
|
||||
var __F = [];
|
||||
function F(tekst)
|
||||
{
|
||||
if (!__F.length)
|
||||
{
|
||||
// TODO: Inlezen uit FAC_LOCALE_MGT, zoek op vbLCL
|
||||
}
|
||||
return tekst;
|
||||
}
|
||||
%>
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
Notes:
|
||||
*/
|
||||
%>
|
||||
<%
|
||||
|
||||
model_generic_template =
|
||||
{
|
||||
@@ -22,41 +20,8 @@ model_generic_template =
|
||||
fields: {},
|
||||
list: { columns: [] },
|
||||
soft_delete: null,
|
||||
autfunction: "WEB_PRSSYS",
|
||||
|
||||
_check_authorization: function(params, method)
|
||||
{
|
||||
params.message = "";
|
||||
var autfunction = "WEB_PRSSYS";
|
||||
params.authparams = user.checkAutorisation(autfunction);
|
||||
},
|
||||
|
||||
_analyze_fields: function (fields, params, jsondata) /* analyseer inkomende data, common voor PUT en POST */
|
||||
{
|
||||
},
|
||||
|
||||
|
||||
REST_GET: function _GET(params, jsondata)
|
||||
{
|
||||
model_generic_template._check_authorization(params, "GET");
|
||||
var query = api2.sqlfields(params, model_generic_template);
|
||||
|
||||
var wheres = api2.sqlfilter(params, model_generic_template);
|
||||
query.wheres = query.wheres.concat(wheres);
|
||||
|
||||
if (model_generic_template.soft_delete && params.filter.show_deleted != "on")
|
||||
query.wheres.push(model_generic_template.soft_delete + " IS NULL");
|
||||
|
||||
var maxcnt = getQParamInt("showall", 0) == 1?S("qp_maxrows2"):S("qp_maxrows");
|
||||
query.wheres.push("ROWNUM <= " + maxcnt + 1); // Eentje extra om overflow-melding te triggeren in resultsettable
|
||||
|
||||
var sql = "SELECT " + query.selects.join(", ")
|
||||
+ " FROM " + query.tables.join(", ")
|
||||
+ (query.wheres.length ? " WHERE " + query.wheres.join(" AND " ) : "")
|
||||
+ " ORDER BY " + (model_generic_template.fields.name?model_generic_template.fields.name.dbs:model_generic_template.fields.id.dbs);
|
||||
|
||||
var json = api2.sql2json (params, sql, model_generic_template);
|
||||
return json;
|
||||
},
|
||||
REST_PUT: function (params, jsondata, the_key) /* update room */
|
||||
{
|
||||
abort_with_warning("generic update not supported yet");
|
||||
@@ -109,13 +74,14 @@ model_generic_template =
|
||||
}
|
||||
}
|
||||
|
||||
function model_generic(table)
|
||||
function model_generic(table, autfunction)
|
||||
{
|
||||
model_generic_template.table = table;
|
||||
model_generic_template.record_name = table.substring(0,1) + table.substring(1).toLowerCase();
|
||||
model_generic_template.autfunction = autfunction;
|
||||
model_generic_template.table = table.toLowerCase();
|
||||
model_generic_template.record_name = table.substring(0,1).toUpperCase() + table.substring(1);
|
||||
model_generic_template.records_name = model_generic_template.record_name + "s";
|
||||
|
||||
var sql = "SELECT cols.column_name, cols.position, cons.status, cons.owner"
|
||||
var sql = "SELECT LOWER(cols.column_name) column_name, cols.position, cons.status, cons.owner"
|
||||
+ " FROM all_constraints cons, all_cons_columns cols"
|
||||
+ " WHERE cols.table_name = " + safe.quoted_sql(table)
|
||||
+ " AND cons.constraint_type = 'P'"
|
||||
@@ -125,7 +91,6 @@ function model_generic(table)
|
||||
var oRs = Oracle.Execute(sql);
|
||||
if (oRs.Eof)
|
||||
{
|
||||
Session.Contents.Remove("scaffolding_table");
|
||||
abort_with_warning("Unable to determine primary key for table {0}".format(table));
|
||||
}
|
||||
|
||||
@@ -133,7 +98,6 @@ function model_generic(table)
|
||||
oRs.MoveNext();
|
||||
if (!oRs.Eof)
|
||||
{
|
||||
Session.Contents.Remove("scaffolding_table");
|
||||
abort_with_warning("Composite primary key not supported for table {0}".format(table));
|
||||
}
|
||||
oRs.Close();
|
||||
@@ -146,7 +110,7 @@ function model_generic(table)
|
||||
model_generic_template.last_analyzed = oRs("last_analyzed").Value;
|
||||
oRs.Close;
|
||||
|
||||
var sql = "SELECT column_name"
|
||||
var sql = "SELECT LOWER(column_name) column_name"
|
||||
+ " , data_type"
|
||||
+ " , data_length"
|
||||
+ " , data_precision"
|
||||
@@ -167,8 +131,6 @@ function model_generic(table)
|
||||
var ora_precision = oRs("data_precision").Value;
|
||||
var ora_scale = oRs("data_scale").Value;
|
||||
|
||||
foreignKeyTable("dummy") // force generating __foreignKeyTable
|
||||
|
||||
switch (ora_type)
|
||||
{
|
||||
case 'NUMBER':
|
||||
@@ -177,14 +139,14 @@ foreignKeyTable("dummy") // force generating __foreignKeyTable
|
||||
{
|
||||
field.datatype = 'float';
|
||||
}
|
||||
if (field.dbs.match(/_KEY$/))
|
||||
if (field.dbs.match(/_key$/))
|
||||
{
|
||||
field.typ = 'key';
|
||||
if (field.dbs != model_generic_template.primary &&
|
||||
field.dbs.replace(/_KEY$/,"") in __foreignKeyTable) // TODO ipv. de replace echt foreign-key constraint controleren
|
||||
foreignKeyTable(field.dbs.replace(/_key$/,""))) // TODO ipv. de replace echt foreign-key constraint controleren
|
||||
{
|
||||
field.foreign = field.dbs.replace(/_KEY$/,"");
|
||||
field.label = field.foreign + "(_KEY)"; // indicatie dat het foreign is
|
||||
field.foreign = field.dbs.replace(/_key$/,"");
|
||||
field.label = field.foreign + "(_key)"; // indicatie dat het foreign is
|
||||
field.filter = "exact";
|
||||
}
|
||||
}
|
||||
@@ -199,8 +161,12 @@ foreignKeyTable("dummy") // force generating __foreignKeyTable
|
||||
|
||||
var fld = oRs.Fields("column_name").Value;
|
||||
|
||||
if (fld == table + "_VERWIJDER")
|
||||
model_generic_template.soft_delete = table + "_VERWIJDER";
|
||||
if (fld == table.toLowerCase() + "_verwijder")
|
||||
model_generic_template.soft_delete = table + "_verwijder";
|
||||
|
||||
// Dan zien we hem ook nergens meer?
|
||||
//if (fld == table + "_AANMAAK")
|
||||
// field.readonly = true;
|
||||
|
||||
if (fld == model_generic_template.primary)
|
||||
{
|
||||
@@ -230,7 +196,10 @@ foreignKeyTable("dummy") // force generating __foreignKeyTable
|
||||
oRs.MoveNext();
|
||||
}
|
||||
oRs.Close();
|
||||
|
||||
api2.generic_REST(model_generic_template);
|
||||
__Logj(model_generic_template);
|
||||
return model_generic_template;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
@@ -19,18 +19,25 @@ model_reportcolumns =
|
||||
primary: "fac_usrrap_cols_key",
|
||||
records_name: "columns",
|
||||
record_name: "column",
|
||||
records_title: L("lcl_rap_columns"),
|
||||
record_title: L("lcl_rap_column"),
|
||||
parent_key: "fac_usrrap_key",
|
||||
autfunction: "WEB_PRSSYS",
|
||||
|
||||
fields: { "id" : { dbs: "fac_usrrap_cols_key", typ: "key", filter: "exact" },
|
||||
"name" : { dbs: "fac_usrrap_cols_column_name", typ: "varchar", label: L("lcl_rap_column"), insertonly: true },
|
||||
"datatype" : { dbs: "fac_usrrap_cols_datatype", typ: "varchar", label: L("lcl_rap_datatype"), insertonly: true,
|
||||
LOV: L("lcl_rap_datatypeLOV")}, // "varchar;Tekst;date;Datum;float;Float;integer;Getal"
|
||||
"sequence" : { dbs: "fac_usrrap_cols_volgnr", typ: "number", label: L("lcl_rap_sequence") },
|
||||
"columnname": { dbs: "fac_usrrap_cols_column_name", typ: "varchar", label: L("lcl_rap_column"), insertonly: true },
|
||||
"caption" : { dbs: "fac_usrrap_cols_caption", typ: "varchar", label: L("lcl_rap_caption")},
|
||||
"datatype" : { dbs: "fac_usrrap_cols_datatype", typ: "varchar", label: L("lcl_rap_datatype"),
|
||||
LOV: "varchar;Tekst;date;Datum;float;Float;integer;Getal"},
|
||||
"filter" : { dbs: "fac_usrrap_cols_filter", typ: "varchar", label: L("lcl_rap_filter")},
|
||||
"total" : { dbs: "fac_usrrap_cols_total", typ: "varchar", label: L("lcl_rap_total")}
|
||||
"filter" : { dbs: "fac_usrrap_cols_filter", typ: "varchar", label: L("lcl_rap_filter"),
|
||||
LOV: L("lcl_rap_filterLOV") }, // "A;Automatisch"
|
||||
"visible" : { dbs: "fac_usrrap_cols_visible", typ: "varchar", label: L("lcl_rap_visible"),
|
||||
LOV: L("lcl_rap_visibleLOV")}, // "V;Visible;I;Invisible;H;hidden"
|
||||
"total" : { dbs: "fac_usrrap_cols_total", typ: "varchar", label: L("lcl_rap_groupby"),
|
||||
LOV: L("lcl_rap_groupbydateLOV") + ";" + L("lcl_rap_groupbynumberLOV") }
|
||||
},
|
||||
list: { columns: ["id", "sequence", "columnname", "caption", "datatype"] },
|
||||
list: { columns: ["sequence", "name", "caption", "datatype", "visible", "total"] },
|
||||
|
||||
REST_GET: function _GET(params)
|
||||
{
|
||||
@@ -58,7 +65,7 @@ model_reportcolumns =
|
||||
|
||||
return { key: the_key };
|
||||
},
|
||||
// Internally used by report_clone
|
||||
// Only internally used by report_clone
|
||||
REST_POST: function (params, jsondata, parent_key) /* insert columns */
|
||||
{
|
||||
if (!params.internal)
|
||||
|
||||
@@ -24,6 +24,7 @@ model_reports_template =
|
||||
records_name: "te bepalen",
|
||||
record_name: "te bepalen",
|
||||
fields: {/* te bepalen */},
|
||||
autfunction: "WEB_PRSSYS",
|
||||
|
||||
_check_authorization: function(params, method)
|
||||
{
|
||||
@@ -122,25 +123,29 @@ model_reports_template =
|
||||
REST_DELETE: false
|
||||
}
|
||||
|
||||
// Voltooi model_reports_template voor een bepaald rapport
|
||||
function model_reports(fac_usrrap_key)
|
||||
{
|
||||
var usrrap = model_reportsx.REST_GET({filter: { "id" : fac_usrrap_key}, include: ["columns"] })[0];
|
||||
|
||||
model_reports_template.table = usrrap.viewname;
|
||||
model_reports_template.record_name = usrrap.viewname.substring(0,1) + usrrap.viewname.substring(1).toLowerCase();
|
||||
model_reports_template.records_name = model_reports_template.record_name + "s";
|
||||
model_reports_template.records_title = usrrap.name;
|
||||
//model_reports_template.autfunction = usrrap.authorisation;
|
||||
|
||||
model_reports_template.list = { columns : [] };
|
||||
model_reports_template.list = { columns : [], canGroup: true };
|
||||
for (var i = 0; i < usrrap.columns.length; i++)
|
||||
{
|
||||
var field = { dbs: usrrap.columns[i].columnname,
|
||||
var field = { dbs: usrrap.columns[i].name,
|
||||
label: usrrap.columns[i].caption,
|
||||
typ: usrrap.columns[i].datatype.id,
|
||||
filter: usrrap.columns[i].filter == "A"?"like":null
|
||||
filter: usrrap.columns[i].filter && usrrap.columns[i].filter.id == "A"?"like":null,
|
||||
total: usrrap.columns[i].total
|
||||
}
|
||||
var fld = "COL" + String(usrrap.columns[i].id)
|
||||
model_reports_template.fields[fld] = field;
|
||||
model_reports_template.list.columns.push(fld);
|
||||
if (usrrap.columns[i].visible.id == 'V')
|
||||
model_reports_template.list.columns.push(fld);
|
||||
}
|
||||
__Logj(model_reports_template);
|
||||
return model_reports_template;
|
||||
|
||||
@@ -22,11 +22,19 @@ model_reportsx =
|
||||
primary: "fac_usrrap_key",
|
||||
records_name: "reports",
|
||||
record_name: "report",
|
||||
records_title: L("lcl_menu_fac_reports"),
|
||||
record_title: L("lcl_usrrap_report"),
|
||||
autfunction: "WEB_PRSSYS",
|
||||
|
||||
fields: { "id" : { dbs: "fac_usrrap_key", typ: "key", label: "Key", filter: "exact" },
|
||||
"name" : { dbs: "fac_usrrap_omschrijving", typ: "varchar", label: L("lcl_usrrap_report"), filter: "like", len : 60},
|
||||
"description" : { dbs: "fac_usrrap_info", typ: "varchar", label: L("lcl_usrrap_info")},
|
||||
"viewname" : { dbs: "fac_usrrap_view_name", typ: "varchar", label: L("lcl_usrrap_viewname"), filter: "like"},
|
||||
"authorisation": { dbs: "fac_functie_key", typ: "key", label: L("lcl_usrrap_functie"), foreign: "fac_functie"}
|
||||
"authorisation": { dbs: "fac_functie_key", typ: "key", label: L("lcl_usrrap_functie"), foreign: "fac_functie"},
|
||||
"styling" : { dbs: "fac_usrrap_functie", typ: "key", label: L("lcl_usrrap_styling"),
|
||||
LOV: L("lcl_usrrap_stylingLOV") }, // 0;on-gestylede;1;gestylede;2;procedure;3;procedure gestyled;8;Via tabelizer
|
||||
|
||||
"autorefresh" : { dbs: "fac_usrrap_autorefresh", typ: "check", label: L("lcl_usrrap_autorefresh")}
|
||||
},
|
||||
list: { columns: ["id", "name", "viewname", "description"] },
|
||||
includes: {"columns": { model: model_reportcolumns,
|
||||
@@ -102,25 +110,23 @@ return; // TODO?
|
||||
|
||||
return json;
|
||||
},
|
||||
REST_PUT: function (params, jsondata, the_key) /* update room */
|
||||
REST_PUT: function (params, jsondata, the_key) /* update report */
|
||||
{
|
||||
model_reportsx._check_authorization(params, "PUT");
|
||||
if (!jsondata.room.id) jsondata.room.id = the_key;
|
||||
var rap_key = the_key;
|
||||
|
||||
var fields = api2.update_fields(params, model_reportsx, jsondata); // Build updater
|
||||
model_reportsx._analyze_fields(fields, params, jsondata);
|
||||
|
||||
var wheres = [" fac_usrrap_key = " + rap_key];
|
||||
var wheres = [" fac_usrrap_key = " + the_key];
|
||||
var roomUpd = buildTrackingUpdate("fac_usrrap", wheres.join(" AND " ), fields, { noValidateToken: true });
|
||||
|
||||
var err = Oracle.Execute(roomUpd.sql, true);
|
||||
if (err.friendlyMsg)
|
||||
abort_with_warning(err.friendlyMsg);
|
||||
|
||||
return { key: rap_key, warning: "" };
|
||||
return { key: the_key, warning: "" };
|
||||
},
|
||||
REST_POST: function (params, jsondata) /* new room */
|
||||
REST_POST: function (params, jsondata) /* new report */
|
||||
{
|
||||
model_reportsx._check_authorization(params, "POST");
|
||||
|
||||
@@ -138,7 +144,7 @@ return; // TODO?
|
||||
|
||||
return { key: rap_key, warning: "" };
|
||||
},
|
||||
REST_DELETE: function (params, the_key) /* delete room */
|
||||
REST_DELETE: function (params, the_key) /* delete report */
|
||||
{
|
||||
model_reportsx._check_authorization(params, "DELETE");
|
||||
var rap_key = params.filter.id;
|
||||
|
||||
@@ -153,7 +153,7 @@ if (!p_bAutoexec)
|
||||
// FAC_USERRAP_FUNCTIE==2 -->Stored procedure
|
||||
FCLTrapportselector("usrrap_key",
|
||||
"sgRapport",
|
||||
{ label: L("lcl_usrrep_report"),
|
||||
{ label: L("lcl_usrrap_report"),
|
||||
rapportKey: -1,
|
||||
rapportViewName: p_rap_name,
|
||||
fcode: p_fcode,
|
||||
@@ -166,7 +166,7 @@ if (!p_bAutoexec)
|
||||
BLOCK_END(); %>
|
||||
<div id="filters"><!-- dynamisch gevuld --></div>
|
||||
<%
|
||||
var buttons = [ {title: L("lcl_usrrep_uitvoeren"), action: "startSearch();startAutoRefreshTimer();" } ];
|
||||
var buttons = [ {title: L("lcl_usrrap_uitvoeren"), action: "startSearch();startAutoRefreshTimer();" } ];
|
||||
CreateButtons(buttons, { entersubmit: true});
|
||||
%>
|
||||
</div>
|
||||
|
||||
@@ -63,7 +63,7 @@ var fac_usrrap = usrrap.fac_usrrap_info(usrrap_key);
|
||||
size="1" style="display:none;">
|
||||
</select>
|
||||
</td><td>
|
||||
<img src="../Pictures/comment.png" id="<%="fclt_f_colvalue"+ nr_charcols+"_q"%>" title="<%=L("lcl_usrrep_beware")%>"
|
||||
<img src="../Pictures/comment.png" id="<%="fclt_f_colvalue"+ nr_charcols+"_q"%>" title="<%=L("lcl_usrrap_beware")%>"
|
||||
style='cursor:pointer'
|
||||
onclick="FillListbox('<%="fclt_f_colvalue" + nr_charcols%>','<%=col.column_name%>', <%=usrrap_key%>)">
|
||||
<input type="hidden" id="<%="fclt_f_colname" + nr_charcols%>"
|
||||
|
||||
@@ -62,7 +62,7 @@ var showall = getQParamInt("showall", 0) == 1;
|
||||
});
|
||||
|
||||
rst.addColumn(new Column({caption: "Key", content:"fac_usrrap_key"}));
|
||||
rst.addColumn(new Column({caption: L("lcl_usrrep_report"), content:"fac_usrrap_omschrijving"}));
|
||||
rst.addColumn(new Column({caption: L("lcl_usrrap_report"), content:"fac_usrrap_omschrijving"}));
|
||||
rst.addColumn(new Column({caption: L("lcl_fac_usrrapxpath"), content:"fac_usrrap_view_name"}));
|
||||
rst.addColumn(new Column({caption: L("lcl_fac_usrrapxcreate"), content:"fac_usrrap_info"}));
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ iface =
|
||||
}
|
||||
var elem = btn.getAttribute("fcltclick");
|
||||
|
||||
window.fcltevent = evt;
|
||||
var result = eval(elem);
|
||||
// Dit lijkt erg onzinning (we zitten binnen iface) maar soms als
|
||||
// een scherm/dialoog net gesloten is door de action van de button
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Context:
|
||||
*/
|
||||
|
||||
var mode = getQParamSafe("mode", "empty");
|
||||
var mode = getQParamSafe("mode", "search");
|
||||
if (mode == "save")
|
||||
var JSON_Result = true;
|
||||
%>
|
||||
@@ -18,7 +18,9 @@ if (mode == "save")
|
||||
<!-- #include file="../Shared/iface.inc" -->
|
||||
<!-- #include file="../Shared/calendar.inc" -->
|
||||
<!-- #include file="../Shared/selector.inc" -->
|
||||
<!-- #include file="../Shared/afdelingselector.inc" -->
|
||||
<!-- #include file="../Shared/persoonselector.inc" -->
|
||||
<!-- #include file="../Shared/kostenplaatsselector.inc" -->
|
||||
<!-- #include file="../Shared/data_recordset.inc" -->
|
||||
<!-- #include file="../Shared/resultset_table_v2.inc" -->
|
||||
<% } %>
|
||||
@@ -35,9 +37,6 @@ function scaffolding(model, scf_params)
|
||||
{
|
||||
scf_params = scf_params || {};
|
||||
|
||||
if (model && mode == 'empty')
|
||||
mode = 'search';
|
||||
|
||||
var imodel = getQParam("model", ""); // include model
|
||||
if (model.includes && imodel in model.includes)
|
||||
{
|
||||
@@ -50,8 +49,6 @@ function scaffolding(model, scf_params)
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case "empty":
|
||||
break;
|
||||
case "search":
|
||||
scaffolding_search(model, scf_params);
|
||||
break;
|
||||
|
||||
@@ -18,9 +18,6 @@ function scaffolding_edit(model, scf_params)
|
||||
js: ["jquery-ui.js", "jquery.timepicker-table.js"],
|
||||
css: ["timePicker-table.css"]})
|
||||
|
||||
// Autorisatie
|
||||
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS");
|
||||
|
||||
var transit = "";
|
||||
if ("transit" in scf_params)
|
||||
transit = "&" + scf_params.transit.name + "=" + safe.url(scf_params.transit.val);
|
||||
@@ -63,7 +60,7 @@ function scaffolding_edit(model, scf_params)
|
||||
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_name, buttons);
|
||||
IFRAMER_HEADER(model.record_title || model.record_name, buttons);
|
||||
%>
|
||||
<div id="edit">
|
||||
<form name="u2" method="post" action="<%=scf_params.this_fullpath%>?mode=save&id=<%=key%><%=transit%>" onsubmit="return false;">
|
||||
@@ -72,12 +69,43 @@ function scaffolding_edit(model, scf_params)
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
var field = model.fields[fld];
|
||||
if (field.readonly)
|
||||
continue; // daarvan hebben we ook de data niet gekregen
|
||||
|
||||
if ((fld == "id" || field.insertonly) && key > 0)
|
||||
ROFIELDTR("fldtxt", field.label||fld, xxx_data[fld]);
|
||||
else if (field.foreign)
|
||||
{
|
||||
var foreign = foreignKeyTable(field.foreign);
|
||||
if (field.foreign.toUpperCase() == "PRS_PERSLID" || field.foreign.toUpperCase() == "ALG_RUIMTE" || !foreign)
|
||||
|
||||
// Zie ook scaffolding_search
|
||||
if (field.foreign.toUpperCase() == "PRS_KOSTENPLAATS")
|
||||
{
|
||||
FCLTkostenplaatsselector(fld,
|
||||
"sg" + fld,
|
||||
user_key,
|
||||
{ label: field.label||fld,
|
||||
kostenplaatsKey: xxx_data[fld]?xxx_data[fld].id:null,
|
||||
filtercode: "AA"
|
||||
});
|
||||
}
|
||||
if (field.foreign.toUpperCase() == "PRS_PERSLID")
|
||||
{
|
||||
FCLTpersoonselector(fld,
|
||||
"sg" + fld,
|
||||
{ label: field.label||fld,
|
||||
perslidKey: xxx_data[fld]?xxx_data[fld].id:null
|
||||
});
|
||||
}
|
||||
if (field.foreign.toUpperCase() == "PRS_AFDELING")
|
||||
{
|
||||
FCLTafdelingselector(fld,
|
||||
"sg" + fld,
|
||||
{ label: field.label||fld,
|
||||
departmentKey: xxx_data[fld]?xxx_data[fld].id:null
|
||||
});
|
||||
}
|
||||
else if (field.foreign.toUpperCase() == "ALG_RUIMTE" || !foreign)
|
||||
{
|
||||
ROFIELDTR("fldtxt", field.label, "TODO: suggest met " + field.foreign);
|
||||
}
|
||||
|
||||
@@ -35,15 +35,13 @@ function scaffolding_list(model, scf_params)
|
||||
|
||||
FCLTHeader.Requires({js: []});
|
||||
|
||||
var autfunction = "WEB_PRSSYS";
|
||||
var authparams = user.checkAutorisation(autfunction);
|
||||
var authparams = user.checkAutorisation(model.autfunction);
|
||||
var showall = getQParamInt("showall", 0) == 1;
|
||||
|
||||
var outputmode = getQParamInt("outputmode", 0)
|
||||
%>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<% FCLTHeader.Generate(); %>
|
||||
<% FCLTHeader.Generate({ outputmode: outputmode }); %>
|
||||
<script>
|
||||
function scf_show(row)
|
||||
{
|
||||
@@ -70,12 +68,14 @@ function scaffolding_list(model, scf_params)
|
||||
}
|
||||
|
||||
var xxx_params = { filter : scf_params.filter || api2.qs2json(), columns: cols, groupby: grps };
|
||||
|
||||
var xxx_array = model.REST_GET(xxx_params);
|
||||
var rst = new ResultsetTable({ dataset: xxx_array,
|
||||
keyColumn: "id",
|
||||
ID: model.table,
|
||||
title: model.records_name,
|
||||
title: model.records_title || model.records_name,
|
||||
showAll: showall,
|
||||
outputmode: outputmode,
|
||||
buttons: buttons
|
||||
});
|
||||
|
||||
@@ -92,7 +92,8 @@ function scaffolding_list(model, scf_params)
|
||||
rst.addColumn(new Column({ caption: field.label || fld, content: fld, datatype: field.typ }));
|
||||
}
|
||||
|
||||
rst.addAction({ action: "scf_show", caption: L("lcl_edit"), isDefault: true } );
|
||||
if (model["REST_PUT"])
|
||||
rst.addAction({ action: "scf_show", caption: L("lcl_edit"), isDefault: true } );
|
||||
|
||||
var cnt = rst.processResultset();
|
||||
%>
|
||||
|
||||
@@ -19,27 +19,26 @@ function scaffolding_search(model, scf_params)
|
||||
if (!scf_params.list.columns.length && "list" in model)
|
||||
scf_params.list.columns = model.list.columns;
|
||||
|
||||
FCLTHeader.Requires({plugins:["jQuery"], js: []});
|
||||
FCLTHeader.Requires({plugins:[], js: []});
|
||||
|
||||
var autfunction = "WEB_PRSSYS";
|
||||
var authparams = user.checkAutorisation(autfunction);
|
||||
var authparams = user.checkAutorisation(model.autfunction);
|
||||
%>
|
||||
<html>
|
||||
<head>
|
||||
<% FCLTHeader.Generate() %>
|
||||
<script>
|
||||
function pick_columns(evt, deze)
|
||||
function pick_columns(deze)
|
||||
{
|
||||
$("#colpicker").show();
|
||||
$("#colpicker").css("left", evt.clientX - $("#colpicker").width() - 50);
|
||||
$("#scfcolpicker").show();
|
||||
$("#scfcolpicker").css("left", window.fcltevent.clientX - $("#scfcolpicker").width() - 50);
|
||||
}
|
||||
|
||||
function doSubmit()
|
||||
{
|
||||
$("#colpicker").hide();
|
||||
$("#scfcolpicker").hide();
|
||||
var cols = [];
|
||||
var groups = [];
|
||||
$("#colpicker tr").each(function()
|
||||
$("#scfcolpicker tr").each(function()
|
||||
{
|
||||
if (!this.id)
|
||||
return;
|
||||
@@ -60,8 +59,8 @@ function scaffolding_search(model, scf_params)
|
||||
<% } %>
|
||||
</script>
|
||||
</head>
|
||||
<body id="searchbody">
|
||||
|
||||
<body id="searchbody">
|
||||
<div id="search">
|
||||
<form name="u2" method="get" target="workFrame">
|
||||
<input type='hidden' name='mode' value='list'>
|
||||
@@ -75,7 +74,7 @@ function scaffolding_search(model, scf_params)
|
||||
if ("estimated_rows" in model)
|
||||
est_title = " <em style='font-size:10px'>estimated {0} rows as of {1}</em>".format(model.estimated_rows, toDateTimeString(model.last_analyzed));
|
||||
|
||||
BLOCK_START("searchtable", L("lcl_filterblok") + est_title);
|
||||
BLOCK_START("searchtable", L("lcl_filterblok") + " " + (model.records_title||model.records_name||"") + est_title);
|
||||
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
@@ -85,7 +84,35 @@ function scaffolding_search(model, scf_params)
|
||||
if (field.foreign)
|
||||
{
|
||||
var foreign = foreignKeyTable(field.foreign);
|
||||
if (field.foreign == "PRS_PERSLID" || field.foreign == "ALG_RUIMTE" || !foreign)
|
||||
|
||||
// Zie ook scaffolding_edit
|
||||
if (field.foreign.toUpperCase() == "PRS_KOSTENPLAATS")
|
||||
{
|
||||
FCLTkostenplaatsselector(fld,
|
||||
"sg" + fld,
|
||||
user_key,
|
||||
{ label: field.label||fld,
|
||||
kostenplaatsKey: -1,
|
||||
filtercode: "AA"
|
||||
});
|
||||
}
|
||||
else if (field.foreign.toUpperCase() == "PRS_PERSLID")
|
||||
{
|
||||
FCLTpersoonselector(fld,
|
||||
"sg" + fld,
|
||||
{ label: field.label||fld,
|
||||
perslidKey: -1
|
||||
});
|
||||
}
|
||||
else if (field.foreign.toUpperCase() == "PRS_AFDELING")
|
||||
{
|
||||
FCLTafdelingselector(fld,
|
||||
"sg" + fld,
|
||||
{ label: field.label||fld,
|
||||
departmentKey: -1
|
||||
});
|
||||
}
|
||||
else if (field.foreign == "ALG_RUIMTE" || !foreign)
|
||||
{
|
||||
ROFIELDTR("fldtxt", field.label, "TODO: Listbox of suggest met " + field.foreign);
|
||||
}
|
||||
@@ -105,36 +132,43 @@ function scaffolding_search(model, scf_params)
|
||||
}
|
||||
}
|
||||
if (model.soft_delete)
|
||||
RWCHECKBOXTR("show_deleted", "fldcheck", L("lcl_show_deleted"), 0);
|
||||
RWCHECKBOXTR("show_deleted", "fldcheck", L("lcl_scf_show_deleted"), 0);
|
||||
|
||||
BLOCK_END();
|
||||
var buttons = [];
|
||||
buttons.push({title: L("lcl_columns"), action: "pick_columns(event, this)" });
|
||||
buttons.push({title: L("lcl_scf_columns"), action: "pick_columns(this)" });
|
||||
buttons.push({title: L("lcl_search"), action: "doSubmit()" });
|
||||
CreateButtons(buttons, { entersubmit: true });
|
||||
%>
|
||||
</form>
|
||||
|
||||
<div id="colpicker" style='padding:10px;border:2px solid black;position:absolute;top:5px;left:500px;background-color:#f0f0f0;display:none'>
|
||||
<div id="scfcolpicker" style='display:none'>
|
||||
<table>
|
||||
<tr><th>Show</th><th>Totals</th></tr>
|
||||
<%
|
||||
var grp = api2.splitLOV2select("G;Group by;S;Sum;C;Count;A;Avg");
|
||||
var grpdate = api2.splitLOV2select("G;Group by;D;Group by date;W;Group by week;M;Group by month;Y;Group by year");
|
||||
if (model.list.canGroup)
|
||||
Response.Write("<tr><th>" + L("lcl_rap_visible") + "</th><th>" + L("lcl_rap_groupby") + "</th></tr>");
|
||||
else
|
||||
Response.Write("<tr><th>" + L("lcl_rap_visible") + "</th></tr>");
|
||||
for (fld in model.fields)
|
||||
{
|
||||
var on = inArray(fld, scf_params.list.columns);
|
||||
Response.Write("<tr id='" + fld + "'><td><label><input type='checkbox' " + (on?"checked='1'":"") + ">" + safe.html(model.fields[fld].label) + "</label></td>")
|
||||
if (model.fields[fld].typ == "date")
|
||||
Response.Write("<td>" + grpdate + "</td>")
|
||||
else
|
||||
Response.Write("<td>" + grp + "</td>")
|
||||
if (model.list.canGroup)
|
||||
{
|
||||
if (model.fields[fld].typ == "date")
|
||||
grp = L("lcl_rap_groupbydateLOV"); // "G;Group by;D;Group by date;W;Group by week;M;Group by month;Y;Group by year";
|
||||
else if (model.fields[fld].typ == 'varchar')
|
||||
grp = L("lcl_rap_groupbyvarcharLOV"); // "G;Group by";
|
||||
else
|
||||
grp = L("lcl_rap_groupbynumberLOV"); // "G;Group by;S;Sum;C;Count;A;Avg";
|
||||
Response.Write("<td>" + api2.splitLOV2select(grp , model.fields[fld].total.id) + "</td>")
|
||||
}
|
||||
Response.Write("</tr>")
|
||||
}
|
||||
%>
|
||||
</table>
|
||||
<input type='button' class='button' value='<%=L("lcl_search")%>' onclick='doSubmit()'>
|
||||
<input type='button' class='button' value='<%=L("lcl_cancel")%>' onclick='$("#colpicker").hide()'>
|
||||
<input type='button' class='button' value='<%=L("lcl_cancel")%>' onclick='$("#scfcolpicker").hide()'>
|
||||
</div>
|
||||
</div> <!-- search -->
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ function scaffolding_show(model, scf_params)
|
||||
if ("js" in scf_params.show)
|
||||
FCLTHeader.Requires({ js: scf_params.show.js });
|
||||
|
||||
// Autorisatie
|
||||
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS");
|
||||
|
||||
var transit = "";
|
||||
if ("transit" in scf_params)
|
||||
transit = "&" + scf_params.transit.name + "=" + safe.url(scf_params.transit.val);
|
||||
@@ -77,7 +74,7 @@ function scaffolding_show(model, scf_params)
|
||||
</head>
|
||||
<body id="showbody">
|
||||
<% var buttons = [];
|
||||
if (authparamsPRSSYS.PRSreadlevel < 9 && authparamsPRSSYS.ALGreadlevel < 9)
|
||||
if (model["REST_PUT"]) // TODO: Eventueel autfunction testen?
|
||||
{
|
||||
if (scf_params.show.buttons)
|
||||
{
|
||||
@@ -92,7 +89,7 @@ function scaffolding_show(model, scf_params)
|
||||
if (model["REST_DELETE"])
|
||||
buttons.push({title: L("lcl_delete"), action: "xxx_delete()", icon: "delete.png" });
|
||||
}
|
||||
IFRAMER_HEADER(model.record_name, buttons);
|
||||
IFRAMER_HEADER(model.record_title || model.record_name, buttons);
|
||||
%>
|
||||
<div id="show">
|
||||
<form name="u2" onSubmit="return false;">
|
||||
|
||||
@@ -25,7 +25,7 @@ function scaffolding_wrap(model, scf_params)
|
||||
|
||||
FCLTHeader.Requires({plugins:["jQuery", "suggest"], js: ["jquery-ui.js"]})
|
||||
|
||||
var scf_title = L("lcl_fac_usrrapx");
|
||||
var scf_title = model.record_title || model.record_name;
|
||||
%>
|
||||
|
||||
<html>
|
||||
|
||||
@@ -3250,3 +3250,13 @@ body.floorscreen3d {
|
||||
#xsledit label, #xslview label {padding-right: 10px;}
|
||||
#xslview {padding: 8px 0 10px 0;}
|
||||
#sDocuments {width: 200px;}
|
||||
|
||||
#scfcolpicker {
|
||||
padding:10px;
|
||||
border:2px solid black;
|
||||
position:absolute;top:5px;left:500px;
|
||||
background-color:#f0f0f0;
|
||||
}
|
||||
#scfcolpicker select {
|
||||
width:150px;
|
||||
}
|
||||
|
||||
@@ -189,6 +189,10 @@ function ROFIELD(pclass, plabel, pvalue, params)
|
||||
if ((pvalue == null || pvalue == "") && params.suppressEmpty)
|
||||
return; // snel klaar
|
||||
|
||||
// Vanuit API2 model
|
||||
if (pvalue != null && typeof pvalue == "object" && "name" in pvalue)
|
||||
pvalue = pvalue["name"];
|
||||
|
||||
if (plabel) {
|
||||
%><td class="label"><label <%=params && params.id? ' for=\"' + params.id + '\"' : ''%>><%=plabel? plabel + ":" : ""%></label></td>
|
||||
<td><%
|
||||
|
||||
@@ -50,10 +50,11 @@ function foreignKeyTable(field)
|
||||
{
|
||||
__foreignKeyTable
|
||||
= {
|
||||
"PRS_PERSLID" : { tbl: "prs_v_perslid_fullnames_all", key: "prs_perslid_key", desc: "prs_perslid_naam_full", alias: "p"},
|
||||
"PRS_PERSLID" : { tbl: "prs_v_perslid_fullnames_all", key: "prs_perslid_key", desc: "prs_perslid_naam_full"},
|
||||
"PRS_KOSTENPLAATS" : { tbl: "prs_kostenplaats", key: "prs_kostenplaats_key", desc: S("prs_kpn_string"), alias: "k"},
|
||||
"PRS_KOSTENPLAATSGRP" : { tbl: "prs_kostenplaatsgrp", key: "prs_kostenplaatsgrp_key", desc: "prs_kostenplaatsgrp_oms", alias: "kpg"},
|
||||
"PRS_KOSTENSOORT" : { tbl: "prs_kostensoort", key: "prs_kostensoort_key", desc: "prs_kostensoort_oms", alias: "ks"},
|
||||
"PRS_KOSTENPLAATSGRP" : { tbl: "prs_kostenplaatsgrp", key: "prs_kostenplaatsgrp_key", desc: "prs_kostenplaatsgrp_oms"},
|
||||
"PRS_KOSTENSOORT" : { tbl: "prs_kostensoort", key: "prs_kostensoort_key", desc: "prs_kostensoort_oms"},
|
||||
"PRS_KOSTENSOORTGRP" : { tbl: "prs_kostensoortgrp", key: "prs_kostensoortgrp_key", desc: "prs_kostensoortgrp_oms"},
|
||||
"CNT_TERMIJN" : { tbl: "cnt_termijn", key: "cnt_termijn_key", desc: lcl.xsql("cnt_termijn_omschrijving", "cnt_termijn_key" )},
|
||||
"CNT_CONTRACT" : { tbl: "cnt_contract", key: "cnt_contract_key", desc: "cnt_contract_nummer_intern" },
|
||||
"CNT_DISCIPLINE" : { tbl: "cnt_discipline", key: "ins_discipline_key", desc: "ins_discipline_omschrijving" },
|
||||
|
||||
Reference in New Issue
Block a user