<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8"
   import="com.novell.webaccess.common.JSPConduit,
           com.novell.emframe.dev.eMFrameUtils,
           com.novell.emframe.dev.DirUtils,
           com.novell.emframe.fw.FwUtils,
           java.util.ArrayList" %>

<%
   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("FwResources");
%>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<iman:stringtable bundle="FwResources"/>
<iman:stringtable bundle="DevResources"/>

<HTML>
<HEAD>
   <LINK rel="stylesheet" href="<c:out value="${ContextPath}" />/portal/modules/dev/css/hf_style.css">
   <iman:eMFrameScripts/>
   <jsp:include page='<%= c.getPath("dev/HelpScripts_inc.jsp") %>' flush="true" />

      <SCRIPT>

   /*******************
    * FUNCTION HEADER *
    *******************/
   function onExit()
   {
      window.location = "webacc?NPService=fw.LaunchService&NPAction=Return&returnID=<c:out value="${GI_ID}"/>";
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function printFrames()
   {
      for(var i = 0; i < parent.frames.length; i++)
      {
         // We just want to print the content frame
         if(parent.frames[i].name == "Content")
         {
            parent.frames[i].print();
            break;
         }
      }
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function sortByColumn(sortColumn, sortDirection)
   {
      var form = document.TasksToUserReport;
      form.nextState.value = "sortByColumn";
      form.sortColumn.value = sortColumn;
      form.sortDirection.value = sortDirection;
      form.merge.value = "fw.TasksToRoleReport";
      form.submit();
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function highlight(row)
   {
      //row.className = "tablecolumnhead1";
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function unhighlight(row)
   {
      //row.className = "tablecolumnhead1";
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function exportReport()
   {
      // open a new window
      var url = "?merge=fw.RBSReportTypeForm&taskId=<c:out value="${GI_ID}"/>";
      ViewWin=window.open(url, 'Export', 'width=400,height=400,resizable=yes,menubar=yes,scrollbars=yes,status=yes' );
      ViewWin.focus();
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function beforePrint()
   {
      var element = document.getElementById("buttondiv");
      element.style.display = "none";
   }

   /*******************
    * FUNCTION HEADER *
    *******************/
   function afterPrint()
   {
      var element = document.getElementById("buttondiv");
      element.style.display = "block";
   }

   function showHelpWindow()
   {
      launchHelp("fw/taskstorolereport.html");
   }

   window.onbeforeprint=beforePrint
   window.onafterprint=afterPrint

   </SCRIPT>
   </HEAD>
   <BODY>
      <FORM name="TasksToUserReport">
         <INPUT type="hidden" name="nextState">
         <INPUT type="hidden" name="taskId" value="<c:out value="${taskId}"/>">
         <INPUT type="hidden" name="merge">
         <INPUT type="hidden" name="error" value="dev.GenErr">
         <INPUT type="hidden" name="sortColumn" value="<c:out value="${sortColumn}"/>">
         <INPUT type="hidden" name="sortDirection" value="<c:out value="${sortDirection}"/>">
         <div class="margintop3">
            <table width="100%" border="0" cellspacing="0" cellpadding="3" style="white-space: nowrap">
               <tr class="tablehead1">
                  <td colspan="5"  style="border-bottom: 2px solid #458ab9"><%= c.toHTML(c.string("TasksToRoleReport.ReportHeader")) %></td>
                  <td width="5%" align="right"><A href='Javascript:showHelpWindow();'><IMG id=helpimage src='<%= c.getModulesUrl() + "/dev/images/help_16.gif" %>' border="0" width="16" height="16" hspace="3"></A></td>
               </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="3" style="white-space: nowrap">
               <tr class="mediumtext" style="background-color: #efeee9">
                  <td rowspan="2" colspan="3" valign="top">
                     <div class="head2"><%= c.toHTML(c.string("RolesToUserReport.RoleName")) %>: <%= c.toHTML(c.var("selectedRolesDisplayNames")) %></div>
                  </td>
               </tr>
               <tr style="background-color: #efeee9">
                  <td><b><%= c.toHTML(c.string("RolesToUserReport.ReportTime")) %></b></td>
                  <td><%= c.toHTML(c.var("reportTime")) %></td>
               </tr>
            </table>
         </div>
   <table border="0" cellspacing="0" cellpadding="3"  style="width: 100%">
      <tr>
      <!----------------------------------------------------------------->
      <!-------------------------- Task Name ---------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 20%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortTaskName")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskName")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Task Object -------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 30%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortTaskObject")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Role Name ---------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 20%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortRoleName")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleName', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RoleName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleName', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleName', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RoleName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleName', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortRoleName', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.RoleName")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Role Object -------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 30%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortRoleObject")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleObject', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RoleObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleObject', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleObject', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RoleObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortRoleObject', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortRoleObject', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.RoleObject")) %>
               </a>
            <% } %>
         </td>
      <%
         ArrayList reportList = (ArrayList)request.getAttribute( "taskReportData");
         if((reportList == null) || (reportList.size() == 0))
         { %>
            <tr>
               <td class="smalltext" colspan='4' style='padding:30'><i><%= c.toHTML(c.string("TasksToUserReport.EmptyReportList")) %></i></td>
            </tr>
       <% } else { %>
         <c:forEach items="${taskReportData}" var="reportData" varStatus="status">
            <c:if test="${status.count > 0}">
               <TR <c:if test="${status.count % 2 == 0}">bgcolor="#efeee9" </c:if> class="smalltext">
                  <td style="width: 20%"><c:out value="${reportData.taskDisplayName}"/></td>
                  <td style="width: 30%"><c:out value="${reportData.taskFDN}"/></td>
                  <td style="width: 20%"><c:out value="${reportData.roleDisplayName}"/></td>
                  <td style="width: 30%"><c:out value="${reportData.roleFDN}"/></td>
                </TR>
            </c:if>
         </c:forEach>
      <% } %>
     <tr>
         <td class="smalltext" colspan="4">&nbsp</td>
      </tr>
   </table>
         <iman:bar/>
         <div id="buttondiv" style="display: block">
            <iman:button key="OK" onClick="onExit(); return false;"/>
            <iman:button key="Print" onClick="printFrames(); return false;"/>
         <iman:button key="Export" onClick="exportReport(); return false;"/>
         </div>
     </FORM>
   </BODY>
</HTML>
