<%@  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" %>

<%
   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.RolesToUserReport;
      form.nextState.value = "sortByColumn";
      form.sortColumn.value = sortColumn;
      form.sortDirection.value = sortDirection;
      form.merge.value = "fw.UsersToRoleReport";
      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/userstorolereport.html");
   }

   window.onbeforeprint=beforePrint
   window.onafterprint=afterPrint

   </SCRIPT>
   </HEAD>
   <BODY>
      <FORM name="RolesToUserReport">
         <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("UsersToRoleReport.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>
      <!----------------------------------------------------------------->
      <!-------------------------- Role Name ---------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 16%">
            <% 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: 24%">
            <% 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>
      <!----------------------------------------------------------------->
      <!-------------------------- Type --------------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 4%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortType")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortType', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Type")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortType', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortType', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Type")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortType', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortType', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.Type")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Member ------------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 24%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortMember")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortMember', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Member")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortMember', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortMember', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Member")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortMember', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortMember', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.Member")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Scope -------------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 24%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortScope")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortScope', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Scope")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortScope', 'ascending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnA.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } else { %>
                     <a href="#" onClick="javascript:sortByColumn('sortScope', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.Scope")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortScope', 'descending');return false">
                        <img  class="margin5r"
                              src="<%= c.getModulesUrl() + "/dev/images/SortcolumnZ.gif" %>"
                              alt="Down"
                              height="16"
                              width="16"
                              align="absmiddle"
                              border="0">
                     </a>
               <% } %>
            <% } else { %>
               <a href="#" onClick="javascript:sortByColumn('sortScope', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.Scope")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Assigned ----------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 24%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortAssigned")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortAssigned', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RightsAssigned")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortAssigned', '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('sortAssigned', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RightsAssigned")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortAssigned', '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('sortAssigned', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.RightsAssigned")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Inherit ------------------------------>
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 24%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortInherit")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortInherit', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RightsInheritable")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortInherit', '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('sortInherit', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("RolesToUserReport.RightsInheritable")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortInherit', '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('sortInherit', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("RolesToUserReport.RightsInheritable")) %>
               </a>
            <% } %>
         </td>
      </tr>
      <c:forEach items="${roleReportData}" var="reportData" varStatus="status">
         <TR <c:if test="${status.count % 2 == 0}">bgcolor="#efeee9" </c:if> class="smalltext">
            <td style="width: 16%"><c:out value="${reportData.roleDisplayName}"/></td>
            <td style="width: 24%"><c:out value="${reportData.roleFDN}"/></td>
            <td style="width: 4%"><img class="margin5r" src="<%= c.getModulesUrl() + "/dev/images/dir/"%><c:out value="${reportData.memberType}"/>.gif" alt="" height="16" width="16" align="absmiddle" border="0"><c:if test="${reportData.isDGAuxClass == true}"><img class="margin5r" src="<%= c.getModulesUrl() + "/dev/images/dir/dynamicGroup.gif" %>" alt="" height="16" width="16" align="absmiddle" border="0"></c:if></td>
            <td style="width: 24%"><c:out value="${reportData.memberFDN}"/></td>
            <td style="width: 24%"><c:out value="${reportData.scopeFDN}"/></td>
            <td style="width: 4%"><input type="Checkbox" disabled <c:if test="${reportData.rightsSet == true}"> checked </c:if></td>
            <td style="width: 4%"><input type="Checkbox" disabled <c:if test="${reportData.inherited == true}"> checked </c:if></td>
          </TR>
      </c:forEach>
     <tr>
         <td class="smalltext" colspan="7">&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>
