<% /*
    $Revision$
    $Id$

    File:           model_bes_srtkenmerk.inc

    Description:    Vanuit CodeCharge gegenereerd model voor bes_srtkenmerk

    Context:

    Notes:
*/
%>
<%

function model_bes_srtkenmerk(params)
{
    params = params || {};
    this.records_name = "orderpropertytypes";
    this.record_name = "orderpropertytype";
    this.table = "bes_srtkenmerk";
    this.primary = "bes_srtkenmerk_key";
    this.soft_delete = "bes_srtkenmerk_verwijder";
    this.autfunction = params.internal?false:"WEB_BESMGT";
    this.record_title = L("bes_srtkenmerk");
    this.records_title = L("bes_srtkenmerk_m");


    this.fields = {
        "id": {
            "dbs": "bes_srtkenmerk_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "bes_s_bes_srtkenmerk_key"
        },
        "name": {
            "dbs": "bes_srtkenmerk_omschrijving",
            "label": L("mgt_srtkenmerk_omschrijving"),
            "typ": "varchar",
            "required": true,
            "translate": true,
            "filter": "like"
        },
        "attributetype": {
            "dbs": "bes_srtkenmerk_kenmerktype",
            "label": L("mgt_srtkenmerk_kenmerktype"),
            "typ": "varchar",
            "required": true,
            "LOV": buildKenmerktypeLOV(),
            "showtransit": true,
            "multiedit": true
        },
        "unit": {
            "dbs": "bes_srtkenmerk_dimensie",
            "label": L("mgt_srtkenmerk_dimensie"),
            "typ": "varchar",
            "translate": true
        },
        "system": {
            "dbs": "bes_srtkenmerk_systeem",
            "label": L("mgt_srtkenmerk_systeem_adv"),
            "typ": "number",
            "bits": [
                {
                    "name": "",
                    "label": "",
                    "typ": "check",
                    "mask": 31,
                    "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
                        },
                        {
                            "name": "overview_req",
                            "label": L("mgt_kenmerk_systeem_overview_req"),
                            "mask": 2,
                            "defaultvalue": 0
                        },
                        {
                            "name": "overview_pur",
                            "label": L("mgt_kenmerk_systeem_overview_pur"),
                            "mask": 16,
                            "defaultvalue": 0
                        }
                    ]
                }
            ],
            "defaultvalue": 0,
            "required": true
        },
        "length": {
            "dbs": "bes_srtkenmerk_lengte",
            "label": L("mgt_srtkenmerk_lengte"),
            "typ": "number"
        },
        "decimals": {
            "dbs": "bes_srtkenmerk_dec",
            "label": L("mgt_srtkenmerk_dec"),
            "typ": "number"
        },
        "minimum": {
            "dbs": "bes_srtkenmerk_nmin",
            "label": L("mgt_srtkenmerk_nmin"),
            "typ": "number"
        },
        "maximum": {
            "dbs": "bes_srtkenmerk_nmax",
            "label": L("mgt_srtkenmerk_nmax"),
            "typ": "number"
        },
        "domain": {
            "dbs": "fac_kenmerkdomein_key",
            "label": L("mgt_kenmerkdomein_key"),
            "typ": "key",
            "foreign": fac_kenmerkdomein_foreign("BES"),
            "LOVinit": ""
        },
        "code": {
            "dbs": "bes_srtkenmerk_code",
            "typ": "varchar",
            "label": L("mgt_srtkenmerk_code"),
            "readonly": !user.has("WEB_PRSSYS")
        }
    };


    this.hook_pre_edit = function (obj, fld)
    {
        var kenmerktype = (obj.attributetype ? obj.attributetype.id : "");
        fld.attributetype.LOV = buildKenmerktypeLOV(kenmerktype);
    %>
    <script type="text/javascript">
      var module = "BES";
      var property_type = "<%=safe.jsstring(kenmerktype)%>";
    </script>
    <%
    }

    this.hook_pre_multi_edit = function (obj, fld, params)
    {
        var id_arr = getQParamIntArray("sel_id", []);
        var multiCount = modelHasMultiedit(fld);
        if (multiCount == 0)
            abort_with_warning(L("mgt_srtkenmerk_nomulti"));
    }


    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);
}
%>