AAIT#33956: Tracking / auditing savepoint. Nog wel wat beter code afsplitsen zodat History-knop breder toepasbaar
svn path=/Website/trunk/; revision=32579
This commit is contained in:
@@ -7,38 +7,51 @@
|
||||
Notes:
|
||||
*/
|
||||
|
||||
function fac_audit()
|
||||
function model_fac_audit()
|
||||
{
|
||||
this.table = "fac_audit";
|
||||
this.primary = "fac_audit_key";
|
||||
this.records_name = "audits";
|
||||
this.record_name = "audit";
|
||||
this.autfunction = "WEB_FACTAB";
|
||||
this.autfunction = "WEB_PRSSYS";
|
||||
this.record_title = L("fac_audit");
|
||||
this.records_title = L("fac_audit_m");
|
||||
|
||||
this.autolcl = function (lcl) // TODO: Kan dit niet gewoon als foreign of is de COALESCE dan een probleem?
|
||||
{
|
||||
return "COALESCE ((SELECT COALESCE(fac_locale_xsl_cust, fac_locale_xsl_tekst) fac_locale_xsl_tekst"
|
||||
+ " FROM fac_locale_xsl xsl"
|
||||
+ " WHERE fac_locale_xsl_lang = " + safe.quoted_sql(user_lang)
|
||||
+ " AND fac_locale_xsl_module = 'ASP'"
|
||||
+ " AND fac_locale_xsl_label = REPLACE(" + lcl + ", 'disc_params', 'discipline'))," // TODO: deze replace pakt voor cnt goed uit. Ook voor de rest?
|
||||
+ " '<'||" + lcl + "||'>')";
|
||||
};
|
||||
|
||||
this.fields = {
|
||||
"id": {
|
||||
"dbs": "fac_audit_key",
|
||||
"label": "Key",
|
||||
"typ": "key",
|
||||
"seq": "fac_s_fac_audit_key"
|
||||
"seq": "fac_s_fac_audit_key",
|
||||
"orderby": " DESC" // eigenlijk altijd nieuwste bovenaan
|
||||
},
|
||||
"table": {
|
||||
"dbs": "fac_audit_tabelnaam",
|
||||
"label": L("fac_audit_tabelnaam"),
|
||||
// filtert niet lekker meer "sql": this.autolcl("fac_audit_tabelnaam"),
|
||||
"typ": "varchar",
|
||||
"readonly": true
|
||||
},
|
||||
"record": {
|
||||
"dbs": "fac_audit_tabelkey",
|
||||
"label": L("fac_audit_tabelkey"),
|
||||
"typ": "varchar",
|
||||
"typ": "key",
|
||||
"readonly": true
|
||||
},
|
||||
"column": {
|
||||
"dbs": "fac_audit_veldnaam",
|
||||
"label": L("fac_audit_veldnaam"),
|
||||
"sql": this.autolcl("fac_audit_veldnaam"),
|
||||
"typ": "varchar",
|
||||
"readonly": true
|
||||
},
|
||||
@@ -47,8 +60,7 @@ function fac_audit()
|
||||
"label": L("fac_audit_actie"),
|
||||
"typ": "varchar",
|
||||
"readonly": true,
|
||||
"LOV": "U;Update;D;Delete"
|
||||
//"LOV": L("fac_audit_typeLOV")
|
||||
"LOV": L("fac_audit_actieLOV")
|
||||
},
|
||||
"old": {
|
||||
"dbs": "fac_audit_waarde_oud",
|
||||
@@ -64,7 +76,7 @@ function fac_audit()
|
||||
},
|
||||
"person": {
|
||||
"dbs": "prs_perslid_key",
|
||||
"label": L("prs_perslid_key"),
|
||||
"label": L("lcl_lcl_naam"),
|
||||
"typ": "key",
|
||||
"foreign": "prs_perslid",
|
||||
"readonly": true
|
||||
@@ -77,12 +89,29 @@ function fac_audit()
|
||||
|
||||
"date": {
|
||||
"dbs": "fac_audit_datum",
|
||||
"label": L("fac_audit_datum"),
|
||||
"label": L("lcl_date"),
|
||||
"typ": "datetime",
|
||||
"readonly": true
|
||||
}
|
||||
}
|
||||
|
||||
// Voor de include (ongebruikt)
|
||||
this.list = {
|
||||
"columns": [
|
||||
"id",
|
||||
"date",
|
||||
"type",
|
||||
"column",
|
||||
"old",
|
||||
"new",
|
||||
"person",
|
||||
"description"
|
||||
]
|
||||
};
|
||||
this.edit = {
|
||||
"modal": true
|
||||
};
|
||||
|
||||
this.REST_GET = generic_REST_GET(this);
|
||||
//this.REST_POST = generic_REST_POST(this);
|
||||
this.REST_PUT = generic_REST_PUT(this);
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
if (getQParam("hmac", ""))
|
||||
protectQS.verify({ allowparams: ["outputmode", "showall", "autosortby", "no_autoscroll", "scf_highlight"]}); // tamper check
|
||||
else
|
||||
user.checkAutorisation("WEB_FACTAB");
|
||||
user.checkAutorisation("WEB_PRSSYS");
|
||||
|
||||
var this_model = new fac_audit();
|
||||
var this_model = new model_fac_audit();
|
||||
|
||||
scaffolding(this_model,
|
||||
scf_params =
|
||||
{
|
||||
"search": {
|
||||
"autosearch": true,
|
||||
@@ -37,17 +37,74 @@ scaffolding(this_model,
|
||||
"list": {
|
||||
"columns": [
|
||||
"id",
|
||||
"date",
|
||||
"type",
|
||||
"column",
|
||||
"old",
|
||||
"new",
|
||||
"date",
|
||||
"person",
|
||||
"description"
|
||||
]
|
||||
},
|
||||
"edit": {
|
||||
"modal": true
|
||||
"modal": false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var table = getQParam("table", "")
|
||||
if (!table) // gebeurt alleen bij intern gebruik/any audit
|
||||
scf_params.list.columns.splice(3, 0, "table");
|
||||
else
|
||||
{
|
||||
this_model.tablesql = "(SELECT *"
|
||||
+ " FROM fac_audit "
|
||||
+ " WHERE fac_audit_tabelnaam = " + safe.quoted_sql(table) +") fac_audit";
|
||||
if (table == "ins_tab_discipline") // dan disc_params er bij halen
|
||||
{
|
||||
var sql = "SELECT ins_discipline_module"
|
||||
+ " FROM ins_tab_discipline"
|
||||
+ " WHERE ins_discipline_key = " + getQParamInt("record")
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var module = oRs("ins_discipline_module").Value.toLowerCase();
|
||||
oRs.Close;
|
||||
if (module != "mrk")
|
||||
{
|
||||
var sql = "SELECT {0}_disc_params_key disc_params_key".format(module)
|
||||
+ " FROM {0}_disc_params".format(module)
|
||||
+ " WHERE {0}_ins_discipline_key = {1}".format(module, getQParamInt("record"));
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var dp_key = oRs("disc_params_key").Value;
|
||||
oRs.Close;
|
||||
this_model.tablesql = "(SELECT fac_audit_key, "
|
||||
+ " fac_audit_tabelnaam, "
|
||||
+ " fac_audit_tabelkey, "
|
||||
+ " fac_audit_veldnaam, "
|
||||
+ " fac_audit_actie,"
|
||||
+ " fac_audit_waarde_oud,"
|
||||
+ " fac_audit_waarde_nieuw,"
|
||||
+ " fac_audit_datum,"
|
||||
+ " prs_perslid_key,"
|
||||
+ " fac_audit_opmerking"
|
||||
+ " FROM fac_audit"
|
||||
+ " WHERE fac_audit_tabelnaam = " + safe.quoted_sql(table)
|
||||
+ " UNION "
|
||||
+ " SELECT fac_audit_key, "
|
||||
+ " 'ins_tab_discipline' fac_audit_tabelnaam, "
|
||||
+ " {0} fac_audit_tabelkey, ".format(getQParamInt("record"))
|
||||
+ " fac_audit_veldnaam, "
|
||||
+ " fac_audit_actie,"
|
||||
+ " fac_audit_waarde_oud,"
|
||||
+ " fac_audit_waarde_nieuw,"
|
||||
+ " fac_audit_datum,"
|
||||
+ " prs_perslid_key,"
|
||||
+ " fac_audit_opmerking"
|
||||
+ " FROM fac_audit"
|
||||
+ " WHERE fac_audit_tabelnaam = " + safe.quoted_sql("{0}_disc_params".format(module))
|
||||
+ " AND fac_audit_tabelkey" + " = " + dp_key
|
||||
+" ) fac_audit";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scaffolding(this_model, scf_params);
|
||||
%>
|
||||
|
||||
@@ -259,7 +259,7 @@ function scaffolding_edit(model, scf_params)
|
||||
</div>
|
||||
<%
|
||||
var buttons = [ ];
|
||||
if (key > 0)
|
||||
if (key > 0 && modal)
|
||||
{
|
||||
var sql = "SELECT COUNT(*)"
|
||||
+ " FROM fac_audit"
|
||||
|
||||
@@ -76,6 +76,14 @@ function scaffolding_show(model, scf_params)
|
||||
"json");
|
||||
});
|
||||
}
|
||||
function scf_history()
|
||||
{
|
||||
<%
|
||||
var url = "appl/mgt/fac_audit.asp?mode=list&table={0}&record={1}".format(model.table, key)
|
||||
var proturl = protectQS.create(url);
|
||||
%>
|
||||
FcltMgr.openDetail("<%= proturl %>");
|
||||
}
|
||||
|
||||
function scf_print()
|
||||
{
|
||||
@@ -85,6 +93,41 @@ function scaffolding_show(model, scf_params)
|
||||
</head>
|
||||
<body id="showbody">
|
||||
<% var buttons = [];
|
||||
if (key > 0)
|
||||
{
|
||||
var wheres = ["fac_audit_tabelnaam = " + safe.quoted_sql(model.table)
|
||||
+ " AND fac_audit_tabelkey = " + key];
|
||||
if (model.table == "ins_tab_discipline") // disc_params ook meetellen
|
||||
{
|
||||
var sql = "SELECT ins_discipline_module"
|
||||
+ " FROM ins_tab_discipline"
|
||||
+ " WHERE ins_discipline_key = " + key;
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var module = oRs("ins_discipline_module").Value.toLowerCase();
|
||||
oRs.Close;
|
||||
if (module != "mrk")
|
||||
{
|
||||
var sql = "SELECT {0}_disc_params_key disc_params_key".format(module)
|
||||
+ " FROM {0}_disc_params".format(module)
|
||||
+ " WHERE {0}_ins_discipline_key = {1}".format(module, key);
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var dp_key = oRs("disc_params_key").Value;
|
||||
oRs.Close;
|
||||
|
||||
wheres.push("fac_audit_tabelnaam = " + safe.quoted_sql("{0}_disc_params".format(module))
|
||||
+ " AND fac_audit_tabelkey" + " = " + dp_key);
|
||||
}
|
||||
}
|
||||
var sql = "SELECT COUNT(*)"
|
||||
+ " FROM fac_audit"
|
||||
+ " WHERE " + wheres.join(" OR ");
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var cnt = oRs(0).Value;
|
||||
oRs.Close();
|
||||
if (cnt > 0)
|
||||
buttons.push({title: L("lcl_history") + " ({0})".format(cnt), action:"scf_history()", icon: "fa-history", id: "btn_scf_history" });
|
||||
}
|
||||
|
||||
if (scf_params.show.buttons)
|
||||
{
|
||||
for (var i = 0; i < scf_params.show.buttons.length; i++)
|
||||
|
||||
Reference in New Issue
Block a user