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

   Poweruser tool to reset the current use of a specific "flag".
   It will clear all the use of this flag and reset the description for next use

   Vereist WEB_FACFAC
   Parameters:
   - module
   - flag
   - optioneel done to clear window

*/
%>
<!--#include file="../Shared/common.inc"-->
<%
    FCLTHeader.Requires({ plugins:["jQuery"], js: [] });


    var authparams = user.checkAutorisation("WEB_FACFAC");

    var pmodule = getQParamSafe("module");
    var pflagnr = getQParamInt("flag");
    var pdone   = getQParamInt("done", 0) == 1;

    var msg = "";
    if (pflagnr < 0 || pflagnr > 9)
        msg = "Flag must be 0..9";

    switch (pmodule.toUpperCase())
    {
        case "BESTELOPDR":
        case "BEZ":
        case "FIN":
        case "MLD":
        case "OPDR":
        case "RES":  break;
        default: msg = "Bad module";
    }

%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script>
        function doemaar()
        {
            var data = { module: "<%=pmodule%>"
                       , flag: <%=pflagnr%>
                       };
            <% protectRequest.dataToken("data"); %>

            $.post( "fac_resetflag_save.asp"
                  , data
                  , function(rdata)
                        {
                            alert( (rdata.success ? "Done successfully": "Something went wrong") );
                            window.location.href = "fac_resetflag.asp?module=<%=pmodule%>&flag=<%=pflagnr%>&done=1";
                        }
                  , "json"
                  );
        }
        function nietdoen()
        {
            window.location.href = "fac_resetflag.asp?module=<%=pmodule%>&flag=<%=pflagnr%>&done=1";
        }
    </script>
  </head>
  <body>
<%
    if (pdone || msg)
        Response.Write(msg);
    else
    {
        var flagcode = pmodule.toLowerCase()+"_flag"+ pflagnr;
        Response.Write("You are about to reset "+pmodule+"-flag '"+L("lcl_"+flagcode)+"', this cannot be undone..");
        Response.Write("<br>&nbsp;");
        Response.Write("<input type='button' style='border: 2px solid black;' value='Yes, I am sure' onclick='doemaar();'>");
        Response.Write("&nbsp;");
        Response.Write("<input type='button' style='border: 2px solid black;' value='Cancel' onclick='nietdoen();'>");
    }
%>
  </body>
</html>
<% ASPPAGE_END(); %>
