<?php

include("../bd/sql_variables.php");

require_once("../class/class.usudep.php");
require_once("../class/class.tipopersonal.php");
require_once("../class/class.especialidad.php");

$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($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($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_tp[$i]['cod']."'>".$res_tp[$i]['descripcion']."</option>";
}
$cadenaesp=$cadenaesp."</select>";


//construytento listado
$Objud = new UsuarioDependencia();
$res_ud = array();
$res_ud = $Objud->listar_per_dep($idj,$ids)
$sumap=0;
for ($i=0;$i<count($res_ud);$i++){
$codigo=$res_ud[$i]['cod'];
$cadenalis=$cadenalis."<tr><td align='left'>".$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'><img src='img/heart_red.png' width='17' height='17' value='$codigo' onClick=verdescansomedico(this.value);></td><td align='center'><img src='img/eye.png' value='$codigo' onClick=verdetallevacaprog(this.value);></td><td align='center'><img src='img/book.png' width='17' height='17' id='person' value='$codigo' onClick=datospersonal(this.value);></td></tr>";
$sumap=$sumap+1;
}
$cadenalis=$cadenalis."<tr><td colspan='8' 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(codigo){
	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(codigo){
	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 verdescansomedico(codigo){
	window.open("verdmedicoprog.php?ugid="+codigo,"","height=200,width=200,scrollbars=NO");
} 
function editarpersonal(codigo){
		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 retornarmenu(){
		var idj = document.getElementById("depa").value;
		var ids = document.getElementById("serv").value;
        var ugid = document.getElementById("ugid").value;		
		document.location= "menuadminprog.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>
<div id='adminpersonal'>
<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><?php echo $cadenatp;?></td>
	<td align='left'>Especialidad</td>
	<td><?php echo $cadenaesp;?></td>
	<td align='center'></td><td width='50'></td><td><button type='button' id='pprog' style='width:80px' class='FacetButton' onclick='retornarmenu();' >Retornar Al<br>Menu Principal</button></td>
	</tr></table>
	<br>
	<div id='admlista'>
	<table align='center' class='FacetFormTABLE'>
	<tr><td colspan='9'class='FacetFieldCaptionTDT' align='center'> PERSONAL ASISTENCIAL </td></tr>
	<tr><td class='FacetFieldCaptionTD' align='center' width='250'>APEDLLIDOS 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'>DesMed</td><td class='FacetFieldCaptionTD' align='center'>VACAC</td><td class='FacetFieldCaptionTD' align='center'>DATOS</td></tr>
	
	<?php echo $cadenalis;?>
	
	</table>
	</div>
	<br>
</fieldset>
</td></tr>
</table>
</body>
</html>