<?php

require_once("class/class.conectar.php");
require_once("class/class.regpersonal.php");

session_start();


if(!isset($_SESSION['username'])) 

{

  header('Location: ../../principal.html'); 

  exit();

} else { 

    $fechaGuardada = $_SESSION["ultimoAcceso"]; 

    $ahora = date("Y-n-j H:i:s"); 

    $tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada)); 	
	
     if($tiempo_transcurrido >= 900) { 
     //1140
      session_destroy();

     header('Location: ../../principal.html');
    
    }else { 

    $_SESSION["ultimoAcceso"] = $ahora; 

   } 

}




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

if(isset($_GET['dni']) && isset($_GET['idj']) && isset($_GET['ids']) && isset($_GET['ugid'])){

$dni = $_GET['dni'];

$idj = $_GET['idj'];
$ids = $_GET['ids'];
$idtp = $_GET['idtp'];
$ugid = $_GET['ugid'];

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

$Objrp = new RegPersonal();
$res_lis_regper = array();
$res_lis_regper = $Objrp->listar_regpersonal($con,$dni);

if (count($res_lis_regper)>0){
for($ih=0;$ih<sizeof($res_lis_regper);$ih++){
  $codplanilla = $res_lis_regper[0]['codplanilla'];
  $nom = $res_lis_regper[0]['nom'];
  $go = $res_lis_regper[0]['grupoocupacional'];
  $tipocont = $res_lis_regper[0]['contrato'];
  $serv = $res_lis_regper[0]['servicio'];
  $jef = $res_lis_regper[0]['jefatura'];
}



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

$anno = date("Y",time());
$mes = date("n",time());

$cbanno = "<select name='cbanno' id='cbanno' onChange='lecturaejereporte()'>";
for ($i=2018;$i<2025;$i++){
$cbanno = $cbanno."<option value='".$i."'";
if(date("Y",time())==$i){ $cbanno = $cbanno."selected";
  //$cbanno = $cbanno.$anno=$i;
} $cbanno = $cbanno.">".$i."</option>";  
}
$cbanno = $cbanno."</select>";




$cbmes = "<select name='cbmes' id='cbmes' onChange='lecturaejereporte()'>";
for ($i=0;$i<count($arraymes);$i++){
$cbmes = $cbmes."<option value='".$arraymes[$i]['idmes']."'";
if(date("n",time())==$arraymes[$i]['idmes']){ $cbmes = $cbmes."selected";
$mm=$i+1;
} $cbmes = $cbmes.">".$arraymes[$i]['mes']."</option>";
}
$cbmes = $cbmes."</select>";

?>

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" type="text/css" href="styles/Style.css">
   <script>setTimeout('document.location.reload()',900000); </script>  
  <script language="JavaScript" type="text/javascript" src="js/ajax.js"></script>
  <title>REGISTRO DE LA PRODUCCION</title>
  <script language="JavaScript">
    function RegistrarProd(){     
      var dni = document.getElementById("dni").value; 
       var aleatorio=Math.random();
      var cadena = "regnuevo.php?dni=" + dni +"&ale="+aleatorio;
      window.open(cadena,"REGISTRAR NUEVO","width=500, height=770");
    }
    
    function RetornarMenu(){
       var cod = document.getElementById("ugid").value; 
       var idj = document.getElementById("idj").value; 
       var ids = document.getElementById("ids").value;        
       var cadena = "../personal/menupersonal.php?idj=" + idj +"&ids="+ids+"&ugid="+cod;
       document.location= cadena;
    }
  </script>
</head>
<body onload='buscarproduccion()'>
  <?php  echo "<input type='hidden' id='dni' name='dni' value='".$dni."'>";
  echo "<input type='hidden' id='anno' name='anno' value='".$anno."'>";
  echo "<input type='hidden' id='mes' name='mes' value='".$mes."'>";
  
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."'>";

  ?>
   <br>
   <br>
   
  <div class="contenedor1">
   <h1>REGISTRO DE LA PRODUCCION EN HORAS EXTRAS Y RPCT</h1>
      <br>
  <table align="center" width="440px" border="0px">
    <tr>
    <tr><td colspan="4" class="tablacabecera">&nbsp;&nbsp;&nbsp;&nbsp;DATOS DEL PERSONAL </td>
    </tr>
    <tr><td width="20px"></td><td class="tabladetalle1" width="140px">DNI</td><td class="tabladetalle2" width="240px"><?php echo $dni;?></td><td width="20px"></td></tr>
     <tr><td></td><td class="tabladetalle1">COD. PLANILLA</td><td class="tabladetalle2"><?php echo $codplanilla;?></td><td></td></tr>
    <tr><td></td><td class="tabladetalle1">APELLIDOS Y NOMBRES</td><td class="tabladetalle2"><?php echo $nom;?></td><td></td></tr>
     <tr><td></td><td class="tabladetalle1">GRUPO OCUPACIONAL</td><td class="tabladetalle2"><?php echo $go;?></td><td></td></tr>
      <tr><td></td><td class="tabladetalle1">CONTRATO</td><td class="tabladetalle2"><?php echo $tipocont;?><td></td></td></tr>
      
       <tr>
      <td colspan="4" class="tablacabecera">&nbsp;&nbsp;&nbsp;&nbsp;DEPENDENCIA </td>
    </tr>
     
      <tr><td></td><td class="tabladetalle1">SERVICIO</td><td class="tabladetalle2"><?php echo $serv;?></td><td></td></tr>
      <tr><td></td><td class="tabladetalle1">DIR / DPTO /DE</td><td class="tabladetalle2"><?php echo $jef;?></td><td></td></tr>
   
  </table>
    <br>
     <div class="divimagen"><img class="imagenmov" src="img/home.png" onClick="RetornarMenu()"></div>
    <br>
     <table width="440px" align="center">
 <tr><td>
  <fieldset>
	<legend align='left'>Seleccione Año y Mes</legend> 
       
       <table align="center">
       <tr>
      <td ></td>
      <td class="tituloconsulta">AÑO</td>
      <td class="tituloconsulta">MES</td>
      <td></td>
      </tr>
      <tr>
     <td></td>
      <td><?php echo $cbanno;  ?></td>
      <td><?php echo $cbmes;  ?></td>
      <td><input type="button" value="CONSULTAR" class="boton1" onClick='buscarproduccion()'>&nbsp;<input type="button" value="REGISTRAR" class="boton1" onClick="RegistrarProd()"></td><td></td>
    </tr>
  </table>
                     
    </fieldset>  
  </td></tr>
  </table>
  <br><br>
  </div>

  
  <br>
  
  
  <div id="divprod">
 
  </div>
  <br>
<br>
</body>
</html>


<?php
}else{
  
  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='idtp' name='ids' value='".$idtp."'>";
echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";
  echo "DNI NO EXISTE";
}
  
}else
{
  header("location:../login.php");
}
  ?>