<?php
  include("stilos/config.inc.php");
  include("clases/BDConexion.php");
  include("clases/clsclinico.php");
  include("Funciones.php");
  session_start();
  $objclinico=new clsclinico;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Registro de Examenes Clinicos - BARRET RESOURCES(PERU) LLC</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stilos/Estilos.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo1 {font-size: 10px}
.Estilo2 {color: #000000}
.Estilo3 {color: #000000; font-size: 10px; }
.Estilo4 {color: #FFFFFF}
-->
</style>
<SCRIPT language=JavaScript src="js/calendario.js"></SCRIPT>
<script>
function enviar_url(form,url){
		if(form1.grabar.value)
		{
			form1.submit();
		}
	}
</script>
<SCRIPT LANGUAGE=javascript>
function fn(form,field)
	{
	var next=0, found=false
	var f=form
	if(event.keyCode!=13) return;
	for(var i=0;i<f.length;i++) {
	if(field.name==f.item(i).name){
	next=i+1;
	found=true
	break;
	}
	}
while(found){
	if( f.item(next).disabled==false && f.item(next).type!='hidden'){
	f.item(next).focus();
	break;
	}
	else{
	if(next<f.length-1)
	next=next+1;
	else
	break;
	}
		}
}
</SCRIPT>
<script language="JavaScript"> 
<!--
//sURL,x,y
function Abrir_Ventanapopup1(sURL,x,y) { 
/*var especificaciones="top=0, left=0, toolbar=no,location=no, status=yes,menubar=no,scrollbars=no, resizable=no, width=1,height=1" 
var titulo="Titulo"
window.open(el_url,titulo,especificaciones);*/ 

if (!window.focus) return;
			var par;
			par = "width=" +x + ",height="+y+","
			par = par + "dependent=no,scrollbars=yes,resizable=no"
			par = par + "menubar=no,toolbar=no,status=yes"
			var ventana = window.open(sURL,"Ver",par)
			ventana.focus();
}
//--> 
</script>

<script language="JavaScript" type="text/JavaScript">
function MensajeEditar(m){
if (m==1){window.alert("Se Guardo el Examen satisfactoriamente")}
}
</script>
<script>
var vent = null;
function foco() {
   if (vent != null)
       vent.focus();
}
function cerrar() {
   vent = null;
}


function volver(form){
  location.reload('fondo.php');
  
  }
</script>
</head>
<body  background="imagenes/fondo.jpg">
<table width="460" border="0" align="center" cellpadding="0" cellspacing="0" >
  <tr class="lblCampo" >
    <td colspan="4"><div align="center">
        <table width="319" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>&nbsp;</td>
            <td valign="bottom">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td width="25"><img src="estilo_tabla/parte_sup_izq.gif" width="25" height="25"></td>
            <td width="409" background="estilo_tabla/parte_sup_cen.gif" valign="bottom">
              <div align="left" class="lblTitulo Estilo4" >Imprimir Ex&aacute;menes Cl&iacute;nicos</div></td>
            <td width="25"><img src="estilo_tabla/parte_sup_der.gif" width="25" height="25" border="0" usemap="#Map"></td>
          </tr>
          <tr>
            <td width="25" background="estilo_tabla/parte_med_izq.gif">&nbsp;</td>
            <td width="409" height="86" background="estilo_tabla/parte_med_cen.gif"><div align="center">
              <table width="731" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="5" >&nbsp;</td>
                  <td width="9" height="19">&nbsp; </td>
                  <td width="606">&nbsp;</td>
                  <td width="101">&nbsp;</td>
                  <td width="10">&nbsp;</td>
                </tr>
                <tr>
                  <td >&nbsp;</td>
                  <td height="19">&nbsp;</td>
                  <td><span class="lblSubTitulo">BUSCAR EL EX&Aacute;MEN CL&Iacute;NICO A IMPRIMIR </span></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td colspan="3" valign="top"><table width="701" border="0" align="center" cellpadding="0" cellspacing="0" >
                      <tr>
                        <td valign="top"><form name="form1" method="post" action="consulta_exa_clinico.php?tipo=<? echo $tipo?>&des=<? echo $des?>">
                            <table width="683" border="0" align="center" cellpadding="0" cellspacing="0" id="apell_nom">
                              <tr bgcolor="#2F8523">
                                <td width="126" class="trCabecera Estilo1"><div align="right" class="Estilo2">Buscar por : </div></td>
                                <td><select name="tipo" class="pnlForm" id="tipo">
                                    <option value="0" <? if($tipo==0){?> selected <? }?>>Todos</option>
                                    <option value="1" <? if($tipo==1){?> selected <? }?>>Apellidos</option>
                                    <option value="2" <? if($tipo==2){?> selected <? }?>>Doc. Identidad</option>
                                  </select>
                                    <input name="des" type="text" class="lblForm" id="des" value="<?= $des?>" size="25" maxlength="25" align="right">
                                    <span class="lblForm">
                                    <input type="submit" name="Submit" value="Buscar" style="<?=$stylo['st2']?>" class="botira">
                                    <input name="k" type="hidden" id="k" value="2">
                                  </span></td>
                              </tr>
                              <tr bgcolor="#2F8523">
                                <td class="trCabecera Estilo1">&nbsp;</td>
                                <td>&nbsp;</td>
                              </tr>
                            </table>
                        </form></td>
                      </tr>
                      <tr>
                        <td><div align="center">
                            <table width="587" border="0" align="center" cellpadding="0" cellspacing="0">
                              <tr>
                                <td><div align="center">
                                    <table width="683" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="<?=$bordetabla?>" bgcolor="<?=$c_fondo['fondo tabla']?>" style="<?=$stylo['tabla']?>">
                                      <tr valign="top" bordercolor="#00CC00" bgcolor="#2F8523">
                                        <td width="64">
                                          <div align="left" class="Estilo3">Cod FIcha </div></td>
                                        <td width="181" bgcolor="#2F8523"><div align="left" class="Estilo3">Apellidos</div></td>
                                        <td width="171" bgcolor="#2F8523" ><div align="left" class="Estilo3">Nombres</div></td>
                                        <td width="104">
                                          <div align="center" class="Estilo3">Grupo Sanguineo </div></td>
                                        <td width="80">
                                          <div align="center" class="Estilo3">Factor RH </div></td>
                                        <td width="69">Total Ficha </td>
                                      </tr>
                                      <? 
				    $regxpag=20;
					if(!isset($pagina)){
					$pagina=0;
					}					
					$regini=$pagina*$regxpag;
					if($tipo==0){						
						$resultado=$objclinico->getPerTodosExaPag($regini,$regxpag);						
					}elseif($tipo==1){						
						$resultado=$objclinico->getPerApePag($des,$regini,$regxpag);
					}else{
						$resultado=$objclinico->getPerCodFichaPag($des,$regini,$regxpag);
					}
				   
                  while($filas=$objclinico->NextRow($resultado))
                   {
				   ?>
                                      <tr valign="top">
                                        <td>
                                          <div align="left"> <? echo $filas['cod_lab']; ?> </div></td>
                                        <td><div align="left"><? echo $filas['appat_per']; ?> <? echo $filas['apmat_per']; ?></div></td>
                                        <td><div align="left"><? echo $filas['nom_per']; ?> </div></td>
                                        <td>
                                          <div align="center">
                                            <?php 
						 echo $filas['grupo'];
						  ?>
                                        </div></td>
                                        <td><div align="center">
                                            <?php 
						 echo $filas['factor_rh'];
				    ?>
                                        </div></td>
                                        <td align="center"><?=$filas['contador'];?></td>
                                      </tr>
                                      <? 
			}
			$objclinico->Liberar($resultado);  
			?>
                                    </table>
                                </div></td>
                              </tr>
                              <tr>
                                <td>
                                  <table width="585" border="0" cellspacing="0" cellpadding="0">
                                    <?
			if($tipo==0){
			$resultados=$objclinico->getPerTodosExaT();
			}elseif($tipo==1){
			$resultados=$objclinico->getPerApeT($des);
			}else{
			$resultados=$objclinico->getPerCodFichaT($des);
			}
			$nfilas=$objclinico->totalrows($resultados);
			$ntotpag=floor(($nfilas/$regxpag));
			if(($nfilas%$regxpag)>0){$ntotpag++;}
			if($ntotpag>0){
			?>
                                    <tr>
                                      <td width="301"><div align="left"><span class="lblForm">Pagina <? echo ($pagina+1);?> de <? echo $ntotpag;?> </span></div></td>
                                    </tr>
                                    <tr>
                                      <td><div align="center" class="lblForm">
                                          <div align="center">
                                            <?
  for($i=0;$i<$ntotpag;$i++){
  	if($i==$pagina){
		echo "[".($i+1)."]";
	}else{ ?>
                                            <a href='<? echo $PHP_SELF."?pagina=$i"?>'><? echo "[".($i+1)."]";?></a>
                                            <? 
	}
	}
  ?>
                                          </div>
                                      </div></td>
                                    </tr>
                                    <? }?>
                                    <tr>
                                      <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <form name="form1" method="post" action="reporte_exaclinico.php">
                                        <td>
                                          <div align="center">
                                            <input type="button" name="Submit2" value="Imprimir" style="<?=$stylo['st2']?>" class="botira" onClick="javascript:Abrir_Ventanapopup1('reporte_exaclinico.php?tipo=<? echo $tipo?>&des=<? echo $des?>',780,510)">
                                            <input name="tipo2" type="hidden" size="5" id="tipo22" value="<? echo $tipo?>">
                                            <input name="des2" type="hidden" size="5" id="des22" value="<? echo $des?>">
                                        </div></td>
                                        <td width="30">&nbsp;</td>
                                        <td width="83"><input name="salir" type="button" style="<?=$stylo['st2']?>" class="botira" id="salir" value=".:   Salir  :." onClick="volver(this.form);"></td>
                                        <td width="171">&nbsp;</td>
                                      </form>
                                    </tr>
                                </table></td>
                              </tr>
                            </table>
                        </div></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                  </table></td>
                  <td>&nbsp;</td>
                </tr>
              </table>
                </div></td>
            <td background="estilo_tabla/parte_med_der.gif">&nbsp;</td>
          </tr>
          <tr>
            <td><img src="estilo_tabla/parte_inf_izq.gif" width="25" height="25"></td>
            <td background="estilo_tabla/parte_inf_cen.gif">&nbsp;</td>
            <td><img src="estilo_tabla/parte_inf_der.gif" width="25" height="25"></td>
          </tr>
        </table>
    </div></td>
  </tr>
  <tr valign="top" class="lblCampo" >
    <td colspan="4">
      <div align="center"> </div></td>
  </tr>
</table>
<map name="Map">
  <area shape="circle" coords="12,11,9" href="fondo.php">
</map>
</body>
</html>
