<%@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: FcltMgr.reload });
  }

  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: FcltMgr.reload });
  }

  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: FcltMgr.reload });
  }
</script>
</head>

<body class="showmode">
<%
SUBFRAME_START();
var buttons = [];
if (canChange) {
    buttons.push({ title: L("lcl_change"), icon: "fa-fclt-edit", action: "edit_phone()", id: "bchange_perslid" });
}
IFRAMER_HEADER("Facilitor Vinder", buttons);  // Harde titel
%>
<script type="text/javascript">
  $(function ()
  {
    FcltMgr.setTitle("<%=itsme ? L("lcl_prs_person_mijndata") : safe.jsstring(thisUser.naam)%>");
  });
</script>
<%

    // ============================= PERSOONSGEGEVENS ======================================
    var inlineEdits = true;
    var btns =  [];
        if(thisUser.werkplekken.length == 1)
        {
          if (S("prs_use_edit_werkplek") < 9 && canChange)
          {
            inlineEdits = false;
            btns.push({ icon: "fa-fclt-edit", title: L("lcl_workplace"), action: "edit_werkplek(this, " + thisUser.werkplekken[0].prs_perslidwerkplek_key + ")", importance: 2});
          }
        }
        if(canChange){
          btns.push({ icon: "fa-fclt-edit", title: L("lcl_prs_work_location"), action: "edit_werklocatie(this, " + user_key + ")", importance: 2});
        }
    BLOCK_START("vinderNaw", thisUser.naam, { buttons: btns, icon: "fa-address-card" });
        Response.write("<tr>"
                      + " <td style='text-align: right'></td>"
                      + " <td class='profile' style='display: flex;align-items: flex-end;'>"
                      + "   <span class='wrapper-span'>"
                      + "     <img id='photo' alt='" + safe.htmlattr(L("fac_profiel")) + " " + safe.htmlattr(L("lcl_photos")) + "' "
                      + (         (S("prs_use_edit_photo") && canChange) ? "onclick='edit_photo(this)'" : "")
                      +             " style='cursor: pointer;' class='profile' src='"
                      +             safe.htmlattr(thisUser.photopath) + "'>"
                      + (     (S("prs_use_edit_photo") && canChange) ?
                               "<span id='editAnim' class='image-edit' title='" + L("lcl_change") + "' onclick='edit_photo(this)'>"
                      +             I("fa-fclt-edit")
                      + "       </span>"                               : "")
                      + "   </span>"
                      + " </td>"
                      +"</tr>");

        ROFIELDTR("fld", L("lcl_prs_person_email"), thisUser.prs_perslid_email, { suppressEmpty: true, type: "email" });
        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, type: "telefoon" });
        ROFIELDTR("fld", L("lcl_prs_person_mobile"), thisUser.prs_perslid_mobiel, { suppressEmpty: true, type: "telefoon" });

        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>
                        <% if(inlineEdits){ %>
                        <span class='labelextra'>
                          <span title='<%=L("lcl_change")%>' onclick='edit_werkplek(this, <%=wpi.prs_perslidwerkplek_key%>)'><%=I("fa-fclt-edit")%></span>
                        </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>
                  </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",
                                 reado        : true,
                                 includepublic: true,
                                 prsauthparams: prs.checkAutorisation(prs_key)
                                });
    BLOCK_END();

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