<%@ taglib uri="struts-bean"  prefix="bean"  %>
<%@ taglib uri="struts-html"  prefix="html"  %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="vkc-taglib"   prefix="vkc"   %>
<%@ page import="vkc.view.TabId" %>
<%@ page import="vkc.statistics.ChartGenerator" %>
<%@ page import="java.io.PrintWriter" %>
<vkc:init/>
<html:html locale="true">
<head>

    <title>Show Statistics</title>

    <vkc:cssinclude />

    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'   />"></script>
    <script type="text/javascript" src="<vkc:rewrite page='/common/overlib/overlib.js'/>"><!-- overLIB (c) Erik Bosrup --></script>

    <script type="text/javascript">

    window.name = "MAINVIEW";

    var currentCalendar = null;
    var associatedTabId = <%=TabId.ADMIN_SHOWSTATISTICS_TAB%>;
    	
    function init() {
      	var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];

        if (tabView && tabView.systemviewtype == "administrationview" && tabView.selectedTabId != associatedTabId) {
          	tabView.location.replace("<%=ctxPath%>/adminTabView.do?selectedTabId=<%=TabId.ADMIN_SHOWSTATISTICS_TAB%>"
          						   + "&lastCategoryId=" + tabViewForm.lastCategoryId.value
          						   + "&lastFunctionalId=" + tabViewForm.lastFunctionalId.value
          						   + "&lastProjectId=" + tabViewForm.lastProjectId.value);
        }

        setAnchor();
    }

    function setAnchor() {
        <logic:present parameter="anchor">
            <bean:parameter id="anchor2" name="anchor"/>
            this.location.hash = '<%=anchor2%>';
        </logic:present>
    }

    function unloadPage() {
    }

    </script>

</head>

<body onload="init();" onUnload="unloadPage();" topmargin="0" marginheight="0">
<table width="100%" align="center" cellspacing="0" cellpadding="0" border="0">
  <html:form action="/showStatistics" method="post">
  <bean:define id="form" name="showStatisticsForm" scope="request" type="vkc.statistics.form.ShowStatisticsForm"/>
  <logic:notEmpty name="form" property="day">
    <html:hidden name="form" property="day"/>
  </logic:notEmpty>
  <logic:notEmpty name="form" property="month">
    <html:hidden name="form" property="month"/>
  </logic:notEmpty>
  <logic:notEmpty name="form" property="year">
    <html:hidden name="form" property="year"/>
  </logic:notEmpty>

  <tr>
    <td>
	  <center>
	  <table border="0">
		<tr>
		  <td align="left">&nbsp;</td>  
		  <td align="center"><b><vkc:message key="vkc.statistics.documents.countDocs" /></b></td>
		  <td align="right">&nbsp;</td>  
		</tr>
		  <td align="left">&nbsp;</td>  
          <td align="center"><html:checkbox name="form" property="cumulate" onclick="submit();" /><vkc:message key="vkc.statistics.cumulate" /></td>
		  <td align="right">&nbsp;</td>  
		<tr>
		  <td align="left"><a href="<%=ctxPath%><vkc:write name="form" property="predecessorLink" />"><<</a></td>  
		  <td align="center">
		    <logic:notEmpty name="form" property="month">
		      <logic:notEmpty name="form" property="day">   
		        <vkc:link page='<%= "/showStatistics.do?year=" + form.getYear()%>' style="font-weight:normal;"><vkc:write name="form" property="year"/></vkc:link>&nbsp;
		        <vkc:link page='<%= "/showStatistics.do?year=" + form.getYear() +"&month=" + form.getMonth()%>' style="font-weight:normal;"><vkc:write name="form" property="month"/></vkc:link>&nbsp;
		        <vkc:write name="form" property="day"/>
		      </logic:notEmpty>
		      <logic:empty name="form" property="day">   
		        <vkc:link page='<%= "/showStatistics.do?year=" + form.getYear() %>' style="font-weight:normal;"><vkc:write name="form" property="year"/></vkc:link>&nbsp;
		        <vkc:write name="form" property="month"/>
		      </logic:empty>          
		    </logic:notEmpty>
		    <logic:empty name="form" property="month">   
		      <vkc:write name="form" property="year"/>
		    </logic:empty>          
		  </td>
		  <td align="right"><a href="<%=ctxPath%><vkc:write name="form" property="successorLink" />">>></a></td>
		</tr>
		<tr>
		  <td colspan="3">
			<%
				String filename = ChartGenerator.generateTimeSeriesChart(request, new PrintWriter(out), form.isCumulate());
				String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;	
			%>
		    <img src="<%=graphURL%>" width="500" height="300" border="0" usemap="#<%=filename%>">
		  </td>
		</tr>
		<tr>
		  <td>&nbsp;</td>
		  <td align="center">
			<logic:notEmpty name="form" property="month">
			  <logic:notEmpty name="form" property="day">
			  <vkc:message key="vkc.statistics.hour"/>
			  </logic:notEmpty>
			  <logic:empty name="form" property="day">
			  <vkc:message key="vkc.statistics.day"/>
			  </logic:empty>
			</logic:notEmpty>
			<logic:empty name="form" property="month">
			  <vkc:message key="vkc.statistics.month"/>
			</logic:empty>
		  </td>
		  <td>&nbsp;</td>
		</tr>
	  </table>
	  </center>
	</td>
  </tr>
<%--

<table cellspacing="1" cellpadding="2" border="0" class='tableLineColor' align='center'>
  <tr class='headerSelected'>
      <td><b><vkc:message key="vkc.statistics.documents"/></b></td>
      <td align="middle"><vkc:message key="vkc.statistics.today"/></td>
      <td align="middle"><vkc:message key="vkc.statistics.thisWeek"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisMonth"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisYear"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.overall"/>&nbsp;</td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.documents.countDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.docStat.countDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.docStat.countDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.docStat.countDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.docStat.countDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.docStat.countDocs"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.documents.amountDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.docStat.formattedAmountDocsInMB"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.docStat.formattedAmountDocsInMB"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.docStat.formattedAmountDocsInMB"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.docStat.formattedAmountDocsInMB"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.docStat.formattedAmountDocsInMB"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.documents.countAuthorsOfDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.docStat.countAuthorsOfDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.docStat.countAuthorsOfDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.docStat.countAuthorsOfDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.docStat.countAuthorsOfDocs"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.docStat.countAuthorsOfDocs"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td colspan="6">&nbsp;</td>
  </tr>
  <tr class='headerSelected'>
      <td><b><vkc:message key="vkc.statistics.categories"/></b></td>
      <td align="middle"><vkc:message key="vkc.statistics.today"/></td>
      <td align="middle"><vkc:message key="vkc.statistics.thisWeek"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisMonth"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisYear"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.overall"/>&nbsp;</td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.categories.countCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.catStat.countCreatedCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.catStat.countCreatedCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.catStat.countCreatedCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.catStat.countCreatedCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.catStat.countCreatedCats"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.categories.countCreatorsOfCats"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.catStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.catStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.catStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.catStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.catStat.countCreators"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td colspan="6">&nbsp;</td>
  </tr>
  <tr class='headerSelected'>
      <td><b><vkc:message key="vkc.statistics.users"/></b></td>
      <td align="middle"><vkc:message key="vkc.statistics.today"/></td>
      <td align="middle"><vkc:message key="vkc.statistics.thisWeek"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisMonth"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.thisYear"/>&nbsp;</td>
      <td align="middle"><vkc:message key="vkc.statistics.overall"/>&nbsp;</td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.users.countNewUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.userStat.countUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.userStat.countUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.userStat.countUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.userStat.countUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.userStat.countUsers"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.users.countActiveUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.userStat.countActiveUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.userStat.countActiveUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.userStat.countActiveUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.userStat.countActiveUsers"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.userStat.countActiveUsers"/></td>
  </tr>
  <tr class='columnUnselected'>
    <td nowrap><vkc:message key="vkc.statistics.users.countNewUsersDAdmin"/></td>
    <td align="right"><vkc:write name="form" property="statistics4Today.userStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentWeek.userStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentMonth.userStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4CurrentYear.userStat.countCreators"/></td>
    <td align="right"><vkc:write name="form" property="statistics4All.userStat.countCreators"/></td>
  </tr>
</table>
--%>
<%--
<br>
<table cellspacing="3" cellpadding="0" border="0" width="100%">
  <tr>
    <td colspan="2" align="center">
      <vkc:button property="action_saveNews" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.save"/></vkc:button>
      <vkc:button property="action_back" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button>
    </td>
  </tr>
</table>
--%>
  </html:form>
</table>
</body>
</html:html>