<?php
//include "clase.conexion.php";
class clsRegistroDepositos extends clsConexion{
	public $varTitulo = "REGISTRO DE GASTOS DE DEPOSITOS";
	public $varMyTabla  = "_sv_asigncion";
	public $varMyID  	  = "id_asignacion";
	function FormuBusqueda() {
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"300", "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"=>"N&deg; Asignacion :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"120",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"text", "id"=>"ide", "name"=>"ide", "valor"=>NULL,
																					 "ancho"=>"100", "alinear"=>"center", 
																					 "keypress"=>"return SoloEnteros(event)")
																			   )
														 	)
											 )				   
								   ),
					  "boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"150", "texto"=>"Buscar Depositos",
					  					   "clase"=>"boton_buscar", "click"=>"javascript:xFormDepositosJS()")
									 )
					);
		return $this->setTablaForm($varTabla);
		}
	
	function FormDepositos($varForm  = NULL)  {
		$varIde = ($varForm["ide"]=="")?"NULL":$varForm["ide"];
		$sqlcab = "call spQuery_Asignacion($varIde, NULL, NULL, NULL, NULL, NULL, NULL);";
		$this->AbrirConexion();
		$rscab = $this->Query($sqlcab);
		$this->CerrarConexion();
		$filacab = $this->FetchArray($rscab);
		$varExiste = $this->NumFilas($rscab);
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"400", "clase"=>"FormTitulo", "titulo"=>$this->varTitulo."<br>=> 1) SOBRANTES REGISTRADOS",
						"formu"=>array("id"=>"FormDepositos", "name"=>"FormDepositos", "metodo"=>"POST", "onsubmit"=>"return false;"),						
						"ocult"=>array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$this->varTitulo),
									   array("tipo"=>"oculto", "id"=>"ide2", "name"=>"ide2", "valor"=>$filacab["ASIG"])
									  ),
						"conte"=>array(array("titulo"=>"N&deg; Asignaci&oacute;n :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["ASIG"])))
											 ),
									   array("titulo"=>"F. Reparto :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["FECHA"])))
											 ),
									   array("titulo"=>"Veh&iacute;culo :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["PLACA"]." - ".$filacab["VEHICULO"])))
											 ),
									   array("titulo"=>"Conductor :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["CCON"]." - ".$filacab["CONDUCTOR"])))
											 )			   
									   ),
						  "boton"=>array(array("tipo"=>"button", "id"=>"breg", "name"=>"breg", "ancho"=>"140",
											   "clase"=>"boton_nuevo", "texto"=>"Nuevo Deposito", "click"=>"javascrip:xFormDocumentoJS()"),
										 array("tipo"=>"button", "id"=>"breg", "name"=>"breg", "ancho"=>"100",
											   "clase"=>"boton_cancelar", "texto"=>"Cancelar", "click"=>"javascrip:xajax_xRegresarBusqueda()")
										 )
					);
		if($varExiste>0)
			return $this->setTablaForm($varTabla);
		else
			return "ERROR";
		}
	
	function GridDepositos($varIde   = NULL, 
						   $varField = NULL, 
						   $varOrder = NULL
						   )  {
		$varFie = (isset($varField) && $varField<>'')? "'$varField'":"NULL";
		$varOrd = (isset($varOrder) && $varOrder<>'')? "'$varOrder'":"NULL";
		$varIde = ($varIde=="")?"NULL":$varIde;		
		$sql = "call spQuery_Asignacion_Depositos($varIde,$varFie,$varOrd);";
		$varTabla=array("id"=>"theTable2", "name"=>"theTable2", "tamano"=>"800", "sql_cab"=>$sql, "orderfun"=>"xGridDepositosJS",
						"body"=>"Cuerpo",
					    "conte"=>array(array("ancho"=>50,  "titulo"=>"CBAN",   "fijo"=>"SI","alinear"=>"center"),
									   array("ancho"=>200, "titulo"=>"BANCO",  "fijo"=>"SI", "funcion"=>array("contar")),
									   array("ancho"=>50,  "titulo"=>"FECHA",  "fijo"=>"SI","alinear"=>"center"),
									   array("ancho"=>50,  "titulo"=>"OPERAC.","fijo"=>"SI","alinear"=>"center"),
									   array("ancho"=>50,  "titulo"=>"MONTO",  "alinear"=>"right", "funcion"=>array("autosuma")),
									   array("ancho"=>100, "titulo"=>"GLOSA"),
									   ), 
						"boton"=>array(array("tipo"=>"img", "id"=>"banu", "name"=>"banu", "img"=>"images/b_table_delete.png", 
											  "toltip"=>array(array("valor"=>"HAGA CLICK PARA <b>ELIMINAR</b> El Deposito<br><b>Banco : </b>"),
															  array("valor"=>0, "tipo"=>"INDEX"),
															  array("valor"=>" - "),
															  array("valor"=>1, "tipo"=>"INDEX"),
															  array("valor"=>"<br><b>Operacion : </b>"),
															  array("valor"=>3, "tipo"=>"INDEX"),
															  array("valor"=>"<br><b>Monto : </b>"),
															  array("valor"=>4, "tipo"=>"INDEX")
															  ),
											   "click"=>array("funcion"=>"xEliminarJS",
															  "param"=>array(array("valor"=>$varIde, "tipo"=>"NUM"),
															  				 array("valor"=>0, "tipo"=>"INDEX"),
																			 array("valor"=>1, "tipo"=>"INDEX"),
																			 array("valor"=>3, "tipo"=>"INDEX"),
																			 array("valor"=>"this", "tipo"=>"NUM")
																			 )
															  )
											 
											    )
										)
							);
		return $this->SetGridTabla2($varTabla);
		
		}
				
	function FormDocumento($varForm  = NULL)  {
		$varIde = ($varForm["ide2"]=="")?"NULL":$varForm["ide2"];
		$sqlcab = "call spQuery_Asignacion($varIde, NULL, NULL, NULL, NULL, NULL, NULL);";
		$this->AbrirConexion();
		$rscab = $this->Query($sqlcab);
		$this->CerrarConexion();
		$filacab = $this->FetchArray($rscab);
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"450", "clase"=>"FormTitulo", "titulo"=>$this->varTitulo."<br>=> 2) REGISTRAR SOBRANTE",
						"conte"=>array(array("titulo"=>"N&deg; Asignaci&oacute;n :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["ASIG"])))
											 ),
									   array("titulo"=>"F. Reparto :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["FECHA"])))
											 ),
									   array("titulo"=>"Veh&iacute;culo :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["PLACA"]." - ".$filacab["VEHICULO"])))
											 ),
									   array("titulo"=>"Conductor :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"simple", "valor"=>$filacab["CCON"]." - ".$filacab["CONDUCTOR"])))
											 )			   
									   )
					);
		$varReturn.= "<form id=\"form\" name=\"form\" method=\"POST\"  onSubmit=\"return validaRegistroPedido(this)\">";
		$varReturn.= $this->setTablaForm($varTabla);
	
		$sqlban = "call spQuery_Lista_Bancos(NULL,'','');";
		
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"450", "clase"=>"Formtitulo", "titulo"=>"DETALLE DEL DOCUMENTO",						
						"ocult"=>array(array("tipo"=>"oculto", "id"=>"asi", "name"=>"asi", "valor"=>$filacab["ASIG"])
									  ),
						"conte"=>array(array("titulo"=>"Banco:", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"ban", "name"=>"ban",
																					 "combo"=>array("sql"=>$sqlban, "ancho"=>"300", "sincod"=>"SI",
																					 				"titulo"=>"--[[SELECCIONAR]]--"
																									)
																			   		)
																			   )
														 	)
											 ),
									   array("titulo"=>"Fecha :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"femi", "name"=>"femi", "alinear"=>"center",
																					 "ancho"=>"130", "locked"=>"SI", "valor"=>date("d/m/Y",time()))
																			   )
														 	)
											 ),
									   array("titulo"=>"Operaci&oacute;n :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"ope", "name"=>"ope", "alinear"=>"center",
																					 "ancho"=>"130")
																			   )
														 	)
											 ),
									   array("titulo"=>"Glosa :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"area", "id"=>"glo", "name"=>"glo", "ancho"=>"300", "alto"=>"50")
																			   )
														 	)
											 ),
									   array("titulo"=>"Monto :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"mon", "name"=>"mon", "alinear"=>"right",
																					 "ancho"=>"100", "keypress"=>"return SoloNumeros(event)")
																			   )
														 	)
											 ),
									   ),
						"boton"=>array(array("tipo"=>"button", "id"=>"bsav", "name"=>"bsav", "ancho"=>"100",
											 "clase"=>"boton_guardar", "texto"=>"Guardar", "click"=>"javascrip:xGrabarJS()"),
									   array("tipo"=>"button", "id"=>"breg", "name"=>"breg", "ancho"=>"100",
											 "clase"=>"boton_cancelar", "texto"=>"Cancelar", "click"=>"javascrip:xajax_xRegresarDescuento()")
									   )
						);
		$varReturn.= $this->setTablaForm($varTabla);
		$varReturn.= "</form>";
		return $varReturn;
		}
						
	function ProcesoGrabar($varForm = NULL) {		
		$varUsr = (isset($_SESSION["_CUSE"]))  ? $_SESSION["_CUSE"] : "1";
		$varAsi = (isset($varForm["asi"]) && $varForm["asi"]<>"")?$varForm["asi"]:"NULL";
		$varBan = (isset($varForm["ban"]) && $varForm["ban"]<>"")?"'".$varForm["ban"]."'":"NULL";
		$varEmi = (isset($varForm["femi"]) && $varForm["femi"]<>"")?"'".FechaMySql($varForm["femi"])."'":"NULL";
		$varOpe = (isset($varForm["ope"]) && $varForm["ope"]<>"")?"'".$varForm["ope"]."'":"NULL";
		$varGlo = (isset($varForm["glo"]) && $varForm["glo"]<>"")?"'".$varForm["glo"]."'":"NULL";
		$varMon = (isset($varForm["mon"]) && $varForm["mon"]<>"")?$varForm["mon"]:"NULL";
		
		$sql = "call spMante_Asignacion_Depositos($varAsi, $varBan, $varOpe, $varEmi, $varGlo, $varMon, $varUsr);";
		$this->AbrirConexion();
		$rs = $this->Query($sql);
		$this->CerrarConexion();
		$Fila = $this->FetchArray($rs);
		
		return $Fila[0];
		}
		
	function ProcesoEliminar($varAsi=NULL, $varBan=NULL, $varOpe=NULL) {
		$sql = "delete from _sv_asignacion_deposito where id_asignacion=$varAsi and id_banco='$varBan' and operacion='$varOpe';";
		$this->AbrirConexion();
		$this->Query($sql);
		return "OK";
		}
	}
	
?>