<% /*
    $Revision$
    $Id$

    File:           model_res_activiteit.inc

    Description:    Vanuit CodeCharge gegenereerd model voor res_activiteit

    Context:

    Notes:
*/
%>
<!-- #include file="./model_res_activiteit_discipline.inc" -->
<!-- #include file="./model_res_kenmerk.inc"-->
<%
function model_res_activiteit()
{
    this.records_name = "bookingactivities";
    this.record_name = "bookingactivity";
    this.table = "res_activiteit";
    this.primary = "res_activiteit_key";
    this.soft_delete = "res_activiteit_verwijder";
    this.autfunction = "WEB_RESMGT";
    this.record_title = L("res_activiteit");
    this.records_title = L("res_activiteit_m");


    this.fields = {
        "id": {
            "dbs": "res_activiteit_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "res_s_res_activiteit_key"
        },
        "bookingactivitytypes": {
            "dbs": "res_srtactiviteit_key",
            "label": L("res_srtactiviteit_key"),
            "typ": "key",
            "required": true,
            "foreign": {
                "tbl": "(SELECT res_srtactiviteit_key"
                     + "      , res_srtactiviteit_omschrijving"
                     + "      , res_srtactiviteit_soort"
                     + "   FROM res_srtactiviteit"
                     + "  WHERE res_srtactiviteit_verwijder IS NULL"
                     + ")",
                "key": "res_srtactiviteit_key",
                "desc": "res_srtactiviteit_omschrijving",
                "extravalue": "res_srtactiviteit_soort"
            },
            "showtransit": true
        },
        "name": {
            "dbs": "res_activiteit_omschrijving",
            "label": L("res_activiteit_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true
        },
        "image": {
            "dbs": "res_activiteit_image",
            "label": L("res_activiteit_image"),
            "typ": "varchar",
            "multiedit": true
        },
        "color": {
            "dbs": "res_activiteit_color",
            "label": L("res_activiteit_color"),
            "typ": "color"
        },
        "descriptionmandatory": {
            "dbs": "res_activiteit_omsverplicht",
            "label": L("res_activiteit_omsverplicht"),
            "typ": "check",
            "multiedit": true
        },
        "posttime": {
            "dbs": "res_activiteit_posttime",
            "label": L("res_activiteit_posttime"),
            "typ": "float",
            "defaultvalue": 0,
            "required": true,
            "multiedit": true
        },
        "visitorsmandatory": {
            "dbs": "res_activiteit_aantalverplicht",
            "label": L("res_activiteit_aantalverplicht"),
            "typ": "number",
            "bits": [
                {
                    "name": "hoe",
                    "label": "",
                    "typ": "radio",
                    "mask": 3,
                    "radios": [
                        {
                            "label": L("res_activiteit_aantalverpl_none"),
                            "mask": 0
                        },
                        {
                            "label": L("res_activiteit_aantalverpl_required"),
                            "mask": 1
                        },
                        {
                            "label": L("res_activiteit_aantalverpl_openframe"),
                            "mask": 2
                        }
                    ]
                }
            ],
            "defaultvalue": 0,
            "required": true,
            "multiedit": true
        },
        "notfrontend": {
            "dbs": "res_activiteit_notfrontend",
            "label": L("res_activiteit_notfrontend"),
            "typ": "check0",
            "multiedit": true
        },
        "sequence": {
            "dbs": "res_activiteit_volgnr",
            "label": L("res_activiteit_volgnr"),
            "typ": "number"
        },
        "duration": {
            "dbs": "res_activiteit_duur",
            "label": L("res_activiteit_duur"),
            "typ": "float",
            "multiedit": true
        },
        "hasendtime": {
            "dbs": "res_activiteit_meteindtijd",
            "label": L("res_activiteit_meteindtijd"),
            "typ": "check0",
            "defaultvalue": 1,
            "multiedit": true
        },
        "blocktimes": {
            "dbs": "res_activiteit_intervals",
            "label": L("res_activiteit_intervals"),
            "typ": "memo",
            "translate": true,
            "multiedit": true
        },
        "ismaster": {
            "dbs": "res_activiteit_ismaster",
            "label": L("res_activiteit_ismaster"),
            "typ": "check0",
            "multiedit": true
        },
        "master": {
            "dbs": "res_activiteit_master_key",
            "label": L("res_activiteit_master_key"),
            "typ": "key",
            "multiedit": true,
            "foreign": {
                "tbl": "(SELECT res_activiteit_key"
                     + "      , res_activiteit_omschrijving"
                     + "   FROM res_activiteit"
                     + "  WHERE res_activiteit_verwijder IS NULL"
                     + "    AND res_activiteit_ismaster = 1"
                     + ")",
                "key": "res_activiteit_key",
                "desc": "res_activiteit_omschrijving"
            }
        },
        "deliverymode": {
            "dbs": "res_activiteit_cvab_mode",
            "label": L("res_activiteit_cvab_mode"),
            "typ": "key",
            "LOV": L("res_activiteit_cvab_modeLOV"),
            "emptyoption": null,
            "emptyisrealvalue": true
        },
        "limitdays": {
            "dbs": "res_activiteit_limiet",
            "label": L("res_activiteit_limiet"),
            "typ": "number"
        },
        "limitdaysfe": {
            "dbs": "res_activiteit_limiet_fe",
            "label": L("res_activiteit_limiet_fe"),
            "typ": "number"
        }
    };

    this.includes = {
        "disciplines": {
            "model": new model_res_activiteit_discipline(),
            "joinfield": "bookingactivity",
            "enable_update": true,
            "multiadd": "bookingdiscipline",
            "required": true
        },
        "custom_properties": {
            "model": new model_res_kenmerk("A", { internal: true }), // Artikel
            "joinfield": "bookingactivity",
            "enable_update": true
        }
    };

    this.hook_pre_show = function (obj, fld)
    {
        var sql = "SELECT res_srtactiviteit_soort"
                + "  FROM res_srtactiviteit"
                + " WHERE res_srtactiviteit_verwijder IS NULL"
                + "   AND res_srtactiviteit_key = " + obj.bookingactivitytypes.id;
        var oRs = Oracle.Execute(sql);
        if (!oRs.eof)
        {
            var srtact_soort = oRs("res_srtactiviteit_soort").Value;
            if (srtact_soort != 1)
                delete this.fields.deliverymode;
        }
        oRs.Close();

        // Toon effectieve waarde limiet (obv setting)
        obj.limitdays   = (obj.limitdays   ? obj.limitdays   : S("res_reservering_limiet"));
        obj.limitdaysfe = (obj.limitdaysfe ? obj.limitdaysfe : S("res_fe_reservering_limiet"));
    }

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