<% /*
    $Revision$
    $Id$

    File:           model_fac_audit.inc
    Description:
    Notes:
*/

function model_fac_audit()
{
    this.records_name = "audits";
    this.record_name = "audit";
    this.table = "fac_audit";
    this.primary = "fac_audit_key";
    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": L("lcl_key"),
            "typ": "key",
            "seq": "fac_s_fac_audit_key"
        },
        "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": "key",
            "readonly": true
        },
        "column": {
            "dbs": "fac_audit_veldnaam",
            "label": L("fac_audit_veldnaam"),
            "sql": this.autolcl("fac_audit_veldnaam"),
            "typ": "varchar",
            "readonly": true
        },
        "type": {
            "dbs": "fac_audit_actie",
            "label": L("fac_audit_actie"),
            "typ": "varchar",
            "readonly": true,
            "LOV": L("fac_audit_actieLOV")
        },
        "old": {
            "dbs": "fac_audit_waarde_oud",
            "label": L("fac_audit_waarde_oud"),
            "typ": "varchar",
            "readonly": true
        },
        "new": {
            "dbs": "fac_audit_waarde_nieuw",
            "label": L("fac_audit_waarde_nieuw"),
            "typ": "varchar",
            "readonly": true
        },
        "person": {
            "dbs": "prs_perslid_key",
            "label": L("lcl_lcl_naam"),
            "typ": "key",
            "foreign": "prs_perslid",
            "readonly": true
        },
        "description": {
            "dbs": "fac_audit_opmerking",
            "typ": "memo",
            "label": L("fac_audit_opmerking")
        },

        "date": {
            "dbs": "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
        };

    var gparams = { "GET": { "orderbys": ["fac_audit_key DESC" ] }}; // eigenlijk altijd nieuwste bovenaan
    this.REST_GET    = generic_REST_GET(this, gparams);
    //this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    //this.REST_DELETE = generic_REST_DELETE(this);
}
%>