<?php
require_once("../class/class.conectar.php");
require_once("../class/class.usudep.php");
require_once("../class/class.vacaciones.php");

$periodo=$_GET['anno'];
$idtp=$_GET['tp'];
$tcont=$_GET['tcont'];
$idj=$_GET['idj'];
$ids=$_GET['ids'];

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

$Objud = new UsuarioDependencia();
$res_ud = array();
if($tcont!=0 and $idtp!=0 ){
$res_ud=$Objud->listar_per_dep_tp_c($conex,$idj,$ids,$idtp,$tcont);
}elseif($tcont==0 and $idtp!=0){
$res_ud=$Objud->listar_per_dep_tp($conex,$idj,$ids,$idtp);
}elseif($tcont!=0 and $idtp==0){
$res_ud=$Objud->listar_per_dep_c($conex,$idj,$ids,$tcont);
}else{
$res_ud=$Objud->listar_per_dep($conex,$idj,$ids);
}

$sumap=0;


$cadenalis="";
$cadenalis="<table align='center' border='1' class='FacetFormTABLE' style='border-collapse: collapse ;border-spacing:  0px;'><tr><td colspan='10'class='FacetFieldCaptionTDT' align='center' height='30'> PERSONAL ASISTENCIAL </td></tr>";
$cadenalis=$cadenalis."<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'>PERIODO</td><td class='FacetFieldCaptionTD' align='center'>VAC. PROG</td><td class='FacetFieldCaptionTD' align='center'>VAC. EJE</td><td class='FacetFieldCaptionTD' align='center'>VER DET.</td><td class='FacetFieldCaptionTD' align='center'>EDITAR</td></tr>";
$s=0;
for ($i=0;$i<count($res_ud);$i++){
$codigo=$res_ud[$i]['cod'];
$vacaprog=0;
$s=$s+1;
$cadenalis=$cadenalis."<tr><td align='left'>".utf8_encode($res_ud[$i]['nombre'])."</td><td align='center'>".utf8_encode($res_ud[$i]['tpersona'])."</td><td align='center'>".utf8_encode($res_ud[$i]['especialidad'])."</td><td align='center'>".utf8_encode($res_ud[$i]['tipocontrato'])."</td><td align='center'>".$res_ud[$i]['fingreso']."</td><td align='center'>".$periodo."</td>";

//vacaciones programadas
$Objvp = new Vacaciones();
$res_vp = array();
$res_vp=$Objvp->aks_vacaciones($conex,$codigo,$periodo,0);

if(count($res_vp)>0){
for ($a=0;$a<count($res_vp);$a++){
if($res_vp[$a]['suma']==$res_vp[$a]['numdias']){
$cadenalis=$cadenalis."<td align='center'><img src='img/check.png' width='15' height='15'></td>";
$vacaprog=1;
	}else{
	$cadenalis=$cadenalis."<td align='center'><img src='img/b_drop.png'></td>";
	}
}/*elseif(($res_vp[$a]['suma']<$res_vp[$a]['numdias']) && ($res_vp[$a]['suma']>0)){
$cadenalis=$cadenalis."<td align='center'><img src='img/check.png' width='15' height='15'></td>";
}*/
}else{
$cadenalis=$cadenalis."<td align='center'><img src='img/b_drop.png'></td>";
}


//vacaciones ejecutadas
$Objve = new Vacaciones();
$res_ve = array();
$res_ve=$Objve->aks_vacaciones($conex,$codigo,$periodo,1);

if(count($res_ve)>0){
for ($a=0;$a<count($res_ve);$a++){
if($res_ve[$a]['suma']==$res_ve[$a]['numdias']){
$cadenalis=$cadenalis."<td align='center'><img src='img/check.png' width='15' height='15'></td>";
$vacaprog=1;
}else{
	$cadenalis=$cadenalis."<td align='center'><img src='img/b_drop.png'></td>";
}/*elseif(($res_ve[$a]['suma']<$res_ve[$a]['numdias']) && ($res_ve[$a]['suma']>0)){
$cadenalis=$cadenalis."<td align='center'><img src='img/check.png' width='15' height='15'></td>";
}*/}
}else{
$cadenalis=$cadenalis."<td align='center'><img src='img/b_drop.png'></td>";
}

$cadenalis=$cadenalis."<td align='center'><input type='hidden' id='vacdet".$s."' value='".$codigo."'><img src='img/ver.jpg' width='17' height='17'  onClick=verdetallevaca($s);></td>";
if($vacaprog==1){
$cadenalis=$cadenalis."<td align='center'><img src='img/green.png' width='17' height='17'></td></tr>";
}else{
$cadenalis=$cadenalis."<td align='center'><input type='hidden' id='vacing".$s."' value='".$codigo."'><img src='img/red.png' width='17' height='17'  onClick=registravaca($s);></td></tr>";
}
$sumap=$sumap+1;
}

$cadenalis=$cadenalis."<tr><td colspan='10' align='center'>El numero de Personal es ".$sumap."</td></tr>";
$cadenalis=$cadenalis."</table>";
?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/Style.css">
</head>
<body>
<?php
echo $cadenalis;
?>
</body>
</html>