<% /*
    $Revision$
    $Id$

    File:           model_cad_thema.inc

    Description:    Vanuit CodeCharge gegenereerd model voor cad_thema

    Context:

    Notes:      TODO: JGL: Ik ben er nog niet helemaal uit hoe de bitjes netjes op te lossen
*/
%>
<%

function model_cad_thema()
{
    this.table = "cad_thema";
    this.primary = "cad_thema_key";
    this.records_name = "cad_themas";
    this.record_name = "cad_thema";
    this.autfunction = "WEB_CADMGT";
    this.record_title = L("cad_thema");
    this.records_title = L("cad_thema_m");


    this.fields = {
        "id": {
            "dbs": "cad_thema_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "cad_s_cad_thema_key"
        },
        "name": {
            "dbs": "cad_thema_omschrijving",
            "label": L("cad_thema_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "filter": "like"
        },
        "view_name": {
            "dbs": "cad_thema_view",
            "label": L("cad_label_view"),
            "typ": "varchar",
            "filter": "like"
        },
        "legendas": {
            "dbs": "cad_legenda_key",
            "label": L("cad_legenda"),
            "typ": "key",
            "foreign": {
                "tbl": "cad_legenda",
                "key": "cad_legenda_key",
                "desc": "cad_legenda_omschrijving"
            },
            "defaultvalue": null,
            "filter": "exact",
            "emptyoption": null
        },
        "authorization": {
            "dbs": "fac_functie_key",
            "label": L("fac_functie_key"),
            "typ": "key",
            "foreign": "fac_functie",
            "LOVinit": ""
        },
        "type_place": {
            "dbs": "plaats.waar",
            "label": L("cad_label_type_waar"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": type_place_LOV(),
            "filter": "exact"
        },
        "type_situation": {
            "dbs": "plaats.situatie",
            "label": L("cad_label_type_situatie"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": type_situation_LOV(),
            "filter": "exact"
        },
        "thema_type": {
            "dbs": "cad_thema_type",
            "label": L("cad_label_type"),
            "typ": "number",
            "defaultvalue": 1,
            "bits": [
                {
                    "name": "waar",
                    "label": L("cad_label_type_waar"),
                    "typ": "radio",
                    "mask": 27,
                    "radios": [
                        {
                            "mask": 1,
                            "label": L("cad_label_type_bi_rui")
                        },
                        {
                            "mask": 9,
                            "label": L("cad_label_type_bi_wp")
                        },
                        {
                            "mask": 17,
                            "label": L("cad_label_type_bi_obj")
                        },
                        {
                            "mask": 2,
                            "label": L("cad_label_type_bu_ts")
                        },
                        {
                            "mask": 18,
                            "label": L("cad_label_type_bu_obj")
                        }
                    ]
                },
                {
                    "name": "situatie",
                    "label": L("cad_label_type_situatie"),
                    "typ": "radio",
                    "mask": 4,
                    "radios": [
                        {
                            "mask": 0,
                            "label": L("cad_label_type_si_act")
                        },
                        {
                            "mask": 4,
                            "label": L("cad_label_type_si_sce")
                        }
                    ]
                },
                {
                    "name": "",
                    "label": "",
                    "typ": "check",
                    "mask": 128,
                    "radios": [
                        {
                            "name": "sleepbaar",
                            "label": L("cad_thema_sleepbaar"),
                            "mask": 128,
                            "readonly": true
                        }
                    ]
                }
            ]
        },
        "thema_url": {
            "dbs": "cad_thema_onclick_url",
            "label": L("cad_thema_onclick_url"),
            "typ": "varchar"
        },
        "_generate": {
            "dbs": "dual.dummy",
            "label": L("cad_thema_genereren"),
            "typ": "check",
            "hidden": true
        },
        "_update": {
            "dbs": "dual.dummy",
            "label": L("cad_thema_bijwerken"),
            "typ": "check",
            "hidden": true
        }
    };


    var ext_sql = "(SELECT BITAND(cad_thema_type, 27) waar"
                + "      , BITAND(cad_thema_type,  4) situatie"
                + "      , cad_thema_key"
                + "   FROM cad_thema) plaats ";
    this.REST_GET    = generic_REST_GET(this, {
        "GET": {
            "tables": [ext_sql],
            "wheres": ["cad_thema.cad_thema_key = plaats.cad_thema_key"]
        }
    });
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this);


    function type_place_LOV()
    {
        return "1;"  + L("cad_label_type_bi_rui")
            + ";9;"  + L("cad_label_type_bi_wp")
            + ";17;" + L("cad_label_type_bi_obj")
            + ";2;"  + L("cad_label_type_bu_ts")
            + ";18;" + L("cad_label_type_bu_obj");
    }
    function type_situation_LOV()
    {
        return "0;" + L("cad_label_type_si_act")
            + ";4;" + L("cad_label_type_si_sce");
    }
}
%>