<% /*
    $Revision$
    $Id$

    File:           model_alg_kenmerk.inc

    Description:    Vanuit CodeCharge gegenereerd model voor alg_kenmerk

    Context:

    Notes:
*/
%>
<%

function model_alg_kenmerk(niveau)
{
    this.table = "alg_kenmerk";
    this.primary = "alg_kenmerk_key";
    this.records_name = "alg_kenmerks";
    this.record_name = "alg_kenmerk";
    this.soft_delete = "alg_kenmerk_verwijder";
    this.autfunction = "WEB_PRSSYS";
    this.record_title = L("mgt_kenmerk") + " " + get_onrgoed_naam(niveau);
    this.records_title = L("mgt_kenmerk_m") + " " + get_onrgoed_naam(niveau);;


    this.fields = {
        "id": {
            "dbs": "alg_kenmerk_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "alg_s_alg_kenmerk_key"
        },
        "alg_kenmerk_niveau": {
            "dbs": "alg_kenmerk_niveau",
            "label": L("mgt_kenmerk_niveau"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": fill_og_niveau_LOV(),
            "defaultvalue": "L"
        },
        "sequence": {
            "dbs": "alg_kenmerk_volgnr",
            "label": L("mgt_kenmerk_volgnummer"),
            "typ": "number",
            "required": true
        },
        "name": {
            "dbs": "alg_kenmerk_omschrijving",
            "label": L("mgt_kenmerk_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true,
            "filter": "like"
        },
        "hint": {
           "dbs": "alg_kenmerk_hint",
            "label": L("mgt_kenmerk_hint"),
            "typ": "memo",
            "translate": true
       },
       "unit": {
            "dbs": "alg_kenmerk_dimensie",
            "label": L("mgt_srtkenmerk_dimensie"),
            "typ": "varchar",
            "translate": true
        },
        "property_type": {
            "dbs": "alg_kenmerk_kenmerktype",
            "label": L("mgt_srtkenmerk_kenmerktype"),
            "typ": "varchar",
            "required": true,
            "insertonly": true,
            "LOV": buildKenmerktypeLOV()
        },
        "required": {
            "dbs": "alg_kenmerk_verplicht",
            "label": L("mgt_kenmerk_verplicht"),
            "typ": "key",
            "LOV": buildVerplichtingList(),
            "emptyoption": null
        },
        "property_group": {
            "dbs": "alg_kenmerk_groep",
            "label": L("mgt_kenmerk_groep"),
            "typ": "key",
            "required": true,
            "LOV": buildGroepsverplichtingList(),
            "emptyoption": null
        },
        "readonly": {
            "dbs": "alg_kenmerk_toonbaar",
            "label": L("mgt_kenmerk_toonbaar"),
            "typ": "check"
        },
        "system": {
            "dbs": "alg_kenmerk_systeem",
            "label": L("mgt_srtkenmerk_systeem"),
            "typ": "check"
        },
        "length": {
            "dbs": "alg_kenmerk_lengte",
            "label": L("mgt_srtkenmerk_lengte"),
            "typ": "number"
        },
        "decimals": {
            "dbs": "alg_kenmerk_dec",
            "label": L("mgt_srtkenmerk_dec"),
            "typ": "number"
        },
        "minimum": {
            "dbs": "alg_kenmerk_nmin",
            "label": L("mgt_srtkenmerk_nmin"),
            "typ": "number"
        },
        "maximum": {
            "dbs": "alg_kenmerk_nmax",
            "label": L("mgt_srtkenmerk_nmax"),
            "typ": "number"
        },
        "domain": {
            "dbs": "fac_kenmerkdomein_key",
            "label": L("mgt_kenmerkdomein_key"),
            "typ": "key",
            "foreign": fac_kenmerkdomein_foreign("ALG"),
            "filter": "exact",
            "LOVinit": ""
        },
        "default": {
            "dbs": "alg_kenmerk_default",
            "label": L("mgt_kenmerk_default"),
            "typ": "memo",
            "translate": true
        },
        "regexp": {
            "dbs": "alg_kenmerk_regexp",
            "label": L("mgt_kenmerk_regexp"),
            "typ": "varchar"
        }
    };


    var gparams = {"GET": {}};
    if (niveau)
    {
        gparams.GET = { wheres: [ "alg_kenmerk.alg_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_onrgoed_naam(niveau)
    {
        var naam = "";
        switch (niveau)
        {
            case "D": naam = L("lcl_district"); break;
            case "L": naam = L("lcl_location"); break;
            case "T": naam = L("lcl_terra"); break;
            case "G": naam = L("lcl_building"); break;
            case "V": naam = L("lcl_floor"); break;
            case "R": naam = L("lcl_room"); break;
        }
        return naam;
    }

}
%>