<%@  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()
   {
      if("<c:out value="${RBSAdmin_RoleType}"/>" == "")
      {
         window.location = "webacc?NPService=fw.LaunchService&NPAction=Return&returnID=<c:out value="${GI_ID}"/>";
      }
      else
      {
         if("<c:out value="${RBSAdmin_RoleType}"/>" == "eGuide")
         {
            var form = document.RoleRightsReport;
            form.nextState.value = "getEguideRolesAndAssignedTasks";
            form.merge.value = "fw.EguideRoleTaskSummary";
            form.submit();
         }
         else
         {
            var form = document.RoleRightsReport;
            form.nextState.value = "getRolesAndAssignedTasks";
            form.merge.value = "fw.RoleTaskSummary";
            form.submit();
         }
         }
   }

   /*******************
    * 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.RoleRightsReport;
      form.nextState.value = "sortByColumn";
      form.sortColumn.value = sortColumn;
      form.sortDirection.value = sortDirection;
      form.merge.value = "fw.RoleRightsReport";
      form.submit();
   }

   /*******************
    * 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/rolerightsreport.html");
   }

   window.onbeforeprint=beforePrint
   window.onafterprint=afterPrint

      </SCRIPT>
   </HEAD>
   <BODY>
      <FORM name="RoleRightsReport">
         <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}"/>">
         <input type=hidden name="selectedRoleDisplayName" value="<c:out value="${selectedRoleDisplayName}"/>">
         <input type=hidden name="selectedRoleFDN" value="<c:out value="${selectedRoleFDN}"/>">
         <input type=hidden name="RBSAdmin_RoleType" value="<c:out value="${RBSAdmin_RoleType}"/>">
         <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("RoleRightsReport.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("selectedRoleDisplayName")) %></div>
                  </td>
                  <td><b><%= c.toHTML(c.string("RolesToUserReport.ReportTime")) %></b></td>
                  <td><%= c.toHTML(c.var("reportTime")) %></td>
               </tr>
               <tr class="mediumtext" style="background-color: #efeee9">
                  <td colspan="3" align="left" valign="top">
                     <div><b><%= c.toHTML(c.string("RolesToUserReport.RoleObject")) %>: </b><%= c.toHTML(c.var("selectedRoleFDN")) %> </div>
                  </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: 25%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortTaskName")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'ascending');return false">
                        <%=c.toHTML(c.string("TasksToUserReport.TaskName"))%>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'ascending');return false">
                        <img  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">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskName', 'descending');return false">
                        <img  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">
                        <%= 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">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'ascending');return false">
                        <img  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">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortTaskObject', 'descending');return false">
                        <img  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">
                        <%= c.toHTML(c.string("TasksToUserReport.TaskObject")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Attribute Name------------------------>
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 25%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortAttributeName")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortAttributeName', 'ascending');return false">
                        <%= c.toHTML(c.string("RoleRightsReport.AttrName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortAttributeName', 'ascending');return false">
                        <img  src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortAttributeName', 'descending');return false">
                        <%= c.toHTML(c.string("RoleRightsReport.AttrName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortAttributeName', 'descending');return false">
                        <img  src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt=""
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortAttributeName', 'descending');return false">
                  <%= c.toHTML(c.string("RoleRightsReport.AttrName")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Privilege ---------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 20%"><%= c.toHTML(c.string("RoleRightsReport.Privilege")) %></td>

      <%
         ArrayList reportList = (ArrayList)request.getAttribute( "roleRightsReportData");
         if((reportList == null) || (reportList.size() == 0))
         { %>
            <tr>
               <td class="smalltext" colspan='4' style='padding:30'><i><%= c.toHTML(c.string("SimpleTableView.noItems")) %></i></td>
            </tr>
       <% } else { %>
         <c:forEach items="${roleRightsReportData}" 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: 25%"><c:out value="${reportData.taskDisplayName}"/></td>
                  <td style="width: 30%"><c:out value="${reportData.taskFDN}"/></td>
                  <td style="width: 20%"><c:out value="${reportData.attrName}"/></td>
                  <td style="width: 25%"><c:out value="${reportData.privDisplayName}"/></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>
