<?php

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

$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");

$idesp=$_GET['esp'];
$idtp=$_GET['tp'];
$idj=$_GET['idj'];
$ids=$_GET['ids'];
$div=$_GET['div'];

$sqllistado = "select a.ug_id as cod, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nombre ";
$sqllistado = $sqllistado." from tb_usuasist a inner join tb_usudep b on ";
$sqllistado = $sqllistado." a.ug_id = b.ug_id where b.j_id='$idj' and b.s_id='$ids' and (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) order by apepat, apemat, nombre";


if($idesp!=0 and $idtp!=0 ){
$sqllistado = "select a.ug_id as cod, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nombre ";
$sqllistado = $sqllistado." from tb_usuasist a inner join tb_usudep b on ";
$sqllistado = $sqllistado." a.ug_id = b.ug_id where b.j_id='$idj' and b.s_id='$ids'  and b.tp_id='$idtp' and b.ua_idespec='$idesp' and (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) order by apepat, apemat, nombre";
}elseif($idesp==0 and $idtp!=0){
$sqllistado = "select a.ug_id as cod, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nombre ";
$sqllistado = $sqllistado." from tb_usuasist a inner join tb_usudep b on ";
$sqllistado = $sqllistado." a.ug_id = b.ug_id where b.j_id='$idj' and b.s_id='$ids'  and b.tp_id='$idtp' and (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) order by apepat, apemat, nombre";
}elseif($idesp!=0 and $idtp==0){
$sqllistado = "select a.ug_id as cod, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nombre ";
$sqllistado = $sqllistado." from tb_usuasist a inner join tb_usudep b on ";
$sqllistado = $sqllistado." a.ug_id = b.ug_id where b.j_id='$idj' and b.s_id='$ids' and b.ua_idespec='$idesp' and (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) order by apepat, apemat, nombre";
}else{
$sqllistado = "select a.ug_id as cod, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nombre ";
$sqllistado = $sqllistado." from tb_usuasist a inner join tb_usudep b on ";
$sqllistado = $sqllistado." a.ug_id = b.ug_id where b.j_id='$idj' and b.s_id='$ids' and (b.ua_estado= 1 or b.ua_estado= 2 or b.ua_estado= 4) order by apepat, apemat, nombre";
}
//echo $sqllistado;
//aumentar  a.tc_idcont='3'
$resultlistado = mysqli_query($con,$sqllistado);
$sumap=0;



$cadenalis="";
if($div==1){
$cadenalis="<select name='dmlist' id='dmlist' size='4' style='width:22em;' onClick='listarfechadm()'>";	
}
if($div==2){
$cadenalis="<select name='vacaproglist' id='vacaproglist' size='4' style='width:22em;' onClick='listarvacaprog()'>";	
}
if($div==3){
$cadenalis="<select name='vacaejelist' id='vacaejelist' size='4' style='width:22em;' onClick='listarvacaeje()'>";	
}
if($div==4){
$cadenalis="<select name='liclist' id='liclist' size='4' style='width:22em;' onClick='listarfechalic()'>";	
}

if($div==5){
$cadenalis="<select name='hrslist' id='hrslist' size='4' style='width:22em;' onClick='listarhoraper()' >";	
}

if($div==6){
$cadenalis="<select name='drproglist' id='drproglist' size='4' style='width:22em;' onClick='listardescradprog()' >";	
}

if($div==7){
$cadenalis="<select name='drejelist' id='drejelist' size='4' style='width:22em;' onClick='listardescradeje()' >";	
}

while ($rowl= mysqli_fetch_assoc($resultlistado)){
$codigo=$rowl['cod'];
$apepat=$rowl['apepat'];
$apemat=$rowl['apemat'];
$nombre=$rowl['nombre'];
$letranom=substr($nombre, 0, 2);
$letraapemat=substr($apemat, 0, 2);
$nombrefijo= utf8_encode($letranom).". ".utf8_encode($apepat)." ".utf8_encode($letraapemat).".";
$cadenalis=$cadenalis."<option value='".$codigo."'";
$sumap=$sumap+1;
if($sumap==1){
$cadenalis=$cadenalis." selected ";
}
$cadenalis=$cadenalis.">".$nombrefijo."</option>";

}
$cadenalis=$cadenalis."</select>";
echo $cadenalis;
?>

