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

     File:          mld_edit_note_save.asp
     Description:   Het echte bewaren van een melding notitie, zonder interactie
     Parameters:    mld_key    Meldingnummer
                    note_key   notitie key
                    note       notitie tekst
     Context:       Vanuit mld_edit_note.asp, queuemail.asp en pda/notitie.asp

*/
var JSON_Result = true;

var mld_key = getQParamInt("mld_key");
var mailed = getQParamInt("mailed", 0);
var LOCKED_USER_OK = { "xmlnode": "melding", "key": mld_key };
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/save2db.inc" -->
<!-- #include file="mld.inc" -->
<!-- #include file="mld_edit_note.inc" -->
<%
protectRequest.validateToken();

var notestamp         = getFParamDate("notestamp", new Date());
var note_key          = getQParamInt("note_key", -1);
var note_parent_key   = getFParamInt("parent_key", -1);
var has_zichtbaarFE   = getFParam("has_zichtbaarFE", 0 ) == 1;
var zichtbaarFE       = getFParam("zichtbaarFE", "off" ) == "on";
var has_notifyBO      = getFParam("has_notifyBO", 0 ) == 1;
var notifyBO          = getFParam("notifyBO", "off" ) == "on";
var has_action2BO     = getFParam("has_action2BO", 0 ) == 1;
var action2BO         = getFParam("action2BO", "off" ) == "on";
var has_assume_not_ok = getFParam("has_assume_not_ok", 0 ) == 1;
var assume_not_ok     = getFParam("assume_not_ok", "off") == "on";

var fac_note_group_key = getFParamInt("fac_note_group_key", null );
if (fac_note_group_key == -1)
{
     fac_note_group_key = null;
}

var changedby = note_recently_changed(mld_key, notestamp);

var result = mld_note_save( mld_key,
                            getFParam("note", ""),
                            { note_key:           note_key,
                              note_parent_key:    note_parent_key,
                              has_zichtbaarFE:    has_zichtbaarFE,
                              zichtFE:            zichtbaarFE,
                              notifyFE:           getFParam("notifyFE", "off" ) == "on",
                              notifyFEchild:      getFParam("notifyFEchild", "off" ) == "on",
                              notifyExt:          getFParam("notifyExt", "off" ) == "on",
                              action2FE:          getFParam("action2FE", "off" ) == "on",
                              has_action2BO:      has_action2BO,
                              action2BO:          action2BO,
                              has_notifyBO:       has_notifyBO,
                              notifyBO:           notifyBO,
                              has_assume_not_ok:  has_assume_not_ok,
                              assume_not_ok:      assume_not_ok,
                              fac_note_group_key: fac_note_group_key,
                              ismailnote:         mailed
                            });

result.success = true;

if (changedby)
    result.warning = L("lcl_mld_is_updatedby").format(changedby);

Response.Write(JSON.stringify(result));
%><% ASPPAGE_END(); %>
