<% /*
    $Revision$
    $Id$

    File:           model_faq_kenmerk.inc

    Description:    Vanuit CodeCharge gegenereerd model voor faq_kenmerk

    Context:

    Notes:
*/
%>
<%

function model_faq_kenmerk(params)
{
    params = params || {};
    this.records_name = "knowledgeproperties";
    this.record_name = "knowledgeproperty";
    this.table = "faq_kenmerk";
    this.primary = "faq_kenmerk_key";
    this.soft_delete = "faq_kenmerk_verwijder";
    this.autfunction = params.internal?false:"WEB_FAQMGT";
    this.record_title = L("faq_kenmerk");
    this.records_title = L("faq_kenmerk_m");
    this.module = "FAQ";

    this.fields = {
        "id": {
            "dbs": "faq_kenmerk_key",
            "label": L("lcl_key"),
            "typ": "key",
            "seq": "faq_s_faq_kenmerk_key"
        },
        "facdiscipline": { // NULL betekent alle disciplines (denk ik)
            "dbs": "faq_discipline_key",
            "label": L("faq_discipline_key"),
            "typ": "key",
            "insertonly": true,
            "foreign": {
                "tbl": "faq_v_aanwezigdiscipline",
                "key": "ins_discipline_key",
                "desc": "ins_discipline_omschrijving"
            },
            "showtransit": true
        },
        "sequence": {
            "dbs": "faq_kenmerk_volgnr",
            "label": L("mgt_kenmerk_volgnummer"),
            "typ": "number",
            "len": 3,
            "required": true
        },
        "name": {
            "dbs": "faq_kenmerk_omschrijving",
            "label": L("mgt_kenmerk_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true
        },
        "hint": {
            "dbs": "faq_kenmerk_hint",
            "label": L("mgt_kenmerk_hint"),
            "typ": "memo",
            "translate": true
        },
        "unit": {
            "dbs": "faq_kenmerk_dimensie",
            "label": L("mgt_srtkenmerk_dimensie"),
            "typ": "varchar",
            "translate": true
        },
        "attributetype": {
            "dbs": "faq_kenmerk_kenmerktype",
            "label": L("mgt_srtkenmerk_kenmerktype"),
            "typ": "varchar",
            "required": true,
            "LOV": buildKenmerktypeLOV(),
            "showtransit": true
        },
        "required": {
            "dbs": "faq_kenmerk_verplicht",
            "label": L("mgt_kenmerk_verplicht"),
            "typ": "key",
            "LOV": buildVerplichtingList(),
            "emptyisrealvalue": true,
            "emptyoption": null
        },
        "group": {
            "dbs": "faq_kenmerk_groep",
            "label": L("mgt_kenmerk_groep"),
            "typ": "key",
            "required": true,
            "LOV": buildGroepsverplichtingList(),
            "emptyoption": null
        },
        "rolecode": {
            "dbs": "faq_kenmerk_rolcode",
            "label": L("mgt_kenmerk_rolcode"),
            "typ": "number",
            "LOV": buildKenmerkRoleCodeLOV({ module: "FAQ" }),
            "required": true
        },
        "readonly": {
            "dbs": "faq_kenmerk_toonbaar",
            "label": L("mgt_kenmerk_toonbaar"),
            "typ": "check"
        },
        "system": {
            "dbs": "faq_kenmerk_systeem",
            "label": L("mgt_srtkenmerk_systeem"),
            "typ": "check"
        },
        "inlist": {
            "dbs": "faq_kenmerk_inlijst",
            "label": L("mgt_kenmerk_systeem_overview"),
            "typ": "check0",
            "multiedit": true
        },
        "length": {
            "dbs": "faq_kenmerk_lengte",
            "label": L("mgt_srtkenmerk_lengte"),
            "typ": "number"
        },
        "decimals": {
            "dbs": "faq_kenmerk_dec",
            "label": L("mgt_srtkenmerk_dec"),
            "typ": "number"
        },
        "minimum": {
            "dbs": "faq_kenmerk_nmin",
            "label": L("mgt_srtkenmerk_nmin"),
            "typ": "number"
        },
        "maximum": {
            "dbs": "faq_kenmerk_nmax",
            "label": L("mgt_srtkenmerk_nmax"),
            "typ": "number"
        },
        "domain": {
            "dbs": "fac_kenmerkdomein_key",
            "label": L("fac_kenmerkdomein_key"),
            "typ": "key",
            "foreign": fac_kenmerkdomein_foreign("FAQ"),
            "LOVinit": ""
        },
        "propertydefault": {
            "dbs": "faq_kenmerk_default",
            "label": L("mgt_kenmerk_default"),
            "typ": "memo",
            "translate": true
        },
        "showexpression": {
            "dbs": "faq_kenmerk_show_expr",
            "label": L("mgt_kenmerk_show_expr"),
            "typ": "memo"
        },
        "regexp": {
            "dbs": "faq_kenmerk_regexp",
            "label": L("mgt_kenmerk_regexp"),
            "typ": "varchar"
        },
        "code": {
            "dbs": "faq_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.attributetype ? 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 = "FAQ";
      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);
}
%>