<%@ LANGUAGE="JavaScript" %>
<% /*
     $Revision$
     $Id$

    File:               sup_detail_chk.asp
    Description:        Muteerscherm voor supervisor

    Parameters:         mld_melding_key: key van de melding

    Context:            Vanuit de klantspecifieke rapportage asle_v_work_list_chk_superv

    Note:               Terminologie:

*/ %>


<!-- #include file='../../../appl/scf/scaffolding_m.inc' -->
<!-- #include file='../../../appl/api2/model_issues.inc' -->
<!-- #include file="../../../appl/mld/mld.inc" -->
<!-- #include file="../../../appl/mld/mld_flexkenmerk.inc" -->

<%
    var id = getQParamInt("id");

    var calls = new model_issues(id, { filter: { scope: "bo"}});

    switch (mode)
    {
        case "edit":

            calls.fields["enddate"].label = 'Beschikbaar';
            calls.fields["enddate"].readonly = true;
            calls.fields["issuetype"].label = 'Omschrijving';
            calls.fields["issuetype"].readonly = true;
            calls.fields["remark"].label = 'Afhandeling';

            var cleaning_type = calls.fields["issuetype"].name;


            calls.edit = { fields: [ "enddate", "issuetype", "remark"],
                           buttons: []
                               };

            var mstat = calls.data.status;
            var cleantype_key = calls.data.issuetype.id;

            if (cleantype_key == 41)
            {   // DND
              calls.edit.buttons.push({ label: "NoServ", params: {click: "asle_mReady('NoService')", dataicon: "delete"}});
              calls.edit.buttons.push({ label: "Plan",   params: {click: "asle_mReady('Service')", dataicon: "check"}});
              calls.edit.buttons.push({ label: "Lijst",  params: {click: "asle_mBack()", dataicon: "home"}});
            }
            else
            {
              calls.edit.buttons.push({ label: "Klaar", params: {click: "asle_mReady('Check')", dataicon: "check"}});
              calls.edit.buttons.push({ label: "Plan",  params: {click: "asle_mReady('Service')", dataicon: "check"}});
              calls.edit.buttons.push({ label: "Lijst", params: {click: "asle_mBack()", dataicon: "home"}});
            }

            calls.hook_pre_edit = function (obj)
            {
                calls.record_title = L("lcl_room") + ": " + obj.room.name;
            }
            var scf_params = { "edit": { requires: { js: ["./asle.js"] }}};
            break;

        case "save":
            if (getQParamInt("mClose", 0) == 1)
            {
                // accepteer eerst even de melding, ander mag ik niets wijzigen.
                if (calls.data.status.id == 2) mld.setmeldingstatus(id, 4); // accepteren
                //mld.setmeldingstatus(id, 5);  // afmelden
                calls.data.status.id = 5;
                calls.data.remark = getFParam("remark");
                var cparams = { filter: { "id": id, "scope": "bo"}};
                var restresult = calls.REST_PUT(cparams, calls.data, id);
                var key = restresult.key;
                var warning = restresult.warning;

                var result = { key: key,
                               warning: warning,
                               keepForm: !!warning,
                               success: true };
                Response.Write(JSON.stringify(result));
                Response.End;
            }
            else
            {
                // accepteer eerst even de melding, ander mag ik niets wijzigen.
                if (calls.data.status.id ==  2)
                {
                   mld.setmeldingstatus(id, 4);
                   calls.data.status.id = 4;
                }
                calls.data.remark = getFParam("remark");
                var cparams = { filter: { "id": id, "scope": "bo"}};
                var restresult = calls.REST_PUT(cparams, calls.data, id);
                var key = restresult.key;
                var warning = restresult.warning;

                var result = { key: key,
                               warning: warning,
                               keepForm: !!warning,
                               success: true };
                Response.Write(JSON.stringify(result));
                Response.End;
            }

            break;
        }
        scaffolding(calls, scf_params);

%>
