<% /*
    $Revision$
    $Id$

    File:           model_ctr_scenario.inc

    Description:    Model voor scenario's

    Context:

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

function model_ctr_scenario()
{
    this.records_name = "scenarios";
    this.record_name = "scenario";
    this.table = "ins_scenario";
    this.primary = "ins_scenario_key";
    this.autfunction = ["WEB_CTRMGT", "WEB_CTRSEN"];
    this.autfunction_add = ["WEB_CTRMGT", "WEB_CTRSEN"];
    this.autfunction_del = "WEB_CTRMGT";
    this.record_title = L("ctr_scenario");
    this.records_title = L("ctr_scenario_m");


    this.fields = {
        "id": {
            "dbs": "ins_scenario_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "ins_s_ins_scenario_key"
        },
        "name": {
            "dbs": "ins_scenario_omschrijving",
            "label": L("ctr_scenario_omschrijving"),
            "typ": "varchar",
            "required": true,
            "translate": true
        },
        "nrelements": {
          "dbs": "nn_elements",
          "sql": "(SELECT COUNT(*) FROM ins_srtcontroledl_xcp isx WHERE isx.ins_scenario_key = ins_scenario.ins_scenario_key)",
          "label": L("ctr_scenario_aantal"),
          "typ": "number"
        },
        "remark": {
            "dbs": "ins_scenario_opmerking",
            "label": L("ctr_scenario_opmerking"),
            "typ": "varchar",
            "translate": true
        },
        "created": {
            "dbs": "ins_scenario_aanmaak",
            "label": L("ctr_scenario_aanmaak"),
            "typ": "date",
            "readonly": true
        },
        "status": {
            "dbs": "ins_scenario_status",
            "label": L("ctr_scenario_status"),
            "foreign": ins.getscenariostatustext,
            "typ": "number"
        },
        "person": {
            "dbs": "prs_perslid_key",
            "label": L("lcl_user"),
            "typ": "key",
            "foreign" : "prs_perslid",
            readonly: true
        }
    };


    this.REST_GET    = generic_REST_GET(this, { GET: { wheres: [ "ins_scenario_key <> 1"] }});
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this, {});
}
%>