<% /*
    $Revision$
    $Id$

    File:           model_bez_kenmerk.inc

    Description:    Vanuit CodeCharge gegenereerd model voor bez_kenmerk

    Context:

    Notes:
*/
%>
<%

function model_bez_kenmerk(params)
{
    params = params || {};
    this.records_name = "visitorproperties";
    this.record_name = "visitorproperty";
    this.table = "bez_kenmerk";
    this.primary = "bez_kenmerk_key";
    this.soft_delete = "bez_kenmerk_verwijder";
    this.autfunction = params.internal?false:"WEB_BEZMGT";
    this.record_title = L("bez_kenmerk");
    this.records_title = L("bez_kenmerk_m");
    this.module = "BEZ";

    this.fields = {
        "id": {
            "dbs": "bez_kenmerk_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "bez_s_bez_kenmerk_key"
        },
        "sequence": {
            "dbs": "bez_kenmerk_volgnr",
            "label": L("mgt_kenmerk_volgnummer"),
            "typ": "number",
            "len": 3,
            "required": true
        },
        "name": {
            "dbs": "bez_kenmerk_omschrijving",
            "label": L("mgt_kenmerk_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true
        },
        "hint": {
            "dbs": "bez_kenmerk_hint",
            "label": L("mgt_kenmerk_hint"),
            "typ": "memo",
            "translate": true
        },
        "unit": {
            "dbs": "bez_kenmerk_dimensie",
            "label": L("mgt_srtkenmerk_dimensie"),
            "typ": "varchar",
            "translate": true
        },
        "attributetype": {
            "dbs": "bez_kenmerk_kenmerktype",
            "label": L("mgt_srtkenmerk_kenmerktype"),
            "typ": "varchar",
            "required": true,
            "LOV": buildKenmerktypeLOV(),
            "showtransit": true
        },
        "required": {
            "dbs": "bez_kenmerk_verplicht",
            "label": L("mgt_kenmerk_verplicht"),
            "typ": "key",
            "LOV": buildVerplichtingList(),
            "emptyisrealvalue": true,
            "emptyoption": null
        },
        "group": {
            "dbs": "bez_kenmerk_groep",
            "label": L("mgt_kenmerk_groep"),
            "typ": "key",
            "required": true,
            "LOV": buildGroepsverplichtingList(),
            "emptyoption": null
        },
        "rolecode": {
            "dbs": "bez_kenmerk_rolcode",
            "label": L("mgt_kenmerk_rolcode"),
            "typ": "number",
            "LOV": buildKenmerkRoleCodeLOV({ module: "BEZ" }),
            "required": true
        },
        "readonly": {
            "dbs": "bez_kenmerk_toonbaar",
            "label": L("mgt_kenmerk_toonbaar"),
            "typ": "check"
        },
        "system": {
            "dbs": "bez_kenmerk_systeem",
            "label": L("mgt_srtkenmerk_systeem_adv"),
            "typ": "number",
            "bits": [
                {
                    "name": "",
                    "label": "",
                    "showasgroup": false,
                    "typ": "check",
                    "mask": 15,
                    "radios": [
                        {
                            "name": "ksystem",
                            "label": L("mgt_kenmerk_systeem"),
                            "mask": 1,
                            "defaultvalue": 0
                        },
/*
                        {
                            "name": "conf",
                            "label": L("mgt_kenmerk_systeem_conf"),
                            "mask": 4,
                            "defaultvalue": 0
                        },
*/
                        {
                            "name": "ano",
                            "label": L("mgt_kenmerk_systeem_ano"),
                            "mask": 8,
                            "defaultvalue": 0
                        }
                    ]
                }
            ],
            "defaultvalue": 0,
            "required": true
        },
        "inlist": {
            "dbs": "bez_kenmerk_inlijst",
            "label": L("mgt_kenmerk_systeem_overview"),
            "typ": "check0",
            "multiedit": true
        },
       "length": {
            "dbs": "bez_kenmerk_lengte",
            "label": L("mgt_srtkenmerk_lengte"),
            "typ": "number"
        },
        "decimals": {
            "dbs": "bez_kenmerk_dec",
            "label": L("mgt_srtkenmerk_dec"),
            "typ": "number"
        },
        "minimum": {
            "dbs": "bez_kenmerk_nmin",
            "label": L("mgt_srtkenmerk_nmin"),
            "typ": "number"
        },
        "maximum": {
            "dbs": "bez_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("BEZ"),
            "LOVinit": ""
        },
        "propertydefault": {
            "dbs": "bez_kenmerk_default",
            "label": L("mgt_kenmerk_default"),
            "typ": "memo",
            "translate": true
        },
        "showexpression": {
            "dbs": "bez_kenmerk_show_expr",
            "label": L("mgt_kenmerk_show_expr"),
            "typ": "memo"
        },
        "regexp": {
           "dbs": "bez_kenmerk_regexp",
            "label": L("mgt_kenmerk_regexp"),
            "typ": "varchar"
        },
        "code": {
            "dbs": "bez_kenmerk_code",
            "label": L("mgt_kenmerk_code"),
            "typ": "varchar",
            "readonly": !user.has("WEB_PRSSYS")
        },
        "authorization": {
            "dbs": "fac_functie_key",
            "label": L("mgt_kenmerk_autorisatie"),
            "typ": "key",
            "foreign": "fac_functie"
        }
    };


    this.hook_pre_show = function (obj, fld)
    {
        fld.propertydefault.label = (obj.attributetype.id == "l" ? L("mgt_kenmerk_icon"): L("mgt_kenmerk_default"));
        fld.readonly.label        = (obj.attributetype.id == "l" ? L("mgt_kenmerk_collapsed"): L("mgt_kenmerk_toonbaar"));
    }

    this.hook_pre_edit = function (obj, fld)
    {
        var kenmerktype = (obj.property_type ? obj.attributetype.id : "");
        fld.attributetype.LOV = buildKenmerktypeLOV(kenmerktype);
        fld.propertydefault.label = ( (obj.id == -1 && obj.attributetype == "l") || (obj.attributetype && obj.attributetype.id == "l") ? L("mgt_kenmerk_icon"): L("mgt_kenmerk_default") );
        fld.readonly.label        = ( (obj.id == -1 && obj.attributetype == "l") || (obj.attributetype && obj.attributetype.id == "l") ? L("mgt_kenmerk_collapsed"): L("mgt_kenmerk_toonbaar"));
    %>
    <script type="text/javascript">
      var module = "BEZ";
      var property_type = "<%=safe.jsstring(kenmerktype)%>";
    </script>
    <%
    }


    this.REST_GET    = generic_REST_GET(this);
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this);
}
%>