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


//var cadena = "parametrizarprog.php?ugid="+ugid+"&mes="+mes+"&anno="+anno+"&idtp="+idtp+"&idj="+idj+"&ids="+ids+"&tusu="+tusu;

$ugid=$_GET['ugid'];
$mes=$_GET['mes'];
$anno=$_GET['anno'];
$idtp=$_GET['idtp'];
$idj=$_GET['idj'];
$ids=$_GET['ids'];
	if(isset($_GET['tusu'])){
	echo "<input type='hidden' id='tusu' name='tusu' value='1'>";
	}else{
	echo "<input type='hidden' id='tusu' name='tusu' value='0'>";
	}



//	$sqllistado = "select a.ug_id as cod, concat(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, (select esp_desc from tb_especialidad ";

?>
<html>
<head>
<title>AREAS A REPROGRAMAR</title>
<link rel="stylesheet" type="text/css" href="../styles/Style.css">
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
<script language="JavaScript">
function cerrarVentana(){
window.close();
}
</script>
</head>
<body>
<?php
echo "<input type='hidden' id='ugid' name='ugid' value='$ugid'>";
echo "<input type='hidden' id='mes' name='mes' value='$mes'>";
echo "<input type='hidden' id='anno' name='anno' value='$anno'>";
echo "<input type='hidden' id='idtp' name='idtp' value='$idtp'>";
echo "<input type='hidden' id='idj' name='idj' value='$idj'>";
echo "<input type='hidden' id='ids' name='ids' value='$ids'>";

?>
	<br><br>
	<table align='center'>
	<tr><td>
	<fieldset>
	<table align='center'>
	<tr><td colspan='2' ><b><font color='red'>SELECIONE AREA A REPROGRAMAR</font></b></td></tr>
	<?php
	$sql = "select b.ga_id as id, (select ga_desc from tb_garea where ga_id=a.ga_id) as area from tb_areaservicio a inner join tb_area b on a.a_id=b.a_id and a.ga_id=b.ga_id where a.s_id='$ids' and a.j_id='$idj' and a.tp_id='$idtp' group by b.ga_id";
	$result = mysqli_query($con,$sql);
		if ($result == false){
		echo 'PROVOCO UN ERROR EN LA CONSULTA';
		}else{
		$cadena = "<select name='tarea' id='tarea'>";
		$cadena = $cadena."<option value='0'>TODO</option>";
		while ($row= mysqli_fetch_assoc($result)){
		$cadena = $cadena."<option value='".$row['id']."'>".$row['area']."</option>";
		}
		$cadena = $cadena."</select>";
		}
	echo "<tr><td colspan='2'>".$cadena."</td></tr>";
	?>
	<tr><td colspan='2' align='center'><input class='llenarboton' type='button' value='Reprogramar' onClick='IniciarReprogramacion()'></td></tr>
	<tr><td colspan='2' align='center'><input class='llenarboton' type='button' value='Cerrar' onClick='cerrarVentana()'></td></tr>
	</table>
	</fieldset>
	</td></tr>
	</table>
</body>
</html>