<?php
require_once("../class/class.conectar.php");
require_once("../class/class.usudep.php");
require_once("../class/class.tipopersonal.php");
require_once("../class/class.tipocontrato.php");
require_once("../class/class.especialidad.php");

$Objcon = new Conectar();
$conex = $Objcon->con();

$idj = $_GET['idj'];
$ids = $_GET['ids'];
$ugid = $_GET['ugid'];

//seleccionando al combo tipo de personal
$Objtp = new TipoPersonal();
$res_tp = array();
$res_tp = $Objtp->buscar_tipoper_dep($conex,$idj,$ids);
$cadenatp="<select id='tipopersonal' onChange='listarpersonalprog();'><option value='0' selected>TODOS</option>";
for ($i=0;$i<count($res_tp);$i++){
$cadenatp=$cadenatp."<option value='".$res_tp[$i]['id']."'>".$res_tp[$i]['nom']."</option>";
}
$cadenatp=$cadenatp."</select>";


//seleccionando al comnbo especialidad
$Obje = new Especialidad();
$res_e = array();
$res_e = $Obje->listar_especialidad($conex,$idj,$ids);
$cadenaesp="<select id='especialidad' onChange='listarpersonalprog();'><option value='0' selected>TODOS</option>";
for ($i=0;$i<count($res_e);$i++){
$cadenaesp=$cadenaesp."<option value='".$res_e[$i]['cod']."'>".$res_e[$i]['descripcion']."</option>";
}
$cadenaesp=$cadenaesp."</select>";


//seleccionando al comnbo tipo de contrato
$Objtc = new TipoContrato();
$res_tc = array();
$res_tc = $Objtc->listar_tp_cont_dep($conex,$idj,$ids);
$cadenatc="<select id='tcontrato' onChange='listarpersonalprog()'><option value='0' selected>TODOS</option>";
for ($i=0;$i<count($res_tc);$i++){
$cadenatc=$cadenatc."<option value='".$res_tc[$i]['cod']."'>".$res_tc[$i]['tipocont']."</option>";
}
$cadenatc=$cadenatc."</select>";

//construytento listado
$Objud = new UsuarioDependencia();
$res_ud = array();
$res_ud = $Objud->listar_per_dep($conex,$idj,$ids);
$sumap=0;
$a=1;
$muestra="";
$cadenalis="";
for ($i=0;$i<count($res_ud);$i++){
$codigo = $res_ud[$i]['cod'];
$muestra = $muestra."<input type='hidden' id='codper".$a."'  name='codper".$a."' value='".$codigo."'>";
$cadenalis=$cadenalis."<tr><td align='left'>".utf8_encode($res_ud[$i]['nombre'])."</td><td align='center'>".$res_ud[$i]['tpersona']."</td><td align='center'>".$res_ud[$i]['especialidad']."</td><td align='center'>".$res_ud[$i]['tipocontrato']."</td><td align='center'>".$res_ud[$i]['fingreso']."</td><td align='center'>".$res_ud[$i]['tiempo']."</td><td align='center'><a href='#' onClick=editarpersonal($a); ><img src='img/b_edit.png' width='17' height='17' border='0'></a></td><td align='center'><a href='#' onClick=transferirpersonal($a); ><img src='img/ver.jpg' width='17' height='17' border='0'></a></td><td align='center'><a href='#' onClick=suspenderpersonal($a); ><img src='img/b_drop.png' border='0'></a></td><td align='center'><a href='#' onClick='verdescansomedico($a)'><img src='img/heart_red.png' width='17' height='17' border='0'></a></td><td align='center'><a href='#' onClick=verdetallevacaprog($a); ><img src='img/eye.png' border='0'></a></td><td align='center'><a href='#' onClick=datospersonal($a);> <img src='img/book.png' width='17' height='17' id='person' border='0' ></a></td><td align='center'><a href='#' onClick=askprogramacion($a);> <img src='img/calendar.png' width='17' height='17' id='person' value='$codigo' border='0'></a></td></tr>";
$sumap = $sumap +1;
$a=$a+1;
}
$cadenalis=$cadenalis."<tr><td colspan='13' align='center'>El numero de Personal es ".$sumap."</td></tr>";
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" type="text/css" href="styles/Style.css">
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>

<script type="text/javascript"> 
function agregarpersonal(){
	var idj = document.getElementById("depa").value;
	var ids = document.getElementById("serv").value;
    var ugid = document.getElementById("ugid").value;
   window.open("adminpersonal.php?idj="+idj+"&ids="+ids+"&ugid="+ugid,"","height=400,width=600,scrollbars=NO");
}

function verdetallevacaprog(a){
	var codigo = document.getElementById("codper"+a).value;
	var idj = document.getElementById("depa").value;
	var ids = document.getElementById("serv").value;
    var ugid = document.getElementById("ugid").value;
   window.open("verdetvacacionesprog.php?ugid="+ugid+"&idj="+idj+"&ids="+ids+"&codigo="+codigo,"","height=400,width=600,scrollbars=NO");
}

function datospersonal(a){
	var codigo = document.getElementById("codper"+a).value;
	var idj = document.getElementById("depa").value;
	var ids = document.getElementById("serv").value;
	window.open("vistapersonal.php?ugid="+codigo+"&idj="+idj+"&ids="+ids,"","height=410,width=390,scrollbars=NO");
} 

function askprogramacion(a){
	var codigo = document.getElementById("codper"+a).value;
	var idj = document.getElementById("depa").value;
	var ids = document.getElementById("serv").value;
	window.open("consultaprog.php?ugid="+codigo+"&idj="+idj+"&ids="+ids,"","height=310,width=390,scrollbars=NO");
} 

function verdescansomedico(a){
    //alert(a);
	var codigo = document.getElementById("codper"+a).value;
	window.open("verdmedicoprog.php?ugid="+codigo,"","height=200,width=200,scrollbars=NO");
}

function transferirpersonal(a){
	var codigo = document.getElementById("codper"+a).value;
	var idj = document.getElementById("depa").value;
	var ids = document.getElementById("serv").value;
	window.open("transferirpersonal.php?ugid="+codigo+"&idj="+idj+"&ids="+ids,"","height=320,width=700,scrollbars=NO");
} 
function editarpersonal(a){
		var codigo = document.getElementById("codper"+a).value;
		var idj = document.getElementById("depa").value;
		var ids = document.getElementById("serv").value;
		window.open("modificarpersonal.php?ugid="+codigo+"&idj="+idj+"&ids="+ids,"","height=400,width=600,scrollbars=NO");
} 
function suspenderpersonal(a){
		var codigo = document.getElementById("codper"+a).value;
		window.open("suspenderpersonal.php?ugid="+codigo,"","height=400,width=600,scrollbars=NO");
} 
function retornarmenu(){
		var idj = document.getElementById("depa").value;
		var ids = document.getElementById("serv").value;
        var ugid = document.getElementById("ugid").value;		
		document.location= "menuadmin.php?idj="+idj+"&ids="+ids+"&ugid="+ugid;
} 
</script> 
</head>
<body id="lista" name="lista">
<?php
echo "<input type='hidden' id='depa' name='depa' value='".$idj."'>";
echo "<input type='hidden' id='serv'  name='serv' value='".$ids."'>";
echo "<input type='hidden' id='ugid'  name='ugid' value='".$ugid."'>";
?>
<table align='center'>
<tr><td>

<fieldset>
	<legend align='left'><font color='blue'>Listado del Personal Asistencial</font></legend>
	<br>
	<table align='center' ><tr><td align='left'>Tipo de Personal</td>
	<td><div id='divtp'><?php echo $cadenatp;?></div></td></tr>
	<tr><td align='left'>Especialidad</td>
	<td><div id='divesp'><?php echo $cadenaesp;?></div></td>
	<td align='center'></td><td width='50'></td><td><img src='../img/home.png' width='70' height='60' onClick='retornarmenu()' alt='Regresar al Menu Principal'></td>
	</tr>
	<tr><td align='left'>Tipo de Contrato</td>
	<td><?php echo $cadenatc;?></td><td><img src='img/icoexcel.png' width='27' height='27' onClick='listarpersonalxlsserv();' alt='Exportar al Excel'><img src='img/agregar.jpg' width='30'  height='30' onClick='agregarpersonal()' alt='AGREGAR NUEVO PERSONAL'></td></tr>
	<tr><td align='left'>Busqueda por Apellido </td><td><input type='text' size='40' id='nombre' onKeyPress='buscarpersonalservicio()'></td></tr>
	</table>
	<br>
	<div id='admlista'>
	<table align='center' class='FacetFormTABLE' border='1' style='border-collapse: collapse ;border-spacing:  0px;'>
	<tr><td colspan='13'class='FacetFieldCaptionTDT' align='center' height='30'> PERSONAL ASISTENCIAL </td></tr>
	<tr><td class='FacetFieldCaptionTD' align='center' width='250' height='25'>APELLIDOS Y NOMBRES</td><td class='FacetFieldCaptionTD' align='center' width='130'>TIPO PERSONAL</td><td class='FacetFieldCaptionTD' align='center' width='130'>ESPECIALIDAD</td><td class='FacetFieldCaptionTD' align='center' width='130'>TIPO DE CONTRATO</td><td class='FacetFieldCaptionTD' align='center' width='100'>FECHA DE INGRESO</td><td class='FacetFieldCaptionTD' align='center' width='70'>PERIOD. LAB.</td><td class='FacetFieldCaptionTD' align='center'>EDITAR</td><td class='FacetFieldCaptionTD' align='center'>TRANSF</td><td class='FacetFieldCaptionTD' align='center'>SUSPE</td><td class='FacetFieldCaptionTD' align='center'>DesMed</td><td class='FacetFieldCaptionTD' align='center'>VACAC</td><td class='FacetFieldCaptionTD' align='center'>DATOS</td><td class='FacetFieldCaptionTD' align='center'>PROG</td></tr>
	
	<?php echo $cadenalis;echo $muestra;?>
	
	</table>
	</div>
	<br>
</fieldset>
</td></tr>
</table>
</body>
</html>