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

     File:          message_list.asp, mobile version of fac/fac_user_messages.asp
     Description:   Toont de gebruikersberichten (statusinfo) in een list

    Note:           Komt straks ergens in een submenu te hangen.
                    Een verwijderfunctie zou nog leuk zijn

*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./resultset_table.inc" -->
<!-- #include file="./mobile.inc" -->
<!-- #include file="./iface.inc" -->
<%
var qrc = getQParamInt("qrc", 0) != 0;
var subject = L("lcl_recent_news");
%>
<html>
  <head>
<% FCLTMHeader.Generate({}); %>
  </head>

  <body>
<%
if (user_key != -1)
{
    var sql = "SELECT m.web_user_mess_dsc"
            + ",     sn.fac_srtnotificatie_url"
            + ",     COALESCE(m.web_user_mess_action_params, ' ') web_user_mess_action_params"
            + ",     m.web_user_mess_action_status"
            + ",     m.web_user_mess_action_datum"
            + ",     m.web_user_message_key"
            + ",     web_user_mess_prioriteit"
            + ",     sn.fac_srtnotificatie_xmlnode"
            + " FROM web_user_messages m, fac_srtnotificatie sn"
            + " WHERE (m.prs_perslid_key_receiver = " + user_key
            + "    OR m.prs_perslid_key_receiver IS NULL) "   // General messages
            + " AND sn.fac_srtnotificatie_key(+)=m.fac_srtnotificatie_key"
            + " AND m.web_user_mess_action_datum > SYSDATE - " + 14
            + " ORDER BY m.web_user_mess_action_datum DESC, m.web_user_message_key DESC";


    function fncolLink(oRs)
    {
        var action;
        if (oRs("fac_srtnotificatie_url").Value != null ) {
            //action = oRs("fac_srtnotificatie_url").Value + oRs("web_user_mess_action_params").Value;
            // Hé, dit kan nu via de pseudo-bookmarks!
            action = "../../default.asp?u=" + oRs("fac_srtnotificatie_xmlnode").Value + "&k=" + oRs("web_user_mess_action_params").Value;
            action = action.replace(/\#/g, "&");
        }
        return action;
    };
      function fnUrgentie(oRs)
      {
        var displ = "";
        switch (oRs("web_user_mess_prioriteit").value)
        {
          case 1:  displ = L("lcl_mld_urg_hoog1"); break;
          case 2:  displ = ""; break;
          case 3:  displ = L("lcl_mld_urg_laag1"); break;
        }
        return displ;
      }

      function fncolSubHeader(oRs)
      {
        return  "";
      };

    PAGE_START();
    HEADER({title: subject, back:!qrc, home: !qrc});
    CONTENT_START();

    var rst = new ResultsetTable({sql: sql,
                                   keyColumn: "web_user_message_key",
                                   linkColumn: fncolLink,
                                   headerColumn: "web_user_mess_dsc",
                                   detailColumn: "web_user_mess_action_datum",
                                   asideColumn: fnUrgentie,
                                   ID: "messagestable",
                                   noSearch: true,
                                   showAll: true
                                  });

    var cnt = rst.processResultset();

    CONTENT_END();
    FOOTER();
    PAGE_END();
      }
%>
  </body>
</html>
