<%@language = "javascript" %>
<% /*
    $Revision$
    $Id$

    File:           mld_stdmelding.asp

    Description:    fac_management aanroep van model_mld_stdmelding

    Context:

    Notes:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../api2/model_mld_stdmelding.inc" -->
<%
var canImport = (user.checkAutorisation("WEB_IMPORT", true) != null);
if (mode != "save" && mode != "delete" && mode != "api2")
{
%>
    <script>
        var mode = "<%=mode%>";
    </script>
<%
}

var stdmld_key = -1;
var model = getQParamSafe("model", "");
if (!model) {
    stdmld_key = getQParamInt("id", -1);
}
var this_model = new model_mld_stdmelding();

var this_params = {
    "search": {
        "autosearch": true,
        "filters": [
            "disciplinetype",
            "discipline",
            "description",
            "issuegroup"
        ],
        "transit": [
            "disciplinetype",
            "discipline",
            "issuegroup"
        ],
        "requires": {
            "js": ["../mgt/mld_stdmelding.js"]
        }
    },
    "list": {
        "columns": [
            "id",
            "disciplinetype",
            "discipline",
            "description",
            "accepttime",
            "processingtime",
            "issuegroup",
            "costtype",
            "service",
            "expires"
        ],
        "orderby": [
            "disciplinetype",
            "discipline",
            "description",
            "issuegroup",
            "costtype",
            "service"
        ]
    },
    "edit": {
        "requires": {
            "js": [
                "jQuery-ui.js",
                "../mgt/srtinstallatieselector.js",
                "../mgt/mld_stdmelding.js"
            ]
        }
    }
    ,
    "layout": {
        "block": [
            {
                "blockid": "mldStdMld",
                "label": L("lcl_mld_standaardmelding"),
                "icon": "fa-tag",
                "ishtmlsafe": true,
                "hidden": false,
                "buttons": [],
                "fields": [
                    "disciplinetype",
                    "discipline",
                    "description",
                    "sequence",
                    "subjectlist",
                    "freetext",
                    "issuegroup",
                    "notfrontend",
                    "canholdthirdparty",
                    "notify",
                    "mandatorylevel",
                    "ownrooms",
                    "costtype",
                    "costcentre",
                    "canrefer",
                    "expires",
                    "externnr"
                ]
            },
            {
                "blockid": "mldRunTime",
                "label": L("lcl_mld_run_time"),
                "icon": "fa-stopwatch",
                "fields": [
                    "regime",
                    "accepttime",
                    "processingtime",
                    "monitorsla",
                    "roomtypedependant",
                    "criticalaccept",
                    "criticaltime",
                    "highpriorityaccept",
                    "highprioritytime",
                    "lowpriorityaccept",
                    "lowprioritytime",
                    "bypriomatrix",
                    "plannable",
                    "plannablefrontend",
                    "_actiondate",
                    "fixedmalus",
                    "periodmalus",
                    "maximummalus"
                ]
            },
            {
                "blockid": "mldHand",
                "label": L("lcl_mld_stdbehandeling"),
                "icon": "fa-construction",
                "fields": [
                    "conceptstatus",
                    "bytag",
                    "noteparticipants",
                    "default_mld_ins_disc",
                    "checksimilar",
                    "immediateready",
                    "copyable",
                    "closingtext"
                ]
            },
            {
                "blockid": "mldObjD",
                "label": L("lcl_mld_obj_details"),
                "icon": "fa-hand-point-right",
                "fields": [
                    "showobject",
                    "personalobjects",
                    "departmentobjects",  // --> personalobjectscope
                    "statusobjrequired",
                    "objectsallowed"
                ]
            },
            {
                "blockid": "mldOpdrD",
                "label": L("lcl_mld_opdr_details"),
                "icon": "fa-money-check-edit",
                "fields": [
                    "service",
                    "requireservice",
                    "ordertypemandatory",
                    "ordertype",
                    "autoorder",
                    "autoorderamount",
                    "limitcatalogue",
                    "enddateempty"
                ]
            },
            {
                "blockid": "mldOverig",
                "label": L("lcl_mld_overig"),
                "icon": "fa-clipboard",
                "fields": [
                    "hint",
                    "externallink",
                    "symbolname",
                    "colors",
                    "survey",
                    "code",
                    "theme"
                ]
            },
            {
                "blockid": "mldHidden",
                "label": L("lcl_mld_hidden_fields"),
                "hidden": true,
                "fields": [
                    "_limitlabel"
                ]
            }
        ]
    }
};

if (canImport) {
    this_params.list.roundtripCode = "MLD";
}

if (stdmld_key > -1)
{
    this_params.wrap = {"frames": [] };

    var sql = "SELECT s.ins_srtdiscipline_ins"
            + "     , s.ins_srtdiscipline_alg"
            + "  FROM mld_stdmelding m"
            + "     , ins_tab_discipline d"
            + "     , ins_srtdiscipline s"
            + " WHERE m.mld_ins_discipline_key = d.ins_discipline_key"
            + "   AND d.ins_srtdiscipline_key = s.ins_srtdiscipline_key"
            + "   AND m.mld_stdmelding_key = " + stdmld_key;
    var oRs = Oracle.Execute(sql);
    var has_ins = oRs("ins_srtdiscipline_ins").Value == 1; // Vakgroeptype; objectgegevens?
    var has_alg = oRs("ins_srtdiscipline_alg").Value > 0;  // Vakgroeptype; plaatsgegevens?
    oRs.Close();

    if (has_ins) {
        this_params.wrap.frames.push({
            url: "mld_stdmelding_srtinst.asp?mode=list&issuetype={0}",
            title: L("mld_stdmelding_srtinst_m"),
            autfunction: "WEB_MLDMGT"
        });
    }

    if (has_alg && user.checkAutorisation("WEB_MLDMGT", true))
    {
        this_params.wrap.frames.push({
            url: "../mgt/mld_stdmsrtruimte.asp?mode=list&stdmelding=" + stdmld_key,
            title: L("lcl_mld_overrule_srtruimte"),
            autfuncton: "WEB_MLDMGT"
        });
        this_params.wrap.frames.push({
            url: "../mgt/mld_stdmsrtgebouw.asp?mode=list&stdmelding=" + stdmld_key,
            title: L("lcl_mld_overrule_srtgebouw"),
            autfuncton: "WEB_MLDMGT"
        });
        this_params.wrap.frames.push({
            url: "../mgt/mld_stdmsrtterreinsector.asp?mode=list&stdmelding=" + stdmld_key,
            title: L("lcl_mld_overrule_srtterrein"),
            autfuncton: "WEB_MLDMGT"
        });
    }
    if (!has_alg && this_model.includes && this_model.includes.roomfunctions) {
        delete this_model.includes.roomfunctions;
    }
}

scaffolding(this_model, this_params);

%>
<% ASPPAGE_END(); %>
