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

    File:               fac_alg_list.asp
    Description:        Show an overview of alg_locatie & alg_v_onroerendgoed items in list-form,
                        which meets with the given requirements
    Parameters:
    Context:            Include frame for fac_show_faq.
    Note:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/resultset_table_v2.inc" -->
<!-- #include file="../MLD/mld.inc" -->
<!-- #include file="../fac/fac.inc" -->

<%
var outputmode = getQParamInt("outputmode", 0); //  0 = screen, 1 = print, 2 = excel etc
var showall    = getQParamInt("showall", 0) == 1;
var faq_key    = getQParamInt("faq_key");

var sql = "SELECT fac_faq_level"
        + "     , fac_faq_datum"
        + "  FROM fac_faq f"
        + " WHERE fac_faq_key = " + faq_key;
var oRs = Oracle.Execute(sql);
if (oRs.Eof)
    shared.record_not_found("<!--" + faq_key + "-->");

var level = oRs("fac_faq_level").Value;
var datum = oRs("fac_faq_datum").Value;
var mustProf = (level & 1) == 0; // Alleen professionals
oRs.close();

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 addButton = [];

%>
<html>
  <head>
<%  FCLTHeader.Generate({outputmode:outputmode}) %>
    <script type="text/javascript">
      var autosearch = 1; //automatisch laden van resultaat op search pagina

      function prs_prsfaq()
      {
        FcltMgr.openModalDetail("../fac/fac_prsfaq.asp?faq_key=<%=faq_key%>",
                                L("lcl_faq_prsfaq"),
                                { callback: FcltMgr.reload });
      }
    </script>
  </head>
  <body id="listbody">
<%
  function fnrowData(oRs)  // doen we hier wat mee dan?
  {
    var bedrijf_key = oRs("bedrijf_key").Value;
    var afdeling_key = oRs("afdeling_key").Value;

    var data = {bedr_key:bedrijf_key, afd_key:afdeling_key };
    return JSON.stringify(data);
  }

  if (this_faq.canChange)
  {
    addButton = [{icon: "fa-fclt-edit", title: L("lcl_change"), action: "prs_prsfaq()"}];
  }

  var sql = "SELECT f.prs_prsfaq_key"
          + "     , b.prs_bedrijf_naam bedrijf_naam"
          + "     , d.prs_afdeling_naam afdeling_naam"
          + "     , b.prs_bedrijf_key bedrijf_key"
          + "     , COALESCE(d.prs_afdeling_key, -1) afdeling_key"
          + "  FROM prs_prsfaq f"
          + "     , prs_bedrijf b"
          + "     , prs_afdeling d"
          + " WHERE f.prs_bedrijf_key = b.prs_bedrijf_key"
          //+ "   AND b.prs_bedrijf_verwijder IS NULL" strikt genomen, maar dat moet je maar opruimen?
          //+ "   AND b.prs_bedrijf_key = d.prs_bedrijf_key(+)" strikt genomen, maar dat hoeven we hier niet te borgen?
          + "   AND f.prs_afdeling_key = d.prs_afdeling_key(+)"
          + "   AND f.fac_faq_key = " + faq_key;

  var rst = new ResultsetTable({ sql: sql
                               , keyColumn: "prs_prsfaq_key"
                               , ID: "prsfaqtable"
                               , noPrint: true
                               , showAll: showall
                               , rowData: fnrowData
                               , outputmode: outputmode
                               , title: L("lcl_faq_voor_prs")
                               , buttons: addButton
                               });

  rst.addColumn(new Column({caption: L("lcl_company"), content: "bedrijf_naam" }));
  rst.addColumn(new Column({caption: L("lcl_department"), content: "afdeling_naam" }));

  var cnt = rst.processResultset();
%>
    </body>
  </html>

<% ASPPAGE_END(); %>
