<% /*
    $Revision$
    $Id$

    File:           model_fac_setting.inc

    Description:    model voor fac_setting

    Context:

    Notes:
*/
%>
<%
function model_fac_setting()
{
    this.table = "fac_setting";
    this.primary = "fac_setting_key";
    this.records_name = "fac_settings";
    this.record_name = "fac_setting";
    this.autfunction = "WEB_PROFIL"; //Om zelf al je geregistreerde gegevens te kunnen inzien
    this.record_title = L("lcl_fac_setting");
    this.records_title = L("lcl_fac_setting_m");


    this.fields = {
        "id": {
            "dbs": "fac_setting_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "seq": "fac_s_fac_setting"
        },
        "module": {
            "dbs": "fac_setting_module",
            "label": L("lcl_fac_module"),
            "typ": "varchar",
            "required": true
        },
        "name": {
            "dbs": "fac_setting_name",
            "label": L("lcl_fac_name"),
            "typ": "varchar",
            "required": true
        },
        "description": {
            "dbs": "fac_setting_description",
            "label": L("lcl_fac_descr"),
            "typ": "varchar",
            "required": true
        },
        "comment": {
            "dbs": "fac_setting_comment",
            "label": L("lcl_fac_comment"),
            "typ": "varchar"
        },
        "flags": {
            "dbs": "fac_setting_flags",
            "label": L("lcl_fac_flags"),
            "typ": "number"
        },
        "type": {
            "dbs": "fac_setting_type",
            "label": L("lcl_fac_settingtype"),
            "typ": "varchar",
            "required": true
        },
        "default": {
            "dbs": "fac_setting_default",
            "label": L("lcl_fac_default"),
            "typ": "varchar"
        },
        "overrule": {
            "dbs": "fac_setting_pvalue",
            "label": L("lcl_fac_overrule"),
            "typ": "varchar"
        },
        "value": {
            "dbs": "value",
            "sql": "COALESCE(fac_setting_pvalue, fac_setting_default)",
            "label": L("lcl_fac_value"),
            "typ": "varchar"
        },
        "date": {
            "dbs": "fac_setting_datum",
            "label": L("lcl_fac_time"),
            "typ": "datetime"
        },
        "changed_by": {
            "dbs": "prs_perslid_key",
            "label": L("prs_perslid"),
            "typ": "key",
            "foreign": "prs_perslid"
        },
        "authorization": {
            "dbs": "fac_functie_key",
            "label": L("fac_functie_key"),
            "typ": "key",
            "foreign": "fac_functie"
        }
    };

    this.list = {
        "columns": [
            "id",
            "name",
            "value"
        ]
    };
    this.search = {
        "autosearch": true
    };


    this.REST_GET    = generic_REST_GET(this,
                                           { "GET": {
                                                     wheres: [ "BITAND(fac_setting_flags,1)=1"
                                                             ]
                                                    }
                                            }
                                      )

    //this.REST_POST   = generic_REST_POST(this);
    //this.REST_PUT    = generic_REST_PUT(this);
    //this.REST_DELETE = generic_REST_DELETE(this, {});
}
%>