<%@ language = "JavaScript" %>
<% /*
    $Revision$
    $Modtime: 2-02-12 12:25 $
    File:               mld_statusupdate.asp
    Description:        A deeplink call from the reports section of Facilitor to finalize calls.
    Parameters:
        meldingnr       Id of the mld_melding
        mld_status      Key of the requested mld_statusses
    Context:            Client specific file to handle a deeplink call.
    Note:
*/ %>
<%
DOCTYPE_Disable = 1;
%>
<!-- #include file="../../appl/Shared/common.inc"-->
<!-- #include file="../../appl/Shared/json2.js" -->
<!-- #include file="../../appl/Shared/funcodes.inc" -->
<%
  message = "Melding is niet aangepast";
  var mld_melding_key = -1;
  var meldingnr = getQParamInt("meldingnr", -1);
  var mld_status = getQParamInt("mld_status", -1);
__Log('voor select');
  sql = " SELECT mld_melding_key, mld_melding_status, mld_melding_afgerond FROM mld_melding WHERE mld_melding_key = " + meldingnr;

  oRs = Oracle.Execute(sql);
  if (!oRs.eof) {
    // meldingnummer is gevonden
    mld_melding_key = oRs('MLD_MELDING_KEY').value;
    mld_melding_status = oRs('MLD_MELDING_STATUS').value;
    mld_melding_afgerond = oRs('MLD_MELDING_AFGEROND').value;

__Log('Melding status: ' + mld_melding_status);
    if (mld_status == 6 && mld_melding_status == 5 && mld_melding_afgerond == 1) {
      // melding verwerken kan alleen voor afgeronde meldingen en ALLEEN door geautoriseerde medewerkers!
__Log('voor func_enabled');
      if (func_enabled["WEB_USER06"]) 
      {
        message = 'Melding ' + mld_melding_key + ' is bevroren.';
        // melding verwerken
        sql = "BEGIN mld.setmeldingstatus("+ mld_melding_key +", 6, " + user_key + "); END;";
        Oracle.Execute(sql);
      }
    }
    result = { success : true, message : message };
    Response.Write(JSON.stringify(result));
  }
%>
