<% /*
    $Revision$
    $Id$

    File:           model_cnt_discipline.inc

    Description:    Vanuit CodeCharge gegenereerd model voor cnt_discipline

    Context:

    Notes:
*/
%>
<!-- #include file="../api2/model_cnt_disc_params.inc" -->
<!-- #include file="../mgt/mgt.inc"-->
<%

function model_cnt_discipline(disc_key, params)
{
    // Eén model voor de buitenwereld
    api2.merge_disc_params_model(this, _model_cnt_discipline);

    this.hook_post_post = function (params, obj, key)
    {
        var org_disc_key = getQParamInt("id", -1);
        var clone_auth = getQParamInt("clone_auth", 0) == 1;
        if (clone_auth)
        {   // Ook de autorisatie van de oude discipline kopieren
            mgt.clone_authorization(key, org_disc_key);
        }
    }

    this.REST_GET    = generic_REST_GET(_model_cnt_discipline,  // Let op: de originele _model_cnt_discipline
                                           { "GET": {
                                               wheres: [ "ins_tab_discipline.ins_discipline_module = 'CNT'"
                                                       ]
                                               }
                                           }
                                       );
    this.REST_POST   = generic_REST_POST(_model_cnt_discipline);
    this.REST_PUT    = generic_REST_PUT(_model_cnt_discipline);
    this.REST_DELETE = generic_REST_DELETE(this, {});
}


_model_cnt_discipline = // Internal only
{
    "records_name":"contractdisciplines",
    "record_name": "contractdiscipline",
    "table": "ins_tab_discipline",
    "audit": { "childtable": "cnt_disc_params" }, // Parameters voor fac_audit.
    "primary": "ins_discipline_key",
    "soft_delete": "ins_discipline_verwijder",
    "autfunction": "WEB_CNTMGT",
    "record_title": L("cnt_discipline"),
    "records_title": L("cnt_discipline_m"),


    "fields": {
        "id": {
            "dbs": "ins_discipline_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "ins_s_ins_discipline_key"
        },
        "name": {
            "dbs": "ins_discipline_omschrijving",
            "label": L("ins_discipline_omschrijving"),
            "typ": "varchar",
            "filter": "like",
            "translate": true,
            "required": true
        },
        "module": {
            "dbs": "ins_discipline_module",
            "label": L("ins_discipline_module"),
            "typ": "varchar",
            "hidden_fld": true,
            "defaultvalue": "CNT"
        },
        "costtype": {
            "dbs": "prs_kostensoort_key",
            "label": L("prs_kostensoort_key"),
            "typ": "key",
            "foreign": "prs_kostensoort"
        },
        "email": {
            "dbs": "ins_discipline_email",
            "label": L("ins_discipline_email"),
            "typ": "varchar"
        },
        "symbolname": {
            "dbs": "ins_discipline_image",
            "typ": "icon",
            "module": "CNTD",
            "label": L("lcl_cnt_symbol_name")
        },
        "externnr": {
            "dbs": "ins_discipline_externnr",
            "typ": "varchar",
            "label": L("extern_nr")
        },
        "externsyncdate": {
            "dbs": "ins_discipline_externsyncdate",
            "typ": "datetime",
            "label": L("extern_syncdate"),
            "hidden_fld": true,
            "readonly": !(user.has("WEB_FACTAB") || user.has("WEB_FACXNR"))
        }
    /* Velden van CNT_DISC_PARAMS komen er dynamisch bij */
    },
    "disc_params": {
        "model": model_cnt_disc_params,
        "joinfield": "contractdiscipline"
    }
}
%>