
<html>
<head>
<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 capturacodigo(num){

var codigo = document.getElementById('codp'+num).value;
var idso = document.getElementById('servp'+num).value;

var idj = document.getElementById('depa').value;
var ids = document.getElementById('serv').value;
var idtp = document.getElementById('idtp').value;
var anno = document.getElementById('anno').value;
var mes = document.getElementById('mes').value;
document.location= "programacion/agregarnuevoper.php?coduni="+codigo+"&idj="+idj+"&ids="+ids+"&idso="+idso+"&idtp="+idtp+"&anno="+anno+"&mes="+mes;
}
function ventanaClose(){ 
   //alert("hola mundo");
    window.close();
}
</script> 
<title>BUSCANDO AL PERSONAL ASISTENCIAL</title>
</head>
<body id="lista" name="lista">
<?php
$anno=$_GET['anno'];
$mes=$_GET['mes'];
$idj=$_GET['idj'];
$ids=$_GET['ids'];
$idtp=$_GET['idtp'];

echo "<input type='hidden' id='anno' name='anno' value='".$anno."'>";
echo "<input type='hidden' id='mes' name='mes' value='".$mes."'>";
echo "<input type='hidden' id='idtp' name='idtp' value='".$idtp."'>";
echo "<input type='hidden' id='depa' name='depa' value='".$idj."'>";
echo "<input type='hidden' id='serv'  name='serv' value='".$ids."'>";


include("bd/sql_variables.php");

include("paginacion/config_newpag.php");
include("paginacion/my_pagina_class.php");
define("NUM_ROWS",'2');
define("NUM_LINKS",'2');

$con= mysqli_connect("$sql_host", "$sql_usuario", "$sql_pass") or die(header ("No Disponible Servidor de Base de Datos"));
mysqli_select_db($con,"$sql_db");

//construytento listado
if($_GET['nombre']){
$nombre = $_GET['nombre'];
$_pagi_sql = "select a.ug_id as cod, concat(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, (select j_abrev from tb_jefatura where j_id=b.j_id) as jefatura, b.s_id as idso ,(select s_abrev from tb_servicio where j_id=b.j_id and s_id=b.s_id) as servicio from tb_usuasist a inner join tb_usudep b on ";
$_pagi_sql = $_pagi_sql."  a.ug_id = b.ug_id where (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) and (a.ua_apepat like '%$nombre%' or a.ua_apemat like '%$nombre%' or a.ua_nom like '%$nombre%') and b.tp_id='$idtp' and b.j_id='$idj' and b.ug_id in (select ug_id from tb_usutrab where j_id=b.j_id and ut_idserva not in ('$ids') and tp_id=b.tp_id) order by nombre";

}else{
$_pagi_sql = "select a.ug_id as cod, concat(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, (select j_abrev from tb_jefatura where j_id=b.j_id) as jefatura, b.s_id as idso, (select s_abrev from tb_servicio where j_id=b.j_id and s_id=b.s_id) as servicio from tb_usuasist a inner join tb_usudep b on ";
$_pagi_sql = $_pagi_sql."  a.ug_id = b.ug_id where (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) and b.tp_id='$idtp' and b.j_id='$idj' and b.ug_id in (select ug_id from tb_usutrab where j_id=b.j_id and ut_idserva not in ('$ids') and tp_id=b.tp_id) order by nombre";

}
//echo $_pagi_sql;

?>

<table align='center'>
<tr><td colspan='4'class='FacetFieldCaptionTDT' align='center'><b>AGREGAR NUEVO PERSONAL ASISTENCIAL</b></td></tr>
<tr><td>
<div id='adminpersonal'>
BUSCAR X APELLIDOS <input type='text' size='60' id='txtnombre' name='txtnombre' onkeyPress='buscarpersonalrepro()' value='<?php if($nombre!=""){echo $nombre;}?>'><br>
<fieldset>
	<legend align='left'><font color='blue'>Listado del Personal Asistencial</font></legend>
	<br>
	<div id='divbuscapersonal'>
	<table align='center' class='FacetFormTABLE'>
	<tr><td colspan='4'class='FacetFieldCaptionTDT' align='center'> PERSONAL ASISTENCIAL </td></tr>
	<tr><td class='FacetFieldCaptionTD' align='center' width='250'>APELLIDOS Y NOMBRES</td><td class='FacetFieldCaptionTD' align='center' width='130'>AREA / DEPARTAMENTO </td><td class='FacetFieldCaptionTD' align='center' width='130'>SERVICIO</td><td class='FacetFieldCaptionTD' align='center' width='130'>AGREGAR</td></tr>
	<?php
	$test = new MyPagina;
       $test->sql = $_pagi_sql;
       $result = $test->get_page_result(); 
       $num_rows = $test->get_page_num_rows();  
       $nav_links = $test->navigation(" | ", "currentStyle"); 
	   $nav_info = $test->page_info("al"); 
       $simple_nav_links = $test->back_forward_link(); 
       $total_recs = $test->get_total_rows(); 


		if ($total_recs>=1)
	   {
		 $i = 0;
		 $s=1;
		 do
   		 {
		 $cod = mysqli_result($result, $i, "cod");
		 $nombre = mysqli_result($result, $i, "nombre");
   		 $jefatura = mysqli_result($result, $i, "jefatura");
         $servicio = mysqli_result($result, $i, "servicio");
		 $idso = mysqli_result($result, $i, "idso");
		 

		echo "<tr><td>".$nombre."</td><td align='center'>".$jefatura."</td><td align='center'>".$servicio."</td><td align='center'><img src='personal/img/b_edit.png' onClick='capturacodigo($s)'><input type='hidden' id='codp".$s."' name='codp".$s."' value='".$cod."'><input type='hidden' id='servp".$s."' name='servp".$s."' value='".$idso."'></td></tr>";
		$s++;
		$i++;
  		}while($i < $num_rows);}
  
echo "</table><br>";

echo "<table align='center' class='FacetFormTABLE'><tr><td colspan='4' class='FacetFieldCaptionTD' align='center'><center>";
 if ((isset($total_recs))&&($total_recs>=1)){ echo ' Registros(s) del '.$nav_info.' de '.$total_recs.' encontrado(s).' ;}else{ echo '0 Registros(s) encontrado(s).';} 
 echo "</center></td></tr><tr><td colspan='4' class='FacetFieldCaptionTD' align='center'><center>";
 if (isset($total_recs)){ echo $nav_links; }
echo "</center></td></tr></table>"; 
	?>
	
	</div>
	<br>
	<center><input type='button' size='60' id='cancelar' value='Cancelar' onClick='ventanaClose()'></center>
</fieldset>
</td></tr>
</table>
</body>
</html>