<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 verprog(ugid){
//alert(ugid);
var mes = document.getElementById("mes").value;
var anno= document.getElementById("anno").value;
var tprog= document.getElementsByName("bprog");
if(tprog[0].checked){
window.open("programacionindividual.php?ugid="+ugid+"&anno="+anno+"&mes="+mes,"","height=500,width=1250,scrollbars=YES");
}
if(tprog[1].checked){
window.open("reprogramacionindividual.php?ugid="+ugid+"&anno="+anno+"&mes="+mes,"","height=500,width=1250,scrollbars=YES");
}
if(tprog[2].checked){
window.open("ejeprogramacionindividual.php?ugid="+ugid+"&anno="+anno+"&mes="+mes,"","height=500,width=1250,scrollbars=YES");
}
}
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;
var tprog= document.getElementById("tprog").value;
if(tprog==0){
document.location = "validarejecucion.php?idj="+idj+"&ids="+ids+"&ugid="+ugid+"&idtp="+idtp+"&anno="+anno+"&mes="+mes;
}
if(tprog==1){
document.location = "validarejecucion.php?idj="+idj+"&ids="+ids+"&ugid="+ugid+"&idtp="+idtp+"&anno="+anno+"&mes="+mes;
}
}

</script>
</head>
<body>
<div id='buscalistado'>

<?php
//session_start();
include("../bd/sql_variables.php");
$db_conexion= mysql_connect("$sql_host", "$sql_usuario", "$sql_pass") or die(header ("No Disponible Servidor de Base de Datos"));
mysql_select_db("$sql_db");

include("paginacion/config_newpag.php");
include("paginacion/my_pagina_class.php");
define("NUM_ROWS",'10');
define("NUM_LINKS",'10');
$tc=0;
//$idj=$_GET['idj'];
//$ids=$_GET['ids'];;
//$idtp=1;
$idj='1';
$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'>";
}

//los servicios
$comboservicio ="<select id='serv1' name='serv1' onChange='listartipopersonal();'>";

$sqljefatura = "select j_desc as nom from tb_jefatura where j_id='$idj'";
$resultjefatura = mysql_query($sqljefatura);
while ($rowj= mysql_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 = mysql_query($sqlserv);
while ($rows= mysql_fetch_array($resultserv)){
$nomservicio = $rows['nom']; 
$idso = $rows['s_id']; 
$comboservicio =$comboservicio."<option value='".$idso."'";
if($_GET['ids']==$idso){ $comboservicio = $comboservicio." selected ";}
$comboservicio =$comboservicio.">".$nomservicio."</option>";
}
$comboservicio =$comboservicio."</select>";


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

if(isset($_GET['tprog']) && isset($_GET['tc'])){
$idj=$_GET['idj'];
$ids=$_GET['ids'];
$ugid=$_GET['udig'];
$tc=$_GET['tc'];
$anno=$_GET['anno'];
$mm=$_GET['mes'];
$idtp=$_GET['idtp'];
$nombre=$_GET['nombre'];
$tprog=$_GET['tprog'];
echo "<input type='hidden' id='tprog' name='tprog' value='".$tprog."'>";

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 "<br>MES ".$mm."<br>";
//echo $ugid;
//nombre de la jefatura
$sqljefatura = "select j_desc as nom from tb_jefatura where j_id='$idj'";
$resultjefatura = mysql_query($sqljefatura);
while ($rowj= mysql_fetch_array($resultjefatura)){
$nomjefatura = $rowj['nom']; 
}

//seleccionando al 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 = mysql_query($sqltpersonal);
//$cadenatp="<select id='tipopersonal' name='tipopersonal'>";
$cadenatp="<Select id='progtp' name='progtp' onChange='buscarpersonal()'>";
while ($rowtp= mysql_fetch_array($resulttpersonal)){
$cadenatp=$cadenatp."<option value='".$rowtp['cod']."'";
if(isset($_GET['idtp'])){
	if($idtp==$rowtp['cod']){
	$cadenatp=$cadenatp." selected ";
	//$idtp = $rowtp['cod'];
	}}
else{ $idtp=1;}
$cadenatp=$cadenatp." >".$rowtp['descripcion']."</option>";
}
$cadenatp=$cadenatp."</select>";

//nombre de servicio
$sqlserv = "select s_desc as nom from tb_servicio where j_id='$idj' and s_id='$ids'";
$resultserv = mysql_query($sqlserv);
while ($rows= mysql_fetch_array($resultserv)){
$nomservicio = $rows['nom']; 
}
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');

?>
<br>
<br>

<form action="menuprogramacion.php" method="GET">

<table align='center'>
<tr><td colspan='2' align='center' class='LlenarTablaGarea'>BUSQUEDA DE LA PROGRAMACION - REPROGRAMACION - EJECUCION DE HORAS<br></td></tr>
<tr><td align='left' colspan='2' class ='FacetDataTextC'>Seleccione Area / Dpto / Servicio a Consultar:</td>
<tr><td class ='FacetDataTextC' colspan='2' align='center'><?php echo $comboservicio;?></td></tr>
<tr><td>
<table align='center' colspan='2'>
<tr><td colspan='2' class='facetfilaTD'>Seleccione Anno y Mes:</td></tr>
<tr><td align='right' class ='FacetDataTextC'>Anno: </td>
<td class ='FacetDataTextC'>
<?php
echo "<select name='anno' id='anno' onchange='buscarpersonal()' >";
for ($i=2000;$i<2100;$i++){
echo "<option value='".$i."'";
if($anno==$i){?> selected
<?php 
$anno=$i;
}elseif((date("Y",time())==$i)&& !($_GET['anno'])){?> selected
<?php
} echo ">".$i."</option>";
}
echo "</select>";
?>
</td></tr>
<tr><td align='right' class ='FacetDataTextC'>Mes: </td><td class ='FacetDataTextC'>
<?php
//echo $_GET['mes'].'<br>';
echo "<select name='mes' id='mes' onchange='buscarpersonal()'>";
for ($i=1;$i<=count($arraymes);$i++){
echo "<option value='".$arraymes[$i-1]['idmes']."'";
if($_GET['mes']==$arraymes[$i-1]['idmes']){?> selected
<?php 
$mm=$i;
}elseif((date("n",time())==$arraymes[$i-1]['idmes']) && !($_GET['mes'])){?> selected
<?php
} echo ">".$arraymes[$i-1]['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='center' class='facetfilaTD'>Tipo de Personal:</td><td align='center' class='facetfilaTD'>Tipo de Contrato</td></tr>
		<tr><td align='center' class ='FacetDataTextC'><div id='divtp'><?php  echo $cadenatp; ?></div></td>
		<td align='center' class ='FacetDataTextC'>
		<select id='tpcont' name='tpcont' onChange='buscarpersonal()'>
		<option value='0' <?php if($tc==0){ echo "selected"; }?>>TODOS</option>
		<option value='1' <?php if($tc==1){ echo "selected"; }?>>ESSALUD</option>
		<option value='2' <?php if($tc==2){ echo "selected"; }?>>C.A.S.</option>
		</select>
		</td></tr>
		</table>
	<br>
	</fieldset>
</td></tr>
<tr><td align='center' colspan='2'><img src='../img/home2.jpg' width='70' height='60' onClick='regresarMPP1()'></td></tr>
</table>
<table>
<tr><td colspan='2' align='center'>
</tr>
</table>
</td>
</tr>
<tr><td><br></td></tr>
<tr><td align='center' class='LlenarTablaGarea' colspan='3'>BUSQUEDA INDIVIDUAL</td></tr>
<tr><td align='center' class='FacetDataTextC' colspan='3'><input type='radio' name='bprog' id='bprog' checked >PROGRAMACION
		<input type='radio' name='bprog' id='bprog'>REPROGRAMACION<input type='radio' name='bprog' id='bprog'>EJECUCION</td></tr>
<tr><td align='center' class='FacetDataTextC' colspan='3'>APELLIDOS Y NOMBRES DEL PERSONAL <input type='text' size='70' id='nombre' name='nombre' onKeyPress='buscarpersonalenteradm()' value='<?php if(isset($_GET['nombre'])){ echo $_GET['nombre'];}?>'> </td></tr>
</table>
<table align='center'><tr><td colspan='3' align='center' class='LlenarTablaGarea'>LISTADO DEL PERSONAL</td></tr>
<tr><td width='50' class='facetfilaTD'>CODIGO</td><td width='250' class='facetfilaTD' align='center'>NOMBRE DEL PERSONAL</td><td class='facetfilaTD' width='50' align='center'>VER</td></tr>

<?php

if(isset($_GET['tprog']) && isset($_GET['tc'])){
$idj=$_GET['idj'];
$ids=$_GET['ids'];
$ugid=$_GET['udig'];
$tc=$_GET['tc'];
$anno=$_GET['anno'];
$mm=$_GET['mes'];
$idtp=$_GET['idtp'];
$nombre=$_GET['nombre'];

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 $tc;
if($tc==0){
$_pagi_sql="select a.ug_id as cod, b.ut_codprog as codigo, CONCAT(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, ";
$_pagi_sql= $_pagi_sql." b.ut_idserva as idsa from tb_usutrab b  inner join tb_usuasist a on a.ug_id= b.ug_id where b.j_id='$idj' ";
$_pagi_sql= $_pagi_sql." and b.tp_id='$idtp' and b.ut_idserva='$ids' and b.uap_anno='$anno' and b.uap_mes ='$mm' and ";
$_pagi_sql= $_pagi_sql." (a.ua_apepat like '$nombre%' or  a.ua_apemat like '$nombre%' or a.ua_nom like '$nombre%') order by nombre";
//echo $_pagi_sql;
}
if($tc==1){
$_pagi_sql="select a.ug_id as cod, b.ut_codprog as codigo, CONCAT(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, ";
$_pagi_sql= $_pagi_sql." b.ut_idserva as idsa from tb_usutrab b  inner join tb_usuasist a on a.ug_id= b.ug_id where b.j_id='$idj' ";
$_pagi_sql= $_pagi_sql." and b.tp_id='$idtp' and b.ut_idserva='$ids' and b.uap_anno='$anno' and b.uap_mes ='$mm' and ";
$_pagi_sql= $_pagi_sql." (a.ua_apepat like '$nombre%' or  a.ua_apemat like '$nombre%' or a.ua_nom like '$nombre%') and a.tc_idcont not in ('3') order by nombre";
//echo $_pagi_sql;
}
if($tc==2){
$_pagi_sql="select a.ug_id as cod, b.ut_codprog as codigo, CONCAT(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, ";
$_pagi_sql= $_pagi_sql." b.ut_idserva as idsa from tb_usutrab b  inner join tb_usuasist a on a.ug_id= b.ug_id where b.j_id='$idj' ";
$_pagi_sql= $_pagi_sql." and b.tp_id='$idtp' and b.ut_idserva='$ids' and b.uap_anno='$anno' and b.uap_mes ='$mm' and ";
$_pagi_sql= $_pagi_sql." (a.ua_apepat like '$nombre%' or  a.ua_apemat like '$nombre%' or a.ua_nom like '$nombre%') and a.tc_idcont in ('3') order by nombre";
//echo $_pagi_sql;
}
}else{

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

$_pagi_sql="select a.ug_id as cod, b.ut_codprog as codigo, CONCAT(a.ua_apepat,' ',a.ua_apemat,' ',a.ua_nom) as nombre, ";
$_pagi_sql= $_pagi_sql." b.ut_idserva as idsa from tb_usutrab b  inner join tb_usuasist a on a.ug_id= b.ug_id where b.j_id='$idj' ";
$_pagi_sql= $_pagi_sql." and b.tp_id='$idtp' and b.ut_idserva='$ids' and b.uap_anno='$anno' and b.uap_mes ='$mm' ";
$_pagi_sql= $_pagi_sql."  order by nombre";
}
$test = new MyPagina;
       $test->sql = $_pagi_sql;
       $result = $test->get_page_result(); 
       $num_rows = $test->get_page_num_rows();  
       $nav_links = $test->navigation(" | ", "currentStyle"); 
	   $nav_info = $test->page_info("al"); 
       $simple_nav_links = $test->back_forward_link(); 
       $total_recs = $test->get_total_rows(); 


		if ($total_recs>=1)
	   {
		 $i = 0;
		 do
   		 {
		 $ugid = mysql_result($result, $i, "cod");
		 $codprog = mysql_result($result, $i, "codigo");
		 $nombre = mysql_result($result, $i, "nombre");
   		 

		echo "<tr><td align='center' width='50' class ='FacetDataTextC'>".$codprog."</td><td width='300' class ='FacetDataTextC'>".$nombre."</td><td align='center' class ='FacetDataTextC'><img src='../img/ver.jpg' width='17' height='17' value='$ugid' onClick=verprog(this.value);></td></tr>";

		$i++;
  		}while($i < $num_rows);}
  
echo "</table><br>";

echo "<table align='center'><tr><td colspan='4' class='FacetFieldCaptionTD' align='center'><center>";
 if ((isset($total_recs))&&($total_recs>=1)){ echo ' Registros(s) del '.$nav_info.' de '.$total_recs.' encontrado(s).' ;}else{ echo '0 Registros(s) encontrado(s).';} 
 echo "</center></td></tr><tr><td colspan='4' class='FacetFieldCaptionTD' align='center'><center>";
 if (isset($total_recs)){ echo $nav_links; }
echo "</center></td></tr></table>"; 
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'>";
}
?>
</div>
</body>
</html>

