<?php
include("../bd/sql_variables.php");
$con= mysqli_connect("$sql_host", "$sql_usuario", "$sql_pass","$sql_db") or die(header ("No Disponible Servidor de Base de Datos"));


$idj=$_GET['idj'];
$ids=$_GET['ids'];
$idga=$_GET['idga'];
$ida=$_GET['ida'];

//nombre de grupo area
$sqlserv = "select (select o_idturn from tb_ordena where o_turn=b.h_horaturn) as tt,b.h_id as idh, concat(date_format(b.h_horaini,'%k:%i %p'),' - ', date_format(b.h_horafin,'%k:%i %p'),' (',b.h_horaturn,') (',b.h_horanum,')') as hora from tb_horario b "; 
$sqlserv = $sqlserv." where b.h_id not in (Select h_id FROM areahora a where a.s_id='$ids' and a.j_id='$idj' and a.a_id='$ida' and a.ga_id='$idga') and b.h_horatipo not in (0) order by tt";

//echo $sqlserv;
$cadenagarea = "";
$cadenagarea = $cadenagarea."<select id='cbhora' >";
$cadenagarea = $cadenagarea."<option value='0'>Seleccione Horario Nuevo </option>";
$resultserv = mysqli_query($con,$sqlserv);
while ($rows= mysqli_fetch_array($resultserv)){
$cadenagarea = $cadenagarea."<option value='".$rows['idh']."'>".$rows['hora']."</option>";
}
$cadenagarea = $cadenagarea."</select>";

echo $cadenagarea;
?>