FSN#31698 Rapportgenerator fixes: beter/ simpeler clonen
svn path=/Website/trunk/; revision=24673
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
Reference in New Issue
Block a user