<?php
if(isset($_POST[bexp])) {	
	$varFIni = ($_POST["eini"]=="") ? "NULL" : "'".FechaMySql($_POST["eini"])."'";
	$varFFin = ($_POST["efin"]=="") ? "NULL" : "'".FechaMySql($_POST["efin"])."'";
	$sql = "call spQuery_Comision_Vendedor($varFIni, $varFFin)";
	$_SESSION[expor_sql_1] =  $sql;
	$_SESSION[expor_sql_2] = NULL;
	$dir = "export.php?page=COMISION MENSUAL";
	header("location: $dir");
	}
		
function MyTable($obj, $varTitulo, $Opcion, $Valor) {
	$Link = $_SERVER['PHP_SELF'];
	$varFINI = (isset($_POST["eini"]))?$_POST["eini"]:NULL;
	$varFFIN = (isset($_POST["efin"]))?$_POST["efin"]:NULL;
	if(!isset($Opcion)) {
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"420", "clase"=>"Formtitulo", "titulo"=>$varTitulo,
						"formu"=>array("id"=>"form", "name"=>"form", "metodo"=>"POST"),						
						"ocult"=>array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$varTitulo),
									   array("tipo"=>"oculto", "id"=>"opt", "name"=>"opt", "valor"=>$Opcion)
									  ),
						"conte"=>array(array("titulo"=>"Fecha Incial :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
											 "campo"=>array("tipo"=>"fecha", "id"=>"eini", "name"=>"eini", "alinear"=>"center","valor"=>$varFINI) ),
									   array("titulo"=>"Fecha Final :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
											 "campo"=>array("tipo"=>"fecha", "id"=>"efin", "name"=>"efin", "alinear"=>"center", "valor"=>$varFFIN) )									   
									   ),
						"boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"80", "alto"=>"22", "texto"=>"Consultar"),			  
									   array("tipo"=>"submit", "id"=>"bexp", "name"=>"bexp", "ancho"=>"80", "alto"=>"22", "texto"=>"Exportar")
									   )
						);
		echo $obj->setTablaForm($varTabla);
		
		if(isset($_POST["bcon"])) {		
			$varFIni = ($_POST["eini"]=="") ? "NULL" : "'".FechaMySql($_POST["eini"])."'";
			$varFFin = ($_POST["efin"]=="") ? "NULL" : "'".FechaMySql($_POST["efin"])."'";
			$sql = "call spQuery_Comision_Vendedor($varFIni, $varFFin)";
			
			$varTabla=array("id"=>"theTable", "name"=>"theTable", "tamano"=>"700", "sql_cab"=>$sql,	"pages"=>50,
							"conte"=>array(array("tamano"=>20, "titulo"=>"CVEN", "alinear"=>"center"),
										   array("tamano"=>300, "titulo"=>"VENDEDOR", "funcion"=>array("contar")),								   
										   array("tamano"=>60, "titulo"=>"SUBTOTAL", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"IGV", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"TOTAL", "alinear"=>"right", "funcion"=>array("autosuma")),
										   array("tamano"=>60, "titulo"=>"S/. COMISION", "alinear"=>"right", "funcion"=>array("autosuma")),
										   )
							);
			echo $obj->SetGridTabla($varTabla);	
			
			}
		}
	} 
?>