<% /*
    $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="../mgt/mgt_tools.inc" -->
<!-- #include file="./model_ctr_discipline.inc" -->
<%
function model_ins_srtcontrole()
{
    this.table = "ins_srtcontrole";
    this.primary = "ins_srtcontrole_key";
    this.records_name = "ins_srtcontroles";
    this.record_name = "ins_srtcontrole";
    this.autfunction = "WEB_INSMGT";
    this.record_title = L("ins_srtcontrole");
    this.records_title = L("ins_srtcontrole_m");


    this.fields = {
        "id": {
            "dbs": "ins_srtcontrole_key",
            "label": "Key",
            "typ": "key",
            "required": true,
            "filter": "exact",
            "seq": "ins_s_ins_srtcontrole_key"
        },
        "level": {
            "dbs": "ins_srtcontrole_niveau",
            "label": L("ins_srtcontrole_niveau"),
            "typ": "varchar",
            "hidden_fld": true,
            "LOV": fill_niveau_LOV()
        },
        "object_key": {
            "dbs": "ins_srtinstallatie_key",
            "label": "ins_srtinstallatie_key",
            "typ": "key",
            "hidden_fld": true
        },
        "object_discipline": {
            "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"
                       }
        },
        "object_group": {
            "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"
                       }
        },
        "object_type": {
            "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"
                       }
        },
        "name": {
            "dbs": "ins_srtcontrole_omschrijving",
            "label": L("ins_srtcontrole_omschrijving"),
            "typ": "varchar",
            "required": true,
            "translate": true
        },
        "info": {
            "dbs": "ins_srtcontrole_info",
            "label": L("ins_srtcontrole_info"),
            "typ": "memo",
            "translate": true
        },
        "ctr_discipline": {
            "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
        },
        "inspection_mode": {
            "dbs": "ins_srtcontrole_mode",
            "label": L("ins_srtcontrole_mode"),
            "typ": "key",
            "required": true,
            "LOV": L("ins_srtcontrole_modeLOV")
        },
        "priority": {
            "dbs": "ins_srtcontrole_level",
            "label": L("ins_srtcontrole_level"),
            "typ": "number",
            "defaultvalue": 10,
            "required": true
        },
        "period": {
            "dbs": "ins_srtcontrole_periode",
            "label": L("ins_srtcontrole_periode"),
            "typ": "float",
            "required": true
        },
        "unit": {
            "dbs": "ins_srtcontrole_eenheid",
            "label": L("ins_srtcontrole_eenheid"),
            "typ": "key",
            "required": true,
            "LOV": L("ins_srtcontrole_eenheidLOV")
        },
        "bits": {
            "dbs": "ins_srtcontrole_bits",
            "label": L("ins_srtcontrole_bits"),
            "typ": "number",
            "hidden_fld": true
        },
        "_moment": {
            "dbs": "",
            "label": L("ins_srtcontrole_moment"),
            "typ": "button",
            "defaultvalue": L("lcl_select")
        },
        "account": {
            "dbs": "prs_kostenplaats_key",
            "label": L("lcl_prs_kosten"),
            "typ": "key",
            "foreign": "prs_kostenplaats",
            "foreignfiltercode": "A", // Alle kostenplaatsen tonen.
            "filter": "exact"
        },
        "costs": {
            "dbs": "ins_srtcontrole_kosten",
            "label": L("ins_srtcontrole_kosten"),
            "iscurrency": true,
            "typ": "float"
        },
        "costs2": {
            "dbs": "ins_srtcontrole_kosten2",
            "label": L("ins_srtcontrole_kosten2"),
            "iscurrency": true,
            "typ": "float"
        },
        "costs3": {
            "dbs": "ins_srtcontrole_kosten3",
            "label": L("ins_srtcontrole_kosten3"),
            "iscurrency": true,
            "typ": "float"
        },
        "material": {
            "dbs": "ins_srtcontrole_materiaal",
            "label": L("ins_srtcontrole_materiaal"),
            "iscurrency": true,
            "typ": "float"
        },
        "hours": {
            "dbs": "ins_srtcontrole_uren",
            "label": L("ins_srtcontrole_uren"),
            "typ": "float"
        },
        "end_date": {
            "dbs": "ins_srtcontrole_eind",
            "label": L("ins_srtcontrole_eind"),
            "typ": "date"
        },
        "afbouw_time": {
            "dbs": "ins_srtcontrole_afbouwtijd",
            "label": L("ins_srtcontrole_afbouwtijd"),
            "typ": "float"
        },
        "inspection_group": {
            "dbs": "ins_srtcontrole_groep",
            "label": L("ins_srtcontrole_groep"),
            "typ": "varchar"
        },
        "percentage": {
            "dbs": "ins_srtcontrole_percentage",
            "label": L("ins_srtcontrole_percentage"),
            "typ": "float"
        },
        "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")
                                                    + ")"
                       }
        },
        "options": {
            "dbs": "ins_srtcontrole_options",
            "label": L("ins_srtcontrole_options"),
            "typ": "number",
            "bits": [
                {
                    "name": "",
                    "label": "",
                    "typ": "check",
                    "mask": 15,
                    "radios": [
                        {
                            "name": "inplan",
                            "label": L("ins_srtcontrole_plan"),
                            "mask": 1,
                            "defaultvalue": 1
                        },
                        {
                            "name": "start",
                            "label": 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
                        }
                    ]
                }
            ]
        },
        "remark": {
            "dbs": "ins_srtcontrole_opmerking",
            "label": L("ins_srtcontrole_opmerking"),
            "typ": "memo"
        }
    };


    this.includes = {
        "kenmerken": {
            "model": new model_ins_kenmerk( {niveau:"C"} ),
            "joinfield": "object_key",
            "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");
    }
}
%>