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

    File:               bez_edit_afspraak_multi_save.asp
    Description:        save script van bez_edit_afspraak_multi.asp
    Globalen:
    Context:
    Note:
*/
var JSON_Result = true;
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/save2db.inc" -->
<!-- #include file="./bez.inc" -->

<%
protectRequest.validateToken();
var afspr_key_arr = getQParamIntArray("afspr_keys");
var warning = "";
var result = {};
var fields = [];

if (Request.Form("actie").Count == 1 && getFParam("check_actie", "off") == "on")
    fields.push({ dbs: "bez_actie_key",  typ: "key",   frm: "actie", track: L("lcl_action"), foreign: "bez_actie" });
if (Request.Form("remark").Count == 1 && getFParam("check_remark", "off") == "on")
    fields.push({ dbs: "bez_afspraak_opmerking", typ: "varchar", frm: "remark", track: L("lcl_vis_remark") });

result = { success : true, refresh: true };

for (var i = 0; i < afspr_key_arr.length; i++)
{
    var afspr_key = afspr_key_arr[i];
    var this_bez = bez.func_enabled_afspraak(afspr_key);
    if (this_bez.canChange)
    {
      var bezUpd = buildTrackingUpdate("bez_afspraak", " bez_afspraak_key = " + afspr_key, fields);
      // Submit the changed fields
      var err = Oracle.Execute(bezUpd.sql, true);
      if (err.friendlyMsg)
        result.warning = err.friendlyMsg;
    }
}

Response.Write(JSON.stringify(result));

ASPPAGE_END();
%>
