<% /*
    $Revision$
    $Id$

    File:           model_ins_srtcontrole.inc

    Description:    Vanuit CodeCharge gegenereerd model voor ins_srtcontrole

    Context:

    Notes:
*/
%>
<!-- #include file="./model_ins_kenmerk.inc"-->
<!-- #include file="./model_ctr_discipline.inc" -->
<%
function model_ins_srtcontrole()
{
    this.records_name = "recurringtasks";
    this.record_name = "recurringtask";
    this.table = "ins_srtcontrole";
    this.primary = "ins_srtcontrole_key";
    this.autfunction = "WEB_INSMGT";
    this.record_title = L("ins_srtcontrole");
    this.records_title = L("ins_srtcontrole_m");
    this.trackcode = "CTRSUP";

    this.fields = {
        "id": {
            "dbs": "ins_srtcontrole_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "ins_s_ins_srtcontrole_key",
            "track": true
        },
        "level": {
            "dbs": "ins_srtcontrole_niveau",
            "label": L("ins_srtcontrole_niveau"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": fill_niveau_LOV(),
            "track": true,
            "insertonly": true
        },
        "objectkey": {
            "dbs": "ins_srtinstallatie_key",
            "label": L("lcl_ins_object"),
            "typ": "key",
            "hidden_fld": true,
            "insertonly": true
        },
        "objectdiscipline": {
            "dbs": "ins_v_allsrtinstallatie.ins_discipline_key",
            "label": L("ins_srtinstallatie_discipline"),
            "typ": "key",
            "required": true,
            "foreign": { "tbl": "ins_v_aanwezigdiscipline",
                         "key": "ins_discipline_key",
                         "desc": "ins_discipline_omschrijving"
                       },
            "insertonly": true,
            "showtransit": true
        },
        "objectgroup": {
            "dbs": "ins_v_allsrtinstallatie.ins_srtgroep_key",
            "label": L("ins_srtinstallatie_srtgroep"),
            "typ": "key",
            "foreign": { "tbl": "ins_srtgroep",
                         "key": "ins_srtgroep_key",
                         "desc": "ins_srtgroep_omschrijving"
                       },
            "insertonly": true,
            "showtransit": true
        },
        "objecttype": {
            "dbs": "ins_v_allsrtinstallatie.ins_srtdeel_key",
            "label": L("ins_srtinstallatie_srtdeel"),
            "typ": "key",
            "foreign": { "tbl": "ins_srtdeel",
                         "key": "ins_srtdeel_key",
                         "desc": "ins_srtdeel_omschrijving"
                       },
            "insertonly": true,
            "showtransit": true,
            "infoPointer": { Url: "appl/ins/ins_srtdeel.asp?srtdeel_key=" }
        },
        "name": {
            "dbs": "ins_srtcontrole_omschrijving",
            "label": L("ins_srtcontrole_omschrijving"),
            "typ": "varchar",
            "required": true,
            "translate": true,
            "track": true
        },
        "info": {
            "dbs": "ins_srtcontrole_info",
            "label": L("ins_srtcontrole_info"),
            "typ": "memo",
            "bb_codes": true,
            "translate": true,
            "track": true
        },
        "taskdiscipline": {
            "dbs": "ctr_discipline_key",
            "label":  L("ctr_discipline"),
            "typ": "key",
            "foreign": { "tbl": "ctr_v_aanwezigdiscipline",
                         "key": "ins_discipline_key",
                         "desc": "ins_discipline_omschrijving"
                       },
            "required": true,
            "showtransit": true,
            "track": true
        },
        "inspectionmode": {
            "dbs": "ins_srtcontrole_mode",
            "label": L("ins_srtcontrole_mode"),
            "typ": "number",
            "required": true,
            "LOV": L("ins_srtcontrole_modeLOV"), // Expliciet zetten, anders wordt er default "range" van gemaakt.
            "track": true
        },
        "priority": {
            "dbs": "ins_srtcontrole_level",
            "label": L("ins_srtcontrole_level"),
            "typ": "number",
            "defaultvalue": 10,
            "required": true,
            "multiedit": true,
            "track": true
        },
        "period": {
            "dbs": "ins_srtcontrole_periode",
            "label": L("ins_srtcontrole_periode"),
            "typ": "float",
            "len": 3,
            "required": true,
            "multiedit": true,
            "track": true
        },
        "unit": {
            "dbs": "ins_srtcontrole_eenheid",
            "label": L("ins_srtcontrole_eenheid"),
            "typ": "number",
            "required": true,
            "LOV": L("ins_srtcontrole_eenheidLOV"),
            "track": true
        },
        "bits": {
            "dbs": "ins_srtcontrole_bits",
            "label": L("ins_srtcontrole_bits"),
            "typ": "number",
            "hidden_fld": true,
            "track": true
        },
        "_moment": {
            "dbs": "",
            "label": L("ins_srtcontrole_moment"),
            "icon": "fa-calendar",
            "typ": "button2",
            "defaultvalue": L("lcl_select"),
            "track": true
        },
        "account": {
            "dbs": "prs_kostenplaats_key",
            "label": L("lcl_prs_kosten"),
            "typ": "key",
            "foreign": "prs_kostenplaats",
            "foreignfiltercode": "A", // Alle kostenplaatsen tonen.
            "track": true
        },
        "costs": {
            "dbs": "ins_srtcontrole_kosten",
            "label": L("ins_srtcontrole_kosten"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true,
            "track": true,
            "relativeValuesAllowed": true
        },
        "costs2": {
            "dbs": "ins_srtcontrole_kosten2",
            "label": L("ins_srtcontrole_kosten2"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true,
            "track": true,
            "relativeValuesAllowed": true
        },
        "costs3": {
            "dbs": "ins_srtcontrole_kosten3",
            "label": L("ins_srtcontrole_kosten3"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true,
            "track": true,
            "relativeValuesAllowed": true
        },
        "material": {
            "dbs": "ins_srtcontrole_materiaal",
            "label": L("ins_srtcontrole_materiaal"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true,
            "track": true,
            "relativeValuesAllowed": true
        },
        "hours": {
            "dbs": "ins_srtcontrole_uren",
            "label": L("ins_srtcontrole_uren"),
            "typ": "float",
            "multiedit": true,
            "track": true
        },
        "enddate": {
            "dbs": "ins_srtcontrole_eind",
            "label": L("ins_srtcontrole_eind"),
            "typ": "date",
            "multiedit": true,
            "track": true,
            "onchange": "DateChangedEnddate()"
        },
        "phasingouttime": {
            "dbs": "ins_srtcontrole_afbouwtijd",
            "label": L("ins_srtcontrole_afbouwtijd"),
            "typ": "float",
            "multiedit": true,
            "track": true
        },
        "taskgroup": {
            "dbs": "ins_srtcontrole_groep",
            "label": L("ins_srtcontrole_groep"),
            "typ": "varchar",
            "track": true
        },
        "percentage": {
            "dbs": "ins_srtcontrole_percentage",
            "label": L("ins_srtcontrole_percentage"),
            "typ": "number",
            "track": true
        },
        "vat": {
            "dbs": "fin_btwtabelwaarde_key",
            "label": L("ins_srtcontrole_btw"),
            "typ": "key",
            "foreign": { "tbl": "fin_btwtabelwaarde",
                         "key": "fin_btwtabelwaarde_key",
                         "desc": "fin_btwtabelwaarde_oms",
                         "where": "fin_btwtabel_key = (SELECT fin_btwtabel_key"
                                                    + "  FROM fin_btwtabelwaarde"
                                                    + " WHERE fin_btwtabelwaarde_key = " + S("fin_btw_default")
                                                    + ")"
                       },
            "track": true
        },
        "issuetype": {
            "dbs": "mld_stdmelding_key",
            "label": L("mld_stdmelding_key"),
            "typ": "key",
            "foreign": "mld_stdmelding",
            "multiedit": true,
            "track": true
        },
        "service": {
            "dbs": "prs_dienst_key",
            "label": L("prs_dienst"),
            "typ": "key",
            "foreign": "prs_dienst",
            "multiedit": true,
            "track": true
        },
        "controlemode": {
            "dbs": "ins_controlemode_key",
            "label":  L("ins_default_controlemode"),
            "typ": "key",
            "foreign": { "tbl": "ins_controlemode",
                         "key": "ins_controlemode_key",
                         "desc": "ins_controlemode_oms"
                       },
            "track": true
        },
        "options": {
            "dbs": "ins_srtcontrole_options",
            "label": L("ins_srtcontrole_options"),
            "typ": "number",
            "multiedit": true,
            "bits": [
                {
                    "name": "",
                    "label": "",
                    "typ": "check",
                    "mask": 15,
                    "radios": [
                        {
                            "name": "inplan",
                            "label": L("ins_srtcontrole_plan"),
                            "mask": 1,
                            "defaultvalue": 1
                        },
                        {
                            "name": "start",
                            "label": ismjob? L("ins_srtcontrole_start_mjob") : L("ins_srtcontrole_start"),
                            "mask": 2,
                            "defaultvalue": 1
                        },
                        {
                            "name": "afmeld",
                            "label": L("ins_srtcontrole_afmeld"),
                            "mask": 4,
                            "defaultvalue": 1
                        },
                        {
                            "name": "afrond",
                            "label": L("ins_srtcontrole_afrond"),
                            "mask": 8,
                            "defaultvalue": 1
                        }
                    ]
                }
            ],
            "track": true
        },
        "remarktext": {
            "dbs": "ins_srtcontrole_opmerking_text",
            "label": L("ins_srtcontrole_opmerking_text"),
            "typ": "key",
            "LOV": "0;;"
                 + "1;" + L("lcl_ins_close") + ";"
                 + "2;" + L("lcl_ins_finish"),
            "emptyoption": null,
            "multiedit": true
        },
        "remark": {
            "dbs": "ins_srtcontrole_opmerking",
            "label": L("ins_srtcontrole_opmerking"),
            "typ": "memo",
            "track": true
        }
    };

    // Met BAUS#80301 is er een eigen menuitem gekomen waarmee de taakkenmerken aangemaakt kunnen worden op dezelfde manier als bij andere kenmerken.
    // Taakkenmerken kunnen dan ook aangemaakt worden die voor alle taken gelden of voor een taakcategorie (ctrdiscipline).
    // Het tabje "Taakkenmerken bij een taak heb je dan niet meer nodig en is daarom hieronder uitgecommentariseerd.
    //
    //// Kenmerk *definities* als include is vrij uitzonderlijk
    //this.includes = {
    //    "custom_properties": {
    //        "model": new model_ins_kenmerk("C", { internal: true }),
    //        "joinfield": "objectkey",
    //        "enable_update": true
    //    }
    //};

    this.REST_GET    = generic_REST_GET(this, {
                            "GET": {
                                "tables": ["ins_v_allsrtinstallatie"],
                                "wheres": [
                                    "ins_srtcontrole.ins_srtinstallatie_key = ins_v_allsrtinstallatie.ins_srtinstallatie_key",
                                    "ins_srtcontrole.ins_srtcontrole_niveau = ins_v_allsrtinstallatie.niveau"
                                ]
                            } }
                       );
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this, {});

    function fill_niveau_LOV()
    {
        return  "D;"+L("ins_srtinstallatie_discipline")
             + ";G;"+L("ins_srtinstallatie_srtgroep")
             + ";S;"+L("ins_srtinstallatie_srtdeel");
    }
}
%>