<?php
//session_start();
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");

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

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

//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_array($resultjefatura)){
$nomjefatura = $rowj['nom']; 
}

//nombre de la jefatura
$comboservicio ="<select id='serv1' name='serv1' onChange='lecturaejereporteterm()' >";
$sqljefatura = "select j_desc as nom from tb_jefatura where j_id='$idj'";
$resultjefatura = mysqli_query($con, $sqljefatura);
while ($rowj= mysqli_fetch_array($resultjefatura)){
$nomjefatura = $rowj['nom']; 
$comboservicio =$comboservicio."<option value='0'";
//if($_GET['ids']==0){ $comboservicio = $comboservicio." selected ";}
$comboservicio =$comboservicio.">".$nomjefatura."</option>";
}

//nombre de servicio
$sqlserv = "select s_id, s_desc as nom from tb_servicio where j_id='$idj'";
$resultserv = mysqli_query($con, $sqlserv);
while ($rows= mysqli_fetch_array($resultserv)){
$nomserviciolist = $rows['nom']; 
$idso = $rows['s_id']; 
$comboservicio =$comboservicio."<option value='".$idso."'";
//if($_GET['ids']==$idso){ $comboservicio = $comboservicio." selected ";}
$comboservicio =$comboservicio.">".$nomserviciolist."</option>";
}
$comboservicio =$comboservicio."</select>";


//seleccionando al combo tipo de personal
$sqltpersonal = "SELECT tp_id as cod, (select tp_desc from tb_tipoperson where tp_id=b.tp_id) as descripcion  FROM tb_usuasist a inner join tb_usudep b on a.ug_id=b.ug_id where b.j_id='$idj' group by b.tp_id";
$resulttpersonal = mysqli_query($con, $sqltpersonal);
$cadenatp="<select id='progtp' name='progtp'>";
while ($rowtp= mysqli_fetch_array($resulttpersonal)){
$cadenatp=$cadenatp."<option value='".$rowtp['cod']."'>".$rowtp['descripcion']."</option>";
}
$cadenatp=$cadenatp."</select>";

echo "<input type='hidden' id='idj' name='idj' value='".$idj."'>";
echo "<input type='hidden' id='ids' name='ids' value='0'>";
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="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>

<link rel="stylesheet" type="text/css" href="styles/Style.css">
<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" />
<script language="JavaScript">
function validarejecucion(){
var mes = document.getElementById("mes").value;
var anno= document.getElementById("anno").value;
var idtp= document.getElementById("progtp").value;
var idj= document.getElementById("idj").value;
var ids= document.getElementById("ids").value;
var ugid= document.getElementById("ugid").value;
document.location = "validarejecucion.php?idj="+idj+"&ids="+ids+"&ugid="+ugid+"&idtp="+idtp+"&anno="+anno+"&mes="+mes;
}

function busquedaP(){
var idj = document.getElementById("idj").value;
var ids = document.getElementById("ids").value;
var ugid = document.getElementById("ugid").value;
var tusu = document.getElementById("tusu").value;
if(tusu==1){
document.location = "buscarprogramacion.php?idj="+idj+"&ids="+ids+"&ugid="+ugid+"&tusu="+tusu;
}else{
document.location = "buscarprogramacion.php?idj="+idj+"&ids="+ids+"&ugid="+ugid;
}
}
</script>
</head>
<body>
<br>
<table align='center' width='800' class="TableDiseno">
<tr><td ><font color='#0000FF'><b>SIPA - Sistema Integrado de la Programacion Asistencial</b></font></td></tr>
<tr><td align='center' class='LlenarJefatura'><?php echo $nomjefatura;?></td></tr>
</table>
<br>
<table align='center' class="TableDiseno">
<tr><td align='center'  class='LlenarTablaGareaTitulo' height="50" colspan="2"><img src="img/reporteadm.jpg" align="middle" width="45" height="45"><b>  REPORTES DEL SISTEMA</b></td></tr>
<tr><td colspan='2' class='facetfilaTD'><b>Seleccione A&ntilde;o y Mes:</b></td></tr>
<tr><td align='right' class ='FacetDataTextC'>A&ntilde;o: </td>
<td class ='FacetDataTextC'>
<?php
echo "<select name='anno' id='anno' onChange='lecturaejereporteterm()'>";
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 align='right' class ='FacetDataTextC'>Mes: </td><td class ='FacetDataTextC'>
<?php
echo "<select name='mes' id='mes' onChange='lecturaejereporteterm()'>";
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'>
<fieldset>
	<legend align='left'><font color='red'></font></legend>
		<br>
	    <table align='center' class='FacetFormTABLET' width='380'>
		<tr><td align='left' colspan='2' class='facetfilaTD'><b>Seleccione Jefatura:</b></td></tr>
		<tr><td align='center' colspan='2'><?php echo $comboservicio;?></td></tr>
		<tr><td align='center' class='facetfilaTD'><b>Tipo de Personal:</b></td><td align='center' class='facetfilaTD'><b>Tipo de Contrato</b></td></tr>
		<tr><td align='center' class ='FacetDataTextC'><?php  echo $cadenatp; ?></td>
		<td align='center' class ='FacetDataTextC'>
		<select id='tpcont' name='tpcont'>
		<option value='1' >ESSALUD</option>
		<option value='2' >C.A.S.</option>
		</select>
		</td></tr>
		</table>
	<br>
	</fieldset>
</td></tr>
</table>
<table align="center">
<tr><td align='center' colspan='2'><img src='../img/home.png' width='70' height='60' onClick='regresarMPterm()' alt='Regresar al Menu Principal'></td></tr>
</table>
<table align="center" >
<tr><td align='center' class='LlenarTablaGarea' width='230'>PROGRAMACION Y REPROGRAMACION</td><td align='center' class='LlenarTablaGarea' >FORMATOS Y PROG. DIARIA</td><td align='center' class='LlenarTablaGarea' width='410'>EJECUCION DE HORAS</td></tr>
<tr><td valign='top' class='TableDisenoSIPA'>		
		<fieldset><br>
		<table  align='center' class='FacetFormTABLET' width='220'>
		<tr><td class='facetfilaTD' align='center' colspan='2'><b>PROGRAMACION</b><td></tr>
		<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='prog' id='prog' checked >MENSUAL<br>
		<input type='radio' name='prog' id='prog' >INDIVIDUAL<br><input type='radio' name='prog' id='prog' >LISTADO</td><td class ='FacetDataTextC'><img src='img/icopdf.png' width='30' height='30' hspace='3' vspace='3' onClick='informaprogterm()'></td></tr>
		</table><br>
		<table  align='center' class='FacetFormTABLET' width='220'>
		<tr><td class='facetfilaTD' align='center' colspan='2'><b>REPROGRAMACION</b><td></tr>
		<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='reprog' id='reprog' checked >MENSUAL<br>
		<input type='radio' name='reprog' id='reprog' >INDIVIDUAL<br><input type='radio' name='reprog' id='reprog' >LISTADO<br><input type='radio' name='reprog' id='reprog' >REPORTE</td><td class ='FacetDataTextC'><img src='img/icopdf.png' width='30' height='30' hspace='3' vspace='3' onClick='informareprogterm()' ></td></tr>
		</table><br>
		</fieldset>
</td><td class='TableDisenoSIPA'>
		<fieldset>
		<table><tr><td>
			<table  align='center' class='FacetFormTABLET' width='220'>
			<tr><td class='facetfilaTD' align='center' colspan='2'><b>PROGRAMACION DIARIA</b><td></tr>
			<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='progd' id='progd'  checked >PROGRAMADO<br>
			<input type='radio' name='progd' id='progd'>REPROGRAMADO</td><td class ='FacetDataTextC'><img src='img/icopdf.png' width='30' height='30' hspace='3' vspace='3' onClick='informaprogindivterm()'></td></tr>
			</table>
		</td><td>
			<table  align='center' class='FacetFormTABLET' width='220'>
			<tr><td class='facetfilaTD' align='center' colspan='2'><b>DESCANSO MEDICO</b><td></tr>
			<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='rddm' id='rddm'  checked >POR JEFATURA<br>
			<input type='radio' name='rddm' id='rddm'>TODAS
			<td class ='FacetDataTextC' align='center'><img src='img/icopdf.png' width='30' height='30' onClick='informadesmedpdf()' hspace='5' vspace='5'><img src='img/icoexcel.png' width='30' height='30' onClick='informadesmedxls()' hspace='5' vspace='5'></td></tr>
			</table>
		</td></tr><tr><td>
		<table  align='center' class='FacetFormTABLET' width='220'>
		<tr><td class='facetfilaTD' align='center' colspan='2'><b>CANTIDAD HRS</b><td></tr>
		<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='hrsprog' id='hrsprog'  checked >PROGRAMADAS<br>
		<input type='radio' name='hrsprog' id='hrsprog'>REPROGRAMADAS<br>
		<input type='radio' name='hrsprog' id='hrsprog'>EJECUTADAS</td><td class ='FacetDataTextC'><img src='img/icopdf.png' width='30' height='30' hspace='3' vspace='3' onClick='informacanthrsprogterm()'></td></tr>
		</table>
		</td><td>
			<table  align='center' class='FacetFormTABLET' width='220'>
			<tr><td class='facetfilaTD' align='center' colspan='2'><b>VACACIONES</b><td></tr>
			<tr><td class='FacetDataTextC' align='center' colspan='2'><input type='radio' name='tpconvaca' id='tpconvaca' checked>POR JEFATURA<input type='radio' name='tpconvaca' id='tpconvaca' >TODAS<td></tr>
			<tr><td class ='FacetDataTextC' width='180'><input type='radio' name='rdvaca' id='rdvaca'  checked >PROGRAMADAS<br>
			<input type='radio' name='rdvaca' id='rdvaca'>EJECUTADAS<br>
			<input type='radio' name='rdvaca' id='rdvaca'>SUSPENDIDOS</td><td class ='FacetDataTextC'>
			<img src='img/icopdf.png' width='30' height='30' onClick='informavacapdf()' hspace='3' vspace='3'><br><img src='img/icoexcel.png' width='30' height='30' onClick='informavacaxls()' hspace='3' vspace='3'>
			</td></tr>
			</table>
		</td></tr></table>
		
		<br>
		</fieldset>
</td><td class='TableDisenoSIPA'>
<fieldset><br>
<table>
<tr>
<td>
<fieldset>
	    <br><table align='center' class='FacetFormTABLET' width='220'>
		<tr><td class='facetfilaTD' align='center'><b>PERIODO</b><td></tr>
		<tr><td class ='FacetDataTextC'><input type='radio' name='perd' id='perd' value='1' checked >PRIMERA QUINCENA<br>
		<input type='radio' name='perd' id='perd' value='2'>SEGUNDA QUINCENA<br></td></tr>
		</table>
	<br><br><br>
	</fieldset>
</td>
<td>
<fieldset>
	    <br><table align='center' class='FacetFormTABLET' width='190'>
		<tr><td class='facetfilaTD' align='center'><b>GUARDIA Y EXTRAS</b><td></tr>
		<tr><td class ='FacetDataTextC'><input type='radio' name='hrseje' id='hrseje' value='1' checked >HORAS EXTRAS<br>
        <input type='radio' name='hrseje' id='hrseje' value='2'>GUARDIAS DIURNAS<br>
		<input type='radio' name='hrseje' id='hrseje' value='3'>GUARDIAS NOCTURNAS<br>
        <input type='radio' name='hrseje' id='hrseje' value='4'  >FORMT NUEVO HRS EXTRAS
        </td></tr>
		</table>
	<br>
	
	</fieldset>
</td>
</tr>
<tr><td colspan='2' align='center'>
<div id='validaeje'>
<?php
$sqleje="SELECT * FROM tb_usuaprueba  where uap_anno='$anno' and uap_mes='$mm' and s_id='0' 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='0' and j_id='$idj'";
$sqlejehrs="select * from tb_horaeje".$anno." where uap_anno='$anno' and uap_mes='$mm' and he_idserva='0' and j_id='$idj'";
//echo $sqleje;
$resulteje = mysqli_query($con, $sqleje);
$resultrepro = mysqli_query($con, $sqlrepro);
$resulthrseje = mysqli_query($con, $sqlejehrs);
if(mysqli_num_rows($resultrepro)==0 ){
echo "<br><input type='button' id='validaeje' name='validaeje' value='Generar Reporte' onClick='GenerarReporte()' disabled>";
}else{
	
	if(mysqli_num_rows($resulthrseje)!=0){
	echo "<input type='button' id='validaeje' name='validaeje' value='Generar Reporte' onClick='GenerarReporte()' >";
	}else{
		echo "NO ESTA VALIDADO LA EJECUCION DE HORAS<BR><input type='button' id='validaeje' name='validaeje' value='Generar Reporte' onClick='GenerarReporte()' disabled >";
	}
	}
?>
</div>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr><td><br><br></td></tr>

</table>
</body>
</html>

