<% /*
    $Revision$
    $Id$

    File:           model_cad_label.inc

    Description:    Vanuit CodeCharge gegenereerd model voor cad_label

    Context:

    Notes:
*/
%>
<%

function model_cad_label()
{
    this.table = "cad_label";
    this.primary = "cad_label_key";
    this.records_name = "cad_labels";
    this.record_name = "cad_label";
    this.autfunction = "WEB_CADMGT";
    this.record_title = L("cad_label");
    this.records_title = L("cad_label_m");


    this.fields = {
        "id": {
            "dbs": "cad_label_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "cad_s_cad_label_key"
        },
        "name": {
            "dbs": "cad_label_omschrijving",
            "label": L("cad_label_omschrijving"),
            "typ": "varchar",
            "translate": true
        },
        "view_name": {
            "dbs": "cad_label_view",
            "label": L("cad_label_view"),
            "typ": "varchar",
            "filter": "like"
        },
        "size": {
            "dbs": "cad_label_size",
            "label": L("cad_label_size"),
            "typ": "number",
            "defaultvalue": "800"
        },
        "visible": {
            "dbs": "cad_label_visible",
            "label": L("cad_label_visible"),
            "typ": "check0",
            "defaultvalue": 1
        },
        "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"
        },
        "label_type": {
            "dbs": "cad_label_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")
                        }
                    ]
                }
            ]
        }
    };


    var ext_sql = "(SELECT BITAND(cad_label_type, 27) waar"
                + "      , BITAND(cad_label_type,  4) situatie"
                + "      , cad_label_key"
                + "   FROM cad_label) plaats ";


    this.REST_GET    = generic_REST_GET(this, {
        "GET": {
            "tables": [ext_sql],
            "wheres": ["cad_label.cad_label_key = plaats.cad_label_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");
    }
}
%>