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

   window.onbeforeprint=beforePrint
   window.onafterprint=afterPrint

   </SCRIPT>
   </HEAD>
   <BODY>
      <FORM name="CustomCategoriesReport">
         <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("CustomCategoriesReport.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><b><%= c.toHTML(c.string("RolesToUserReport.ReportTime")) %></b>
                  <%= c.toHTML(c.var("reportTime")) %></td>
               </tr>
            </table>
         </div>
   <table border="0" cellspacing="0" cellpadding="3"  style="width: 100%">
      <tr>
      <!----------------------------------------------------------------->
      <!-------------------------- Category Name ---------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 17%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortCategoryName")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryName', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryName', '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('sortCategoryName', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryName")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryName', '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('sortCategoryName', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryName")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Category Object -------------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 22%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortCategoryObject")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryObject', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryObject', '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('sortCategoryObject', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCategoryObject', '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('sortCategoryObject', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CategoryObject")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Collection Object--------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 22%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortCollectionObject")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortCollectionObject', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CollectionObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCollectionObject', '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('sortCollectionObject', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CollectionObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCollectionObject', '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('sortCollectionObject', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("CustomCategoriesReport.CollectionObject")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Creator Object--------------------->
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 22%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortCreatorObject")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortCreatorObject', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CreatorObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCreatorObject', '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('sortCreatorObject', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CreatorObject")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortCreatorObject', '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('sortCreatorObject', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("CustomCategoriesReport.CreatorObject")) %>
               </a>
            <% } %>
         </td>
      <!----------------------------------------------------------------->
      <!-------------------------- Creation Date ------------------------>
      <!----------------------------------------------------------------->
         <td nowrap valign="bottom" class="tablecolumnhead1" style="width: 17%">
            <% if (c.var("sortColumn").equalsIgnoreCase("sortDate")) { %>
               <% if (c.var("sortDirection").equalsIgnoreCase("descending")) { %>
                     <a href="#" onClick="javascript:sortByColumn('sortDate', 'ascending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CreationDate")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortDate', '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('sortDate', 'descending');return false"
                                 onmouseover="highlight(this)"
                                 onmouseout="unhighlight(this)">
                        <%= c.toHTML(c.string("CustomCategoriesReport.CreationDate")) %>
                     </a>
                     <a href="#" onClick="javascript:sortByColumn('sortDate', '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('sortDate', 'descending');return false"
                           onmouseover="highlight(this)"
                           onmouseout="unhighlight(this)">
                  <%= c.toHTML(c.string("CustomCategoriesReport.CreationDate")) %>
               </a>
            <% } %>
         </td>

      <%
         ArrayList reportList = (ArrayList)request.getAttribute( "customCategoryReportData");
         if((reportList == null) || (reportList.size() == 0))
         { %>
            <tr>
               <td class="smalltext" colspan='4' style='padding:30'><i><%= c.toHTML(c.string("CustomCategoriesReport.EmptyReportList")) %></i></td>
            </tr>
       <% } else { %>
         <c:forEach items="${customCategoryReportData}" 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: 17%"><c:out value="${reportData.categoryDisplayName}"/></td>
                  <td style="width: 22%"><c:out value="${reportData.categoryFDN}"/></td>
                  <td style="width: 22%"><c:out value="${reportData.collectionFDN}"/></td>
                  <td style="width: 22%"><c:out value="${reportData.creatorFDN}"/></td>
                  <td style="width: 17%"><c:out value="${reportData.creationDate}"/></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>
