<?php
//session_start();
require_once("../class/class.conectar.php");
require_once("../class/class.jefaturas.php");
require_once("../class/class.usuaprueba.php");

$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 jefaturas
$Objj = new Jefaturas();
$res_jef = array();$res_serv = array();
$res_jef=$Objj->buscar_jefatura($conex,$idj);
$nomjefatura=$res_jef[0]['nom'];
if($ids!=0){
$res_serv=$Objj->buscar_jefatura_servicio($conex,$idj,$ids);
$nomservicio=$res_serv[0]['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."'>";
//combo tipo de personal
$sqltpersonal = "select a.tp_id as cod, (select tp_desc from tb_tipoperson where tp_id=a.tp_id) as descripcion from tb_areatipopersona a where a.j_id='$idj' and a.s_id='$ids'";
//echo $sqltpersonal;
$resulttpersonal = mysqli_query($conex,$sqltpersonal);
//$cadenatp="<select id='tipopersonal' name='tipopersonal'>";
$a=0;
$idtp="";
$cadenatp = "<select id='progtp' onchange='evaluareprogramacion();'>";
while ($rowtp= mysqli_fetch_assoc($resulttpersonal)){
$cadenatp=$cadenatp."<option value='".$rowtp['cod']."'";
if($a==0){
$cadenatp=$cadenatp." selected ";
$a=1;
$idtp=$rowtp['cod'];
}
$cadenatp=$cadenatp." >".$rowtp['descripcion']."</option>";
}
$cadenatp=$cadenatp."</select>";


$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="stylesheet" type="text/css" href="../styles/Style.css">
<link rel="shortcut icon" href="logo.ico" type="image/x-icon">
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>

  <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" /-->


</head>
<body>
<br>
<br>
<table align='center'>
<form action="menuprogramacion.php" method="GET">
<tr><td colspan='2' align='center' class='LlenarJefatura' width='400'><?php echo $nomjefatura;?></td></tr>
<tr><td colspan='2' align='center' class='LlenarServicio' width='400'><?php echo $nomservicio;?></td></tr>
<tr><td colspan='2'><br></td></tr>

<tr><td colspan='2' align='center' class='LlenarTablaGarea' valign='middle' height='30'>REPROGRAMACION DE TURNOS</td></tr>
<tr><td width='100' class ='FacetDataTextC'>Tipo de Personal</td><td class ='FacetDataTextC'>
<?php echo $cadenatp;?>
</td></tr>
<tr><td class ='FacetDataTextC'>Año</td>
<td class ='FacetDataTextC'>
<?php
echo "<select name='anno' id='anno' onchange='evaluareprogramacion();'>";
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='evaluareprogramacion();'>";
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>";

//consutando la validacion de la programacion
$Objua = new UsuarioAprueba;
$res_val = array();
$res_val = $Objua->ask_validado($conex,$anno,$mm,$ids,$idj,$idtp,1);
if(count($res_val)>0){
  $progval=1;
}else{
  $progval=0;
}

?>
</td></tr>
<tr>
  <td colspan='2' class='facetfilaTD' align='center' height='25'>
    <div id="divlistapersonal">

          <?php if($progval==0){
            echo "<input type='button' value='Reprogramar' id='reprogramar' name='reprogramar' onClick='reprogramarpersonal()'";
            echo "disabled class='llenarnoboton'";
            echo "><br><font color='red'><b>PROGRAMACION NO VALIDADA</b></font>";
          }else{
            echo "<input type='button' value='Reprogramar' id='reprogramar' name='reprogramar' onClick='reprogramarpersonal()'";
            echo "class='llenarboton'";
            echo ">";
          }
          ?>

    </div>
  </td>
</tr>
</form>
</table>
<table></table>
<br><br>

<center><div id="divlistapersonal">
<?php
//$validarboton ="<table align='center'><tr><td colspan='2' align='center'><input type='button' class='llenarboton' value='Reprogramar' id='reprogramar' name='reprogramar' onClick='reprogramarpersonal()' ";
//$validarboton =$validarboton." disabled ";
$validarboton ="<table align='center'>";
$validarboton =$validarboton."<tr><td align='center'><img src='../img/home.png' width='70' height='60' onClick='regresarMP()'></td></tr><tr><td align='center'><input type='button' class='llenarboton' value='Validar Reprogramaciones Realizadas' name='savereprog' id='savereprog' onClick='savereprog()'><br><br><input type='button' class='llenarboton' value='Consulta Faltas del Personal' name='consultafaltas' id='consultafaltas' onClick='consultafaltas()'></td></tr></table><br><br>";
echo $validarboton;
?>
</div></center>
</body>
</html>
