<% /*
    $Revision$
    $Id$

    File:           model_prs_kostencombinatie.inc

    Description:    Vanuit CodeCharge gegenereerd model voor prs_kostencombinatie

    Context:

    Notes:
*/
%>
<%
var costtype_search = getQParam("_name", "");
costtype_search = "%" + costtype_search.toUpperCase() + "%";

function model_prs_kostencombinatie()
{
    this.records_name = "costcombinations";
    this.record_name = "costcombination";
    this.table = "prs_kostencombinatie";
    this.primary = "prs_kostencombinatie_key";
    this.autfunction = "WEB_FINMSU";
    this.record_title = L("prs_kostencombinatie");
    this.records_title = L("prs_kostencombinatie_m");
    this.defaultIcon = "fa-clipboard-check";

    this.fields = {
        "id": {
            "dbs": "prs_kostencombinatie_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "prs_s_prs_kostencombinatie_key"
        },
        "_name": { // Wordt gebruikt om op omschrijving van kostensoort te kunnen zoeken, ipv een listbox
            "dbs": "",
            "label": L("prs_kostensoort_key")+"/"+L("prs_kostensoort_oms"),
            "typ": "varchar",
            "hidden_fld": true,
            "filter": "like"
        },
        "costtype": {
            "dbs": "prs_kostensoort_key",
            "label": L("prs_kostensoort_key"),
            "typ": "key",
            "required": true,
            "foreign": "prs_kostensoort",
            "showtransit": true
        },
        "group": {
            "dbs": "prs_kostenplaatsgrp_key",
            "label": L("prs_kostenplaatsgrp_key"),
            "typ": "key",
            "required": true,
            "foreign": {
                "tbl": "prs_kostenplaatsgrp",
                "key": "prs_kostenplaatsgrp_key",
                "desc": "prs_kostenplaatsgrp_oms"
            },
            "showtransit": true
        }
    };

    this.list = {
        "columns": [
            "costtype",
            "group"
        ]
    };
    this.search = {
        "autosearch": true
    };
    this.edit = {
        "modal": true
    };

    var xmodel = getQParam("model", "");
    if (mode == "list" && xmodel == this.records_name)
    {
        this.REST_GET = generic_REST_GET(this);
    }
    else
    {
        var ext_sql = "(SELECT prs_kostensoort_key"
                    + "      , prs_kostensoort_upper"
                    + "      , prs_kostensoort_opmerking"
                    + "      , prs_kostensoort_refcode"
                    + "   FROM prs_kostensoort"
                    + ") ks";

        this.REST_GET    = generic_REST_GET(this, {
            "GET": {
                "wheres": [ "EXISTS "
                          + "  (SELECT 1 "
                          + "     FROM prs_kostensoort "
                          + "    WHERE     prs_kostensoort.prs_kostensoort_key = "
                          + "              prs_kostencombinatie.prs_kostensoort_key "
                          + "          AND (   prs_kostensoort_upper LIKE " + safe.quoted_sql(costtype_search)
                          + "               OR UPPER (prs_kostensoort_opmerking) LIKE " + safe.quoted_sql(costtype_search)
                          + "               OR UPPER (prs_kostensoort_refcode) LIKE " + safe.quoted_sql(costtype_search)
                          + "))"
                          ]
            }
        });
    }


    this.REST_POST   = generic_REST_POST(this);
    this.REST_PUT    = generic_REST_PUT(this);
    this.REST_DELETE = generic_REST_DELETE(this);
}
%>