<?php
//include "clase.conexion.php";
class clsVentaDia extends clsConexion{
	public $varTitulo = "REPORTE DE VENTAS POR DIA";
	public $varMyTabla  = "_sv_venta";
	public $varMyID  	  = "id_venta";
	function FormuBusqueda() {
		$varEst = array("AC"=>"ACTIVO", "PP"=>"PAGADO PARCIAL","CA"=>"CANCELADO","AN"=>"ANULADO");
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"450", "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),
									   array("tipo"=>"oculto", "id"=>"opt", "name"=>"opt", "valor"=>$Opcion)
									  ),
						"conte"=>array(array("titulo"=>"Vendedor :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"text", "id"=>"vcod", "name"=>"vcod", "valor"=>$_POST["vcod"],
																					 "ancho"=>"50", "alinear"=>"center", 
																					 "keypress"=>"return SoloEnteros(event)",
																					 "blur"=>"xajax_seleccionar_vendedor(this.value)", 
																					 "dclick"=>"fn_cargar_listado_vendedor('vcod', 'vnom')"),
																			   array("tipo"=>"text", "id"=>"vnom", "name"=>"vnom", "valor"=>$_POST["vnom"], 
																					 "ancho"=>"250", "clase"=>"inputDisable", "locked"=>"SI")
																			   )
														 	)
											 ),
									   array("titulo"=>"Fecha Inicial :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"fini", "name"=>"fini", "alinear"=>"center",
																					 "ancho"=>"130", "valor"=>$varFINI)
																			   )
														 	)
											 ),
									   array("titulo"=>"Fecha Final :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"ffin", "name"=>"ffin", "alinear"=>"center", 
																					 "ancho"=>"130", "valor"=>$varFFIN)
																			   )
														 	)
											 )
									 ),
					  "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()")							 
									 )
					);
		return $this->setTablaForm($varTabla);
		}
 	
	function GridDatos($varForm  = NULL) {
		$varIni = (isset($varForm["fini"]) && $varForm["fini"]<>'')? "'".FechaMySql($varForm["fini"])."'":"NULL";
		$varFin = (isset($varForm["ffin"]) && $varForm["ffin"]<>'')? "'".FechaMySql($varForm["ffin"])."'":"NULL";
		$varVen = (isset($varForm["vcod"]) && $varForm["vcod"]<>'')? $varForm["vcod"]:"NULL";
		$sql = "call spQuery_Venta_Dia($varVen, $varIni, $varFin);";
		
		$varCab = array(array("cab"=>"DATOS", "det"=>array("PDV","FACTURADO","CONTADO","CREDITO","PARCIAL","RECHAZO","EFECTIVO","%PARC.","%RECH.","%EFEC."))
						);
		$varNiv = array(0 =>array("COD"=>"DIA","DES"=>"FEMI"),
						1 =>array("COD"=>"CVEN","DES"=>"VENDEDOR"),
						2 =>array("COD"=>"CTOT","DES"=>"TOTAL"),
						);
		$varFor = array(13=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>10, "funcion"=>"porc")),
						14=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>11, "funcion"=>"porc")),
						15=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>12, "funcion"=>"porc"))
						);
		return  $this->setGridCombina($varCab, $sql, $varNiv, NULL, $varFor);
		}
	
	function Imprimir ($varVen=NULL, $varIni=NULL, $varFin=NULL)
		{
		$varDia = $varIni." - ".$varFin;
		$varIni = (isset($varIni) && $varIni<>'')? "'".FechaMySql($varIni)."'":"NULL";
		$varFin = (isset($varFin) && $varFin<>'')? "'".FechaMySql($varFin)."'":"NULL";
		$varVen = (isset($varVen) && $varVen<>'')? $varVen:"NULL";
		
		$sql = "call spQuery_Venta_Dia($varVen, $varIni, $varFin);";
		$varCab = array(array("cab"=>"DATOS", "det"=>array("PDV","FACTURADO","CONTADO","CREDITO","PARCIAL","RECHAZO","EFECTIVO","%PARC.","%RECH.","%EFEC."))
						);
		$varNiv = array(0 =>array("COD"=>"DIA","DES"=>"FEMI"),
						1 =>array("COD"=>"CVEN","DES"=>"VENDEDOR"),
						2 =>array("COD"=>"CTOT","DES"=>"TOTAL"),
						);
		$varFor = array(13=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>10, "funcion"=>"porc")),
						14=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>11, "funcion"=>"porc")),
						15=>array("tipodat"=>"porc", "formula"=>array("valor1"=>7, "valor2"=>12, "funcion"=>"porc"))
						);
		$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: 15%; vertical-align: middle; text-align:left;"><b>Dia Liquidado</b></td>';
		$html.='<td style="width: 1%; vertical-align: middle; text-align:center;"><b></b></td>';
		$html.='<td style="width: 34%; vertical-align: middle; text-align:left;"><b></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>'.$varDia.'</b></td>';
		$html.='<td style="vertical-align: middle; text-align:center;"><b></b></td>';
		$html.='<td style="vertical-align: middle; text-align:left;"><b></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, NULL, $varFor);
		$html.='</td>';
		$html.='</tr>';			
		$html.='</table>';
		return $html;
		}
	}
	
?>