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

    File:        prs_phonebook.asp (formerly phone_book.asp;29)

    Description:   Toont frontend zoekvelden voor lijst van personen (telefoongids)
    Parameters:    {NADER UITWERKEN}
    Context:       Vanuit menu
    Note:
                    TODO: overdreven checks op parameters verschonen.
                          default-actie definieren (optioneel personendetails)
                          mode 4?
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->
<!-- #include file="../Shared/functieselector.inc" -->
<%
// suggest en jQuery worden door persoonselector.inc, plaatsselector.inc en afdelingselector.inc al als plugin toegevoegd
// plaatsselector.js wordt door plaatsselector.inc als js script toegevoegt
FCLTHeader.Requires({plugins:["jQuery", "kenmerk"],
                     js: []});

/***** Get webform parameters *****/
  var autfunction = "WEB_PHONEB";
  var authparams = user.checkAutorisation(autfunction);
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">
      function startSearch(mode)
      {
        if (mode==4) // Overige telefoons is een usrrap
        {
          var url = "../fac/fac_usrrap_list.asp?key=<%=S("phone_usrrap_key")%>&sqlWhere=";
<%        if (S("prs_plaats_key") == -1)
          { %>
            var loc_key = $('#locatiekey').val();
            var bld_key = $('#gebouwkey').val();
            if (bld_key > 0)
            {
              url += "FCLT_3D_GEBOUW_KEY=" + bld_key;
            }
            else
              if (loc_key > 0)
              {
                  url += "FCLT_3D_LOCATIE_KEY=" + loc_key;
              }
<%        } %>
          window.document.getElementById("workFrame").src = url;
          return;
        }

        document.forms.u2.mode.value = String(mode);

        doSubmitWithKenmerken();
        return;
      }

      function advanced()
      {
        var lvl = "P";
        var key = 0;
        var prs_key = "";
        var url = "load_kenmerk.asp?disc=" + "&urole=bo" + "&advanced=1" + "&hasFilter=1" + "&link_key=" + prs_key + "&niveau=" + lvl;
        showKenmerkModal(url, "<%=L("lcl_properties")%>");
      }
      $(function()
      {
        FcltMgr.setTitle(L("lcl_pb_filterblok"));
      });
    </script>

  </head>
  <body id="searchbody">
    <form method="get" action="prs_phonebook_list.asp" target="workFrame" name="u2" onsubmit='startSearch(1);return false'>
      <% SEARCH_PAGE_START({ header: L("lcl_filterblok") + " <span id='phonebookteaser'>" + S("prs_phonebook_info") + "</span>", ishtmlsafe: true });
      SEARCH_BLOCK_START();%>
            <input type="hidden" name="user_key" value="<%=user_key%>">
              <tr class="primsearch">
                <td class="label">
                    <label for="naam"><%=L("lcl_name")%></label><input type="hidden" name="mode"></td>
                <td><input type="text" class="fld wildcard" id="naam" name="Naam"></td>
              </tr>
              <tr class="primsearch">
                <td class="label"><label for="telefoon"><%=L("lcl_pb_phone")%></label></td>
                <td><input type="text" class="fld wildcard" id="telefoon" name="Telefoon"></td>
              </tr>
<%
// TODO #ifdef UWVA#20021
if (S("ph_cust_flexsearch_key") > 0) // 1193
{
     sql = "SELECT k.fac_kenmerkdomein_key kenmerkdomein_key"
          + "  FROM prs_kenmerk k"
          + " WHERE prs_kenmerk_key = " + S("ph_cust_flexsearch_key");
     var oRs = Oracle.Execute(sql);
     kenmerkdomein_key = oRs("kenmerkdomein_key").value;
     oRs.Close();
%>
    <tr class="primsearch">
        <td class="label"><label for="Suggestcust_flex_show"><%=L("lcl_pb_cust_flexsearch")%></label></td>
        <td><input type='text' id='Suggestcust_flex_show' name='Suggestcust_flex_show' value='' class='fld'>
    <input type='hidden' id='cust_flexval' name='cust_flexval'>
     <script type="text/javascript">
      $(function()
      {
        Suggestcust_flex = new Suggest({objectName: "Suggestcust_flex",
                                        queryField: $("#Suggestcust_flex_show")[0],
                                        queryUrl: "../shared/Suggest/SuggestKenmerkDomein.asp?module=PRS&kenmerkdomein_key=<%=kenmerkdomein_key%>",
                                        initKey: '',
                                        keyField: $("#cust_flexval")[0]
                                      });

      });
    </script>
    </td>
    </tr>
<%
}

              if (S("prs_plaats_key") == -1) // Gewone locatie listbox
              {
                  FCLTplaatsselector(authparams.ALGreadlevel, { locatiekey: null,
                                                                startlevel: 2, // locatie
                                                                eindlevel: 4, // verdieping
                                                                whenEmpty: L("lcl_search_generic"),  // want filter
                                                                filtercode: "FAC"
                                                              });
              }
              else
              { %>
                <tr class="primsearch">
                  <td class="label"><label for="place"><%=L("lcl_location")%></label></td>
                  <td><input type="text" class="fld wildcard" name="place"></td>
                </tr>
<%            }
SEARCH_BLOCK_END();
SEARCH_BLOCK_START();
             if (S("prs_ph_bedrijf") == 1)
              { // TODO: ook de autorisatie betrekken (bedenk: bedrijf "Boventallig?")
                sql = "SELECT prs_bedrijf_key"
                    + ", prs_bedrijf_naam"
                    + " FROM prs_v_aanwezigbedrijf"
                    + " WHERE prs_bedrijf_intern = 1"
                    + " ORDER BY 2"
                FCLTselector("bedrijf", sql,
                             { label: L("lcl_company"),
                               emptyOption: "",
                               trclass: "primsearch",
                               whenEmpty: L("lcl_search_generic")  // want filter
                             });
              }
              FCLTafdelingselector("dept",
                               "dept",
                               { label: L("lcl_prs_organisatie"),
                                 autlevel: authparams.PRSreadlevel, // Was voorheen niet aanwezig
                                 filtercode: "A", // Alleen afdelingen die personen bevatten
                                 whenEmpty: L("lcl_search_generic")
                               });
              %>
              <tr class="primsearch">
                <td class="label"><label for="nivwc"><%=L("lcl_pb_organization") %></label></td>
                <td><input type="text" class="fld wildcard" id="nivwc" name="nivwc" value=""></td>
              </tr>
<%            if (S("phone_show_functie"))
              {
                FCLTfunctieselector("func", "func" ,
                                        {label: L("lcl_prs_person_function"),
                                         filtercode: "E", // only existing
                                         whenEmpty: L("lcl_search_generic")  // want filter
                                        });
              }
              CHECKBOXTR(L("lcl_pb_photo"), "fldchkphoto", "pb_photo", 0, { trclass: "primsearch"});
              %>
<%    SEARCH_BLOCK_END();

      var buttons =  [ {title: L("lcl_search_pers"), action:"startSearch(1)", id:"bSearchP", icon: "fa-users", importance: 1 } ];
      if (S("ph_loc_search")) {
        buttons.push({title: L("lcl_search_org"), action:"startSearch(2)", id:"bSearchL", icon: "fa-location-arrow", importance: 2 } );
      }
      if (S("ph_bedr_search")) {
        buttons.push({title: L("lcl_search_bedr"), action:"startSearch(3)", id:"bSearchB", icon: "fa-industry", importance: 2 } );
      }
      if (S("phone_usrrap_key")>-1) {
        buttons.push({title: L("lcl_pb_customrapport"), action:"startSearch(4)", id:"bSearchC", icon: "fa-list", importance: 2 } );
      }

      buttons.push({title: L("lcl_shared_advanced"), action:"advanced()", id:"bAdvanced", icon: "fa-filter", importance: 3 });
      SIMPLE_BLOCK_START();
        CreateButtons(buttons, {entersubmit: true, showIcons: true});
      SIMPLE_BLOCK_END();
      SEARCH_PAGE_END();
%>
      </form>


    <div id="result">
      <iframe width="100%" height="100%"
              src="../Shared/empty.asp"
              name="workFrame" id="workFrame"
              onload='FcltMgr.iframeLoaded(this)'
              frameborder="0" scrolling="no">
      </iframe>
    </div>
</body>
</html>
<% ASPPAGE_END(); %>
