<% /*
    $Revision$
    $Id$

    File:           model_res_artikel.inc

    Description:    Vanuit CodeCharge gegenereerd model voor res_artikel

    Context:

    Notes:
*/
%>
<!-- #include file="./model_res_kenmerk.inc"-->
<%
function model_res_artikel()
{
    this.records_name = "bookingconsumables";
    this.record_name = "bookingconsumable";
    this.table = "res_artikel";
    this.primary = "res_artikel_key";
    this.soft_delete = "res_artikel_verwijder";
    this.soft_expire = "res_artikel_vervaldatum";
    this.autfunction = "WEB_RESMSU";
    this.record_title = L("res_artikel");
    this.records_title = L("res_artikel_m");


    this.fields = {
        "id": {
            "dbs": "res_artikel_key",
            "label": L("lcl_key"),
            "typ": "key",
            "required": true,
            "seq": "res_s_res_artikel_key"
        },
        "name": {
            "dbs": "res_artikel_omschrijving",
            "label": L("res_artikel_omschrijving"),
            "typ": "varchar",
            "translate": true,
            "required": true,
            "filter": "like"
        },
        "code": {
            "dbs": "res_artikel_nr",
            "label": L("res_artikel_nr"),
            "typ": "varchar"
        },
        "bookingdiscipline": {
            "dbs": "res_discipline_key",
            "label": L("res_discipline_key"),
            "typ": "key",
            "required": true,
            "foreign": {
                "tbl": "(SELECT ins_discipline_key"
                     + "      , ins_discipline_omschrijving"
                     + "   FROM ins_tab_discipline"
                     + "  WHERE ins_discipline_verwijder IS NULL"
                     + "    AND ins_discipline_module='RES'"
                     + "    AND ins_discipline_min_level=2)",
                "key": "ins_discipline_key",
                "desc": "ins_discipline_omschrijving"
            },
            "LOVinit": "",
            "multiedit": true,
            "showtransit": true
        },
        "unit": {
            "dbs": "res_artikel_eenheid",
            "label": L("res_artikel_eenheid"),
            "typ": "varchar",
            "translate": true,
            "multiedit": true
        },
        "price": {
            "dbs": "res_artikel_prijs",
            "label": L("res_artikel_prijs"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true,
            "relativeValuesAllowed": true
        },
        "vat": {
            "dbs": "res_artikel_btw",
            "label": L("res_artikel_btw"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true
        },
        "fixedprice": {
            "dbs": "res_artikel_prijs_vast",
            "label": L("res_artikel_prijs_vast"),
            "typ": "check0",
            "multiedit": true
        },
        "purchaseprice": {
            "dbs": "res_artikel_inkoopprijs",
            "label": L("res_artikel_inkoopprijs"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true
        },
        "staffcosts": {
            "dbs": "res_artikel_kostenpersoneel",
            "label": L("res_artikel_kostenpersoneel"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true
        },
        "generalcosts": {
            "dbs": "res_artikel_kostenalgemeen",
            "label": L("res_artikel_kostenalgemeen"),
            "iscurrency": true,
            "typ": "float",
            "multiedit": true
        },
        "minimumorder": {
            "dbs": "res_artikel_minimum",
            "label": L("res_artikel_minimum"),
            "typ": "number",
            "multiedit": true
        },
        "remark": {
            "dbs": "res_artikel_opmerking",
            "label": L("res_artikel_opmerking"),
            "typ": "memo",
            "translate": true
        },
        "freedescription": {
            "dbs": "res_artikel_vrije_omschrijving",
            "label": L("res_artikel_vrije_omschrijving"),
            "typ": "check0"
        },
        "sequence": {
            "dbs": "res_artikel_volgnummer",
            "label": L("res_artikel_volgnummer"),
            "typ": "number",
            "multiedit": true
        },
        "group": {
            "dbs": "res_artikel_groep",
            "label": L("res_artikel_groep"),
            "typ": "varchar",
            "multiedit": true
        },
        "image": {
            "dbs": "res_artikel_image",
            "label": L("res_artikel_image"),
            "typ": "file",
            "module": "RESPHA"
        },
        "open": {
            "dbs": "res_artikel_begintijd",
            "label": L("res_artikel_begintijd"),
            "typ": "float",
            "LOV": api2.getTimetable(),
            "emptyoption": "Standaard",
            "multiedit": true
        },
        "close": {
            "dbs": "res_artikel_eindtijd",
            "label": L("res_artikel_eindtijd"),
            "typ": "float",
            "LOV": api2.getTimetable(),
            "emptyoption": "Standaard",
            "multiedit": true
        },
        "startdate": {
            "dbs": "res_artikel_ingangsdatum",
            "label": L("res_artikel_ingangsdatum"),
            "typ": "date",
            "multiedit": true
        },
        "expirationdate": {
            "dbs": "res_artikel_vervaldatum",
            "label": L("res_artikel_vervaldatum"),
            "typ": "date",
            "multiedit": true
        },
        "flags": {
            "dbs": "res_artikel_flags",
            "label": L("res_artikel_flags"),
            "typ": "check",
            "multiedit": true
        },
        "externnr": {
            "dbs": "res_artikel_externnr",
            "typ": "varchar",
            "label": L("extern_nr")
        },
        "externsyncdate": {
            "dbs": "res_artikel_externsyncdate",
            "typ": "datetime",
            "label": L("extern_syncdate"),
            "readonly": !(user.has("WEB_FACTAB") || user.has("WEB_FACXNR"))
        }
    };

    var gparams = {
            GET: {
                wheres: ["(res_artikel.res_discipline_key IN (SELECT c.ins_discipline_key FROM res_discipline c where c.ins_discipline_verwijder IS NULL))"]
            }
        };

    // Kenmerk *definities* als include is vrij uitzonderlijk
    this.includes = {
        "custom_properties": {
            "model": new model_res_kenmerk("C", { internal: true }), // Discipline/Catalogus artikel.
            "joinfield": "article",
            "enable_update": true
        }
    };

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