<% /*
    $Revision$
    $Id$

    File:           model_cnt_contract_plaats.inc

    Description:    Koppeling tussen het contract en de locatie waarop deze betrekking heeft.

    Context:

    Notes:
*/
%>
<%

function model_cnt_contract_plaats(params)
{
    params = params || {};
    this.records_name = "contractlocations";
    this.record_name = "contractlocation";
    this.table = "cnt_contract_plaats";
    this.primary = "cnt_contract_plaats_key";
    this.soft_delete = "cnt_contract_plaats_verwijder";
    this.autfunction = params.internal?false:"WEB_CNTUSE";
    this.record_title = L("cnt_contract_plaats");
    this.records_title = L("cnt_contract_plaats_m");
    this.module = "CNT";


    this.fields = {
        "id": {
            "dbs": "cnt_contract_plaats_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "cnt_s_cnt_contract_plaats_key"
        },
        "contract": {
            "dbs": "cnt_contract_key",
            "label": L("lcl_cnt_contract"),
            "typ": "key",
            "foreign": {
                "tbl": "cnt_contract",
                "key": "cnt_contract_key",
                "desc": "cnt_contract_nummer_intern"
            }
        },
        "realestate": {
            "dbs": "cnt_alg_plaats_key",
            "label": L("cnt_alg_key"),
            "typ": "key",
            "filter": "exact"
        },
        "realestate_type": {
            "dbs": "cnt_alg_plaats_code",
            "label": L("cnt_alg_code"),
            "typ": "varchar",
            "LOV": fill_real_estate_level_LOV()
        },
/*
        "location": {
            "dbs": "cnt_onrgoed.alg_locatie_key",
            "label": "locatie_key",
            "typ": "key"
        },
*/
        "created": {
            "dbs": "cnt_contract_plaats_aanmaak",
            "label": L("cnt_contract_plaats_aanmaak"),
            "typ": "datetime"
        },
        "weight": {
            "dbs": "cnt_contract_plaats_gewicht",
            "label": L("cnt_contract_plaats_gewicht"),
            "typ": "float"
        }
    };

/*
    var cnt_onrgoed_sql = "(SELECT alg_type"
                        + "      , alg_onroerendgoed_keys alg_keys"
                        + "      , alg_ruimte_key"
                        + "      , alg_verdieping_key"
                        + "      , alg_gebouw_key"
                        + "      , alg_terreinsector_key"
                        + "      , alg_locatie_key"
                        + "   FROM alg_v_allonroerendgoed"
                        + "  UNION"
                        + " SELECT 'L'"
                        + "      , alg_locatie_key"
                        + "      , NULL,NULL,NULL,NULL"
                        + "      , alg_locatie_key"
                        + "   FROM alg_locatie"
                        + ") cnt_onrgoed";

    this.REST_GET    = generic_REST_GET(this, {
        "GET": {
            "tables": [ cnt_onrgoed_sql],
            "wheres": [ "cnt_onrgoed.alg_type = cnt_contract_plaats.cnt_alg_plaats_code"
                      , "cnt_onrgoed.alg_keys = cnt_contract_plaats.cnt_alg_plaats_key"
                      ]
        }
    });
*/
    this.REST_GET    = generic_REST_GET(this);
    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this, {});

    function fill_real_estate_level_LOV()
    {
        return  "D;"+L("lcl_district")
             + ";L;"+L("lcl_location")
             + ";G;"+L("lcl_building")
             + ";R;"+L("lcl_room"); // Moet hier T en V ook nog bij?
    }

}
%>