%
/******************************************************************************
* Copyright (c) 2000-2005 e-Deal
*
* e-Deal S.A.
* 55 rue Brillat Savarin
* 75013 Paris
* France
*
* T: +33 (0)1 53 80 80 30
* F: +33 (0)1 73 01 69 77
* http://www.e-deal.com
*
* La diffusion de ce code source sous quelque forme que ce soit sans
* l'autorisation de E-DEAL est interdite.
*
* Vous êtes autorisés à modifier ce code source uniquement pour votre usage
* propre et sous réserve que les mentions de copyright demeurent intactes.
*
* Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou
* implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour
* responsable des dommages pouvant résulter de l'utilisation de ce code
* source.
******************************************************************************/
%><%@page session="true" contentType="text/plain" %><%@ page import="com.edeal.frontline.FlContext" %><%@ page import="com.edeal.frontline.DataDictionary" %><%@ page import="com.edeal.frontline.Utils" %><%@ page import="com.edeal.frontline.navigation.FlRequest" %><%@ page import="java.util.Vector" %><%@ page import="java.util.GregorianCalendar" %><%@ page import="java.util.Date" %><%@ page import="javax.servlet.jsp.JspPage" %><%@ page import="javax.servlet.jsp.JspFactory" %><%@ page import="java.util.Hashtable" %><%@ page import="java.util.Calendar" %><%@ page import="java.text.SimpleDateFormat" %><%@ page import="java.util.Locale" %><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><%
final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
FlRequest flRequest = new FlRequest(request);
FlContext context = flRequest.getContext();
Vector list = (Vector)flRequest.getAttribute("list");
String pDate = Utils.getRequestParameter(context, request, "date");
GregorianCalendar cal = new GregorianCalendar();
if (pDate != null && !"".equals(pDate)) {
cal.setTime(Utils.formatFromWeb(pDate));
}
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Date begDate = cal.getTime();
%>
var _element;
<% if (list.size() > 40) {
StringBuffer buf = new StringBuffer();
buf.append("");
buf.append(Utils.getMessage(session, "L63E6", true, "Trop de résultats. Veuillez limiter votre recherche."));
buf.append("");
%>
_element = document.getElementById('errorMessage');
_element.innerHTML = '<%= buf.toString() %>';
_element = document.getElementById('controlRow');
if (_element != null) _element.style.display = 'none';
_element = document.getElementById('campYearRow');
if (_element != null) _element.style.display = 'none';
<% for (int row = 0; row < 40; ++row) { %>
_element = document.getElementById('campYearRow<%= row %>');
if (_element != null) _element.style.display = 'none';
<% }
return;
} else {
%>
_element = document.getElementById('errorMessage');
_element.innerHTML = '';
<% }
cal.setTime(begDate);
cal.add(Calendar.MONTH, -3);
%>
_element = document.getElementById('campDoubleLeft');
if (_element != null) _element.href= 'javascript:goTo(\'<%= Utils.formatToWebDate(cal.getTime(), false) %>\')';
<%
cal.setTime(begDate);
cal.add(Calendar.MONTH, -1);
%>
_element = document.getElementById('campLeft');
if (_element != null) _element.href= 'javascript:goTo(\'<%= Utils.formatToWebDate(cal.getTime(), false) %>\')';
<%
cal.setTime(begDate);
cal.add(Calendar.MONTH, 1);
%>
_element = document.getElementById('campRight');
if (_element != null) _element.href= 'javascript:goTo(\'<%= Utils.formatToWebDate(cal.getTime(), false) %>\')';
<%
cal.setTime(begDate);
cal.add(Calendar.MONTH, 3);
%>
_element = document.getElementById('campDoubleRight');
if (_element != null) _element.href= 'javascript:goTo(\'<%= Utils.formatToWebDate(cal.getTime(), false) %>\')';
_element = document.getElementById('controlRow');
if (_element != null) _element.style.display = '';
<%
cal.setTime(begDate);
SimpleDateFormat sdf = new SimpleDateFormat("MM");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy");
for (int cnt = 0; cnt < 12; ++cnt) {
%>
_element = document.getElementById('campMonth<%= cnt %>');
_element.innerHTML = '<%= sdf.format(cal.getTime()) %>
<%= sdf2.format(cal.getTime()) %>';
<%
cal.add(Calendar.MONTH, 1);
}
%>
_element = document.getElementById('campYearRow');
if (_element != null) _element.style.display = '';
<%
int rowCount = list.size();
Vector ids = new Vector();
Vector titles = new Vector();
Vector stages = new Vector();
for (int row = 0; row < rowCount; row++) {
Hashtable yearRow = (Hashtable)list.elementAt(row);
String stgID = (String)yearRow.get("StgID");
String cpgID = (String)yearRow.get("StgCpgID");
String cpgTitle = (String)yearRow.get("StgCpgID:CpgTitle");
Date stgDateBeg = (Date)yearRow.get("StgDateBeg");
GregorianCalendar begCal = new GregorianCalendar();
begCal.setTime(stgDateBeg);
Hashtable monthes;
if (!ids.contains(cpgID)) {
ids.addElement(cpgID);
titles.addElement(cpgTitle);
monthes = new Hashtable();
stages.addElement(monthes);
} else {
monthes = (Hashtable)stages.elementAt(ids.indexOf(cpgID));
}
cal.setTime(begDate);
for (int j = 0; j < 12; j++) {
Integer nb = (Integer)monthes.get("" + j);
if (begCal.get(Calendar.MONTH) == cal.get(Calendar.MONTH) && begCal.get(Calendar.YEAR) == cal.get(Calendar.YEAR)) {
nb = nb == null ? new Integer(1) : new Integer(nb.intValue() + 1);
monthes.put("" + j, nb);
}
cal.add(Calendar.MONTH, 1);
}
}
for (int row = 0; row < ids.size(); row++) {
String currID = (String)ids.elementAt(row);
String currTitle = (String)titles.elementAt(row);
Hashtable currStages = (Hashtable)stages.elementAt(row);
StringBuffer htmlString = new StringBuffer("");
htmlString.append("" + Utils.formatToWeb(currTitle, false) + " ");
htmlString.append("");
%>
_element = document.getElementById('campYearRow<%= row %>Link');
if (_element != null) {
_element.className = 'campLink';
_element.innerHTML = '<%= Utils.formatToJavascript(htmlString.toString()) %>';
}
<%
cal.setTime(begDate);
cal.set(Calendar.DAY_OF_MONTH, 1);
for (int col = 0; col < 12; ++col) {
Integer nb = (Integer)currStages.get(String.valueOf(col));
%>
_element = document.getElementById('campYearRow<%= row %>Col<%= col %>');
if (_element != null) {
<% if (nb != null && nb.intValue() > 0) {
StringBuffer innerHTML = new StringBuffer();
innerHTML.append("");
innerHTML.append("");
innerHTML.append(nb.intValue());
innerHTML.append("");
%>
_element.innerHTML = '<%= Utils.formatToJavascript(innerHTML.toString()) %>';
<% } else { %>
_element.innerHTML = ' ';
<% } %>
}
<%
cal.add(Calendar.MONTH, 1);
}
%>
_element = document.getElementById('campYearRow<%= row %>');
if (_element != null) _element.style.display = '';
<%
}
for (int cnt = rowCount; cnt < 40; ++cnt) { %>
_element = document.getElementById('campYearRow<%= cnt %>');
if (_element != null) _element.style.display = 'none';
<% } %>