<%
/******************************************************************************
 * 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"%><%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@ page import="com.edeal.frontline.FieldNotInitializedException" %>
<%@ page import="com.edeal.frontline.FlContext" %>
<%@ page import="com.edeal.frontline.PopulationBean" %>
<%@ page import="com.edeal.frontline.FrontlineException" %>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<jsp:useBean class="com.edeal.frontline.PopulationBean" id="Population" 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();
String id = null;
try {
	id = Population.getID();
} catch (FieldNotInitializedException fnie) {
}
if (id == null){
	id = (String)request.getAttribute("PopID");
	if (id != null) {
		try {
			Population = new PopulationBean(id, context);
			request.setAttribute("Population", Population);
		} catch (FrontlineException e) {
		}
	}

}
int popType = 0;
try {
	popType = Population.getPopType();
} catch (FieldNotInitializedException ex) {
}

%>

<script type="text/javascript" language="javascript">
function doAddPopulationEntry() {
	window.open('<fl:link url="<%= \"/add_populationentry.fl?PopType=\" + popType + \"&PopID=\" + id %>" list="true"/>', 'AddPopulationEntry<%= id %>', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=780,height=600,screenX=50,screenY=10');
}
function doDelete() {
	if (window.confirm('<fl:getMessage code="M2004" alt="Etes-vous sûr de vouloir supprimer?" js="true"/>') == true) {
		//Delete population in Ajax to redirect to POPULATION or POPULATIOJ		
		<%
		String str = flRequest.computeURL("/delete_object_ajax.fl?type=Population&id="+id);
		%>
		doAjax('<%=str%>', waitNredirect);
	}
}

function waitNredirect(arrIndex) {
	if (eDealXmlhttpArr[arrIndex].readyState == 4){
	<%if (popType == 0){%>
		window.location = '<fl:link url="/list_criteria.fl?lc=POPULATION"/>';
	<%}else{%>
		window.location = '<fl:link url="/list_criteria.fl?lc=POPULATIOJ"/>';
	<%}%>	
	}
}

function doImportFile() {
	window.open('<fl:link url="<%= \"/import_population.fl?id=\" + id %>" list="true"/>', 'import<%= id %>', 'width=550,height=300,resizable');
}
</script>
<fl:access name="Population" operation="edit">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link list="true" url="<%= \"/edit_population.fl?PopType=\" + popType + ( id != null ? \"&id=\" + id : \"\") %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="A0008" alt="Modifier"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>
<fl:access name="Population" operation="delete">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:doDelete()">
					<p class="actions_tabletext"><fl:getMessage code="A0007" alt="Supprimer"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>
<% if (popType == 0) { %>
<fl:access name="PopulationEntry" operation="create">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:doImportFile()">
					<p class="actions_tabletext"><fl:getMessage code="A0015" alt="Importer"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/population_actions.fl?id=\" + id %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="A0010" alt="actions"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
<% } else { %>
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="/population_journalist_actions.fl"/>">
					<p class="actions_tabletext"><fl:getMessage code="A0010" alt="actions"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
<% } %>
<fl:access name="Population" operation="create">
	<fl:access name="Population" operation="read">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/population_sample.fl?id=\" + id %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="L615E" alt="Echantillonage"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/population_split.fl?id=\" + id %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="L615D" alt="Découpage"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	</fl:access>
</fl:access>
