<% /*
    $Revision$
    $Id$

    File:           model_res_discipline.inc

    Description:    Vanuit CodeCharge gegenereerd model voor res_catalogus

    Context:

    Notes:          intern hebben we een apart model voor _res_disc_params
                    Naar de buitenwereld presenteren we het als één model
*/
%>

<!-- #include file="model_res_disc_params.inc" -->
<!-- #include file="./model_res_activiteit_discipline.inc" -->
<%
function model_res_discipline(disc_key, params)
{
    // Eén model voor de buitenwereld
    api2.merge_disc_params_model(this, _model_res_discipline);

    this.REST_GET    = generic_REST_GET(_model_res_discipline,  // Let op: de originele _model_res_discipline
                                           { "GET": {
                                                     wheres: [ "ins_tab_discipline.ins_discipline_module = 'RES'"
                                                             ]
                                                    }
                                            }
                                      )

    this.REST_POST   = generic_REST_POST(_model_res_discipline);
    this.REST_PUT    = generic_REST_PUT(_model_res_discipline);
    this.REST_DELETE = generic_REST_DELETE(this, {});
}

_model_res_discipline = // Internal only
{
    "table": "ins_tab_discipline",
    "primary": "ins_discipline_key",
    "records_name": "reservationcatalogs",
    "record_name": "reservationcatalog",
    "fields": {
        "id": {
            "dbs": "ins_discipline_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "ins_s_ins_discipline_key"
        },
        "ins_discipline_module": {
            "dbs": "ins_discipline_module",
            "label": L("ins_discipline_module"),
            "typ": "varchar",
            "required": true,
            "defaultvalue": "RES",
            "hidden_fld": true
        },
        "ins_discipline_min_level": {
            "dbs": "ins_discipline_min_level",
            "label": L("ins_discipline_min_level"),
            "typ": "key",
            "required": true,
            "insertonly": true,
            "LOV": L("ins_discipline_min_levelLOV"),
            "LOVinit": ""
        },
        "name": {
            "dbs": "ins_discipline_omschrijving",
            "label": L("ins_discipline_omschrijving"),
            "typ": "varchar",
            "filter": "like",
            "translate": true,
            "required": true
        },
        "sequence": {
            "dbs": "ins_discipline_volgnr",
            "label": L("ins_discipline_volgnr"),
            "typ": "number"
        },
        "costtype": {
            "dbs": "prs_kostensoort_key",
            "label": L("prs_kostensoort_key"),
            "typ": "key",
            "foreign": "prs_kostensoort",
            "LOVinit": ""
        },
        "ins_discipline_kpnverplicht": {
            "dbs": "ins_discipline_kpnverplicht",
            "label": L("ins_discipline_kpnverplicht"),
            "typ": "check"
        },
        "ins_discipline_email": {
            "dbs": "ins_discipline_email",
            "label": L("ins_discipline_email"),
            "typ": "varchar"
        },
        "ins_discipline_ktopercentage": {
            "dbs": "ins_discipline_ktopercentage",
            "label": L("ins_discipline_ktopercentage"),
            "typ": "number"
        },
        "ins_discipline_ktodrempel": {
            "dbs": "ins_discipline_ktodrempel",
            "label": L("ins_discipline_ktodrempel"),
            "typ": "number"
        }
    /* Velden van RES_DISC_PARAMS komen er dynamisch bij */
    },
    "disc_params": {
        model: model_res_disc_params,
        joinfield: "res_ins_discipline_key"
    },

    includes : {
        "activities": {
            "model": new model_res_activiteit_discipline(),
            "joinfield": "res_discipline_key",
            "enable_update": true
        }
    },
    "soft_delete": "ins_discipline_verwijder",
    "autfunction": "WEB_RESMGT",
    "record_title": L("res_v_res_catalogus"),
    "records_title": L("res_v_res_catalogus_m")
}
%>