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

     File:          opdr_edit_note_save.asp
     Description:   Het echte bewaren van een opdracht notitie, zonder interactie
     Parameters:    opdr_key   opdrachtnummer
                    note_key   notitie key
                    note       notitie tekst
     Context:       Vanuit opdr_edit_note.asp

*/
var JSON_Result = true;

var opdr_key = getQParamInt("opdr_key");
var mailed = getQParamInt("mailed", 0);

var LOCKED_USER_OK = { "xmlnode": "opdracht", "key": opdr_key };
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/save2db.inc" -->
<!-- #include file="mld.inc" -->
<!-- #include file="opdr_edit_note.inc" -->
<%
protectRequest.validateToken();

var note_key = getQParamInt("note_key", -1);
var result   = {};

var note            = getFParam("note", "");
var note_parent_key = getFParamInt("parent_key", -1);
var fromModule      = getFParamSafe("module", "opdr");

var has_zichtbaarFE = getFParam("has_zichtbaarFE", 0 ) == 1;
var zichtbaarFE     = getFParam("zichtbaarFE", "off" ) == "on";
var has_notifyFE    = getFParam("has_notifyFE", 0 ) == 1;
var notifyFE        = getFParam("notifyFE", "off" ) == "on";
var has_action2FE   = getFParam("has_action2FE", 0 ) == 1;
var action2FE       = getFParam("action2FE", "off" ) == "on";

if (!has_zichtbaarFE && (notifyFE || action2FE))
    zichtbaarFE = true;

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_zichtbaarUITV    = getFParam("has_zichtbaarUITV", 0 ) == 1;
var zichtbaarUITV        = getFParam("zichtbaarUITV", "off" ) == "on";
var has_notifyUITV       = getFParam("has_notifyUITV", 0 ) == 1;
var notifyUITV           = getFParam("notifyUITV", "off" ) == "on";
var has_action2UITV      = getFParam("has_action2UITV", 0 ) == 1;
var action2UITV          = getFParam("action2UITV", "off" ) == "on";

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

result = opdr_note_save(opdr_key,
                        {   note:               note,
                            note_key:           note_key,
                            note_parent_key:    note_parent_key,
                            fromModule:         fromModule,

                            has_zichtbaarFE:    has_zichtbaarFE,
                            zichtFE:            zichtbaarFE,
                            has_notifyFE:       has_notifyFE,
                            notifyFE:           notifyFE,
                            has_action2FE:      has_action2FE,
                            action2FE:          action2FE,

                            has_notifyBO:       has_notifyBO,
                            notifyBO:           notifyBO,
                            has_action2BO:      has_action2BO,
                            action2BO:          action2BO,

                            has_zichtbaarUITV:  has_zichtbaarUITV,
                            zichtUITV:          zichtbaarUITV,
                            has_notifyUITV:     has_notifyUITV,
                            notifyUITV:         notifyUITV,
                            has_action2UITV:    has_action2UITV,
                            action2UITV:        action2UITV,

                            fac_note_group_key: fac_note_group_key,
                            ismailnote:         mailed
                        });

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

ASPPAGE_END(); %>
