FSN#31698 Rapportgenerator savepoint
svn path=/Website/trunk/; revision=24350
This commit is contained in:
@@ -448,15 +448,13 @@ api2 = {
|
||||
break;
|
||||
case "date": // onderscheid date en datetime?
|
||||
case "datetime":
|
||||
// exact: dbs == filterval; nodig? zoiets dan:
|
||||
//if (filter == "exact")
|
||||
//{
|
||||
// var safe_val = new Date(parseInt(filterval, 10));
|
||||
// safe_val = safe_val.toSQL();
|
||||
// field.dbs = "TRUNC("+field.dbs+")";
|
||||
//}
|
||||
// range: (dbs >= start_value, dbs <= end_value)
|
||||
if (filter == "range")
|
||||
if (filter == "exact")
|
||||
{
|
||||
var safe_val = api2.toDate(filterval);
|
||||
safe_val = safe_val.toSQL();
|
||||
operand = " = ";
|
||||
}
|
||||
else if (filter == "range")
|
||||
{
|
||||
var safe_val;
|
||||
if (filterval1) {
|
||||
@@ -499,6 +497,10 @@ api2 = {
|
||||
safe_val = safe_val.toUpperCase();
|
||||
}
|
||||
}
|
||||
if (filter == "exact" && (field.typ == "date" || field.typ == "datetime"))
|
||||
{
|
||||
dbs = "TRUNC("+dbs+")";
|
||||
}
|
||||
wheres.push(dbs + operand + safe_val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,18 +26,21 @@ model_reportcolumns =
|
||||
|
||||
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"), xxinsertonly: true,
|
||||
"datatype" : { dbs: "fac_usrrap_cols_datatype", typ: "varchar", label: L("lcl_rap_datatype"),
|
||||
required: true,
|
||||
LOV: L("lcl_rap_datatypeLOV")}, // "varchar;Tekst;date;Datum;datetime;Datumtijd;float;Float;currency;Bedrag;integer;Getal"
|
||||
"sequence" : { dbs: "fac_usrrap_cols_volgnr", typ: "number", label: L("lcl_rap_sequence") },
|
||||
"caption" : { dbs: "fac_usrrap_cols_caption", typ: "varchar", label: L("lcl_rap_caption")},
|
||||
"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"),
|
||||
required: true,
|
||||
LOV: L("lcl_rap_visibleLOV")}, // "V;Visible;I;Invisible;H;hidden"
|
||||
"group" : { dbs: "fac_usrrap_cols_group", typ: "varchar", label: L("lcl_rap_groupby"),
|
||||
required: true,
|
||||
LOV: L("lcl_rap_groupbyLOV") }
|
||||
},
|
||||
list: { columns: ["sequence", "name", "caption", "datatype", "visible", "group"] },
|
||||
list: { columns: ["sequence", "name", "caption", "datatype", "visible", "filter", "group"] },
|
||||
|
||||
hook_pre_edit: function (obj)
|
||||
{
|
||||
@@ -51,9 +54,11 @@ model_reportcolumns =
|
||||
break;
|
||||
case "varchar":
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
model_reportcolumns.fields.datatype.readonly = true;
|
||||
break;
|
||||
case "float":
|
||||
case "number":
|
||||
case "integer":
|
||||
case "currency":
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,S,C,A");
|
||||
model_reportcolumns.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "float,currency,integer");
|
||||
|
||||
@@ -17,39 +17,31 @@
|
||||
<!-- #include file="../fac/fac_usrrap.inc" -->
|
||||
<%
|
||||
|
||||
model_reports_template =
|
||||
function model_reports_template()
|
||||
{
|
||||
table: "te bepalen",
|
||||
primary: null,
|
||||
records_name: "te bepalen",
|
||||
record_name: "te bepalen",
|
||||
fields: {/* te bepalen */},
|
||||
autfunction: "WEB_PRSSYS",
|
||||
this.table = "te bepalen";
|
||||
this.primary = null;
|
||||
this.records_name = "te bepalen";
|
||||
this.record_name = "te bepalen";
|
||||
this.fields = {/* te bepalen */};
|
||||
this.autfunction = "WEB_PRSSYS";
|
||||
|
||||
_check_authorization: function(params, method)
|
||||
this.REST_GET = function _GET(params, jsondata)
|
||||
{
|
||||
params.message = "";
|
||||
var autfunction = "WEB_PRSSYS";
|
||||
params.authparams = user.checkAutorisation(autfunction);
|
||||
},
|
||||
|
||||
REST_GET: function _GET(params, jsondata)
|
||||
{
|
||||
model_reports_template._check_authorization(params, "GET");
|
||||
var groupbys = [];
|
||||
if (params.columns && params.groupby)
|
||||
{
|
||||
if (params.columns.length != params.groupby.length)
|
||||
INTERNAL_ERROR_GROUP_MISMATCH;
|
||||
for (var fld in model_reports_template.fields)
|
||||
for (var fld in this.fields)
|
||||
{
|
||||
if (!inArray(fld, params.columns))
|
||||
delete model_reports_template.fields[fld];
|
||||
delete this.fields[fld];
|
||||
}
|
||||
for (var i=0; i < params.columns.length; i++)
|
||||
{
|
||||
var fld = params.columns[i];
|
||||
var field = model_reports_template.fields[fld];
|
||||
var field = this.fields[fld];
|
||||
field.keepdbsforfilter = true;
|
||||
switch (params.groupby[i])
|
||||
{
|
||||
@@ -69,6 +61,7 @@ model_reports_template =
|
||||
case "A":
|
||||
field.sql = "AVG(" + field.dbs + ")";
|
||||
field.label = "AVG(" + field.label + ")";
|
||||
field.newtyp = "float";
|
||||
break;
|
||||
case "D":
|
||||
field.sql = "TRUNC(" + field.dbs + ", 'DD')";
|
||||
@@ -97,9 +90,9 @@ model_reports_template =
|
||||
}
|
||||
}
|
||||
}
|
||||
var query = api2.sqlfields(params, model_reports_template);
|
||||
var query = api2.sqlfields(params, this);
|
||||
|
||||
var wheres = api2.sqlfilter(params, model_reports_template);
|
||||
var wheres = api2.sqlfilter(params, this);
|
||||
query.wheres = query.wheres.concat(wheres);
|
||||
|
||||
var maxcnt = getQParamInt("showall", 0) == 1?S("qp_maxrows2"):S("qp_maxrows");
|
||||
@@ -118,32 +111,37 @@ model_reports_template =
|
||||
order.push(i+1)
|
||||
sql += " ORDER BY " + order.join(", ");
|
||||
|
||||
for (var fld in model_reports_template.fields)
|
||||
for (var fld in this.fields)
|
||||
{ // Overrules voor groeperingen
|
||||
model_reports_template.fields[fld].typ = model_reports_template.fields[fld].newtyp || model_reports_template.fields[fld].typ;
|
||||
this.fields[fld].typ = this.fields[fld].newtyp || this.fields[fld].typ;
|
||||
}
|
||||
var json = api2.sql2json (params, sql, model_reports_template);
|
||||
var json = api2.sql2json (params, sql, this);
|
||||
|
||||
return json;
|
||||
},
|
||||
REST_PUT: false,
|
||||
REST_POST: false,
|
||||
REST_DELETE: false,
|
||||
};
|
||||
this.REST_PUT = false;
|
||||
this.REST_POST = false;
|
||||
this.REST_DELETE = false;
|
||||
|
||||
search: { title: L("lcl_usrrap_report") }
|
||||
this.search = { title: L("lcl_usrrap_report") }
|
||||
}
|
||||
|
||||
// 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;
|
||||
user.auth_required_or_abort(usrrap);
|
||||
|
||||
model_reports_template.list = { columns : [], canGroup: true };
|
||||
var model = new model_reports_template();
|
||||
model.table = usrrap.viewname;
|
||||
model.record_name = usrrap.viewname.substring(0,1) + usrrap.viewname.substring(1).toLowerCase();
|
||||
model.records_name = model.record_name + "s";
|
||||
model.records_title = usrrap.name;
|
||||
if (usrrap.authorisation)
|
||||
user.checkAutorisation(usrrap.authorisation);
|
||||
model.autfunction = usrrap.authorisation;
|
||||
|
||||
model.list = { columns : [], canGroup: true };
|
||||
for (var i = 0; i < usrrap.columns.length; i++)
|
||||
{
|
||||
var field = { dbs: usrrap.columns[i].name,
|
||||
@@ -151,19 +149,26 @@ function model_reports(fac_usrrap_key)
|
||||
typ: usrrap.columns[i].datatype.id,
|
||||
group: usrrap.columns[i].group
|
||||
};
|
||||
if (usrrap.columns[i].filter && usrrap.columns[i].filter.id == "A")
|
||||
if (usrrap.columns[i].filter)
|
||||
{
|
||||
if (usrrap.columns[i].filter.id == "A")
|
||||
{
|
||||
field.filter = { "date": "range",
|
||||
"datetime": "range",
|
||||
"varchar": "like"
|
||||
}[ field.typ ] || "exact";
|
||||
}
|
||||
var fld = "COL" + String(usrrap.columns[i].id)
|
||||
model_reports_template.fields[fld] = field;
|
||||
if (usrrap.columns[i].visible.id == 'V')
|
||||
model_reports_template.list.columns.push(fld);
|
||||
else
|
||||
{
|
||||
field.filter = api2.splitLOV("E;exact;L;like;R;range")[usrrap.columns[i].filter.id]
|
||||
}
|
||||
__Logj(model_reports_template);
|
||||
return model_reports_template;
|
||||
}
|
||||
var fld = "C" + String(usrrap.columns[i].id)
|
||||
model.fields[fld] = field;
|
||||
if (usrrap.columns[i].visible.id == 'V')
|
||||
model.list.columns.push(fld);
|
||||
}
|
||||
__Logj(model);
|
||||
return model;
|
||||
}
|
||||
%>
|
||||
@@ -101,18 +101,19 @@ return; // TODO?
|
||||
|
||||
REST_GET: function _reportsx_GET(params, jsondata)
|
||||
{
|
||||
model_reportsx._check_authorization(params, "GET");
|
||||
var query = api2.sqlfields(params, model_reportsx);
|
||||
|
||||
var wheres = api2.sqlfilter(params, model_reportsx);
|
||||
query.wheres = query.wheres.concat(wheres);
|
||||
|
||||
if (params.authparams.ALGreadlevel > -1)
|
||||
{ // Er is een scope-beperking van kracht
|
||||
query.wheres.push("r.fac_usrrap_key IN"
|
||||
+ " (SELECT fac_usrrap_key FROM fac_v_my_rooms"
|
||||
+ " WHERE prs_perslid_key = " + user_key
|
||||
+ " AND niveau = " + params.authparams.ALGreadlevel + ")");
|
||||
authparams = user.checkAutorisation("WEB_PRSSYS", true);
|
||||
if (!authparams)
|
||||
{
|
||||
query.wheres.push("(fac_functie_key IN"
|
||||
+ " (SELECT w.fac_functie_key"
|
||||
+ " FROM fac_v_webgebruiker W"
|
||||
+ " WHERE w.prs_perslid_key = " + user_key
|
||||
+ " ) OR fac_functie_key IS NULL)");
|
||||
}
|
||||
var sql = "SELECT " + query.selects.join(", ")
|
||||
+ " FROM " + query.tables.join(", ")
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/iface.inc" -->
|
||||
<!-- #include file="../Shared/calendar.inc" -->
|
||||
<!-- #include file="../Shared/rapportselector.inc" -->
|
||||
|
||||
<%
|
||||
FCLTHeader.Requires ({ plugins: ["jQuery"],
|
||||
FCLTHeader.Requires ({ plugins: [],
|
||||
js: []
|
||||
});
|
||||
|
||||
@@ -50,7 +49,7 @@ if (!p_bAutoexec)
|
||||
// for this report in filterframe
|
||||
function emptyFilterAndReport()
|
||||
{
|
||||
//document.u2.action = "../fac/fac_report.asp";
|
||||
if ($("#usrrap_key").val() > 0)
|
||||
document.forms.u2.submit();
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ if (!p_bAutoexec)
|
||||
</head>
|
||||
|
||||
<body id="searchbody">
|
||||
<form name="u2" method="get" action="fac_usrrap_search.asp" xxtarget="workFrame" onsubmit='return false'>
|
||||
<form name="u2" method="get" action="fac_usrrap_search.asp" onsubmit='return false'>
|
||||
<input type="hidden" name="fclt_key" value="<%=fclt_key%>">
|
||||
<% if (!p_bAutoexec)
|
||||
{ %>
|
||||
@@ -104,15 +103,5 @@ if (!p_bAutoexec)
|
||||
}
|
||||
%>
|
||||
</form>
|
||||
|
||||
<div id="result">
|
||||
<iframe width="100%" height="100%"
|
||||
src="../Shared/empty.asp"
|
||||
name="workFrame" id="workFrame"
|
||||
marginwidth="0" marginheight="0"
|
||||
onload="FcltMgr.iframeLoaded(this)"
|
||||
frameborder="0" scrolling="auto">
|
||||
</iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -15,12 +15,14 @@ if (mode == "save")
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<% if (mode != "save") { %>
|
||||
<% if (mode != "list") { %>
|
||||
<!-- #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" -->
|
||||
<% } %>
|
||||
@@ -144,7 +146,7 @@ function scf_RWFIELDTR(field, fld, val)
|
||||
+ " ORDER BY 2";
|
||||
FCLTselector(fld, sql, { label: field.label||fld,
|
||||
initKey: val?val.id:null,
|
||||
emptyOption: "" // TODO: Niet bij required?
|
||||
emptyOption: field.required?null:""
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -153,7 +155,7 @@ function scf_RWFIELDTR(field, fld, val)
|
||||
var sql = api2.splitLOV2sql(field.LOV);
|
||||
FCLTselector(fld, sql, { label: field.label||fld,
|
||||
initKey: val?val.id:null,
|
||||
emptyOption: "" // TODO: Niet bij required?
|
||||
emptyOption: field.required?null:""
|
||||
});
|
||||
}
|
||||
else if (field.typ == "check")
|
||||
|
||||
@@ -25,17 +25,21 @@ function scaffolding_edit(model, scf_params)
|
||||
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];
|
||||
if ("hook_pre_edit" in model)
|
||||
model.hook_pre_edit(xxx_data);
|
||||
}
|
||||
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
|
||||
%>
|
||||
@@ -58,7 +62,7 @@ function scaffolding_edit(model, scf_params)
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body id="editbody" <%=modal?"class='modal scaffolding'":""%>>
|
||||
<body id="<%=modal?"mod_scaffolding":"editbody"%>" <%=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" }];
|
||||
@@ -72,9 +76,9 @@ function scaffolding_edit(model, scf_params)
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
var field = model.fields[fld];
|
||||
if (field.readonly)
|
||||
if (field.readonly || fld == "id")
|
||||
scf_ROFIELDTR(field, fld, xxx_data[fld]);
|
||||
else if ((fld == "id" || field.insertonly) && key > 0)
|
||||
else if (field.insertonly && key > 0)
|
||||
scf_ROFIELDTR(field, fld, xxx_data[fld]);
|
||||
else
|
||||
scf_RWFIELDTR(field, fld, xxx_data[fld]);
|
||||
|
||||
@@ -35,7 +35,11 @@ function scaffolding_list(model, scf_params)
|
||||
|
||||
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)
|
||||
%>
|
||||
@@ -72,7 +76,7 @@ function scaffolding_list(model, scf_params)
|
||||
var xxx_array = model.REST_GET(xxx_params);
|
||||
|
||||
var rst = new ResultsetTable({ dataset: xxx_array,
|
||||
keyColumn: "id",
|
||||
keyColumn: ("id" in model.fields?"id":null),
|
||||
ID: model.table,
|
||||
title: model.records_title || model.records_name,
|
||||
showAll: showall,
|
||||
|
||||
@@ -23,6 +23,7 @@ function scaffolding_search(model, scf_params)
|
||||
|
||||
FCLTHeader.Requires({plugins:[], js: []});
|
||||
|
||||
if (model.autfunction)
|
||||
var authparams = user.checkAutorisation(model.autfunction);
|
||||
%>
|
||||
<html>
|
||||
@@ -89,7 +90,10 @@ function scaffolding_search(model, scf_params)
|
||||
scf_RWFIELDTR(field, fld, null);
|
||||
else if (field.filter == "range")
|
||||
{
|
||||
var org_label = field.label;
|
||||
field.label = org_label + " " + L("lcl_from");
|
||||
scf_RWFIELDTR(field, "start_" + fld, null);
|
||||
field.label = org_label + " " + L("lcl_to");
|
||||
scf_RWFIELDTR(field, "end_" + fld, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,14 +87,15 @@ if (p_autosortby.substr(0,1) == '-')
|
||||
// <form> printform is nodig bij printen reserveringen i.v.m. POST formulier
|
||||
// maar <form> mag niet binnen een ander <form> voorkomen en moet eigenlijk wel binnen body staan
|
||||
// Formulier als tekstring samenstellen en m.b.v. $(document).ready(function(){}) binnen de body zetten (resultset_table_v2.js)
|
||||
var postformHTML = '';
|
||||
|
||||
if (Request.ServerVariables("REQUEST_METHOD") == "POST")
|
||||
{
|
||||
var postformHTML = '<div id=\"postform\">'
|
||||
+ '<form id=\"printform\" name=\"printform\" target=\"_blank\" method=\"post\">'
|
||||
+ '<input type=\"hidden\" id=\"outputmode\" name=\"outputmode\" value=\"0\">' // input outputmode wordt gezet in doOutput()
|
||||
+ '<input type=\"hidden\" id=\"autosortby\" name=\"autosortby\" value=\"0\">' // input autosortby wordt gezet in doOutput()
|
||||
+ '<input type=\"hidden\" id=\"showall\" name=\"showall\" value=\"1\">';
|
||||
|
||||
if (Request.ServerVariables("REQUEST_METHOD") == "POST")
|
||||
{
|
||||
var items = new Enumerator(Request.Form());
|
||||
|
||||
while (!items.atEnd())
|
||||
@@ -109,9 +110,9 @@ if (Request.ServerVariables("REQUEST_METHOD") == "POST")
|
||||
}
|
||||
items.moveNext();
|
||||
}
|
||||
}
|
||||
postformHTML += '</form>'
|
||||
+ '</div>';
|
||||
}
|
||||
|
||||
var isPlain = false;
|
||||
var isPrinting = false;
|
||||
|
||||
Reference in New Issue
Block a user