<?php
//session_start();
include("../bd/sql_variables.php");

require_once("../class/class.conectar.php");
require_once("../class/class.usuaprueba.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");

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

date_default_timezone_set("America/Lima"); setlocale(LC_TIME,"es_PE.UTF-8");

$idj=$_GET['idj'];
$ids=$_GET['ids'];
$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'>";
}

//echo $ugid;
//nombre de la jefatura
$sqljefatura = "select j_desc as nom from tb_jefatura where j_id='$idj'";
$resultjefatura = mysqli_query($con,$sqljefatura);
while ($rowj= mysqli_fetch_assoc($resultjefatura)){
$nomjefatura = $rowj['nom'];
}
//nombre de servicio
$sqlserv = "select s_desc as nom from tb_servicio where j_id='$idj' and s_id='$ids'";
$resultserv = mysqli_query($con,$sqlserv);
if(mysqli_num_rows($resultserv)!=0){
while ($rows= mysqli_fetch_array($resultserv)){
$nomservicio = $rows['nom'];
}}else{
$nomservicio = "";
}
echo "<input type='hidden' id='idj' name='idj' value='".$idj."'>";
echo "<input type='hidden' id='ids' name='ids' value='".$ids."'>";
echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";


$arraymes = array();
$arraymes[] = array('idmes'=>'1','mes'=>'ENERO');
$arraymes[] = array('idmes'=>'2','mes'=>'FEBRERO');
$arraymes[] = array('idmes'=>'3','mes'=>'MARZO');
$arraymes[] = array('idmes'=>'4','mes'=>'ABRIL');
$arraymes[] = array('idmes'=>'5','mes'=>'MAYO');
$arraymes[] = array('idmes'=>'6','mes'=>'JUNIO');
$arraymes[] = array('idmes'=>'7','mes'=>'JULIO');
$arraymes[] = array('idmes'=>'8','mes'=>'AGOSTO');
$arraymes[] = array('idmes'=>'9','mes'=>'SETIEMBRE');
$arraymes[] = array('idmes'=>'10','mes'=>'OCTUBRE');
$arraymes[] = array('idmes'=>'11','mes'=>'NOVIEMBRE');
$arraymes[] = array('idmes'=>'12','mes'=>'DICIEMBRE');

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SIPA - SISTEMA INTEGRADO DE LA PROGRAMACION ASISTENCIAL</title>

<link rel="shortcut icon" href="logo.ico" type="image/x-icon">
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>

<link type="text/css" rel="stylesheet" href="src/css/jscal2.css" />
    <link type="text/css" rel="stylesheet" href="src/css/border-radius.css" />
              <!-- <link type="text/css" rel="stylesheet" href="src/css/reduce-spacing.css" /> -->

    <link id="skin-win2k" title="Win 2K" type="text/css" rel="alternate stylesheet" href="src/css/win2k/win2k.css" />
    <link id="skin-steel" title="Steel" type="text/css" rel="alternate stylesheet" href="src/css/steel/steel.css" />
    <link id="skin-gold" title="Gold" type="text/css" rel="alternate stylesheet" href="src/css/gold/gold.css" />
    <link id="skin-matrix" title="Matrix" type="text/css" rel="alternate stylesheet" href="src/css/matrix/matrix.css" />

    <link id="skinhelper-compact" type="text/css" rel="alternate stylesheet" href="src/css/reduce-spacing.css" />

    <script src="src/js/jscal2.js"></script>
	           <!--script src="src/js/lang/en.js"></script-->
             <!-- you actually only need to load one of these; we put them all here for demo purposes -->
     <script src="src/js/lang/es.js"></script>

    <!--link type="text/css" rel="stylesheet" href="demopage.css" /-->
    <link rel="stylesheet" type="text/css" href="../styles/Style.css">
</head>
<body>
<br>
<br>
<table align='center'>
<tr><td align='center' class='LlenarJefatura' width='400'><?php echo $nomjefatura;?></td></tr>
<tr><td align='center' class='LlenarServicio' width='400'><?php echo $nomservicio;?></td></tr>
</table>
<br><br>
<table align='center'>
<tr><td colspan='2' align='center' class='LlenarTablaGarea' width='300' height='30'>INFORME DE TURNOS PROGRAMADOS</td></tr>
<tr><td colspan='2' class='facetfilaTD'>Seleccione dia:</td></tr>
<tr><td colspan='2' align='center' class ='FacetDataTextC'>
<input type='text' id='txtrepro' name='txtrepro' size='10' value='<?php //if(isset($_GET['ugid'])){ echo $fechaing;}?>'>
		<button id="f_rangeStart_trigger"><img src="../img/b_calendar.png" ></button>
                <button id="f_clearRangeStart" onclick="clearRangeStart()">clear</button><button id="valida" onclick="evaluaejecutado();"><img src="../img/b_edit.gif"></button>
                <script type="text/javascript">
				  var LEFT_CAL = Calendar.setup({
                    //cont: "cont",
                    //weekNumbers: true,
                    //selectionType: Calendar.SEL_MULTIPLE,
                    //showTime: 12
                    // titleFormat: "%B %Y"
					})
                  new Calendar({
                          inputField: "txtrepro",
                          dateFormat: "%d/%m/%Y",
                          trigger: "f_rangeStart_trigger",
                          bottomBar: false,
                          onSelect: function() {
                                  var date = Calendar.intToDate(this.selection.get());
								  LEFT_CAL.setLanguage('es');
                                  LEFT_CAL.args.min = date;
                                  LEFT_CAL.redraw();
                                  this.hide();
                          }
                  });
                  function clearRangeStart() {
                          document.getElementById("txtrepro").value = "";
                          LEFT_CAL.args.min = null;
                          LEFT_CAL.redraw();
                  };
                </script>

</td></tr>

</table>
<table></table>
<br><br>

<center><div id="divbotonejecutar">
<?php

$validarboton ="<table align='center'><tr><td colspan='2' align='center'><input type='button' class='llenarnoboton' disabled value='Informa Turnos Ejecutados' id='hrsejecutar' name='hrsejecutar'";

$validarboton =$validarboton." disabled ";

$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;

?>
</div></center>
<br><br>
<table align='center'>
<tr>
  <td align='center' class='LlenarTablaGarea' width='300' height='30'>VALIDAR EJECUCION DE TURNOS PROGRAMADOS</td>
</tr>
<tr>
  <td>
<table align='center'>
<tr><td colspan='2' class='facetfilaTD' width='300'>Seleccione Año y Mes:</td></tr>
<tr><td  colspan='2' align='center'></td>
<tr>
    <td class ='FacetDataTextC'>Año</td>
    <td class ='FacetDataTextC'>
    <?php
    echo "<select name='anno' id='anno' onChange='lecturaeje()'>";
    for ($i=2000;$i<2100;$i++){
    echo "<option value='".$i."'";
    if(date("Y",time())==$i){?> selected
    <?php
    $anno=$i;
    } echo ">".$i."</option>";
    }
    echo "</select>";
    ?>
    </td>
</tr>
<tr>
  <td class ='FacetDataTextC'>Mes</td>
  <td class ='FacetDataTextC'>
    <?php
    echo "<select name='mes' id='mes' onChange='lecturaeje()'>";
    for ($i=0;$i<count($arraymes);$i++){
    echo "<option value='".$arraymes[$i]['idmes']."'";
    if(date("n",time())==$arraymes[$i]['idmes']){?> selected
    <?php
    $mm=$i+1;
    } echo ">".$arraymes[$i]['mes']."</option>";
    }
    echo "</select>";
    ?>
  </td>
</tr>
<tr><td colspan='2' align='center'>

<?php

echo "<input type='hidden' id='anno' name='anno' value='".$anno."'>";
echo "<input type='hidden' id='mes' name='mes' value='".$mm."'>";
echo "<div id='validaeje'>";
$Objvalprog1 = new UsuarioAprueba();
$Objvalprog2 = new UsuarioAprueba();
$Objvaleje1 = new UsuarioAprueba();
$Objvaleje2 = new UsuarioAprueba();
$res_vprog1=array();$res_vprog2=array();$res_veje1=array();$res_veje2=array();
$res_vprog1 = $Objvalprog1->ask_validado($conex,$anno,$mm,$ids,$idj,1,1);
$res_vprog2 = $Objvalprog2->ask_validado($conex,$anno,$mm,$ids,$idj,2,1);
$res_veje1 = $Objvaleje1->ask_validadoeje($conex,$anno,$mm,$ids,$idj,2);
$res_veje2 = $Objvaleje2->ask_validadoeje($conex,$anno,$mm,$ids,$idj,3);
if(count($res_vprog1)==0 && count($res_vprog2)==0){
  echo "<font color='red'><b>NO EXISTE PROGRAMACION DEL MES</b></font><BR>";
}else{
  if(count($res_veje1)>0){
  //echo "<input type='button' class='llenarnoboton' value='Ejecucion Validado &#x00A; 1ra Quincena' id='hrsejecutar' name='hrsejecutar' disabled style='width:130px' cursor:pointer;>";
    echo "<div id='divvaleje1'><button id='btnvalejeq1' name='btnvalejeq1' class='llenarnoboton' onClick='valejequincena(1)' style='width:130px' disabled>";
    echo "Ejecucion Validado <br> 1ra Quincena";
    echo "</button></div>";
  }else{
    echo "<div id='divvaleje1'><button id='btnvalejeq1' name='btnvalejeq1' onClick='valejequincena(1)' style='width:130px'>";
    echo "Validar Ejecucion <br> 1ra Quincena";
    echo "</button></div>";
  }

  if(count($res_veje2)>0){
    echo "<div id='divvaleje2'><button id='btnvalejeq2' name='btnvalejeq2' class='llenarnoboton' onClick='valejequincena(2)' style='width:130px' disabled>";
    echo "Ejecucion Validado <br> 2da Quincena";
    echo "</button></div>";
  }else{
    echo "<div id='divvaleje2'><button id='btnvalejeq2' name='btnvalejeq2'  onClick='valejequincena(2)' style='width:130px'>";
    echo "Validar Ejecucion <br> 2da Quincena";
    echo "</button></div>";
  }
}
echo "</div>";
?>
</td></tr>
</table></td></tr>
</table>

</body>
</html>
