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

    File:               fac_user_info_phone (derived from fac/fac_user_info.asp)
    Description:        Details van een user aka persoon
    Parameters:         prs_key (default user_key)
    Context:            Vanuit de telefoongids
                        Optioneel ook vanuit menu, en is dan altijd Mijn Profiel (geen params, dus user_key)
                        Gestripte versie van fac_user_info.asp
    Note:               Het is VEREIST de prs_key mee te krijgen.
*/ %>
<!--#include file="../Shared/common.inc" -->
<!--#include file="../../appl/shared/iface.inc" -->
<!--#include file="../../appl/prs/prs.inc" -->
<!--#include file="../../appl/prs/prs_flexkenmerk.inc" -->
<%
FCLTHeader.Requires({plugins:["jQuery", "suggest"],
                          js: ["jquery-ui.js"]});


// AUTORISATIEPARAMETERS
  var prs_key = getQParamInt("prs_key", user_key);
  var itsme = (prs_key == user_key);

  var sql = "SELECT prs_srtperslid_key"
          + "  FROM prs_perslid"
          + " WHERE prs_perslid_key = " + prs_key;
  var oRs = Oracle.Execute(sql);
  if (oRs.Eof)
    shared.record_not_found();
  var prs_srtkey = oRs("prs_srtperslid_key").value;
  oRs.Close();
%>
<html>
<head>
<%
  FCLTHeader.Generate();

  var xfunc = user.func_enabled("*", null, null, prs_key);
  var canChange = itsme && xfunc.canWrite("WEB_PROFIL");
  var thisUser = prs.prs_perslid(prs_key, { withWP: true, withWL: true, withPhoto: true }); // geeft ook alle informatie
%>

<script  type="text/javascript" >
  function edit_werkplek(img, pwp_key)
  {
      var url = "../../appl/prs/prs_move_perslidwerkplek.asp?pwp_key=" + pwp_key;
      FcltMgr.openModalDetail(url, "<%=safe.jsstring(thisUser.naam)%>",
                  { callback: function (data) { if (data.wp_aanduiding) {$(img).closest("tr").find("input").val(data.wp_aanduiding);} } });
  }

  function edit_werklocatie(img, prs_key)
  {
      var url = "../../appl/prs/prs_move_huidigewerkplek.asp?prs_key=" + prs_key;
      FcltMgr.openModalDetail(url, "<%=safe.jsstring(thisUser.naam)%>",
                  { callback: function (data) { if (data.wp_aanduiding) {$(img).closest("tr").find("input").val(data.wp_aanduiding);} } });
  }

  function edit_photo(img)
  {
      var url = "<%=protectQS.create("../../appl/shared/BijlagenForm.asp?module=SML&key=" + prs_key)%>";
      FcltMgr.openModalDetail(url, "<%=L("lcl_mrk_upload_foto")%>",
                  { callback: FcltMgr.reload } );
  }

  function edit_phone(inp)
  {
      var url = "../../appl/prs/prs_edit_perslid_modal.asp?prs_key=<%=prs_key%>"
      FcltMgr.openModalDetail(url, "<%=safe.jsstring(thisUser.naam)%>",
                  { callback: function(data) { if (data.refresh) FcltMgr.reload() } });
  }
</script>
</head>

<body id="showbody">
<%
var buttons = [];
if (canChange) {
    buttons.push({ title: L("lcl_change"), icon: "wijzigen.png", action: "edit_phone()", id: "bchange_perslid" });
}
IFRAMER_HEADER("Facilitor Vinder", buttons);
%>
<script  type="text/javascript" >
  $(document).ready(function () {
                FcltMgr.setTitle("<%=itsme ? L("lcl_prs_person_mijndata") : safe.jsstring(thisUser.naam)%>");
            });
</script>
<%

    // ============================= PERSOONSGEGEVENS ======================================
    BLOCK_START("vinderNaw", safe.html(thisUser.naam));
    %>  <tr valign="top">
          <td colspan="2"></td><td rowspan="20">
              <div  style='position:relative;z-index:1'><img id='photo' src="<%=thisUser.photopath %>">
          <% if (S("prs_use_edit_photo") && canChange)
            {%><br>
                    <img src='../../appl/Pictures/wijzigen.png'
                         class='details'
                         title='<%=L("lcl_change")%>'
                         onclick='edit_photo(this)'>
            <% } %></div>
          </td>
        </tr>

<%      AFIELDTR('fldmailto details', L("lcl_prs_person_email"), "mailto:" + thisUser.prs_perslid_email, thisUser.prs_perslid_email, {suppressEmpty: true});
        ROFIELDTR('fld', L("lcl_prs_person_dept_name"), thisUser.prs_afdeling_naam);
        ROFIELDTR('fld', L("lcl_prs_person_function"), thisUser.prs_srtperslid, {suppressEmpty: true});
        ROFIELDTR('fld', L("lcl_prs_person_phone"), thisUser.prs_perslid_telefoonnr, {suppressEmpty: true});

        ROFIELDTR('fld', L("lcl_prs_person_mobile"), thisUser.prs_perslid_mobiel, {suppressEmpty: true});

        for (wp in thisUser.werkplekken) // is reeds gesorteerd op volgnr
        {
            var wpi = thisUser.werkplekken[wp];
            //var infoPointer = {Url:"appl/alg/alg_locatie.asp?key="+wpi.alg_locatie_key(), Title: L("lcl_alg_locatie_frame")};
            var infoPointer = null; // vooralsnog toch maar
            if (!wpi.isVirtueel && S("prs_use_edit_werkplek") < 9 && canChange)
            {   // Reeele eigen werkplekken mogen bewerkt worden.
                %><tr><td class="label">
                        <label class="selector"><%=(wp == 0? L("lcl_prs_workplace") : null)%></label>
                        <span class='labelextra'>
                            <img class='details' src='../../appl/Pictures/wijzigen.png'
                                 title='<%=L("lcl_change")%>'
                                 onclick='edit_werkplek(this, <%=wpi.prs_perslidwerkplek_key%>)'>
                        </span></td>
                       <td><%ROFIELD('fldroom', null, wpi.prs_werkplek_aanduiding,{ infoPointer: infoPointer }); %></td>
                </tr><%
            }
            else
                ROFIELDTR('fldroom', (wp == 0? L("lcl_prs_workplace") : null), wpi.prs_werkplek_aanduiding, {suppressEmpty: true, infoPointer: infoPointer});
        }

        var wl = thisUser.werklocatie.alg_locatie_key? thisUser.werklocatie.aanduiding : "";
        if (canChange)
        {   // Huidige werkplek is een reeele werkplek.
            %><tr><td class="label">
                    <label class="selector"><%=L("lcl_prs_work_location")%></label>
                    <span class='labelextra'>
                        <img class='details' src='../../appl/Pictures/wijzigen.png'
                             title='<%=L("lcl_change")%>'
                             onclick='edit_werklocatie(this, <%=user_key%>)'>
                    </span></td>
                   <td><%ROFIELD('fldworklocation', null, wl); %></td>
            </tr><%
        }
        else
          ROFIELDTR('fld', L("lcl_prs_work_location"), wl, {suppressEmpty: true});

    // ============================= FLEXKENMERKEN =========================================
        generateFlexKenmerkCode({link_key     : prs_key,
                                 srt_key      : prs_srtkey,
                                 niveau       : "P",
                                 flexcolumns  : 1,
                                 reado        : true,
                                 publiconly   : true,
                                 prsauthparams: prs.checkAutorisation(prs_key)
                                });
    BLOCK_END();

    if (itsme && S("prs_use_mld_wijzigkey") > 0)
    {
      BLOCK_START("vinderMelding", "");
        %><tr><td><%
        buttons = [{ title: L("lcl_prs_mld_wijzig"), icon: "briefcase.png", action: "FcltMgr.openDetail('appl/mld/mld_melding.asp?urole=fe&disc="+S("prs_use_mld_wijzigkey")+"', {forcedeep: true})" }];
        CreateButtons(buttons);
        %></td></tr><%
      BLOCK_END();
    }
%>
</body>
</html>
