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

$anno = $_GET['anno'];
$mm = $_GET['mes'];
$idh =$_GET['idh'];
$ida =$_GET['ida'];
$idga =$_GET['idga'];
$idj = $_GET['idj'];
$ids = $_GET['ids'];
$idtp = $_GET['idtp'];
$val = $_GET['valor'];
$ugid = $_GET['ugid'];
//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'>";
//}

if($val==1){
$sqlask="select * from tb_horaprog".$anno." where j_id='$idj' and hp_idserva='$ids' and uap_mes='$mm' and uap_anno='$anno' and h_id='$idh'and ga_id='$idga' and a_id='$ida' and tp_id='$idtp'";
}
if($val==2){
$sqlask="select * from tb_horareprog".$anno." where j_id='$idj' and hr_idserva='$ids' and uap_mes='$mm' and uap_anno='$anno' and h_id='$idh'and ga_id='$idga' and a_id='$ida' and tp_id='$idtp'";
}
//echo $sqlask;
$resultask = mysqli_query($con,$sqlask);
if(mysqli_num_rows($resultask)==0){
//if(isset($_GET['tusu'])){
//$tusu = $_GET['tusu'];
//$url ="editarturnosub.php?idga=".$idga."&ida=".$ida."&idj=".$idj."&ids=".$ids."&idh=".$idh."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&valor=".$val."&tusu=".$tusu;
//}else{
$url ="editarturnosub.php?idga=".$idga."&ida=".$ida."&idj=".$idj."&ids=".$ids."&idh=".$idh."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&valor=".$val;
//}
//header("Location:".$url);
echo "<script language=Javascript> location.href=\"$url\"; </script>";
}else{
if($val==1){
//if(isset($_GET['tusu'])){
//$tusu = $_GET['tusu'];
//$url = "progasistencialsub.php?idj=".$idj."&ids=".$ids."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&error=1&idga=".$idga."&tusu=".$tusu;
//}else{
$url = "progasistencialsub.php?idj=".$idj."&ids=".$ids."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&error=1&idga=".$idga;
//}
}
if($val==2){
//if(isset($_GET['tusu'])){
//$tusu = $_GET['tusu'];
//$url = "reprogramacionmessub.php?idj=".$idj."&ids=".$ids."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&error=1&idga=".$idga."&tusu=".$tusu;
//}else{
$url = "reprogramacionmessub.php?idj=".$idj."&ids=".$ids."&anno=".$anno."&mes=".$mm."&idtp=".$idtp."&ugid=".$ugid."&error=1&idga=".$idga;
//}
}
//header("Location:".$url);
echo "<script language=Javascript> location.href=\"$url\"; </script>";
}
?>