public function listadoPI($entidad, $bali, $basedatos)
    {
        ?>
  <script language="JavaScript" type="text/javascript">
    /**
    * funcion demo del evento onclick en la tabla
    */
    function envia()
    {
      document.forms[0].submit();
    }
    /**
    * funcion de captura de pulsaci�n de tecla en Internet Explorer
    */ 
    var tecla;
    function capturaTecla(e) 
    {
        if(document.all)
            tecla=event.keyCode;
        else
        {
            tecla=e.which; 
        }
     if(tecla==13)
        {
            document.forms[0].submit();
        }
    }  
    document.onkeydown = capturaTecla;
</script>


<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana1","width=700,height=600,scrollbars=YES") 
} 
</script> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style12 {font-size: 10px}
.style7 {font-size: 9px}
.style13 {color: #FFFFFF}
.enlace {cursor:default;}
.style9 {
	color: #0000FF;
	font-size: 9px;
}
-->
</style>
</head>
<META HTTP-EQUIV="Refresh"
CONTENT="30"> 
<body>
<?php 
        require CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        //ventanasPrototype::links();
        ?>
<form id="form1" name="form1" method="post" action="#">
  <h1 align="center">Hacer Devoluciones </h1>
  <span class="style12"></span>
  <table width="597" border="0.2" align="center">
    <tr>
      <th width="65" bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13"># Cuenta  </span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Nombre del paciente:</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Cuarto</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13"> Cargos</span></div></th>
    </tr>
    <tr>
      <?php 
        $almacenesCierreCuenta = new articulosDetalles();
        $sSQL = "SELECT *\r\nFROM\r\nclientesInternos \r\nWHERE entidad='" . $entidad . "' AND\r\nstatusCuenta = 'abierta'\r\nand\r\n(status='activa' or status='ontransfer')\r\nand \r\n(statusDeposito='pagado' or statusDeposito='cxc' or statusDeposito='urgencias')\r\nand\r\ntipoPaciente='interno' \r\nor \r\n(solicitaTransferencia='si' and almacenTransferencia!='')\r\nORDER BY keyClientesInternos ASC\r\n ";
        if ($result = mysql_db_query($basedatos, $sSQL)) {
            while ($myrow = mysql_fetch_array($result)) {
                if ($col) {
                    $color = '#FFCCFF';
                    $col = "";
                } else {
                    $color = '#FFFFFF';
                    $col = 1;
                }
                $sSQL31 = "SELECT status FROM\r\nclientesInternos\r\nWHERE \r\nkeyClientesInternos='" . $myrow['keyClientesInternos'] . "'";
                $result31 = mysql_db_query($basedatos, $sSQL31);
                $myrow31 = mysql_fetch_array($result31);
                ?>
      <td height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                echo $myrow['keyClientesInternos'];
                ?>
</span></td>
      <td width="396" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"> 
		  <?php 
                echo $myrow['paciente'];
                if ($myrow['status'] == 'ontransfer') {
                    echo '   [Se solicit� la transferencia de �ste paciente]';
                }
                if ($almacenesCierreCuenta->almacenesCierreCuenta($bali, $fecha1, $hora1, $usuario, $myrow['keyClientesInternos'], $entidad, $numeroE, $nCuenta, $basedatos) == 'cargado') {
                    echo '<span class="style9">' . ' [La Cuenta en este departamento ha sido Liberada]' . '</span>';
                }
                ?>
      </span></td>
      <td width="65" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                echo $myrow['cuarto'];
                ?>
</span></td>
      <td width="53" bgcolor="<?php 
                echo $color;
                ?>
" class="style12">

	  <a href="#" onClick="javascript:ventanaSecundaria('listadoArticulos.php?numeroE=<?php 
                echo $myrow['numeroE'];
                ?>
&nCuenta=<?php 
                echo $myrow['nCuenta'];
                ?>
&almacen=<?php 
                echo $bali;
                ?>
&seguro=<?php 
                echo $_POST['seguro'];
                ?>
&tipoPaciente=<?php 
                echo "interno";
                ?>
')">
	  <img src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/agregar.gif" alt="Agregar Articulos" width="12" height="12" border="0"/>	  </a>  	  </td>
    </tr>
    <?php 
            }
        }
        ?>
    <input name="nombres" type="hidden" value="<?php 
        echo $nombrePaciente;
        ?>
" />
  </table>
  <span class="style12"><span class="style7">
  <input name="nombrePaciente" type="hidden" id="nombrePaciente" value="<?php 
        echo $nombrePaciente;
        ?>
" />
  <input name="nombrePaciente2" type="hidden" id="nombrePaciente2" value="<?php 
        echo $nombrePaciente;
        ?>
"/>
  <input name="tipoSeguro" type="hidden" id="tipoSeguro" value="<?php 
        echo $myrow['seguro'];
        ?>
"/>
  </span></span>

</form>
</body>
</html>


<?php 
    }
        echo $color;
        ?>
" class="codigosmid"><?php 
        echo $myrow['keyClientesInternos'];
        ?>
</td>
      <td width="270" bgcolor="<?php 
        echo $color;
        ?>
"  class="normalmid">
		  <?php 
        echo $myrow['paciente'];
        if ($myrow['status'] == 'ontransfer') {
            echo '   [Se solicit� la transferencia de �ste paciente]';
        }
        if ($almacenesCierreCuenta->almacenesCierreCuenta($bali, $fecha1, $hora1, $usuario, $myrow['keyClientesInternos'], $entidad, $numeroE, $nCuenta, $basedatos) == 'cargado') {
            echo '<span class="style9">' . ' [La Cuenta en este departamento ha sido Liberada]' . '</span>';
        }
        ?>
      </span></td>
      <td width="78" bgcolor="<?php 
        echo $color;
        ?>
" class="normalmid"><?php 
        echo $myrow['cuarto'];
        ?>
</span></td>
    </tr>
    <?php 
    }
}
    public function listaInternos($estado, $fecha1, $hora1, $usuario, $ALMACEN, $entidad, $TITULO, $ventana, $basedatos)
    {
        ?>



<script language=javascript> 
function ventanaSecundaria11 (URL){ 
   window.open(URL,"ventana11","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 

<?php 
        if ($_GET['alta'] == 'activar') {
            $sSQL31 = "Select * From clientesInternos WHERE keyClientesInternos='" . $_GET['nT'] . "'";
            $result31 = mysql_db_query($basedatos, $sSQL31);
            $myrow31 = mysql_fetch_array($result31);
            $numeroE = $myrow31['numeroE'];
            $nCuenta = $myrow31['nCuenta'];
            $keyClientesInternos = $myrow31['keyClientesInternos'];
            $sSQL32 = "Select * From procesoAlta WHERE \r\nalmacen='" . $ALMACEN . "'\r\nand\r\nentidad='" . $entidad . "'\r\nand\r\nkeyClientesInternos='" . $_GET['nT'] . "'";
            $result32 = mysql_db_query($basedatos, $sSQL32);
            $myrow32 = mysql_fetch_array($result32);
            if (!$myrow32['numeroE']) {
                $paso = '2';
                $status = $estado;
            }
            if (!$myrow32['numeroE'] and $estado == 'cargado') {
                $agrega1 = "\r\nINSERT INTO procesoAlta ( numeroE, nCuenta, almacen, status, nPaso, fecha, hora, usuario,keyClientesInternos,entidad\r\n) values ( \r\n'" . $numeroE . "', '" . $nCuenta . "', '" . $ALMACEN . "', '" . $status . "', '" . $paso . "', '" . $fecha1 . "', '" . $hora1 . "','" . $usuario . "',\r\n'" . $keyClientesInternos . "','" . $entidad . "' )";
                mysql_db_query($basedatos, $agrega1);
                echo mysql_error();
            } else {
                $q = "UPDATE procesoAlta set \r\nstatus='cargado',nPaso='2' \r\n\r\nWHERE \r\nalmacen='" . $ALMACEN . "'\r\nand\r\nentidad='" . $entidad . "'\r\nand\r\nkeyClientesInternos='" . $_GET['nT'] . "'";
                mysql_db_query($basedatos, $q);
                echo mysql_error();
            }
            $alta = 'desactivar';
        }
        if (!$alta) {
            $alta = 'activar';
        }
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<?php 
        $estilos = new muestraEstilos();
        $estilos->styles();
        ?>
</head>
<META HTTP-EQUIV="Refresh"
CONTENT="60"> 
<body>
<?php 
        require CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        //ventanasPrototype::links();
        ?>
<form id="form1" name="form1" method="get" action="#">
  <h1 align="center" class="titulos"> <?php 
        echo $TITULO;
        ?>
</h1>
  <table width="739" border="0.2" align="center">
    <tr>
      <th width="50" bgcolor="#660066" class="style12" scope="col"><div align="left" class="blanco"># Folio</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left" class="blanco">Nombre del paciente:</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left" class="blanco">Seguro</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="center" class="blanco">Usuario</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="center" class="blanco">Fecha</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="center" class="blanco">Cuarto</div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="center" class="blanco">Status</div></th>
    </tr>
    <tr>
      <?php 
        $almacenesCierreCuenta = new articulosDetalles();
        $cierreCuentaReporte = new articulosDetalles();
        $sSQL = "SELECT *\r\nFROM\r\nclientesInternos \r\nWHERE \r\nentidad='" . $entidad . "'\r\nAND\r\n(tipoPaciente='interno' or tipoPaciente='urgencias')\r\nand\r\nstatusCuenta = 'abierta'\r\nand\r\nstatus='activa'\r\nand \r\n(statusDeposito='pagado' or statusDeposito='cxc' or statusDeposito='urgencias')\r\nORDER BY keyClientesInternos DESC\r\n ";
        if ($result = mysql_db_query($basedatos, $sSQL)) {
            while ($myrow = mysql_fetch_array($result)) {
                if ($col) {
                    $color = '#FFCCFF';
                    $col = "";
                } else {
                    $color = '#FFFFFF';
                    $col = 1;
                }
                $seguro = $myrow['seguro'];
                $nT = $myrow['keyClientesInternos'];
                $sSQL1711 = "\r\n\tSELECT \r\nnomCliente\r\nFROM\r\nclientes\r\nWHERE \r\nnumCliente = '" . $seguro . "'\r\n\r\n";
                $result1711 = mysql_db_query($basedatos, $sSQL1711);
                $myrow1711 = mysql_fetch_array($result1711);
                $seguro = $myrow1711['nomCliente'];
                if ($seguro) {
                    $tipoCliente = 'aseguradora';
                } else {
                    $tipoCliente = 'particular';
                }
                if (!$seguro) {
                    $seguro = 'particular';
                }
                $sSQL11 = "\r\n\tSELECT \r\n*\r\nFROM\r\nprocesoAlta\r\nWHERE \r\nentidad='" . $entidad . "' \r\nand\r\nkeyClientesInternos = '" . $nT . "'\r\nand\r\nalmacen='" . $ALMACEN . "'\r\n";
                $result11 = mysql_db_query($basedatos, $sSQL11);
                $myrow11 = mysql_fetch_array($result11);
                $sSQL12 = "\r\nSELECT \r\naltaEspecial\r\nFROM\r\nalmacenes\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\nalmacen = '" . $ALMACEN . "'\r\nand\r\naltaEspecial='si'\r\n";
                $result12 = mysql_db_query($basedatos, $sSQL12);
                $myrow12 = mysql_fetch_array($result12);
                ?>
      <td height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="codigos">
	  
	  <?php 
                echo $myrow['keyClientesInternos'];
                ?>
</td>


      <td width="253" bgcolor="<?php 
                echo $color;
                ?>
" class="normal">

	  	  <?php 
                echo $myrow['paciente'];
                echo $cierreCuentaReporte->cierreCuentaReportes($entidad, $nT, $numeroE, $nCuenta, $basedatos);
                if ($almacenesCierreCuenta->almacenesCierreCuenta($ALMACEN, $fecha1, $hora1, $usuario, $myrow['keyClientesInternos'], $entidad, $numeroE, $nCuenta, $basedatos) == 'cargado') {
                    echo '<span class="style9">' . ' [La Cuenta en este departamento ha sido Liberada]' . '</span>';
                }
                ?>
          <input name="nombrePaciente" type="hidden" id="nombrePaciente" value="<?php 
                echo $nombrePaciente;
                ?>
"/>
        <input name="tipoSeguro" type="hidden" id="tipoSeguro" value="<?php 
                echo $seguro;
                ?>
"/>
      </span></td>

      <td width="143" bgcolor="<?php 
                echo $color;
                ?>
" class="normal">
	  <?php 
                echo $seguro;
                ?>
</td>
      <td width="61" bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><?php 
                echo $myrow11['usuario'];
                ?>
</td>
      <td width="94" bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><?php 
                echo $myrow11['fecha'] . " " . $myrow11['hora'];
                ?>
</td>
      <td width="60" bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><?php 
                echo $myrow['cuarto'];
                ?>
</td>
      <td width="48" bgcolor="<?php 
                echo $color;
                ?>
" class="normal">
	  
	  
	  
	  
	  <?php 
                //alta especial
                if ($myrow12['altaEspecial'] and $myrow11['status'] == 'standby') {
                    ?>
	  <img src="<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/imagenes/iconosSima/lock_icon.jpg" alt="LA CUENTA ESTA EN PROCESO" width="12" height="12" border="0" />
	  
	  
	  <?php 
                } else {
                    ?>
	  
	  <?php 
                    if ($myrow11['status'] == 'request' or $myrow11['status'] == 'standby') {
                        ?>
	  
	  	
	  <a href='liberarCuenta.php?codigo=<?php 
                        echo $code;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&medico=<?php 
                        echo $_POST['medico'];
                        ?>
&alta=<?php 
                        echo $alta;
                        ?>
&nT=<?php 
                        echo $nT;
                        ?>
'"><img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/iconosSima/lock_icon.jpg" alt="LA CUENTA YA FUE REVISADA, FALTA LIBERAR" width="12" height="12" border="0"  onclick="if(confirm('Esta seguro que deseas liberar la cuenta del paciente <?php 
                        echo $myrow['paciente'];
                        ?>
?') == false){return false;}" />	  </a>
	  
	  <?php 
                    } else {
                        if ($myrow11['status'] == 'cargado') {
                            ?>

	    <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/iconosSima/unlock_icon.jpg" alt="CUENTA REVISADA" width="12" height="12" border="0"  />
	  <?php 
                        } else {
                            ?>
	  <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/pendiente.png" alt="LA CUENTA FALTA POR REVISAR" width="12" height="12" border="0"  />
	  <?php 
                        }
                    }
                }
                ?>
	  </td>
    </tr>
    <?php 
            }
        }
        ?>
    <input name="menu" type="hidden" value="<?php 
        echo $menu;
        ?>
" />
  </table>



<?php 
        $titulo = 'prueba';
        $url = $ventana;
        $abajo = 70;
        $izquierda = 0;
        $ancho = 300;
        $alto = 200;
        //$ventanas=new ventanasPrototype();
        //$ventanas->despliegaVentana($titulo,$url,$abajo,$izquierda,$anchura,$altura);
        ?>


  <p>&nbsp;</p>
</form>
</body>
</html>


<?php 
    }