<html>
<head>
<link rel="stylesheet" type="text/css" href="../styles/Style.css">
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
</head>
<body>
<?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"));


if(isset($_GET['idj']) && isset($_GET['ids']) && isset($_GET['idtp']) && isset($_GET['anno'])  && isset($_GET['mes'])){
$idj = $_GET['idj'];
$ids = $_GET['ids'];
$per = $_GET['idtp'];
$anno = $_GET['anno'];
$mm = $_GET['mes'];

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'>";
}

//validar el boton de grabar modificar del mes
$sqlconval="select * from tb_usutrab where j_id='$idj' and s_id='$ids' and uap_anno='$anno' and uap_mes ='$mm' and tp_id='$per'";
echo $sqlconval;
$resultconval = mysqli_query($con,$sqlconval);
$validarboton ="<table align='center'><tr><td colspan='2' align='center'><input type='button'  value='Informa Turnos Ejecutados' id='hrsejecutar' name='hrsejecutar' onClick='informahrsejecutadas()' ";
if(mysqli_num_rows($resultconval)==0 ){
$validarboton =$validarboton."class='llenarnoboton'  disabled ";
}else{
$validarboton =$validarboton."class='llenarboton' ";
}
}

if(isset($_GET['fecha'])){

$fecha = $_GET['fecha'];
//echo $fecha;
$idj = $_GET['idj'];
$ids = $_GET['ids'];

$dia=substr($fecha, 0, 2);
$mm=substr($fecha, 3, 2);
$anno=substr($fecha, 6, 4);

//validar el boton de grabar
$sqleje="SELECT * FROM tb_usuaprueba  where uap_anno='$anno' and uap_mes='$mm' and s_id='$ids' and j_id='$idj' and uap_tipoproc='3'";
$sqlrepro="select * from tb_horareprog".$anno." where uap_anno='$anno' and uap_mes='$mm' and hr_idserva='$ids' and j_id='$idj'";
$sqlejehrs="select * from tb_horaeje".$anno." where uap_anno='$anno' and uap_mes='$mm' and he_idserva='$ids' and j_id='$idj'";
//echo $sqlrepro;
$resulteje = mysqli_query($con,$sqleje);
$resultrepro = mysqli_query($con,$sqlrepro);
$resulthrseje = mysqli_query($con,$sqlejehrs);
//echo $sqlconval;

$validarboton ="<table align='center'><tr><td colspan='2' align='center'><input type='button' value='Informa Turnos Ejecutados' id='hrsejecutar' name='hrsejecutar' onClick='informahrsejecutadas()' ";


if(mysqli_num_rows($resultrepro)==0 ){
$validarboton =$validarboton."class='llenarnoboton'  disabled ";
}else{
$validarboton =$validarboton."class='llenarboton' ";
}

}

$validarboton =$validarboton."></td></tr><tr><td align='center'><img src='../img/home.png' width='70' height='60' onClick='regresarMP()'></td></tr></table><br><br>";
echo $validarboton;
?>
</body>
</html>
