<?php
require('../Operaciones/Sentencias_Estadistica.php');
$L_Mun=$_GET['Lista'];
$Anio=$_GET['Anio'];

print_r($L_Mun);
$Esta_Basica= new Estadistica_C();
$dato=$Esta_Basica->Estadistica('['.$L_Mun.']', $Anio);
$Lista_D=[];
$Cont=0;
while ($row=$dato->fetch_assoc()){	$Lista_D[$Cont]=array('Nombre'=>$row['nombre'],'Mov'=>$row['Mov'],'Ene'=>$row['Ene'],'Feb'=>$row['Feb'],'Mar'=>$row['Mar'],'Abr'=>$row['Abr'],'May'=>$row['May'],'Jun'=>$row['Jun'],'Jul'=>$row['Jul'],'Ags'=>$row['Ags'],'Sep'=>$row['Sep'],'Oct'=>$row['Oct'],'Nov'=>$row['Nov'],'Dic'=>$row['Dic'],'Anio'=>$row['Anio']);
	$Cont++;
}
//$Lista = json_encode($Lista_D);
//print_r($Lista);

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Tabla_Graf.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo "<head><meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\" /></head>";
$salida ="";
$salida.='<table border="1"><tbody><thead><tr><th width="14%">Municipio</th><th width="7%">Año</th><th width="6%">Ene</th><th width="6%">Feb</th><th width="7%">Mar</th><th width="6%">Abr</th><th width="7%">May</th><th width="5%">Jun</th><th width="5%">Jul</th><th width="6%">Ags</th><th width="6%">Sep</th><th width="6%">Oct</th><th width="7%">Nov</th><th width="6%">Dic</th><th width="6%">Tot</th></tr></thead>';
	foreach($Lista_D as $Val=>$key) {		
		$salida.= '<tr><td>'.$key['Nombre'].'</td><td>'.$key['Anio'].'</td><td>'.$key['Ene'].'</td><td>'.$key['Feb'].'</td><td>'.$key['Mar'].'</td><td>'.$key['Abr'].'</td><td>'.$key['May'].'</td><td>'.$key['Jun'].'</td><td>'.$key['Jul'].'</td><td>'.$key['Ags'].'</td><td>'.$key['Sep'].'</td><td>'.$key['Oct'].'</td><td>'.$key['Nov'].'</td><td>'.$key['Dic'].'</td><td>'.$key['Mov'].'</td></tr>';
	}
$salida.='</tbody></table>';
echo $salida;

?>