<?php

require_once("../class/class.conectar.php");

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

$ugid=$_GET['codigo'];

if(isset($_GET['idt'])){
$ugid = $_GET['ugid'];
$idfecha = $_GET['idfecha'];
$sqlupdate = "update tb_vacaciones set v_estado=2 where v_id='$idfecha' and ug_id='$ugid' and v_estado=0";
//echo $sqlupdate;
$resultdm = mysqli_query($conex,$sqlupdate);
echo "<script type='text/javascript'>window.opener.location.reload(); </script>";
}


//seleecionado vacaciones programadas
$sqlvacaprog="select v_id as id, concat(date_format(v_fechaini,'%d/%m/%Y'),' - ', date_format(v_fechafin,'%d/%m/%Y'),' (', v_numdias,')') ";
$sqlvacaprog=$sqlvacaprog." as dias, v_periodo as periodo from tb_vacaciones where ug_id='$ugid' and v_estado=0 order by v_fechaini desc";
$resultvacaprog = mysqli_query($conex,$sqlvacaprog);
$cadenavp="<select size='4' style='width:23em;' id='idfechavp'>";
while ($rowvp= mysqli_fetch_array($resultvacaprog)){
$codigo=$rowvp['id'];
$dias=$rowvp['dias'].$rowvp['periodo'];
$cadenavp=$cadenavp."<option value='".$codigo."'>".$dias."</option>";
}
$cadenavp=$cadenavp."</select>";

//seleecionado vacaciones ejecutadas
$sqlvacaeje="select v_id as id, concat(date_format(v_fechaini,'%d/%m/%Y'),' - ', date_format(v_fechafin,'%d/%m/%Y'),' (', v_numdias,')') ";
$sqlvacaeje=$sqlvacaeje." as dias, v_periodo as periodo from tb_vacaciones where ug_id='$ugid' and v_estado=1 order by v_fechaini desc";
$resultvacaeje = mysqli_query($conex,$sqlvacaeje);
$cadenave="<select size='4' style='width:23em;'>";
while ($rowve= mysqli_fetch_array($resultvacaeje)){
$codigo=$rowve['id'];
$dias=$rowve['dias'].$rowve['periodo'];
$cadenave=$cadenave."<option value='".$codigo."'>".$dias."</option>";
}
$cadenave=$cadenave."</select>";

//seleccionando al personal
$sqlp = "select concat(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, date_format(b.ud_fechaing,'%d/%m/%Y') as fechaing from tb_usuasist a inner join tb_usudep b on a.ug_id=b.ug_id where a.ug_id='$ugid'" ;
//echo $sqltc;
$resultp = mysqli_query($conex,$sqlp);
while ($rowp= mysqli_fetch_array($resultp)){
$nombre = $rowp['nombre'];
$fechaing = $rowp['fechaing'];
}
?>
<html>
<head>
<title>VACACIONES PROGRAMADAS Y EJECUTADAS</title>
<link rel="stylesheet" type="text/css" href="styles/Style.css">
<script language="JavaScript">
function cerrarVentana(){
window.close();
}
function SuspenderVaca(){ 
   //alert("hola mundo");
	var ugid = document.getElementById('ugid').value;
	var numid = document.getElementById('idfechavp').value;
	//alert(numid);
    window.location ="vervacaciones.php?ugid="+ugid+"&idfecha="+numid+"&idt=1";
	//window.opener.location.reload(); window.close();
} 
</script>
<head>
<body>
<br>
<table align='center' class='FacetFormTABLE'>
<tr><td colspan='2' align='center' class='FacetFieldCaptionTDT'>PERSONAL ASISTENCIAL</td></tr>
<?php echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";?>
<tr><td colspan='2' align='center'><?php echo $nombre; ?></td></tr>
<tr><td colspan='2' align='center' class='FacetFieldCaptionTDT'>FECHA DE INGRESO</td></tr>
<tr><td colspan='2' align='center'><?php echo $fechaing; ?></td></tr>
<tr><td colspan='2' align='center'></td></tr>
<tr><td colspan='2' align='center' class='FacetFieldCaptionTDT'>VACACIONES PROGRAMADAS Y EJECUTADAS</td></tr>
<tr><td align='center' class='FacetFieldCaptionTDT'>VAC. PROGRAMADAS</td><td align='center' class='FacetFieldCaptionTDT'>VAC. EJECUTADAS</td></tr>
<tr><td align='center'><?php echo $cadenavp; ?></td><td align='center'><?php echo $cadenave; ?></td></tr>
<tr><td colspan='2' align='center'><input type='button' value='     Cerrar     ' onClick='cerrarVentana()'></td></tr>
</table>
</body>
</html>