<% /*
    $Revision$
    $Id$

    File:           model_prs_kenmerk.inc

    Description:    Vanuit CodeCharge gegenereerd model voor prs_kenmerk

    Context:

    Notes:
*/
%>
<%

function model_prs_kenmerk(niveau)
{
    this.table = "prs_kenmerk";
    this.primary = "prs_kenmerk_key";
    this.records_name = "prs_kenmerks";
    this.record_name = "prs_kenmerk";
    this.soft_delete = "prs_kenmerk_verwijder";
    this.autfunction = "WEB_PRSSYS";
    this.record_title = L("mgt_kenmerk") + " " + get_prs_naam(niveau);
    this.records_title = L("mgt_kenmerk_m") + " " + get_prs_naam(niveau);


    this.fields = {
        "id": {
            "dbs": "prs_kenmerk_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "prs_s_prs_kenmerk_key"
        },
        "prs_kenmerk_niveau": {
            "dbs": "prs_kenmerk_niveau",
            "label": L("mgt_kenmerk_niveau"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": fill_prs_niveau_LOV(),
            "defaultvalue": "P"
        },
        "sequence": {
            "dbs": "prs_kenmerk_volgnr",
            "label": L("mgt_kenmerk_volgnummer"),
            "typ": "number",
            "required": true
        },
        "name": {
            "dbs": "prs_kenmerk_omschrijving",
            "label": L("mgt_kenmerk_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true
        },
        "hint": {
            "dbs": "prs_kenmerk_hint",
            "label": L("mgt_kenmerk_hint"),
            "typ": "memo",
            "translate": true
        },
        "unit": {
            "dbs": "prs_kenmerk_dimensie",
            "label": L("mgt_srtkenmerk_dimensie"),
            "typ": "varchar",
            "translate": true
        },
        "property_type": {
            "dbs": "prs_kenmerk_kenmerktype",
            "label": L("mgt_srtkenmerk_kenmerktype"),
            "typ": "varchar",
            "required": true,
            "LOV": buildKenmerktypeLOV()
        },
        "required": {
            "dbs": "prs_kenmerk_verplicht",
            "label": L("mgt_kenmerk_verplicht"),
            "typ": "key",
            "LOV": buildVerplichtingList(),
            "emptyoption": null
        },
        "property_group": {
            "dbs": "prs_kenmerk_groep",
            "label": L("mgt_kenmerk_groep"),
            "typ": "key",
            "required": true,
            "LOV": buildGroepsverplichtingList(),
            "emptyoption": null
        },
        "readonly": {
            "dbs": "prs_kenmerk_toonbaar",
            "label": L("mgt_kenmerk_toonbaar"),
            "typ": "check"
        },
        "system": {
            "dbs": "prs_kenmerk_systeem",
            "label": L("mgt_srtkenmerk_systeem"),
            "typ": "check"
        },
        "length": {
            "dbs": "prs_kenmerk_lengte",
            "label": L("mgt_srtkenmerk_lengte"),
            "typ": "number"
        },
        "decimals": {
            "dbs": "prs_kenmerk_dec",
            "label": L("mgt_srtkenmerk_dec"),
           "typ": "number"
        },
        "minimum": {
            "dbs": "prs_kenmerk_nmin",
            "label": L("mgt_srtkenmerk_nmin"),
            "typ": "number"
        },
        "maximum": {
            "dbs": "prs_kenmerk_nmax",
            "label": L("mgt_srtkenmerk_nmax"),
            "typ": "number"
        },
        "position": {
            "dbs": "prs_srtperslid_key",
            "label": L("prs_srtperslid_key"),
            "typ": "key",
            "foreign": {
                "tbl": "prs_srtperslid",
                "key": "prs_srtperslid_key",
                "desc": "prs_srtperslid_omschrijving"
            },
            "filter": "exact"        },
        "domain": {
            "dbs": "fac_kenmerkdomein_key",
            "label": L("mgt_kenmerkdomein_key"),
            "typ": "key",
            "foreign": fac_kenmerkdomein_foreign("PRS"),
            "filter": "exact",
            "LOVinit": ""
        },
        "default": {
            "dbs": "prs_kenmerk_default",
            "label": L("mgt_kenmerk_default"),
            "typ": "memo",
            "translate": true
        },
        "regexp": {
            "dbs": "prs_kenmerk_regexp",
            "label": L("mgt_kenmerk_regexp"),
            "typ": "varchar"
        }
    };


    var gparams = {"GET": {}};
    if (niveau)
    {
        gparams.GET = { wheres: [ "prs_kenmerk.prs_kenmerk_niveau = " + safe.quoted_sql(niveau) ] };
    }


    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, {});


    function get_prs_naam(niveau)
    {
        var naam = "";
        switch (niveau)
        {
            case "B": naam = L("lcl_company");    break;
            case "A": naam = L("lcl_department"); break;
            case "P": naam = L("lcl_person");     break;
            case "C": naam = L("lcl_contact");    break;
        }
        return naam;
    }
}
%>