<% /*
    $Revision$
    $Id$

    File:           model_res_ruimte_opstelling.inc

    Description:    Vanuit CodeCharge gegenereerd model voor res_ruimte_opstelling

    Context:

    Notes:
*/
%>
<%

function model_res_ruimte_opstelling(fnparams)
{
    this.gparams = {fn: fnparams || {} };
    this.records_name = "bookingconfigurations";
    this.record_name = "bookingconfiguration";
    this.table = "res_ruimte_opstelling";
    this.primary = "res_ruimte_opstel_key";
    this.soft_delete = "res_ruimte_opstel_verwijder";
    this.autfunction = "WEB_RESMSU";
    this.record_title = L("res_ruimte_opstelling");
    this.records_title = L("res_ruimte_opstelling_m");
    this.defaultIcon = "fa-chair-office";

    this.fields = {
        "id": {
            "dbs": "res_ruimte_opstel_key",
            "label": L("lcl_key"),
            "typ": "key",
            "hidden_fld": true,
            "required": true,
            "seq": "res_s_res_ruimte_opstel_key"
        },
        "bookingroom": {
            "dbs": "res_ruimte_key",
            "label": L("res_v_aanwezigruimte"),
            "typ": "key",
            "foreign": {
                "tbl": "res_ruimte",
                "key": "res_ruimte_key",
                "desc": "res_ruimte_nr"
            }
        },
        "bookingconfiguration": {
            "dbs": "res_opstelling_key",
            "label": L("res_opstelling_key"),
            "typ": "key",
            "required": true,
            "foreign": {
                "tbl": "res_opstelling",
                "key": "res_opstelling_key",
                "desc": "res_opstelling_omschrijving",
                "where": "res_opstelling_verwijder is null"
            },
            "uniquewith": "bookingroom"
        },
        "capacity": {
            "dbs": "res_ruimte_opstel_bezoekers",
            "label": L("res_ruimte_opstel_bezoekers"),
            "typ": "number",
            "required": true
        },
        "setuptime": {
            "dbs": "res_ruimte_opstel_tijd",
            "label": L("res_ruimte_opstel_tijd"),
            "typ": "float",
            "trimZeros": true,
            "defaultvalue": 0,
            "required": true
        },
        "isdefault": {
            "dbs": "res_ruimte_opstel_default",
            "label": L("res_ruimte_opstel_default"),
            "typ": "check"
        },
        "configimage": {
            "dbs": "res_ruimte_opstel_image",
            "label": L("res_ruimte_opstel_image"),
            "typ": "file",
            "module": "RESPHO"
        },
        "configcapacity": {
            "dbs": "res_ruimte_opstel_maxbezoeker",
            "sql": "(SELECT ro.res_opstelling_omschrijving ||' ('|| res_ruimte_opstelling.res_ruimte_opstel_bezoekers ||')'"
                 + "   FROM res_opstelling ro"
                 + "  WHERE ro.res_opstelling_key = res_ruimte_opstelling.res_opstelling_key"
                 + "    AND ro.res_opstelling_verwijder is null)",
            "label": L("res_opstelling_key")+" ("+L("res_ruimte_opstel_bezoekers") +")",
            "typ": "varchar"
        },
        "configsetuptime": {
            "dbs": "res_ruimte_opstel_minmaxtijd",
            "sql": "(SELECT CASE WHEN MIN(ro.res_ruimte_opstel_tijd) = MAX(ro.res_ruimte_opstel_tijd)"
                            + "  THEN TO_CHAR(MAX(ro.res_ruimte_opstel_tijd))"
                            + "  ELSE TO_CHAR(MIN(ro.res_ruimte_opstel_tijd)) ||'-'|| TO_CHAR(MAX(ro.res_ruimte_opstel_tijd))"
                 + "        END"
                 + "  FROM res_ruimte_opstelling ro"
                 + " WHERE ro.res_ruimte_key = res_ruimte_opstelling.res_ruimte_key)",
            "label": L("res_ruimte_opstel_tijd"),
            "typ": "varchar"
        }
    };


    this.list = {
        "columns": [
            "id",
            "bookingroom",
            "bookingconfiguration",
            "capacity",
            "setuptime",
            "isdefault"
        ]
    };
    this.search = {
        "autosearch": true
    };
    this.edit = {
        modal: true
    };


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

}
%>