<%
/******************************************************************************
 * Copyright (c) 2000-2006 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" %>
<%@ page import="com.edeal.frontline.Utils" %>
<%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@ page import="com.edeal.frontline.FlContext" %>
<%@ page import="com.edeal.frontline.FieldNotInitializedException" %>
<%@ page import="com.edeal.frontline.DataDictionary" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.edeal.frontline.initializers.PersonEventInitializer" %> 
<%@ page import="com.edeal.frontline.helper.EventBaseHelper.EventCategory" %> 
<%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<jsp:useBean class="com.edeal.frontline.PersonEventBean" id="PersonEvent" scope="request"/>
<%
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();

String id = flRequest.getParameter("id");

LinkedHashMap<String, String> listInscriptionStatusIDAndDisplay = (LinkedHashMap<String, String>) flRequest.getAttribute(PersonEventInitializer.LIST_INSCRIPTION_STATUS);
if (listInscriptionStatusIDAndDisplay == null) {
	listInscriptionStatusIDAndDisplay = new LinkedHashMap<String, String>();
}

LinkedHashMap<String, String> listParticipationStatusIDAndDisplay = (LinkedHashMap<String, String>) flRequest.getAttribute(PersonEventInitializer.LIST_PARTICIPATION_STATUS);
if (listParticipationStatusIDAndDisplay == null) {
	listParticipationStatusIDAndDisplay = new LinkedHashMap<String, String>();
}

String msqQuota = (String) flRequest.getAttribute(PersonEventInitializer.MSG_QUOTA); 
EventCategory eventCategory = (EventCategory) flRequest.getAttribute(PersonEventInitializer.EVENT_TYPE);

String pvtEventID = null;
try {
	pvtEventID = PersonEvent.getPvtEventID();
} catch (FieldNotInitializedException fnie) {
}

String pvtParStatus = null;
try {
	pvtParStatus = PersonEvent.getPvtParStatus();
} catch (FieldNotInitializedException fnie) {
}

String pvtInsStatus = null;
try {
	pvtInsStatus = PersonEvent.getPvtInsStatus();
} catch (FieldNotInitializedException fnie) {
}

String NonRepondu = null;
try {
	NonRepondu = dico.getRefIdByCode("Esp", "Te1", "NORES");
} catch (Exception e) {
	e.printStackTrace();
}

%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp">
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/master_css.jsp">
<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/master_js.jsp"></script>
<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/checkFields.jsp"></script>
<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/presentField.js"></script>
<script type="text/javascript" language="javascript" src="<fl:webapp/>/js/utils.js"></script>
<script language="javascript">

function doPvtEventIDChange() {		
	var f = document.forms[0];
	f.action = "<fl:webapp/>/refresh_personevent.fl";
	f.submit();
}

function doSubmit() {
	var f = document.forms[0];
	if (f.PvtEventID.value == '') {
		alert('<fl:getMessage code="L818E" alt="Veuillez sélectionner un événement" js="true"/>');
		f.PvtEventID.focus();
		return;
	} 
	if (f.PvtPersonID.value == '') {
		alert('<fl:getMessage code="M9040" alt="Veuillez sélectionner une personne" js="true"/>');
		f.PvtPersonID.focus();
		return;
	}  
	
	f.$$returnedHtmlBody.value = 'Nothing here';
	f.$$returnedHtmlHead.value = '<sc' + 'ript language=\"javascript\">window.top.opener.doRefreshEvents();window.top.close();</scr' + 'ipt>';	
	f.submit();
}	
</script>
<title><fl:getMessage code="L2025" alt="e-Deal"/></title>
<link rel="stylesheet" href="<fl:webapp/>/css/common_css.jsp" type="text/css">
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp">
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/master_css.jsp">
<script language="javascript" src="<fl:webapp/>/js/jsOnload.jsp"></script>
</head>
<body>
<div id="object_css" style="top: 0px; left: 0px; bottom: 0px; height: 100%;">
<fl:bigTabs ignoreList="" objectTitle="<%= Utils.getMessage(session, \"F80AF\", false, true, \"Inscription\") %>">
<fl:form action="/save_personevent.fl" bean="PersonEvent">
	<input type="hidden" name="$$returnedHtmlHead" value=""/>
	<input type="hidden" name="$$returnedHtmlBody" value="Closing..."/>
	<input type="hidden" name="$$presentFields" value="" />
	<table class="container" cellpadding="0">
	<% if ((msqQuota != null) && (EventCategory.MEET.equals(eventCategory))) { %>		
		<tr>
			<td colspan="3" class="titreFiche">
				<%= msqQuota %>
			</td>
		</tr>
		<tr class="ligne_separation"><td colspan="3"></td></tr>
	<% } %>
		<tr>
			<td class="column2">	
				<table class="data_column" cellpadding="0">
				  	<fl:fieldEdit property="PvtEventID" mandatoryMsgCode="L818E"/>			
				</table>
			</td>
			<td class="separation"><div class="separation"></div></td>
			<td class="column2">
				<table class="data_column" cellpadding="0">
					<fl:fieldEdit property="PvtPersonID" mandatoryMsgCode="M9040"/>
				</table>
			</td>
		</tr>
		<tr class="ligne_separation"><td></td></tr>	
		<tr>
			<td class="column2">	
				<table class="data_column" cellpadding="0">
				  	<tr class="fieldline">
				  		<td class="dataLabel" id="PvtInsStatus_label"><div><label title="Inscription" for="PvtInsStatus"><fl:getMessage code="F80AF" alt="Inscription"/></label></div></td>
						<td class="dataValue">
							<div>
								<select name="PvtInsStatus" class="input select chpsTextObligatoire">
<% 							Iterator iter = listInscriptionStatusIDAndDisplay.keySet().iterator();
							while (iter.hasNext()) {
								String statusID = (String) iter.next();
								String statusDisplay = (String) listInscriptionStatusIDAndDisplay.get(statusID);
%> 
									<option value="<%= statusID %>" <%= statusID.equals(pvtInsStatus) ? "selected" : "" %>><%= statusDisplay %></option> 
<%
							}
%>										
								</select>
							</div>
						</td>
					</tr>			 
				</table>
			</td>
			<td class="separation"><div class="separation"></div></td>
			<td class="column2">
				<table class="data_column" cellpadding="0">
					<fl:fieldEdit property="PvtPerInsRep"/>			
				</table>
			</td>
		</tr>

		<tr class="ligne_separation"><td></td></tr>	
		<tr>
			<td class="column2">	
				<table class="data_column" cellpadding="0">
				 	<tr class="fieldline">
				  		<td class="dataLabel" id="PvtParStatus_label"><div><label title="Participation" for="PvtParStatus"><fl:getMessage code="L8186" alt="Participation"/></label></div></td>
						<td class="dataValue">
							<div>
								<select name="PvtParStatus" class="input select chpsTextObligatoire">
									<!-- <option value=""></option> -->
<%
								Iterator iter2 = listParticipationStatusIDAndDisplay.keySet().iterator();
								while (iter2.hasNext()) {
									String statusID = (String) iter2.next();
									String statusDisplay = (String) listParticipationStatusIDAndDisplay.get(statusID);
%> 
									<option value="<%= Utils.formatToWeb(statusID, true) %>" 
											<%= (id==null && statusID.equals(NonRepondu)) ? "selected" : "" %>>
										<%= Utils.formatToWeb(statusDisplay, true) %>
									</option> 
<%
								}
%>										
								</select>
							</div>
						</td>
					</tr>				
				</table>
			</td>
			<td class="separation"><div class="separation"></div></td>
			<td class="column2">
				<table class="data_column" cellpadding="0">
					<fl:fieldEdit property="PvtPerParRep"/>			
					<!-- 
					<fl:fieldEdit property="PvtPerParAcc"/>
					 -->	
				</table>		
			</td>
		</tr>
	
	</table>
</fl:form>
</fl:bigTabs>
<br>
<table class="data_column" cellpadding="0">
	<tr>
		<td style="text-align: center;">
			<a href="javascript:doSubmit();"><img style="border: none;" src="<fl:webapp/>/icons/ico/valid_green_long.gif"></a>
			&nbsp;&nbsp;&nbsp;
			<a href="javascript:window.close()"><img style="border: none;" src="<fl:webapp/>/icons/ico/fermer_red_long.gif"></a>
		</td>
	</tr>
</table>
</div>
</body>
</html>