<% /*
    $Revision$
    $Id$

    File:           model_mld_vrije_dagen.inc

    Description:    Vanuit CodeCharge gegenereerd model voor mld_vrije_dagen

    Context:

    Notes:
*/
%>
<%

function model_mld_vrije_dagen()
{
    this.records_name = "daysoff";
    this.record_name = "dayoff";
    this.table = "mld_vrije_dagen";
    this.primary = "mld_vrije_dagen_key";
    this.autfunction = "WEB_PRSSYS";
    this.record_title = L("mld_vrije_dagen");
    this.records_title = L("mld_vrije_dagen_m");


    this.fields = {
        "id": {
            "dbs": "mld_vrije_dagen_key",
            "label": "key",
            "typ": "key",
            "hidden_fld": true,
            "required": true,
            "seq": "mld_s_mld_vrije_dagen_key"
        },
        "dayoff": {
            "dbs": "mld_vrije_dagen_datum",
            "label": L("mld_vrije_dagen_datum"),
            "typ": "date",
            "required": true,
            "autosize": true,
            "filter": "range",
            "friendlyname": true
        },
        "name": {
            "dbs": "mld_vrije_dagen_id",
            "label": L("lcl_calendar"),
            "typ": "varchar",
            "required": true,
            "defaultvalue": "Default"
        },
        "calendar": {
            "dbs": "kalender.kalender_id",
            "label": L("lcl_calendar"),
            "typ": "varchar",
            "foreign": {
                "tbl": "(SELECT DISTINCT"
                     + "        mld_vrije_dagen_id cl_key"
                     + "   FROM mld_vrije_dagen"
                     + ")",
                "key": "cl_key",
                "desc": "cl_key"
            }
        },
        "year": {
            "dbs": "jaren.jaar_key",
            "label": L("lcl_mld_year"),
            "typ": "varchar",
            "foreign": {
                "tbl": "(SELECT DISTINCT"
                     + "        TO_CHAR(EXTRACT(YEAR FROM mld_vrije_dagen_datum)) yr_key"
                     + "   FROM mld_vrije_dagen"
                     + ")",
                "key": "yr_key",
                "desc": "yr_key"
            }
        }
    };

    this.edit = {
        "modal": true
    };

    this.hook_pre_edit = function(obj, fld)
    {
        //fld.calendar.label = "&nbsp;";
        fld.calendar.label = L("mld_vrije_dagen_kalender_1");
        fld.name.label = L("mld_vrije_dagen_kalender_2");
    }

    function get_tbl_yr()
    {
        var sql = "(SELECT DISTINCT"
                + "        EXTRACT(YEAR FROM mld_vrije_dagen_datum) jaar_key"
                + "      , mld_vrije_dagen_id cl_key"
                + "   FROM mld_vrije_dagen" 
                + ") jaren";
        return sql;
    }
    function get_tbl_cl()
    {
        var sql = "(SELECT DISTINCT mld_vrije_dagen_id kalender_id"
                + "   FROM mld_vrije_dagen"
                + ") kalender";
        return sql;
    }
    var gparams = { GET: { tables: [ get_tbl_yr()
                                   , get_tbl_cl()
                                   ]
                         , wheres: [ "EXTRACT(YEAR FROM mld_vrije_dagen.mld_vrije_dagen_datum) = jaren.jaar_key"
                                   , "mld_vrije_dagen.mld_vrije_dagen_id = kalender.kalender_id"
                                   , "mld_vrije_dagen.mld_vrije_dagen_id = jaren.cl_key"
                                   ]
                         , orderbys: ["jaren.jaar_key"
                                     ,"mld_vrije_dagen.mld_vrije_dagen_id"
                                     ,"mld_vrije_dagen.mld_vrije_dagen_datum"
                                     ]
                         }
                  };

    this.REST_GET    = generic_REST_GET(this, gparams);
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this, gparams);
    this.REST_DELETE = generic_REST_DELETE(this);
}
%>