<%/******************************************************************************
 * Copyright (c) 2000-2012 E-DEAL
 *
 * E-DEAL S.A.
 * 41, rue Périer
 * 92120 Montrouge
 * France
 *
 * T: +33 (0)1 73 03 29 80
 * 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/html; charset=UTF-8" import="com.edeal.frontline.*, java.util.*"%>
<%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
<%@ 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);
	String id = flRequest.getParameter("id");
	LinkedHashMap<String, String> questionsCount = (LinkedHashMap<String, String>)flRequest.getAttribute("questionsCount");
	String title = (String) flRequest.getAttribute("title");
	if (questionsCount == null) {
		questionsCount = new LinkedHashMap<String, String>();
	}
	Iterator<String> itValue = questionsCount.values().iterator();
	Iterator<String> itKey = questionsCount.keySet().iterator();
%>
<script language="javascript" src="<fl:webapp/>/js/edeal/libraries/jqplot/1.0.8/excanvas.min.js" type="text/javascript"/><!-- comment --></script>
<script src="<fl:webapp/>/js/edeal/libraries/jqplot/1.0.8/jquery.jqplot.min.js" type="text/javascript"/><!-- comment --></script>
<script src="<fl:webapp/>/js/edeal/libraries/jqplot/1.0.8/plugins/jqplot.pieRenderer.min.js" type="text/javascript"/><!-- comment --></script>
<link href="<fl:webapp/>/js/edeal/libraries/jqplot/1.0.8/jquery.jqplot.css" rel="stylesheet" type="text/css"/>
<script language="javascript">
	function plotGraph(graphID, jsonData) {
	  $.jqplot (graphID, [jsonData], 
	    { 
	      seriesDefaults: {
	        // Make this a pie chart.
	        renderer: $.jqplot.PieRenderer, 
	        rendererOptions: {
	          // Put data labels on the pie slices.
	          // By default, labels show the percentage of the slice.
	          showDataLabels: true
	        }
	      }, 
	      legend: { show:true }
	    }
	  );
	}

</script>
<fl:bigTabs objectTitle="<%= Utils.getMessage(session, \"L63EE\", false, true, \"Questionnaire\") %>" ou="<%= \"/get_form_answers.fl\" + (id != null ? \"?id=\" + id : \"id\") %>">
	<table class="container" cellpadding="0">
		<tr>
			<td class="titreFiche" colspan="3">
				<%= title %>
			</td>
		</tr>
		<tr class="ligne_separation"><td></td></tr>		
	</table>
	<table class="container">		
<%	
if (!questionsCount.isEmpty()) {
	int i = 0;
	while (itValue.hasNext()) {
		String  json = itValue.next();
		String label = itKey.next();
%>
		<tr>
			<td class="titreInterneSmalltabs"><%= Utils.formatToWeb(label, true) %></td>
		</tr>
		<tr>
			<td>
				<table class="container">
					<tr>
						<td>
							<div id="chart_<%= i %>"></div>
							<script language="javascript">
								var jsonArr = jQuery.parseJSON('<%= json %>');
								plotGraph("chart_<%= i %>", jsonArr);
							</script>
						</td>
					</tr>
				</table>			
			</td>
		</tr>	
<%		
		i++;
	} 
} else {
%>
		<tr>
			<td colspan="2" class="dataLabel"><fl:getMessage code="L81B8" alt="Aucune réponse disponible pour ce questionnaire"/></td>
		</tr>	
<%	
}
%>	
	</table>
</fl:bigTabs>