<?php
if(isset($_POST["bexp"])) {		
	$sql = "call spQuery_Report_AnalComp_Proveedor('$_POST[anio]', '$_POST[tipo]');";
	$_SESSION["expor_sql_1"] =  $sql;
	$_SESSION["expor_sql_2"] = NULL;
	$varTitulo = (isset($_POST["titu"]))?$_POST["titu"]:"Reporte";
	$dir = "export.php?page=$varTitulo";
	header("location: $dir");
	}
function MyTable($obj, $Titulo, $Opcion, $Valor, $TamFila) {	
	$Link = $_SERVER['PHP_SELF'];
	if(!isset($Opcion)) {	
		$sqanio = "select distinct id_anio, id_anio from _sv_metas order by id_anio desc;";
		$varTipo = array("V" => "VALOR VENTA", "I" => "IGV", "T" => "VENTA TOTAL");
		
		$sql = "select id_almacen, nombre from _sv_almacen where _estado = 'A'";
		$varForm = array("id"=>"form", "name"=>"form", "metodo"=>"POST", "onsubmit"=>"return validaForm(this)");
		$varTabla= array("tamano"=>"400", "titulo"=>$Titulo, "clase"=>"FormTitulo");
		$varConte= array(array("titulo"=>"Aņo :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
							   "campo"=>array("tipo"=>"select", "id"=>"anio", "name"=>"anio", "valor"=>$_POST[anio], "ancho"=>"100",
											  "combo"=>array("sql"=>$sqanio, "sincod"=>"SI", "ancho"=>"100"))),
						 array("titulo"=>"Tipo Datos :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
							   "campo"=>array("tipo"=>"select_simple", "id"=>"tipo", "name"=>"tipo", "valor"=>$_POST[tipo], "ancho"=>"100",
											  "combo"=>array("sql"=>$varTipo, "sincod"=>"SI", "ancho"=>"200")))
						 );
		$varOcult= array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$Titulo, "ancho"=>"100")
						 );
		$varBoton=array(array("tipo"=>"submit", "id"=>"bbus", "name"=>"bbus", "ancho"=>"80", "alto"=>"22", "texto"=>"Buscar"),
						array("tipo"=>"submit", "id"=>"bexp", "name"=>"bexp", "ancho"=>"80", "alto"=>"22", "texto"=>"Exportar")
						);
		echo $obj->setFormulario($varForm, $varTabla, $varConte, $varBoton, $varOcult);
		
		if(isset($_POST["bbus"]))	{	
			$sql = "call spQuery_Report_AnalComp_Proveedor('$_POST[anio]', '$_POST[tipo]');";
			$varTabla=array("id"=>"theTable", "name"=>"theTable", "tamano"=>"900", "sql_cab"=>$sql,	"pages"=>50,
							"conte"=>array(array("tamano"=>20, "titulo"=>"CPRO", "alinear"=>"center"),
										   array("tamano"=>150, "titulo"=>"PROVEEDOR", "funcion"=>array("contar")),								   
										   array("tamano"=>60, "titulo"=>"ENE", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"FEB", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"MAR", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"ABR", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"MAY", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"JUN", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"JUL", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"AGO", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"SET", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"OCT", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"NOV", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"DIC", "alinear"=>"right", "funcion"=>array("autosuma")),
										   )
							);
			echo $obj->SetGridTabla($varTabla);	
			}
		}	
	} 
?>