<%
/******************************************************************************
 * Copyright (c) 2000-2004 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" import="com.edeal.frontline.*,java.text.*,java.util.*,java.lang.StringBuffer"%>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="com.edeal.frontline.PersonBean" %>
<%@ page import="com.edeal.frontline.navigation.*" %>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<%!

private TimeZone getTimeZone(HttpSession session, DataDictionary dico, String tzoID){
	TimeZone timeZone =  (TimeZone) session.getAttribute("timezone");
	
	if (timeZone==null){
		timeZone = TimeZone.getDefault();
	}
	
	String tzoCode = null;
	
	if (tzoID==null) return timeZone;
	
	try{
		tzoCode = (String) dico.getRefDisp("Tzo", "Te2", tzoID);
		timeZone = TimeZone.getTimeZone(tzoCode);
	}catch(Exception e){}
	
	return timeZone;
}
%>
<%

	final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
	FlRequest flRequest = new FlRequest(request);
	FlContext context = flRequest.getContext();
	DataDictionary dico = context.getDataDictionary();
	//HttpSession session = flRequest.getSession();
	FlLocale locale = FlLocale.getInstance(session);
	
	Vector corDispList = Utils.explodeList(((String)flRequest.getAttribute("corDispList")),"|");
	Vector corGrpDispList = Utils.explodeList(((String)flRequest.getAttribute("corGrpDispList")),"|");
	Vector tzNameList = Utils.explodeList(((String)flRequest.getAttribute("tzNameList")),"|");	
	Vector tzoCode = Utils.explodeList((String)flRequest.getAttribute("tzoCodeList"),"|");	 
	String actIDs = flRequest.getParameter("actID");
	String corIDs = flRequest.getParameter("corID");	
	String multivalSeparator = flRequest.getParameter("$$multivalSeparator");
	if (multivalSeparator==null || "".equals(multivalSeparator)){
		multivalSeparator = "|";
	}
	
	Vector listActID = null;
	Vector listCorID = null;
	String actID = null;
	String actTzoID = null;
	ActorBean actor = null;
	String tzName = "";
	
	TimeZone currentTZ = null;
	TimeZone localTimeZone = (TimeZone) session.getAttribute("timezone");
	
	if (localTimeZone == null){
		localTimeZone = TimeZone.getDefault();
	}
	
	SimpleDateFormat defaultFormat = locale.getSimpleDateFormat("dd/MM/yyy HH:mm");
	SimpleDateFormat dateFormat = locale.getDateFormat();
	SimpleDateFormat timeFormat = locale.getTimeFormat(false);
	
	String intDate = flRequest.getParameter("date");
	String intBegin = flRequest.getParameter("timeBeg");
	String intEnd = flRequest.getParameter("timeEnd");
	

	
	if (actIDs!=null && !"".equals(actIDs) ){
		listActID = Utils.explodeList(actIDs, multivalSeparator);
	}
	
	if(corIDs!=null && !"".equals(corIDs)){
		listCorID = Utils.explodeList(corIDs, multivalSeparator);
	}
	
	Date dateDebut = null;
	Date dateFin = null;
	
	
	dateDebut = defaultFormat.parse(intDate+" "+intBegin);
	dateFin = defaultFormat.parse(intDate+" "+intEnd);
%>
<html>
<head>
	<title><fl:getMessage code="L655B" alt="Visualisation des horaires"/></title>

	
	<link href="<fl:webapp/>/css/smalltabs_css.jsp" rel="stylesheet" type="text/css">
	<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp">
	<link rel="stylesheet" href="<fl:webapp/>/css/master_css.jsp" type="text/css">

	<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/utils.js"></script>
	<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/master_js.jsp"></script>


	<link href="<fl:webapp/>/css/smalltabs_css.jsp" rel="stylesheet" type="text/css">
	<script language="javascript" type="text/javascript" src="<fl:webapp/>/js/smalltabs.jsp"></script>
<style type="text/css">
.dataValueX {
	width: 30%;
	overflow: hidden;
	margin: 0px;
	padding: 0px;
	padding-left: 10px;
	font-size: small;
	font-size: expression("x-small");
	color: rgb(0, 0, 0);
	font-family: Arial, Verdana, sans-serif;
	vertical-align: top;
	padding: 4px;
}
.borderLineOne {
	//border-right: 1px dashed #9EC6D0;
	border-bottom: 1px dashed #9EC6D0;
}
.borderLineTwo {
	border-right: 1px dashed #9EC6D0;
}
.borderLineTree {
	border-left: 1px dashed #9EC6D0;
}
.borderLineRight {
	border-right: 1px dashed #9EC6D0;
}
</style>
</head>	
<body>

<div id="object_css" style="top: 0px;">
<fl:bigTabs objectTitle="<%=Utils.getMessage(session, \"L655A\", \"Liste des participants en fonction de leur fuseau horaire\")%>">
<!-- fl:getMessage code="L655A" alt="Liste des participants en fonction de leur fuseau horaire"/-->

<% if (listActID!=null && listActID.size()> 0 ) { %>
<fl:smallTabs name="ActList">
<fl:sTab id="j" hideLink="true" title="">
<div class="edealGrid">
<div id="grid-data" class="data">
<table width="95%" cellspacing="3" cellpadding="3" border="0" align="center">
	<thead>
	<tr valign="top">
		<th width="65%" style="text-align: left" colspan="2"><fl:getMessage code="F1050" alt="Acteur(s)"/></th>
		<th width="15%" style="text-align: left"><fl:getMessage code="F2019" alt="Date"/></th>
		<th width="10%" style="text-align: left"><fl:getMessage code="L6619" alt="De"/></th>
		<th width="10%" style="text-align: left"><fl:getMessage code="L6368" alt="A"/></th>
	</tr>
	</thead>	
	<%
	boolean colorBlue = true;	
	for(int i=0; i<listActID.size(); i++){
		colorBlue = !colorBlue;
		actID = (String)listActID.get(i);
		try{
			actor = new ActorBean(actID, context);
			
			try{
				actTzoID = null;
				actTzoID = actor.getActTzoID();
				tzName = (String) dico.getRefDisp("Tzo", "Te1", actTzoID);
					
			}catch(Exception e1){
				tzName="";
			}
			currentTZ = getTimeZone(session, dico, actTzoID);
					

			
			dateFormat.setTimeZone(currentTZ);
			timeFormat.setTimeZone(currentTZ);				
					
			%>
		<tbody>
		<tr valign="top">
			<td width="40%" colspan="2" class="<%= colorBlue ? "tabSimpleFdBleu" : "tabSimpleFdBlanc" %>">
				<%=actor.toString()%>
				<%if (!"".equals(tzName)){%><br><img src="<fl:webapp/>/icons/ico/retard.gif">&nbsp;<%=tzName%><%}%>
				
			</td>
			<td width="15%" class="<%= colorBlue ? "tabSimpleFdBleu" : "tabSimpleFdBlanc" %>"><%=dateFormat.format(dateDebut)%></td>
			<td width="10%" class="<%= colorBlue ? "tabSimpleFdBleu" : "tabSimpleFdBlanc" %>"><%=timeFormat.format(dateDebut)%></td>
			<td width="10%" class="<%= colorBlue ? "tabSimpleFdBleu" : "tabSimpleFdBlanc" %>"><%=timeFormat.format(dateFin)%></td>
		</tr>	
		</tbody>	
			<%									
		}catch(Exception e){
			logger.error("STACK TRACE",e);
		}
	}
%>
</div>
</div>
</table>
</fl:sTab>
</fl:smallTabs>
<% } %>
<% if (listCorID != null && listCorID.size() > 0) { %>
&nbsp;
<fl:smallTabs name="CorList">
<fl:sTab hideLink="true" id="h" title="">
<div class="edealGrid">
<div id="grid-data" class="data">
<table width="95%" cellspacing="3" cellpadding="3" border="0" align="center">
<thead>
	<tr valign="top">
		<th width="65%" style="text-align: left" colspan="2"><fl:getMessage code="L3024" alt="Correspondant(s)"/></th>
		<th width="15%" style="text-align: left"><fl:getMessage code="F2019" alt="Date"/></th>
		<th width="10%" style="text-align: left"><fl:getMessage code="L6619" alt="De"/></th>
		<th width="10%" style="text-align: left"><fl:getMessage code="L6368" alt="A"/></th>
	</tr>
</thead>
<% 
		boolean colorBleu = true;
		for(int k=0;k<listCorID.size();k++){
			colorBleu = !colorBleu;
			String classType = "tabSimpleFdBleu";
			if (colorBleu) classType = "tabSimpleFdBleu";
			else classType = "tabSimpleFdBlanc";
%>
			<tbody>					
				<tr valign="top">				
					<td width="65%" class="<%= classType %>" colspan="2">
						<%= (String) corDispList.elementAt(k) %>
						<% 
							if(tzoCode != null && tzoCode.size() >= k+1){
								if(tzoCode.elementAt(k) != null && !"null".equals(tzoCode.elementAt(k))){
									currentTZ = getTimeZone(session, dico,(String)tzoCode.elementAt(k));
									dateFormat.setTimeZone(currentTZ);
									timeFormat.setTimeZone(currentTZ);
								}
							}
						%>
						<%
						String grpDisplay = "";
						if(corGrpDispList != null && !corGrpDispList.isEmpty()){
							if(corGrpDispList.elementAt(k) != null)
							grpDisplay = corGrpDispList.elementAt(k).toString();
						}						  
						%>
						<%= grpDisplay%>
<%
						if (tzNameList != null && tzNameList.size() >= k+1){						
							String strTZ = null;
							strTZ = (String) tzNameList.elementAt(k);							
							
							if(strTZ != null && !" ".equals(strTZ)){
%>
								<br><img src="<fl:webapp/>/icons/ico/retard.gif">&nbsp;	<%=strTZ%>
<%							}
						}
%>					
					</td>
					<td width="15%" class="<%= classType %>"><%=dateFormat.format(dateDebut)%></td>
					<td width="10%" class="<%= classType %>"><%=timeFormat.format(dateDebut)%></td>
					<td width="10%" class="<%= classType %>"><%=timeFormat.format(dateFin)%></td>
				</tr>
			</tbody>
		<% 
		} 
		%>
</table>
</fl:sTab>
</fl:smallTabs>
<% } %>
</fl:bigTabs>
<br>
<table class="container" width="100%">
	<tr class="fieldline">
		<td colspan="2" style="text-align: center;">
			<a href="javascript:window.close()"><img src="<fl:webapp/>/icons/ico/fermer_red_long.gif"></a>
		</td>
	</tr>
</table>
</div>
</body>
</html>