FSN#31698 Rapportgenerator fixes: beter/ simpeler clonen
svn path=/Website/trunk/; revision=24673
This commit is contained in:
@@ -640,6 +640,11 @@ api2 = {
|
||||
else // simpel
|
||||
var newval = jsondata[fld];
|
||||
|
||||
if (field.LOV && newval && typeof newval == "object" && "id" in newval)
|
||||
{ // dereference
|
||||
newval = newval.id;
|
||||
}
|
||||
|
||||
switch (field.typ)
|
||||
{
|
||||
case "key": // De foreign keys action { "id": "5", "name": "afhalen" }
|
||||
|
||||
@@ -13,18 +13,20 @@
|
||||
*/
|
||||
|
||||
// model_reportcolumns is uitsluitend beschikbaar onder model_reports(x) die de autorisatie dan ook doet
|
||||
model_reportcolumns =
|
||||
function model_reportcolumns(usrrap_key, params)
|
||||
{
|
||||
table: "fac_usrrap_cols",
|
||||
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",
|
||||
params = params || {};
|
||||
this.table = "fac_usrrap_cols";
|
||||
this.primary = "fac_usrrap_cols_key";
|
||||
this.records_name = "columns";
|
||||
this.record_name = "column";
|
||||
this.records_title = L("lcl_rap_columns");
|
||||
this.record_title = L("lcl_rap_column");
|
||||
this.parent_key = "fac_usrrap_key",
|
||||
this.autfunction = "WEB_PRSSYS",
|
||||
|
||||
fields: { "id" : { dbs: "fac_usrrap_cols_key", typ: "key", filter: "exact", seq: "fac_s_fac_usrrap_cols_key" },
|
||||
this.fields =
|
||||
{ "id" : { dbs: "fac_usrrap_cols_key", typ: "key", filter: "exact", seq: "fac_s_fac_usrrap_cols_key" },
|
||||
"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"),
|
||||
required: true,
|
||||
@@ -40,38 +42,39 @@ model_reportcolumns =
|
||||
"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", "filter", "group"] },
|
||||
};
|
||||
|
||||
hook_pre_edit: function (obj)
|
||||
this.list = { columns: ["sequence", "name", "caption", "datatype", "visible", "filter", "group"] };
|
||||
|
||||
this.hook_pre_edit = function (obj)
|
||||
{
|
||||
switch (obj.datatype.id)
|
||||
{
|
||||
case "date":
|
||||
case "datetime":
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,D,W,M,Q,Y,H");
|
||||
model_reportcolumns.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "date,datetime,time");
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,D,W,M,Q,Y,H");
|
||||
this.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "date,datetime,time");
|
||||
break;
|
||||
case "time":
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,H");
|
||||
model_reportcolumns.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "date,datetime,time");
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,H");
|
||||
this.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "date,datetime,time");
|
||||
break;
|
||||
case "varchar":
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
model_reportcolumns.fields.datatype.readonly = true;
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
this.fields.datatype.readonly = true;
|
||||
break;
|
||||
case "float":
|
||||
case "number":
|
||||
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,number");
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G,S,C,A");
|
||||
this.fields.datatype.LOV = api2.filterLOV(L("lcl_rap_datatypeLOV"), "float,currency,number");
|
||||
break;
|
||||
default:
|
||||
model_reportcolumns.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
this.fields.group.LOV = api2.filterLOV(L("lcl_rap_groupbyLOV"), "G");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
_view2columns: function (usrrap_key)
|
||||
this._view2columns = function (usrrap_key)
|
||||
{
|
||||
var sql = "SELECT fac_usrrap_view_name"
|
||||
+ " FROM fac_usrrap"
|
||||
@@ -151,17 +154,17 @@ model_reportcolumns =
|
||||
colpar.datatype = 'date';
|
||||
}
|
||||
|
||||
var params = { };
|
||||
model_reportcolumns._REST_POST(params, colpar, usrrap_key);
|
||||
var params = { internal: true };
|
||||
this.REST_POST(params, colpar, usrrap_key);
|
||||
oRs.MoveNext();
|
||||
}
|
||||
oRs.Close();
|
||||
},
|
||||
|
||||
REST_GET: function _GET(params)
|
||||
this.REST_GET = function _GET(params)
|
||||
{
|
||||
var query = api2.sqlfields(params, model_reportcolumns );
|
||||
var wheres = api2.sqlfilter(params, model_reportcolumns);
|
||||
var query = api2.sqlfields(params, this );
|
||||
var wheres = api2.sqlfilter(params, this);
|
||||
query.wheres = query.wheres.concat(wheres);
|
||||
|
||||
var sql = "SELECT " + query.selects.join(", ")
|
||||
@@ -169,18 +172,18 @@ model_reportcolumns =
|
||||
+ " WHERE " + query.wheres.join(" AND " )
|
||||
+ " ORDER BY fac_usrrap_cols_volgnr";
|
||||
|
||||
var json = api2.sql2json (params, sql, model_reportcolumns );
|
||||
var json = api2.sql2json (params, sql, this );
|
||||
if (!json.length)
|
||||
{
|
||||
model_reportcolumns._view2columns(parseInt(params.filter.pid,10));
|
||||
var json = api2.sql2json (params, sql, model_reportcolumns );
|
||||
this._view2columns(parseInt(params.filter.pid,10));
|
||||
var json = api2.sql2json (params, sql, this );
|
||||
}
|
||||
|
||||
return json;
|
||||
},
|
||||
REST_PUT: function (params, jsondata, the_key) /* update columns */
|
||||
};
|
||||
this.REST_PUT = function (params, jsondata, the_key) /* update columns */
|
||||
{
|
||||
var fields = api2.update_fields(params, model_reportcolumns, jsondata); // Build updater
|
||||
var fields = api2.update_fields(params, this, jsondata); // Build updater
|
||||
|
||||
var sql = buildUpdate("fac_usrrap_cols", fields) + " fac_usrrap_cols_key = " + the_key;
|
||||
var err = Oracle.Execute(sql, true);
|
||||
@@ -190,24 +193,27 @@ model_reportcolumns =
|
||||
return { key: the_key };
|
||||
},
|
||||
// Only internally used by report_clone
|
||||
REST_POST: function (params, jsondata, parent_key) /* insert columns */
|
||||
this.REST_POST = function (params, jsondata, parent_key) /* insert columns */
|
||||
{
|
||||
if (!params.internal)
|
||||
INTERNAL_ERROR_INTERNAL_ONLY;
|
||||
var fields = api2.update_fields(params, model_reportcolumns, jsondata); // Build updater
|
||||
var fields = api2.update_fields(params, this, jsondata); // Build updater
|
||||
|
||||
fields["id"] = model_reportcolumns.fields["id"];
|
||||
fields["id"] = this.fields["id"];
|
||||
fields["xxx"] = { dbs: "fac_usrrap_key", typ: "key", val: parent_key };
|
||||
var roomIns = buildInsert("fac_usrrap_cols", fields, { noValidateToken: true });
|
||||
var col_key = roomIns.sequences["fac_usrrap_col_key"];
|
||||
var rapIns = buildInsert("fac_usrrap_cols", fields, { noValidateToken: true });
|
||||
var col_key = rapIns.sequences["fac_usrrap_col_key"];
|
||||
|
||||
var err = Oracle.Execute(roomIns.sql, true);
|
||||
var err = Oracle.Execute(rapIns.sql, true);
|
||||
if (err.friendlyMsg)
|
||||
abort_with_warning(err.friendlyMsg);
|
||||
|
||||
return { key: col_key, warning: "" };
|
||||
}
|
||||
// REST_DELETE: not supported
|
||||
|
||||
if (!params.internal)
|
||||
{
|
||||
this.REST_POST = false;
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
@@ -43,7 +43,7 @@ function model_reportsx(usrrap_key, params)
|
||||
filters: ["id", "name", "description"]
|
||||
};
|
||||
|
||||
this.includes = {"columns": { model: model_reportcolumns,
|
||||
this.includes = {"columns": { model: new model_reportcolumns(usrrap_key, { internal: true }),
|
||||
joinfield: "fac_usrrap_key"
|
||||
}
|
||||
};
|
||||
@@ -113,7 +113,7 @@ function model_reportsx(usrrap_key, params)
|
||||
var json = api2.sql2json (params, sql, this);
|
||||
if (json.length == 1 && params.include && json[0].columns.length == 0)
|
||||
{
|
||||
model_reportcolumns._view2columns(params.filter.id);
|
||||
this.includes["columns"].model._view2columns(params.filter.id);
|
||||
var json = api2.sql2json (params, sql, this );
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var submitting = getQParamInt("submit", 0) == 1;
|
||||
var col_key = getQParamInt("col_key");
|
||||
|
||||
var col_params = { filter: { id: col_key } };
|
||||
var col_data = model_reportcolumns.REST_GET(col_params)[0];
|
||||
var col_data = new model_reportcolumns().REST_GET(col_params)[0];
|
||||
var mdl = model_reportcolumns.fields; // Handiger
|
||||
|
||||
%>
|
||||
|
||||
@@ -20,23 +20,16 @@ var JSON_Result = true;
|
||||
<!-- #include file="../api2/model_reportsx.inc" -->
|
||||
<%
|
||||
|
||||
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS", true);
|
||||
user.auth_required_or_abort(authparamsPRSSYS.PRSwritelevel < 9 && authparamsPRSSYS.ALGwritelevel < 9);
|
||||
var authparamsPRSSYS = user.checkAutorisation("WEB_PRSSYS");
|
||||
|
||||
var usrrap_key = getQParamInt("usrrap_key");
|
||||
var oldrap = usrrap.fac_usrrap_info(usrrap_key); // Niet via 'model', die kan geen VIEW-rapporten aan
|
||||
|
||||
var data = { "name" : "Clone: " + toDateTimeString(new Date) + " " + oldrap.omschrijving,
|
||||
"description" : oldrap.info,
|
||||
"viewname" : oldrap.view_name,
|
||||
"authorisation": oldrap.fac_functie_key,
|
||||
columns: []
|
||||
}
|
||||
var oldrap = new model_reportsx(usrrap_key, { include: ["columns"] });
|
||||
oldrap.data.name = "Clone: " + toDateTimeString(new Date, true) + " " + oldrap.data.name;
|
||||
|
||||
var reportsx = new model_reportsx(-1, { internal: true });
|
||||
reportsx._clone_report_cols(usrrap_key, data);
|
||||
var params = { internal: true }; // Zodat POST op kolommen wordt geaccepteerd
|
||||
var new_key = reportsx.REST_POST(params, { "report": data } );
|
||||
var newrap = new model_reportsx(-1, { internal: true }); // internal zodat POST op kolommen wordt geaccepteerd
|
||||
var params = { isNew: true };
|
||||
var new_key = newrap.REST_POST(params, oldrap.data );
|
||||
|
||||
Response.Redirect("../fac/fac_reportx.asp?mode=wrap&id=" + new_key.key);
|
||||
%>
|
||||
Reference in New Issue
Block a user