<?php
//include "clase.conexion.php";
class clsTrabajadorEmpresa extends clsConexion{
	public $varTitulo 	= "MAESTRO DE TRABAJADORES POR EMPRESA";
	public $varMyTabla  = "_srh_trabajador_empresa";
	public $varMyID  	= "id_trabajador";
	function FormuBusqueda() {
		$sqltip = "call spQuery_Lista_Tipo_Trabajador(NULL,NULL);";
		$sqlest = "call spQuery_Lista_Estado_Trabajador(NULL,NULL);";
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"430", "clase"=>"FormTitulo", "titulo"=>$this->varTitulo." - BUSQUEDA",
						"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"=>"Codigo :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"cod", "name"=>"cod", "alinear"=>"center", "ancho"=>"70")))
											 ),
									   array("titulo"=>"Nombre :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"nam", "name"=>"nam", "ancho"=>"306")))
											 ),
									   array("titulo"=>"Empresa :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"text", "id"=>"ecod", "name"=>"ecod", "valor"=>$_POST["ecod"], 
																					 "ancho"=>"50", "alinear"=>"center", 
																					 "blur"=>"xajax_seleccionar_empresa(this.value)", 
																					 "dclick"=>"fn_cargar_listado_empresa('ecod', 'enom')"),
																			   array("tipo"=>"text", "id"=>"enom", "name"=>"enom", "valor"=>$_POST["enom"], 
																					 "ancho"=>"250", "clase"=>"inputDisable", "locked"=>"SI")
																			   )
															)
											 ),
									  array("titulo"=>"Estado Trab. :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"est", "name"=>"est", 
															 						 "titulo"=>"--[[SELECCIONAR]]--", "sql"=>$sqlest, "ancho"=>"306")))
											 )
									   ),
					  "boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"90", "texto"=>"Buscar",
										   "clase"=>"boton_buscar", "click"=>"javascript:xBuscarJS()"),
									 array("tipo"=>"button", "id"=>"bexp", "name"=>"bexp", "ancho"=>"90", "texto"=>"Exportar",
										   "clase"=>"boton_exportar", "click"=>"javascript:xExportarJS()"),								
									 array("tipo"=>"button", "id"=>"bnew", "name"=>"bnew", "ancho"=>"90", "texto"=>"Nuevo", 
										   "clase"=>"boton_nuevo", "click"=>"javascript:FormuRegistroJS('', '', '', 'NEW')"),
									 )
					);
		return $this->setTablaForm($varTabla);
		}
 	function GridDatos($varForm  = NULL, 
					   $varField = NULL, 
					   $varOrder = NULL
					   )  {
						  
		$varFie = (isset($varField) && $varField<>'')? "'$varField'":"NULL";
		$varOrd = (isset($varOrder) && $varOrder<>'')? "'$varOrder'":"NULL";
		$varCod = ($varForm["cod"]=="")? "NULL": $varForm["cod"];
		$varNom = ($varForm["nam"]=="")? "NULL":"'".$varForm["nam"]."'";
		$varEmp = ($varForm["ecod"]=="")? "NULL":$varForm["ecod"];
		$varEst = ($varForm["est"]=="Ninguno")? "NULL":$varForm["est"];
		
		$sql = "call spQuery_Trabajador_Empresa($varCod, $varNom, $varEmp, $varEst, $varFie, $varOrd)";
		$varTabla=array("id"=>"theTable", "name"=>"theTable", "tamano"=>"1000", "sql_cab"=>$sql,	"pages"=>20,
					    "conte"=>array(array("titulo"=>"CTRA",      "ancho"=>"40" , "alinear"=>"center", "tipodat"=>"texto"), 
								   	   array("titulo"=>"TRABAJADOR","ancho"=>"300", "fijo"=>"SI", "funcion"=>array("contar")),
									   array("titulo"=>"CEMP",      "ancho"=>"40" , "alinear"=>"center", "oculto"=>"SI"), 
									   array("titulo"=>"EMPRESA",  	"ancho"=>"90", "fijo"=>"SI"),
									   array("titulo"=>"CAGE",      "ancho"=>"40" , "alinear"=>"center", "oculto"=>"SI"), 
									   array("titulo"=>"AGENCIA",  	"ancho"=>"90", "fijo"=>"SI"),
									   array("titulo"=>"CARE",      "ancho"=>"40" , "oculto"=>"SI"), 
								   	   array("titulo"=>"AREA",		"ancho"=>"300", "fijo"=>"SI"),
									   array("titulo"=>"CCAR",      "ancho"=>"40", "oculto"=>"SI"), 
								   	   array("titulo"=>"CARGO",		"ancho"=>"300", "fijo"=>"SI"),
									   array("titulo"=>"CPLA",      "ancho"=>"40", "oculto"=>"SI"), 
								   	   array("titulo"=>"PLANILLA",	"ancho"=>"300", "fijo"=>"SI"),
									   array("titulo"=>"FING.",		"ancho"=>"60", "alinear"=>"center"),
									   array("titulo"=>"FPLA",		"ancho"=>"60", "alinear"=>"center"),
									   array("titulo"=>"FSAL",		"ancho"=>"60", "alinear"=>"center"),
									   array("titulo"=>"BASE",		"ancho"=>"60", "alinear"=>"right"),
									   array("titulo"=>"BONO",		"ancho"=>"60", "alinear"=>"right"),
									   array("titulo"=>"VIATI",		"ancho"=>"60", "alinear"=>"right"),
									   array("titulo"=>"ESTADO",	"ancho"=>"100", "fijo"=>"SI"),
									   ), 
						"boton"=>array(array("tipo"=>"img", "id"=>"bbus", "name"=>"bbus", "img"=>"../images/16x16/table_edit.png", 
												 "toltip"=>array(array("valor"=>"HAGA CLICK PARA <b>EDITAR</b> EL TRABAJADOR"),
												 				 array("valor"=>"<br><b>Empresa : </b>"),
																 array("valor"=>2, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>3, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Trabajador : </b>"),
																 array("valor"=>0, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>1, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Planilla : </b>"),
																 array("valor"=>10, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>11, "tipo"=>"INDEX"),
																),
												 "click"=>array("funcion"=>"FormuRegistroJS",
																"param"=>array(array("valor"=>0, 	  "tipo"=>"INDEX"),
																			   array("valor"=>2, 	  "tipo"=>"INDEX"),
																			   array("valor"=>10, 	  "tipo"=>"INDEX"),
																			   array("valor"=>"EDIT", "tipo"=>"TEXTO")
																			  )
																)
												 
												),
										   array("tipo"=>"img", "id"=>"badd", "name"=>"badd", "img"=>"../images/16x16/table_delete.png", 
												 "toltip"=>array(array("valor"=>"HAGA CLICK PARA <b>ELIMINAR</b> EL TRABAJADOR"),
																 array("valor"=>"<br><b>Empresa : </b>"),
																 array("valor"=>2, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>3, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Trabajador : </b>"),
																 array("valor"=>0, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>1, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Planilla : </b>"),
																 array("valor"=>10, "tipo"=>"INDEX"),
																 array("valor"=>" - "),
																 array("valor"=>11, "tipo"=>"INDEX"),
																 ),
												 "click"=>array("funcion"=>"xEliminarJS",
																"param"=>array(array("valor"=>2, "tipo"=>"INDEX"),
																			   array("valor"=>3, "tipo"=>"INDEX"),
																			   array("valor"=>0, "tipo"=>"INDEX"),
																			   array("valor"=>1, "tipo"=>"INDEX"),
																			   array("valor"=>10, "tipo"=>"INDEX"),
																			   array("valor"=>11, "tipo"=>"INDEX"),
																			   array("valor"=>"this", "tipo"=>"NUM"),
																			   )
																)
												 )
										)
							);
		return $this->SetGridTabla2($varTabla);
		}
	function FormuRegistro($varTra=NULL, $varEmp=NULL, $varPla=NULL, $varOpt=NULL) {
		if($varOpt=="NEW") {
			$SubTit = $this->varTitulo." - NUEVO";
			$varLock = "NO";
			$varClas = "";
			$Fila["id_empresa"]	  			= "1";
			$Fila["id_tipo_trabajador"]	  	= "21";
			$Fila["id_tipo_contrato"]	  	= "03";
			$Fila["id_tipo_pago"]	  	  	= "1";
			$Fila["id_banco_hab"]	  	  	= "00";
			$Fila["id_periodicidad"]	  	= "1";
			$Fila["id_estado_trabajador"] 	= "1";
			$Fila["id_sistema"]		  		= "O";
			$Fila["id_regimen"]			  	= "99";
			}
		else {
			$SubTit =  $this->varTitulo." - EDITAR";
			$varLock = "SI";
			$varClas = "inputDisable";
			$sql = "select T.apellido_paterno, T.apellido_materno, T.nombre, TE.* 
					from ".$this->varMyTabla." TE
					inner join _sv_trabajador T ON TE.id_trabajador = T.id_trabajador
					where TE.id_trabajador  = $varTra
					and TE.id_empresa		= $varEmp
					and TE.id_tipo_planilla = $varPla;";
			$this->AbrirConexion();
			$rs = $this->Query($sql);
			$this->CerrarConexion();
			$Fila = $this->FetchArray($rs);			
			}
		$sqlemp = "call spQuery_Lista_Empresa($_SESSION[_CUSE], NULL, NULL);";
		$sqlage = "call spQuery_Lista_Agencia($_SESSION[_CUSE],'$Fila[id_empresa]',NULL,NULL);";
		$sqlare = "call spQuery_Lista_Area(NULL,NULL);";
		$sqlsub = "call spQuery_Lista_Sub_Area('$Fila[id_area]',NULL,NULL);";
		$sqlcar = "call spQuery_Lista_Cargo('$Fila[id_area]',NULL,NULL);";	
		
		$sqlest	= "call spQuery_Lista_Estado_Trabajador(NULL,NULL);";
		$sqlsex	= array("M"=>"MASCULINO", "F"=>"FEMENINO");
		$sqlttra = "call spQuery_Lista_Tipo_Trabajador_RRHH(NULL,NULL);";
		$sqltcon = "call spQuery_Lista_Tipo_Contrato(NULL,NULL);";
		$sqltpag = "call spQuery_Lista_Tipo_Pago(NULL,NULL);";
		$sqltban = "call spQuery_Lista_Bancos('$Fila[id_tipo_pago]', NULL,NULL);";
		$sqltcts = "call spQuery_Lista_Bancos('2', NULL,NULL);";
		$sqltpla = "call spQuery_Lista_Tipo_Planilla(NULL,NULL);";
		$sqltces = "call spQuery_Lista_Tipo_Cese(NULL,NULL);";
		$sqltper = "call spQuery_Lista_Tipo_Periodicidad(NULL,NULL);";
		$sqlfla = array("N"=>"NO", "S"=>"SI");
		$sqlsis = array("O"=>"NINGUNO", "N"=>"NACIONAL", "P"=>"PRIVADO");
		$sqlreg = "call spQuery_Lista_Regimen('$Fila[id_sistema]', NULL,NULL);";
		$varFormu=array("id"=>"form", "name"=>"form", "metodo"=>"POST");
		$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"450", "clase"=>"FormTitulo", "titulo"=>$this->varTitulo,						
						"ocult"=>array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$this->varTitulo),
									   array("tipo"=>"oculto", "id"=>"opt", "name"=>"opt", "valor"=>$varOpt),
									   array("tipo"=>"oculto", "id"=>"femi", "name"=>"femi", "valor"=>$Fila["FECHA"]),
									   array("tipo"=>"oculto", "id"=>"emp1", "name"=>"emp1", "valor"=>$Fila["id_empresa"]),
									   array("tipo"=>"oculto", "id"=>"tpla1", "name"=>"tpla1", "valor"=>$Fila["id_tipo_planilla"]),
									   ),
						"conte"=>array(array("titulo"=>"Codigo :", "clase1"=>"FormCampo1", "clase2"=>"interior", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"tra", "name"=>"tra", "clase"=>$varClas,
											 										 "valor"=>$Fila[$this->varMyID], "alinear"=>"center", "ancho"=>"70",
																					 "keypress"=>"return SoloEnteros(event)", "locked"=>$varLock, 
																					 "blur"=>"xajax_seleccionar_trabajador_rrhh(this.value)", 
																					 "dclick"=>"fn_cargar_listado_trabajador_rrhh()"),
																			   array("tipo"=>"simple", "valor"=>"Situacion : ", "clase_in"=>"FormCampo1", 
																			   		 "ancho"=>"70"),
																			   array("tipo"=>"select", "id"=>"est", "name"=>"est",
																					 "valor"=>$Fila["id_estado_trabajador"], "sql"=>$sqlest, "ancho"=>"180",
																					 "titulo"=>"--[[SELECCIONAR]]--"),
																			   )
														 	)
											 ),
									   array("titulo"=>"Ape. Paterno :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"apat", "name"=>"apat", "clase"=>"inputDisable",
											 										 "valor"=>$Fila["apellido_paterno"], "locked"=>"SI", "ancho"=>"335")
																			   )
														 	)
											 ),
									   array("titulo"=>"Ape. Materno :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"amat", "name"=>"amat", "clase"=>"inputDisable",
											 										 "valor"=>$Fila["apellido_materno"], "locked"=>"SI", "ancho"=>"335")
																			   )
														 	)
											 ),
									   array("titulo"=>"Nombres :", "clase1"=>"FormCampo1", "clase2"=>"interior",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"nom", "name"=>"nom", "clase"=>"inputDisable",
											 										 "valor"=>$Fila["nombre"], "locked"=>"SI", "ancho"=>"335")
																			   )
														 	)
											 ),
									   ),
					  "boton"=>array(array("tipo"=>"button", "id"=>"bsav", "name"=>"bsav", "ancho"=>"90",
										   "clase"=>"boton_guardar", "texto"=>"Grabar", "click"=>"javascrip:xGrabarJS()"),			  
								     array("tipo"=>"button", "id"=>"breg", "name"=>"breg", "ancho"=>"90",
										   "clase"=>"boton_cancelar", "texto"=>"Cancelar", "click"=>"javascrip:xajax_xRegresar()")
									 )
					);

		$varTab_1=array("id"=>"tabla", "name"=>"table", "tamano"=>"720", "clase"=>"FormTitulo", "titulo"=>"DATOS GENERALES",
						"conte"=>array(array("titulo"=>"Empresa :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "ancho"=>"120",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"emp", "name"=>"emp", "sincod"=>"SI", 
																					 "valor"=>$Fila["id_empresa"], "clase"=>$varClas, "locked"=>$varLock, 
																					 "sql"=>$sqlemp, "titulo"=>"--[[SELECCIONAR]]--", "ancho"=>"300",
																					 "reload"=>"xajax_comboAgencia(this.value, 'divAge','age','300')"),
																			   array("tipo"=>"simple", "valor"=>"Fecha Ingreso Empresa : ", 
																			   		 "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"fing", "name"=>"fing", 
																			   		 "valor"=>FechaFormat($Fila["fecha_ingreso"]),
																			   		 "ancho"=>"120", "alinear"=>"center")
																			   )
														 	)
											 ),
									   array("titulo"=>"Agencia :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "ancho"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"age", "name"=>"age", "sql"=>$sqlage,
																					 "valor"=>$Fila["id_agencia"], 
																			   		 "titulo"=>"--[[SELECCIONAR]]--", "ancho"=>"300", "div"=>"divAge"),
																			   array("tipo"=>"simple", "valor"=>"Fecha Ingreso Planilla : ", 
																			   		 "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"fpla", "name"=>"fpla", "ancho"=>"120", 
																			   		 "valor"=>FechaFormat($Fila["fecha_ingreso_planilla"]), "alinear"=>"center")
																			   )
														 	)
											 ),
									   array("titulo"=>"Area :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"are", "name"=>"are", "valor"=>$Fila["id_area"],  "ancho"=>"300",
																					 "sql"=>$sqlare, "reload"=>"xajax_ComboAreaCargo(this.value,300)", "titulo"=>"--[[SELECCIONAR]]--"),
																			   array("tipo"=>"simple", "valor"=>"Monto Sueldo Bruto : ", "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"mbru", "name"=>"mbru", "valor"=>$Fila["remuneracion_mensual"], "ancho"=>"120")
																			   )
														 	)
											 ),
									   array("titulo"=>"Sub Area :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"sub", "name"=>"sub", "valor"=>$Fila["id_sub_area"], "ancho"=>"300", "div"=>"divSub",
																					 "sql"=>$sqlsub, "titulo"=>"--[[SELECCIONAR]]--"),
																			   array("tipo"=>"simple", "valor"=>"Cond. Laboral Bono : ", "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"mbon", "name"=>"mbon", "valor"=>$Fila["condilab_bono"], "ancho"=>"120")
																			   )
														 	)
											 ),
									   array("titulo"=>"Cargo :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"car", "name"=>"car", "valor"=>$Fila["id_cargo"], "ancho"=>"300", "div"=>"divCar",
																					 "sql"=>$sqlcar, "titulo"=>"--[[SELECCIONAR]]--"),
																			   array("tipo"=>"simple", "valor"=>"Cond. Laboral Viatico : ", "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"mvia", "name"=>"mvia", "valor"=>$Fila["condilab_viatico"], "ancho"=>"120")
																			   )
														 	)
											 ),
									   array("titulo"=>"Motivo Cese :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tces", "name"=>"tces", "valor"=>$Fila["id_tipo_cese"], "ancho"=>"300",
																			   		 "sql"=>$sqltces,  "titulo"=>"--[[SELECCIONAR]]--"),
																			   array("tipo"=>"simple", "valor"=>"Fecha Salida/Cese : ", "clase_in"=>"FormCampo1", "ancho"=>"150"),
																			   array("tipo"=>"texto", "id"=>"fsal", "name"=>"fsal", "valor"=>FechaFormat($Fila["fecha_salida"]), 
																			   		 "ancho"=>"120", "alinear"=>"center")
																			   )
														 	)
											 ),
									   )
							);

		$varTab_2=array("id"=>"tabla", "name"=>"table", "tamano"=>"720", "clase"=>"FormTitulo", "titulo"=>"DATOS LABORALES",
						"conte"=>array(array("titulo"=>"Tipo Trabajador :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"100",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"ttra", "name"=>"ttra", "valor"=>$Fila["id_tipo_trabajador"], 
																					 "ancho"=>"250", "sql"=>$sqlttra, "titulo"=>" --[[SELECCIONAR]]-- "),
																			   array("tipo"=>"simple", "valor"=>"Retener Sueldo : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"select_simple", "id"=>"fret", "name"=>"fret", "valor"=>$Fila["flag_retener"],
																					 "combo"=>array("sql"=>$sqlfla, "sincod"=>"SI", "ancho"=>"80")),
																			   
																			   )
														 	)
											 ),
									   array("titulo"=>"Tipo Contrato :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tcon", "name"=>"tcon", "valor"=>$Fila["id_tipo_contrato"],
																					 "sql"=>$sqltcon, "titulo"=>" --[[SELECCIONAR]]-- ", "ancho"=>"250"),
																			   array("tipo"=>"simple", "valor"=>"Asignacion Familiar : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"select_simple", "id"=>"fasi", "name"=>"fasi", "valor"=>$Fila["flag_asigfam"],
																					 "combo"=>array("sql"=>$sqlfla, "sincod"=>"SI", "ancho"=>"80"))
																			   )
														 	)
											 ),
									   array("titulo"=>"Tipo Pago :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tpag", "name"=>"tpag", "valor"=>$Fila["id_tipo_pago"], 
																			   		 "sql"=>$sqltpag, "ancho"=>"250", "titulo"=>"--[[SELECCIONAR]]--",
																					 "reload"=>"xajax_comboBanco(this.value)"),
																			   array("tipo"=>"simple", "valor"=>"Afecto Renta 5ta : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"select_simple", "id"=>"fqui", "name"=>"fqui", "valor"=>$Fila["flag_quinta"],
																					 "combo"=>array("sql"=>$sqlfla, "sincod"=>"SI", "ancho"=>"80"))
																			   )
														 	)
											 ),
									   
									   array("titulo"=>"Banco Haberes :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tban", "name"=>"tban", "valor"=>$Fila["id_banco_pago"],
																					 "sql"=>$sqltban, "titulo"=>" --[[SELECCIONAR]]-- ", "ancho"=>"250", "div"=>"divBan"),
																			   array("tipo"=>"simple", "valor"=>"Nro. Cta. Haberes : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"texto", "id"=>"cuehab", "name"=>"cuehab", "valor"=>$Fila["nro_cuenta_pago"], 
																			   		 "ancho"=>"200"),
																			   )
														 	)
											 ),
									   array("titulo"=>"Banco CTS :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tcts", "name"=>"tcts", "valor"=>$Fila["id_banco_cts"],
																					 "sql"=>$sqltcts, "titulo"=>" --[[SELECCIONAR]]-- ", "ancho"=>"250"),
																			   array("tipo"=>"simple", "valor"=>"Nro. Cta. CTS : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"texto", "id"=>"cuects", "name"=>"cuects", "valor"=>$Fila["nro_cuenta_cts"], 
																			   		 "ancho"=>"200"),
																			   )
														 	)
											 ),
									   array("titulo"=>"Tipo Planilla :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select", "id"=>"tpla", "name"=>"tpla", 
																					 "valor"=>$Fila["id_tipo_planilla"], "clase"=>$varClas, "locked"=>$varLock,
																					 "sql"=>$sqltpla, "titulo"=>" --[[SELECCIONAR]]-- ", "ancho"=>"250"),
																			   array("tipo"=>"simple", "valor"=>"Periodicidad : ", 
																			   		 "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"select", "id"=>"tper", "name"=>"tper", 
																			   		 "valor"=>$Fila["id_tipo_periodicidad"],
																					 "sql"=>$sqltper, "titulo"=>" --[[SELECCIONAR]]-- ", "ancho"=>"200"),
																			   )
														 	)
											 ),
									   )
							);
		
		$varTab_3=array("id"=>"tabla", "name"=>"table", "tamano"=>"720", "clase"=>"FormTitulo", "titulo"=>"REGIMEN DE PENSIONES",
						"conte"=>array(array("titulo"=>"Sist. Pension :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm", "tamano"=>"90",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select_simple", "id"=>"sis", "name"=>"sis", "valor"=>$Fila["id_sistema"],
																					 "combo"=>array("sql"=>$sqlsis, "ancho"=>"250",
																					 "reload"=>"xajax_comboRegimen(this.value, 'divReg','reg','250')")),
																			   array("tipo"=>"simple", "valor"=>"Regimen : ", "clase_in"=>"FormCampo1", "ancho"=>"90"),
																			   array("tipo"=>"select", "id"=>"reg", "name"=>"reg", "valor"=>$Fila["id_regimen"], 
																			   		 "sql"=>$sqlreg, "titulo"=>"--[[SELECCIONAR]]--", "ancho"=>"250", "div"=>"divReg")
																			   )
														 	)
											 ),
									   array("titulo"=>"Nro. CUSPP  :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"texto", "id"=>"cuspp", "name"=>"cuspp", "valor"=>$Fila["nro_cuspp"], 
																			   		 "ancho"=>"250"),
																			   array("tipo"=>"simple", "valor"=>"Carnet Seguro : ", "clase_in"=>"FormCampo1", "ancho"=>"120"),
																			   array("tipo"=>"texto", "id"=>"carseg", "name"=>"carseg", "valor"=>$Fila["nro_seguro"], 
																			   		 "ancho"=>"250"),
																			   )
														 	)
											 ),
									   array("titulo"=>"Salud Vida :", "clase1"=>"FormCampo1", "clase2"=>"interiorForm",
											 "campo"=>array("tipo"=>"varios",
															"contenido"=>array(array("tipo"=>"select_simple", "id"=>"salv", "name"=>"salv", "valor"=>$Fila["flag_saludvida"],
																					 "combo"=>array("sql"=>$sqlfla, "sincod"=>"SI", "ancho"=>"80")),
																			   
																			   )
														 	)
											 ),
									   )
							);
		
											
		$varTabs =array(array("name"=>"Datos Generales",
							  "tipo"=>"form",  "alto"=>"300", "ancho"=>"730", "tabla"=>$varTab_1
							  ),
						array("name"=>"Datos Laborales",
							  "tipo"=>"form",  "alto"=>"300", "ancho"=>"730", "tabla"=>$varTab_2
							  ),	
						array("name"=>"Regimen Pension",
							  "tipo"=>"form",  "alto"=>"300", "ancho"=>"730", "tabla"=>$varTab_3
							  )
						);
		$varReturn.= $this->setTablaFormTabs($varFormu, $varTabla, $varTabs);
		$varReturn.= "</form>";
		
		return $varReturn;
		}
		
	function ProcesoGrabar($varForm = NULL) {		
		$varOpt	= "'$varForm[opt]'";
		$varTra = ($varForm["tra"]=="")?"NULL": $varForm["tra"];
		$varEmp = ($varForm["emp"]=="")?"NULL": $varForm["emp"];
		if($varForm["opt"]=="NEW") $varPla = ($varForm["tpla"]=="")?"NULL": "'".$varForm["tpla"]."'";
		else $varPla = ($varForm["tpla1"]=="")?"NULL": "'".$varForm["tpla1"]."'";
		$varEst = ($varForm["est"]=="")?"NULL":$varForm["est"];
		if($varForm["opt"]=="NEW") $varEmp = ($varForm["emp"]=="")?"NULL": $varForm["emp"];
		else $varEmp = ($varForm["emp1"]=="")?"NULL": $varForm["emp1"];
		$varAge = ($varForm["age"]=="Ninguno")?"NULL": $varForm["age"];
		$varAre = ($varForm["are"]=="Ninguno")?"NULL": $varForm["are"];
		$varSub = ($varForm["sub"]=="Ninguno")?"NULL": $varForm["sub"];
		$varCar = ($varForm["car"]=="Ninguno")?"NULL": $varForm["car"];
		$varTip = ($varForm["ttra"]=="")?"NULL": "'".$varForm["ttra"]."'";
		$varFIng = ($varForm["fing"]=="")?"NULL": "'".FechaMySql($varForm["fing"])."'";
		$varFSal = ($varForm["fsal"]=="")?"NULL": "'".FechaMySql($varForm["fsal"])."'";
		$varFPla = ($varForm["fpla"]=="")?"NULL": "'".FechaMySql($varForm["fpla"])."'";
		$varCes  = ($varForm["tces"]=="Ninguno")?"NULL": "'".$varForm["tces"]."'";
		$varCon  = ($varForm["tcon"]=="")?"NULL": "'".$varForm["tcon"]."'";
		$varPer  = ($varForm["tper"]=="")?"NULL": "'".$varForm["tper"]."'";
		$varPag  = ($varForm["tpag"]=="")?"NULL": "'".$varForm["tpag"]."'";
		$varBanP = ($varForm["tban"]=="")?"NULL": "'".$varForm["tban"]."'";
		$varCueP = ($varForm["cuehab"]=="")?"NULL": "'".$varForm["cuehab"]."'";
		$varBanC = ($varForm["tcts"]=="Ninguno")?"NULL": "'".$varForm["tcts"]."'";
		$varCueC = ($varForm["cuects"]=="")?"NULL": "'".$varForm["cuects"]."'";
		$varRem  = ($varForm["mbru"]=="")?0: $varForm["mbru"];
		$varBon  = ($varForm["mbon"]=="")?0: $varForm["mbon"];
		$varVia  = ($varForm["mvia"]=="")?0: $varForm["mvia"];		
		$varRet  = ($varForm["fret"]=="")?"NULL": "'".$varForm["fret"]."'";
		$varQui  = ($varForm["fqui"]=="")?"NULL": "'".$varForm["fqui"]."'";
		$varAsi  = ($varForm["fasi"]=="")?"NULL": "'".$varForm["fasi"]."'";
		$varSis  = ($varForm["sis"]=="")?"NULL": "'".$varForm["sis"]."'";
		$varReg  = ($varForm["reg"]=="")?"NULL": "'".$varForm["reg"]."'";
		$varCus  = ($varForm["cuspp"]=="")?"NULL": "'".$varForm["cuspp"]."'";
		$varCarS = ($varForm["carseg"]=="")?"NULL": "'".$varForm["carseg"]."'";
		$varVid  = ($varForm["salv"]=="")?"NULL": "'".$varForm["salv"]."'";		
		$varUsr = (isset($_SESSION["_CUSE"]))?$_SESSION["_CUSE"]:1;
  		
		$sql = "call spMante_Trabajador_Empresa($varOpt,  $varTra,  $varEmp,  $varPla,  $varEst, $varAge, $varAre, $varSub, $varCar, 
												$varTip,  $varFIng, $varFSal, $varFPla, $varCes, $varCon, $varPer, $varPag, $varBanP, 
												$varCueP, $varBanC, $varCueC, $varRem,  $varBon, $varVia, $varRet, $varQui, $varAsi,           
      											$varSis,  $varReg,  $varCus,  $varCarS,	$varVid, $varUsr);";
	
		$this->AbrirConexion();
		$rs = $this->Query(utf8_decode($sql));
		$this->CerrarConexion();
		$Fila = $this->FetchArray($rs);
		
		return $Fila[0];
		}
		
	function ProcesoEliminar($varEmp, $varTra, $varPla) {
		$varUsr = (isset($_SESSION["_CUSE"]))?$_SESSION["_CUSE"]:1;
		$sql = "delete from ".$this->varMyTabla." 
				where id_empresa 	 = $varEmp
				and id_trabajador 	 = $varTra
				and id_tipo_planilla = $varPla;";
		$this->AbrirConexion();
		$this->Query($sql);
		$this->CerrarConexion();
		}
	}
	
?>