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

    File:           fac_faq.asp
    Status:
    Description:    wrapper voor faq bewerk / show

    Parameters:     faq_key

    Context:
    Note:

*/ %>
<!--#include file="../Shared/common.inc" -->
<!--#include file="../Shared/iface.inc" -->
<!--#include file="fac.inc" -->

<%
FCLTHeader.Requires({plugins:["jQuery", "suggest"], js: ["jquery-ui.js"]})


  var faq_key = getQParamInt("faq_key", -1);
  var fac_title = L("lcl_faq_kennisbank") + " " + faq_key;

  // Frontend mag ingevoerde items bekijken
  // Frontoffice mag items aanmaken en bewerken
  // Backoffice mag ingevoerde items publiceren (publicatie datum zetten/aanpassen)
  var this_faq = fac.func_enabled_faq(faq_key); // Wat heb ik zoal aan rechten op deze specifieke kennisbankitem.

  user.auth_required_or_abort(this_faq.canReadAny);

  var haveOnlyFErights = (!this_faq.canFOread && !this_faq.canBOread && this_faq.canFEread);
  var isProf = this_faq.canFOread || this_faq.canBOread;

  if (faq_key != -1)
  {
    sql= "SELECT 1 FROM alg_locatie WHERE alg_locatie_verwijder is null and ROWNUM = 1";
    oRs = Oracle.Execute(sql);
    var anylocs = !oRs.eof;
    oRs.close();

    if (anylocs)
    {
      sql= "SELECT 1 FROM alg_algfaq WHERE ROWNUM = 1 and fac_faq_key = " + faq_key;
      oRs = Oracle.Execute(sql);
      var hasAnyFaqLocs = !oRs.eof;
      oRs.close();
    }

    sql= "SELECT 1 FROM prs_prsfaq WHERE ROWNUM = 1 and fac_faq_key = " + faq_key;
    oRs = Oracle.Execute(sql);
    var hasAnyFaqBedr = !oRs.eof;
    oRs.close();

    sql= "SELECT 1 FROM mld_stdmeldingfaq WHERE ROWNUM = 1 and fac_faq_key = " + faq_key;
    oRs = Oracle.Execute(sql);
    var hasAnyFaqStdm = !oRs.eof;
    oRs.close();

    sql= "SELECT 1 FROM mld_typeopdrfaq WHERE ROWNUM = 1 and fac_faq_key = " + faq_key;
    oRs = Oracle.Execute(sql);
    var hasAnyFaqTypeopdr = !oRs.eof;
    oRs.close();
  }


%>
<html>
<head>
<%
   FCLTHeader.Generate();
%>
  <script type="text/javascript" >
      <% if (faq_key > 0) { %>
        FcltMgr.setTitle("<%=safe.jsstring(fac_title)%>", {hot:false});
      <% } %>

      function facClose(params)
      {
          <% if (faq_key == -1)
             { %>
              if (params.cancel)
              {
                  FcltMgr.closeDetail(window, params );
                  return true;
              }
              if (!params.keepForm)
                  window.location.href = "fac_faq.asp?verynew=1&faq_key=" + params.faq_key;
          <% } else { /* Bestaand object bewerkt, switch naar show-mode */ %>
              if (params.close)
              {
                FcltMgr.closeDetail(window, { close: true})
              }
              if (!params.keepForm && !params.deleted)
                  $("#facFrame")[0].src = "fac_show_faq.asp?faq_key=<%=faq_key%>";
          <% } %>
      }
    </script>
</head>

<body>
<%
PAGE_START();
if (faq_key == -1)
{
    var page="fac_edit_faq.asp"; // Maak een nieuw
    IFRAMER("facFrame", page, { FcltClose: "facClose", icon: "fa-bookmark", title: L("lcl_faq_item") } );
}
else
{
    var page="fac_show_faq.asp";
    page += "?faq_key=" + faq_key;
    IFRAMER("facFrame", page, { FcltClose: "facClose", icon: "fa-bookmark", title: L("lcl_faq_item") } );

    if (isProf || (haveOnlyFErights && hasAnyFaqStdm))
    {
      page="fac_stdmelding_list.asp";
      page += "?faq_key=" + faq_key;
      IFRAMER("facstdmeldingFrame", page, {FcltClose: "facClose", icon: "fa-list", title: L("lcl_faq_voor_stdmelding") });
    }

    if (isProf || (haveOnlyFErights && hasAnyFaqTypeopdr))
    {
      page="fac_typeopdr_list.asp";
      page += "?faq_key=" + faq_key;
      IFRAMER("factypeopdrFrame", page, {FcltClose: "facClose", icon: "fa-list", title: L("lcl_faq_voor_typeopdr") });
    }

    if (anylocs)
    {
        if (isProf || (haveOnlyFErights && hasAnyFaqLocs))
        {
          page="fac_alg_list.asp";
          page += "?faq_key=" + faq_key;
          IFRAMER("facalgFrame", page, {FcltClose: "facClose", icon: "fa-list", title: L("lcl_faq_voor_alg") });
        }
    }

    if (isProf || (haveOnlyFErights && hasAnyFaqBedr))
    {
      page="fac_prs_list.asp";
      page += "?faq_key=" + faq_key;
      IFRAMER("facprsFrame", page, {FcltClose: "facClose", icon: "fa-list", title: L("lcl_faq_voor_prs") });
    }

    // tracking naar subframe :-)
    if (isProf)
    {
      page = protectQS.create("../shared/status_info.asp?faq_key=" + faq_key + "&urole=" + (isProf? "fo" : "fe"));
      IFRAMER("mldhistoryframe", page, { icon: "fa-list", title: L("lcl_tracking") } );
    }
}
PAGE_END();
%>
</body>
</html>
<% ASPPAGE_END(); %>
