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

    File:               shared/Bijlagenform.asp
    Description:        Toon de bijlagen bij een entiteit
    Parameters:
        key             ALG_RUIMTE_KEY of ...
        Module          "ALG" of "CNT" of ...
                        of "FGII" om DWF bestanden te uploaden naar S("flexfilespath") + "/cad/concept"
                        of "FGIIV" om DWF bestanden te uploaden naar S("flexfilespath") + "/cad/vlucht"
                        of "FGIIS" om DWF bestanden te uploaden naar S("flexfilespath") + "/cad/symbols/"
                        of "FGIIP" om DWF bestanden te uploaden naar S("flexfilespath") + "/cad/prj/"<scenario_key>
                        of "INSPHS"/"INSPHD" om JPG bestanden te uploaden naar cust/photos/INS
                        of "RESPHR" om JPG bestanden te uploaden naar cust/photos
        Kenmerk_key     ALG_KENMERK_KEY of ...

        DoDelete        optioneel: bestandsnaam om te verwijderen
        Reado           optioneel: readonly
        encrypt         optioneel: met name "E" voor encrypted
    Context:            Binnen ModalForm.asp als gebruiker knopje "Bijlagen"
                        drukt van een flexkenmerk type "F"/"E"/"M"
                        en/of: self-submit bij verwijderen bestand
                        en/of: FGII specifiek DWF bestanden folder
    Note:               Al de FG-varianten worden altijd oplopend op bestandsnaam gesorteerd.
                        Met TAMPER bescherming!
    TODO: pMulti, Reado en encrypt zelf bepalen uit key, Module, en Kenmerk_key, ach, we hebben tamper bescherming

*/
var pKey = getQParamInt("key", -1);
var pModule = getQParamSafe("module");
var showall = getQParamInt("showall", 0) == 1;
var imp_exp_key = getQParamInt("imp_exp_key", -1);
var pNiveau = getQParamSafe("niveau", "");
var pTmpfolder = getQParam("tmpfolder", "");
if (pModule == "MLD" && pNiveau == "M")
    var LOCKED_USER_OK = { "xmlnode": "melding", "key": pKey };
else if (pModule == "MLD" && pNiveau == "O")
    var LOCKED_USER_OK = { "xmlnode": "opdracht", "key": pKey };
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="./flexfiles.inc" -->

<%

var agent = String(Request.ServerVariables("HTTP_USER_AGENT"));
if (!agent.match(/MSIE \d|Trident/))
{
  FCLTHeader.Requires({ js:["./BijlagenForm_async.js"] });
}

protectQS.verify({ allowparams: ["no_autoscroll", "newfilename"] }); // tamper check

// key of folder wordt doorgegeven

var pKenmerk_key = getQParamInt("kenmerk_key", -1);
var pMulti  = getQParamInt("multi", 0) == 1;
var pReado  = getQParamInt("reado", 0) == 1;
var pCanDelete = getQParamInt("candelete", 1) == 1;

var showFilter = getFParam("showFilter", ""); // zoek mogelijkheid binnen lijst bestanden
var pAlgLevel = getQParam("kenmerk_module", "");

var transitParam = buildTransitParam(["key", "module", "niveau", "kenmerk_key", "encrypt", "extFilter", "pregexp",
                                      "showFilter", "reado", "multi", "tmpfolder", "kenmerk_module",
                                      "zipfile", "autozipfile", "candelete", "imp_exp_key"]);

  // Sorteer afhankelijk van de setting S("flexFilesOrdering") twee FileToAdd record's
  // Hierbij wordt geen onderscheid gemaakt tussen kleine of hoofd letters
  function dateSort(a, b)
  {
    if (new Date(a.date) > new Date(b.date))
      if (S("flexFilesOrdering") == 0) return 1;
      else return -1;
    if (new Date(a.date) < new Date(b.date))
      if (S("flexFilesOrdering") == 0) return -1;
      else return 1;
    return 0;
  }
  // plain sort
  function plainSort(a, b)
  {
    if (new Date(a.date) > new Date(b.date))
      return 1;
    if (new Date(a.date) < new Date(b.date))
      return -1;
    return 0;
  }

params = flexProps(pModule, pKey === -1 ? getQParam("newfilename",  "") : pKey, String(pKenmerk_key), pNiveau, {getFiles: true, showall: showall, alglevel: pAlgLevel, imp_exp_key: imp_exp_key});

//var pregexp = getQParam("pregexp", null);
var default_afmeting = (params.regexp ? params.regexp.substr(1) : "");


if (params.extFilter)
{
    var regFilter = params.extFilter;
    regFilter = regFilter.replace(/( |,|;)/g,"|"); // Altijd | karakter
    regFilter = ".*\\." + "(" + regFilter + ")$"; // er moet een punt voor en extensie is aan het einde
}

function MatchFile(fName)
{
  if (fName.toLowerCase() == "web.config") // die nooit tonen
    return false;

  if (!new RegExp(S("flexAllowedExt"), "ig").test(fName))
    return;

  if (showFilter=="")
      return true;

  //return fName.match(new RegExp(showFilter,"i"));
  return fName.toUpperCase().indexOf(String(showFilter).toUpperCase()) >= 0;
}

var fileArray = []; // Array of file information
for (i=0; i<params.files.length; i++)
{   // filter op filenaam
    if (MatchFile(params.files[i].name))
        fileArray.push(params.files[i]);
}

if (params.pickfile)
    fileArray.sort(plainSort); // Sorteer de bestanden simpel
else
    fileArray.sort(dateSort);  // Sorteer de bestanden

__Log("Zoeken bestanden onder " + params.AttachPath);

%>

<html>
  <head>
  <meta charset="windows-1252">
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      window.return_data = {};
      var clientresize = (typeof createImageBitmap == "function" ? "1" : "0");
      var looseFiles = [];
      var isMultiple;
      var default_afmeting = "<%=safe.jsstring(default_afmeting)%>";
      var values = default_afmeting.split("x");
      var dragonCount = 0;
      default_afmeting_width = parseInt(values[0]);
      default_afmeting_height = parseInt(values[1]);

      var isAdvancedUpload = function() {
        var div = document.createElement("div");
        return (("draggable" in div) || ("ondragstart" in div && "ondrop" in div)) && "FormData" in window && "FileReader" in window;
      }();

      $(function() {
        isMultiple = $("input#file-upload").attr("multiple") ? 1 : 0;
        $body = $("body#mod_bijlagen");
        if (isAdvancedUpload) {
          $body.addClass("droppable")
          .on("drag dragstart dragend dragover dragenter dragleave drop", function(e) {
            e.originalEvent.dataTransfer.dropEffect = "copy";
            e.preventDefault();
            e.stopPropagation();
          })
          .on("dragover dragenter", function(e) {
            if (document.forms.u2.imgfile) // Anders betreft het een enkel bestand die al gevuld is.
                $body.addClass("dragon");
          })
          .on("dragleave dragend drop", function(e) {
            $body.removeClass("dragon");
          })
          .on("drop", function(e) {
            dragonCount++;
            addFiles(e.originalEvent.dataTransfer, null, dragonCount);
          });
        }

        // Does not work in lte IE 11
        $(document).on("paste", function (e)
        {
          var data = (e.originalEvent || e).clipboardData;

          if (data.items.length && data.items[0].type.indexOf("image") !== -1)
            addFiles(data.items[0], "ctrlv");
        });
      });

      function safeFilename(s)
      {
        return s.replace(/[\x00-\x1F|\/|\\|\*|\%\<\>\"\:\;\?\|\+]+/g, "_");
      }

      function addFiles(fileInput, source, dragonCount)
      {
        if (document.forms.u2.imgfile){ // Anders betreft het een enkel bestand die al gevuld is.
          if (source == "ctrlv")
          {
            looseFiles = [fileInput.getAsFile()]; // List of File instead of FileList
            document.getElementById("displayFilename").innerText = fileInput.getAsFile().name;
            FcltMgr.resized();
            iface.button[looseFiles.length ? "enable" : "disable" ]("btn_upload_submit");
          }
          else
          {
            var looseFilesBuffer = [];
            looseFilesBuffer = $.extend(true, {}, fileInput.files);

            for(var i = 0; i < looseFilesBuffer.length; i++){
              looseFiles.push(fileInput.files[i]);
            }
            displayFilename(fileInput, looseFilesBuffer, dragonCount);
            iface.button[fileInput.files && fileInput.files.length ? "enable" : "disable"]("btn_upload_submit");
          }
        }
      }

      function FindFile(fname)
      {
        document.forms.finder.action="<%=protectQS.create("Bijlagenform.asp?x=x" + transitParam)%>";
        document.forms.finder.target="_self";
        document.forms.finder.submit();
      }
<%    if (pCanDelete)
      { %>
        function DeleteFile(fname, safeDeleteurl)
        {
          FcltMgr.confirm(L("lcl_delete") + " " + safeFilename(fname) + "?", function() {
              var data = {};
              protectRequest.dataToken(data);
              $.post(safeDeleteurl,
                  data,
                  FcltCallbackRefresh
              );
          });
        }
<%    } %>

      function validateFile(file)
      {
        // Controleer extenties
<%      if (params.extFilter) { %>
            if (!new RegExp("<%=safe.jsstring(regFilter)%>", "ig").test(file.name))
            {
                FcltMgr.alert(L("lcl_shared_file_ext_invalid_start") + "<%=safe.jsstring(params.extFilter)%>" + L("lcl_shared_file_ext_invalid_end"));
                return false;
            }
<%      } %>
        if (!new RegExp("<%=safe.jsstring(S("flexAllowedExt"))%>", "ig").test(file.name))
        {
            FcltMgr.alert(L("lcl_shared_file_ext_not_allowed"));
            return false;
        }
<%      if (S("asp_max_upload") > 0) { %>
            // Controleer maximale grootte
            if (file.size > <%=S("asp_max_upload")%>)
            {
                FcltMgr.alert(L("lcl_shared_size_exceeded").format(file.name, "<%=S("asp_max_upload")%>"));
                return false;
            }
<%      } %>
        return true;
      }

      function doSubmitUpload()
      {
        var fileList = looseFiles.length ? looseFiles : document.forms.u2.imgfile.files;
        var loopFiles = isMultiple ? fileList.length : (fileList.length ? 1 : 0); // JGL: nnFiles was een betere naam geweest?

        if (document.forms.u2.imgfile.value == "" && !looseFiles.length)
            return false;
        if (clientresize == 1)
        { // all browsers except Internet Explorer
            asyncCall(fileList, loopFiles, default_afmeting_width, default_afmeting_height);
        }else{ // Internet Explorer
            console.log("unsupported browser detected for resizing image.");
            validate(fileList, loopFiles);
        }

      }

      function validate(fl, loopFiles) {

      // File(s) valideren
      for (var i = 0; i < loopFiles; i++)
      {
          if (!validateFile(fl[i]))
              return false;
      }

      // Controleer of het te uploaden bestand al bestaat.
      var tName = "";
      var equals = [];
      var fRow = $("td div#filename a", "#filetable");

      if (fRow.length)
          for (var x = 0; x < loopFiles; x++)
          {
              for(var y = 0; y < fRow.length; y++)
              {
                tName = fRow[y].innerText.replace(/^\s+|\s+$/g,""); // spaties ervoor en erachter verwijderen.
                fName = safeFilename(fl[x].name.toLowerCase());
                if (tName.toLowerCase() == fName)
                {

                  equals.push(tName);

                  break;
                }
              }
          }
  <%      if (!pCanDelete)
      { %>
      if (equals.length)
          FcltMgr.alert(L("lcl_shared_file_no_overwrite"));
      else
  <%      } %>
      FcltMgr.confirm((equals.length > 1 ? L("lcl_shared_files_replace") : L("lcl_shared_file_replace")).format(equals.join(", ")),
                        { autoconfirm: !equals.length,
                          fncancel: function() { /* geen actie bij confirm=cancel */ }
                        },
                        function()
                        {   // confirm=OK
                          iface.button.disable("closeButton");
                            $("#uploading").show();
                            FcltMgr.resized();

                            document.forms.u2.action = "<%=protectQS.create("UploadForm_save.asp?action=insert" + transitParam)%>" + "&clientresize=" + clientresize;

                            if (looseFiles.length || fl.length)
                            {
                                $form = $("form[name=u2]");
                                var ajaxData = new FormData();
                                if (looseFiles.length)
                                {
                                    for (var i = 0; i < loopFiles; i++){
                                        ajaxData.append("imgfile", fl[i]);
                                    }
                                }
                                else // fl.length
                                {
                                    for (var i = 0; i < fl.length; i++){
                                        ajaxData.append("imgfile", fl[i]);
                                    }
                                }
                                ajaxData.append("<%=protectRequest.theVar%>", "<%=safe.htmlattr(protectRequest.theToken())%>");
                                $.ajax({
                                    url: $form.attr("action"),
                                    type: $form.attr("method"),
                                    data: ajaxData,
                                    cache: false,
                                    contentType: false,
                                    processData: false,
                                    success: FcltCallbackAndThen(uploadDone)
                                  });
                            }
                            else
                            {
                              document.forms.u2.submit(); // JGL: Wat doet deze submit als je geen files hebt?
                            }
                        }
                      );

      }

      // handle asynchronous bitmap compressing within an Object
      var BitmapCompressor = function(file, fstr) {
        var _file = file;
        var _fstr = fstr;
        var that = this;
        this.complete = false;          // true when finished
        this.complete_success = false;  // true when finished with success
        this.success = function(response) {
          displayFilenameCb(response, _fstr);
          that.complete = true;
          that.complete_success = true;
        };
        this.catch = function(err) {
          resp = {};
          resp.width = "0px";
          resp.height = "0px";
          displayFilenameCb(resp, fstr); //name cant be retrieved.
          that.complete = true;
          that.complete_success = false;
        };
        //Spot where it still crashes
        if (default_afmeting && fstr.match(/\.(jpg|jpeg)$/i) && typeof createImageBitmap == 'function') {
          console.log("Getting size for " + fstr)
          createImageBitmap(_file).then(that.success).catch(that.catch);
        } else{
          var response = {};
          response.width = "0px";
          response.height = "0px";
          displayFilenameCb(response, _fstr);
          that.complete = true;
          that.complete_success = true;
        }
        //that.success;
        FcltMgr.resized();
      }

      function displayFilename(fileInput, lfb, dragonCount)
      {
          var fstr = "";
          var files = fileInput.files;
          var loopNames = isMultiple ? files.length : (files.length ? 1 : 0);
          var bitmap_compressor_array = [];

          var dfn = document.getElementById("displayFilename");
          if(lfb){
            if(lfb.length === 1){

            }else {
              dfn.innerHTML = "";
            }
          }else{
            dfn.innerHTML = "";
          }

          if((dfn.childElementCount + 1) !== dragonCount){
            // Er is een mixture van drag en selecteren gebruikt. Dan de preview maar goed houden.
            dfn.innerHTML = "";
          }

          for (var i = 0; i < loopNames; i++) {
            fstr = safeFilename(files[i].name);
            bitmap_compressor_array.push(new BitmapCompressor(files[i], fstr));
          }
          // compression is of all files is complete when all the objects in bitmap_compressor_array return complete == true
          FcltMgr.resized();
      }

      function displayFilenameCb(img, fileString){
        var dfn = document.getElementById("displayFilename");

        var fs = document.createElement("a");
        fs.innerText = fileString;

        var resizeOptions = document.createElement("div");
        resizeOptions.id = "file-size-" + fileString;

        var originalSizeOpt = document.createElement("input");
        originalSizeOpt.id = "file-original-size-" + fileString.replace(".", "_");
        originalSizeOpt.type = "radio";
        originalSizeOpt.name = "imgresize-" + fileString.replace(".", "_");
        originalSizeOpt.style.float = "right";
        originalSizeOpt.style.marginTop = "4px";

        var osotxt = document.createElement("a");
        osotxt.innerHTML = L("lcl_attachment_bigger").format(img.width, img.height); //lcl hier
        osotxt.style.float = "right";
        osotxt.onclick = function () {
          originalSizeOpt.checked = true;
          normalSizeOpt.checked = false;
        };

        var normalSizeOpt = document.createElement("input");
        normalSizeOpt.id = "file-normal-size-" + fileString.replace(".", "_");;
        normalSizeOpt.type = "radio";
        normalSizeOpt.name = "imgresize-" + fileString.replace(".", "_");;
        normalSizeOpt.checked = true;
        normalSizeOpt.style.float = "right";
        normalSizeOpt.style.marginTop = "4px";

        var nsotxt = document.createElement("a");
        nsotxt.innerHTML = L("lcl_attachment_normal").format(default_afmeting_width, default_afmeting_height); //lcl hier
        nsotxt.style.float = "right";
        nsotxt.style.paddingRight = "10px";
        nsotxt.onclick = function () {
          originalSizeOpt.checked = false;
          normalSizeOpt.checked = true;
        };

        resizeOptions.appendChild(fs);
        if(default_afmeting !== ""){
          if(img.width >= default_afmeting_width || img.height >= default_afmeting_height){
            resizeOptions.appendChild(osotxt);
            resizeOptions.appendChild(originalSizeOpt);
            resizeOptions.appendChild(nsotxt);
            resizeOptions.appendChild(normalSizeOpt);
          }
        }
        dfn.appendChild(resizeOptions);
        FcltMgr.resized();
      }

      function uploadDone(data)
      {
        var uploaded_files = data.safefilename;
        for (i = 0; i < uploaded_files.length; i++) {
          FcltMgr.topmanager().window.$.toast({ loaderBg: "#fff", text: L("lcl_appendix_added").format(safe.html(uploaded_files[i])), icon: "success", position: "top-center"});
        }
        let extraTransitParam = "";
<%      if (pKey === -1 && "linkImmediate" in params && !params.multi) { %>
        extraTransitParam = "&newfilename=" + encodeURIComponent(uploaded_files[0].replace(/\.dwf$/, ""));
<%      } %>
        window.location = "<%=protectQS.create("BijlagenForm.asp?x=x" + transitParam)%>" + extraTransitParam;
      }

      function Sluiten(defVal)
      {
        if ($("#closeButton").hasClass("btn_disabled"))
        {
          FcltMgr.alert(L("lcl_busy_upload_file"));
        }
        var unUploadedFiles = (looseFiles.length ? looseFiles.length : (document.forms.u2.imgfile ? document.forms.u2.imgfile.files.length : 0));
        FcltMgr.confirm(L("lcl_shared_unfinished_uploads"),
                          { autoconfirm: !unUploadedFiles,
                            fncancel: function() { /* geen actie bij confirm=cancel */ }
                          },
                          function()
                          {
                            window.return_data.org_data=FcltMgr.dialogArguments();
                            if (defVal) {
                                window.return_data.fileName = defVal;
                                delete window.return_data.multi;
                            }
                            FcltMgr.closeDetail(window, return_data);
                          });
      }

    </script>
  </head>

  <body class="fclt-modal" id="mod_bijlagen" onLoad="FcltMgr.resized();">
<%    if (params.pickfile || params.searchfile) // Zoekveldje erboven
      { // Eigen formpje vanwege andere encoding
      SIMPLE_BLOCK_START();
%>
      <form name="finder" method="post" target="_self">
        <div class="simple-content-wrapper">
          <div class="input-button-wrapper">
            <input type="text" name="showFilter" class="fld" value="<%=safe.htmlattr(showFilter)%>">
<%
            buttons = [];
            buttons.push({ title: L("lcl_search"), action: "FindFile()", importance: 1, icon: "fa-search" });
            CreateButtons(buttons);
%>
          </div>
        </div>
      </form>
<%    SIMPLE_BLOCK_END();
      }
    if (params.tooManyFiles)
        Response.Write("<p>Only 1000 files shown</p>");
%>
    <form name="u2" method="post" enctype="multipart/form-data">
<%
MODAL_BLOCK_START("bijlagen", L("lcl_appendixes"), { icon: "fa-paperclip" });
%>
      <thead>
        <tr>
          <th><%=L("lcl_filename")%></th>
          <th style="text-align:right"><%=L("lcl_filedate")%></th>
          <th style="text-align:right"><%=L("lcl_filesize")%></th>
<%        if (!pReado && pCanDelete)
          { %>
            <th><%=L("lcl_filedelete")%></th>
<%        } %>
        </tr>
      </thead>
      <tbody id="filetable">
<%
          // De array fileArray is al goed gesorteerd.
          for (var i = 0; i < fileArray.length; i++)
          {
            var faName = fileArray[i].name;
            %>
            <tr>
              <td>
<%              if (params.pickfile)
                { //onclick levert tekening naam op
%>
                  <a onClick="FcltMgr.closeDetail(window, { success: true, fileName: '<%=safe.jsstring(fileArray[i].name)%>'})">
                    <%=safe.html(faName)%>
                  </a>
<%              }
                else
                { %>
                  <div id="filename">
                  <a href="#" onclick='parent.FcltMgr.windowopen("<%=protectQS.create(OpenFlexFile(pModule, fileArray[i].key, { name: fileArray[i].name, niveau: pNiveau, kenmerk_key: pKenmerk_key, tmpfolder: pTmpfolder, key: pKey} )+"&doSave=1")%>"); return false;'>
                    <%=safe.html(faName)%>
                  </a>
                </div>
<%              } %>
              </td>
              <td align="right"><%=toDateTimeString(fileArray[i].date)%></td>
              <td align="right"><%=fileArray[i].size%></td>
<%            if (!pReado && (!params.keephistory || fileArray[i].ishistory) && pCanDelete)
              { %>
                <td align="center">
                <span class="default-clickable-icon" onClick="DeleteFile('<%=safe.jsstring(safe.html(fileArray[i].name))%>', '<%=safe.jsstring(protectQS.create("Bijlagenform_delete.asp?DoDelete="+Server.URLEncode(fileArray[i].name)+transitParam))%>')"
                    title="<%=L("lcl_filedelete")%>"><%=I("fa-trash-alt")%>
                  </span>
                </td>
<%            } %>
            </tr>
<%        }
        if (fileArray.length == 0 && !params.pickfile)
        { %>
          <tr>
            <td colspan="5"><%=L("lcl_nofiles")%></td>
          </tr>
<%      } %>
<%
      var buttons = [];
      if (!pReado && (pMulti || params.multi || fileArray.length == 0)) // Uploadknop erbij
      {
        buttons.push({ title: L("lcl_do_upload_file"), action: "doSubmitUpload()", singlepress: true, id: "btn_upload_submit", icon: "fa-cloud-upload"});
        var isMultiple = (((pMulti || params.multi) && !params.forcesingle) ? "multiple" : "");
%>      <tr><td colspan="4">
          <div class="dragdrop">
            <%=I("fa-sign-in-alt fa-rotate-90")%>&nbsp;<%=(isMultiple ? L("lcl_drag_files") : L("lcl_drag_file"))%>&nbsp;<%=L("lcl_fac_api_of")%>
            <br><label for="file-upload" class="uploadbutton"><%=I("fa-upload")%>&nbsp;<%=L("lcl_select_file")%></label>
<%          if (!regFilter || new RegExp(regFilter, "ig").test("png")) { %>
            <script>
              // window.clipboardData is only supported in IE whereas our functionality to Ctrl+V a PrtScr exists only outside of IE
              if (typeof window.clipboardData == "undefined") // = Not Internet Explorer
              {
                document.write("<br>" + I("fa-clipboard") + "&nbsp;" + L("lcl_fac_api_of") + "&nbsp;" + L("lcl_paste_screenshot"));
              }
            </script>
<%          } %>
          </div>
          <div id="displayFilename"></div>
          <% if (params.extFilter) {
            Response.Write(L("lcl_allowed_extensions") + ": " + safe.html(params.extFilter.split("|").join(" ")));
          } %>
              <input id="file-upload" type="file" <%=isMultiple%> name="imgfile" style="width: 95%" onchange="looseFiles=[];displayFilename(this);iface.button[this.value?'enable':'disable']('btn_upload_submit')">

          <div id="uploading" style="display:none">
                  Please wait...
          </div>
      </td>

      </tr>
<%    } %>

      </tbody>

      <script type="text/javascript">
            window.return_data = {
              success: true,
              cnt: <%=fileArray.length%>,
              multi: <%=params.multi ? "true" : "false"%>,
              fileName: "<%=safe.jsstring(fileArray.length > 0? fileArray[0].name : "")%>"
<%          if (fileArray.length === 1) { %>
            , deleteUrl: "<%=protectQS.create(rooturl + "/appl/Shared/Bijlagenform_delete.asp?DoDelete=" + Server.URLEncode(fileArray[0].name) + transitParam)%>"
            , deepUrl: "<%=protectQS.create(rooturl + "/appl/shared/BijlagenStream.asp?module=" + pModule + "&key=" + pKey + "&filename=" + Server.URLEncode(fileArray[0].name))%>"
<%          } %>
            };
            FcltMgr.setCloseParams(window.return_data); // Zelfs als je kruisje gebruikt
            $(function ()
              {
                iface.button.disable("btn_upload_submit");
              }
            );
      </script>
<%    MODAL_BLOCK_END();

      if (pModule === "STYLE") {
        buttons.push({id: "greyscale", title: L("lcl_fac_template_greyscale"), action: "Sluiten('## grijstint ##')", icon: "fa-circle-half-stroke far"});
        buttons.push({id: "transparent", title: L("lcl_fac_template_transparent"), action: "Sluiten('## transparant ##')", icon: "fa-square-dashed"});
      }

      buttons.push({id: "closeButton", title: L("lcl_window_done"), action: "Sluiten()", icon: "fa-fclt-save"});

      SIMPLE_BLOCK_START();
        CreateButtons(buttons);
      SIMPLE_BLOCK_END();
IFACE.FORM_END();
%>

    </form>
</body>
</html>
