<?php

				require_once("conexion/conexion.php");

?>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Graficos</title>

		<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
		<style type="text/css">
${demo.css}
		</style>
        
        <script src="highcharts.js"></script>
		<script src="exporting.js"></script>
		<script type="text/javascript">
$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: '¿Con qué frecuencia usa nuestro producto o servicio?'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Clientes',
            data: [
			
			<?php
			$sql=mysql_query("SELECT obspos, cdgfre, count(*) AS frecuencia   FROM encuesta  GROUP BY cdgfre");
			while($res=mysql_fetch_array($sql)){
			$cdgfre=$res['cdgfre'];
				
			   $query_frecuencia="SELECT * FROM frecuencia_ser WHERE cdgfre='$cdgfre'";
	   		   $rs_query_frecuencia=mysql_query($query_frecuencia);
			   $dscfre= mysql_result($rs_query_frecuencia,0,"dscfre");
			?>
			
                ['<?php echo $dscfre; ?>', <?php echo $res['frecuencia'] ?>],
			
			<?php
			}
			?>	

            ]
        }]
    });
});


		</script>
	</head>
	<body>


<div id="container" style="min-width: 290px; height: 380px; max-width: 600px; margin-top:5px; margin-left:25%"> 
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>
<br>
<div id="zonaContenidoPP">
  <div align="center">
      <?php
  	$query_busqueda="SELECT count(*) as filas FROM encuesta ";
	$rs_busqueda=mysql_query($query_busqueda);
	 $numero_encuestas=mysql_result($rs_busqueda,0,"filas");
  
  ?>
    <table class="" width="100%" cellspacing=0 cellpadding=0 border=0 ID="Table1">
    <tr>
      <td>&nbsp;</td>
      <td width="15%">&nbsp;</td>
      <td width="9%">&nbsp;</td>
      <td width="10%">Total Encuestas</td>
      <td width="8%"><?  echo $numero_encuestas; ?></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <tr>
      <td width="17%">&nbsp;</td>
    <td colspan="2"><div align="center">Respuesta</div></td>
    <td colspan="2"><div align="center">Asignadas</div></td>
    <td width="18%"><div align="center">Porcentaje</div></td>
     <td width="13%">&nbsp;</td>
     <td width="10%">&nbsp;</td>
    <?php
		$sql=mysql_query("SELECT obspos, cdgfre, count(*) AS frecuencia   FROM encuesta  GROUP BY cdgfre ORDER BY frecuencia DESC");
		while($res=mysql_fetch_array($sql)){
		$cdgfre=$res['cdgfre'];
				
			   $query_frecuencia="SELECT * FROM frecuencia_ser WHERE cdgfre='$cdgfre'";
	   		   $rs_query_frecuencia=mysql_query($query_frecuencia);
			   $dscfre= mysql_result($rs_query_frecuencia,0,"dscfre");
			
	?>	   
      <tr>
        <td width="17%">&nbsp;</td>
        <td colspan="2"><div align="left"><?  echo $dscfre; ?> </div>          <div align="left"></div>          <div align="left"></div></td>
        <td colspan="2" ><div align="center"><? echo $res['frecuencia'] ?></div></td>
        <td width="18%"><div align="center"><? echo round (($res['frecuencia']/$numero_encuestas)*100,2) ?></div>          <div align="left"></div></td>
        <td colspan="2"><div align="center"></div></td>
      </tr>
        </tr>
      
      <? $contador++;
							}
						?>
    </table>
  
  </div>
</div>
<br>

<center>
  <table width="100%" border="0">
    <tr>
      <td width="10%">&nbsp;</td>
      <td width="35%">&nbsp;</td>
      <td width="5%"> <a href="ejemplo2.php"><img src="img/Arrow-Right_48x48-32.png" alt="Anterior"></a></td>
      <td width="11%"><a href="ejemplo2.php"><img src="img/Arrow-Left_48x48-32.png" alt="Siguiente"></a></td>
      <td width="29%">&nbsp;</td>
      <td width="10%">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>

	</body>
</html>
