<?php
//include "clase.conexion.php";
class clsMargenVendedor extends clsConexion{
	public $varTitulo 	= "MARGEN DE UTILIDAD POR VENDEDOR";
	function FormuBusqueda() {
		$sqanio = "select distinct id_anio, id_anio from _sv_metas order by id_anio desc;";
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"400", "clase"=>"Formtitulo", "titulo"=>$this->varTitulo,
						"formu"=>array("id"=>"form", "name"=>"form", "metodo"=>"POST", "onsubmit"=>"return false;"),						
						"ocult"=>array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$this->varTitulo)
									  ),
						"conte"=>array(array("titulo"=>"Periodo :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
										     "campo"=>array("tipo"=>"varios",
														    "contenido"=>array(array("tipo"=>"select", "id"=>"anio", "name"=>"anio",
																				     "combo"=>array("sql"=>$sqanio, "sincod"=>"SI", "titulo"=>"--[[ANIO]]--", "ancho"=>"150",))
																			   )
														   )
										    )
									   ),
						"boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"100", "texto"=>"Buscar",
					  					   "clase"=>"boton_buscar", "click"=>"javascript:xBuscarJS()"),
									 array("tipo"=>"button", "id"=>"bexp", "name"=>"bexp", "ancho"=>"100", "texto"=>"Exportar",
									 	   "clase"=>"boton_exportar", "click"=>"javascript:xExportarJS()"),								
									 array("tipo"=>"button", "id"=>"bimp", "name"=>"bimp", "ancho"=>"100", "texto"=>"Imprimir", 
										   "clase"=>"boton_imprimir", "click"=>"javascript:xImprimirJS('', 'NEW')"),
									 )
						);
		return $this->setTablaForm($varTabla);
		}
 	function GridDatos($varForm = NULL)  
		{						  
		$sql = "call spQuery_Rentabilidad_Vendedor('$varForm[anio]');";
		$varCab = array(array("cab"=>"ENE-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"FEB-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"MAR-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"ABR-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"MAY-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"JUN-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"JUL-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"AGO-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"SET-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"OCT-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"NOV-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"DIC-".$varForm["anio"], "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"TOTAL", "det"=>array("VENTA","UTIBRU"))
						);
		$varNiv = array(0 =>array("COD"=>"CVEN","DES"=>"VENDEDOR"),
						1 =>array("COD"=>"CTIP","DES"=>"TIPO"),
						2 =>array("COD"=>"CEMP","DES"=>"EMPRESA"));
		$varReturn =  $this->setGridCombina($varCab, $sql, $varNiv);
		return $varReturn;
		}
	function Imprimir ($varAni = NULL)  
		{
		$sql = "call spQuery_Rentabilidad_Vendedor('$varAni');";
		$varCab = array(array("cab"=>"ENE-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"FEB-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"MAR-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"ABR-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"MAY-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"JUN-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"JUL-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"AGO-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"SET-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"OCT-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"NOV-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"DIC-".$varAni, "det"=>array("VENTA","UTIBRU")),
						array("cab"=>"TOTAL", "det"=>array("VENTA","UTIBRU"))
						);
		$varNiv = array(0 =>array("COD"=>"CVEN","DES"=>"VENDEDOR"),
						1 =>array("COD"=>"CTIP","DES"=>"TIPO"),
						2 =>array("COD"=>"CEMP","DES"=>"EMPRESA"));
		$html='<table style="width: 98%; padding: 0; margin-top:10px; margin-bottom:10px; border-collapse:collapse;" align="center">';
		$html.='<thead>';
		$html.='<tr>';
		$html.='<td>';
		$html.='<table style="width: 100%;">';
		$html.='<tr>';
		$html.='<td style="width: 9%; vertical-align: middle; text-align:left;"><b>Periodo</b></td>';
		$html.='<td style="width: 1%; vertical-align: middle; text-align:center;"><b>:</b></td>';
		$html.='<td style="width: 40%; vertical-align: middle; text-align:left;"><b>'.$varAni.'</b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:right;"><b>'.Config("SYSEMP").'</b></td>';
		$html.='</tr>';
		$html.='<tr>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b>Fecha</b></td>';
		$html.='<td style="vertical-align: middle; text-align:center;"><b>:</b></td>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b>'.$varIni.' - '.$varFin.'</b></td>';
		$html.='<td style="vertical-align: middle; text-align:right;"><b>'.$this->varTitulo.'</b></td>';
		$html.='</tr>';
		$html.='<tr>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b></b></td>';
		$html.='<td style="vertical-align: middle; text-align:center;"><b></b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:left;"><b>';

		$html.='</b></td>';
		$html.='<td style="width: 50%; vertical-align: middle; text-align:right;">'.MostrarFechaActual().'</td>';
		$html.='</tr>';
		$html.='</table>';
		$html.='</td>';
		$html.='</tr>';
		$html.='</thead>';	
		$html.='<tr>';
		$html.='<td>';				
		$html.= $this->setGridCombinaPrint($varCab, $sql, $varNiv);
		$html.='</td>';
		$html.='</tr>';			
		$html.='</table>';
		return $html;
		}
	}
?>