public function eCuentaE($usuario, $entidad, $almacen, $fecha1, $hora1, $dia, $usu, $nT, $basedatos)
    {
        $bali = $almacen;
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        $seguroT = ltrim($myrow3['seguro']);
        //***************aplicar pago**********************
        if ($_POST['actualizar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                if ($aseguradora[$i]) {
                    $status = 'efectivo';
                    $keyCAP[] = $aseguradora[$i];
                } else {
                    $status = 'cxc';
                    $keyCAP[] = $particular[$i];
                }
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusAlta='" . $status . "',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
            //cierra for
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['imprimir']) {
            //*************SACO EL NUMERO DE MOVIMIENTO y lo actualizo*************************
            $sSQLC = "Select * From statusCaja where entidad='" . $entidad . "' and usuario='" . $usuario . "' order by keySTC DESC ";
            $resultC = mysql_db_query($basedatos, $sSQLC);
            $myrowC = mysql_fetch_array($resultC);
            $q = "UPDATE statusCaja set \r\nnumRecibo= numRecibo+1\r\nwhere\r\nentidad='" . $entidad . "'\r\nand\r\nkeyCatC='" . $myrowC['keyCatC'] . "'\r\nand\r\nstatus='abierta'\r\norder by keySTC DESC ";
            mysql_db_query($basedatos, $q);
            echo mysql_error();
            $sSQLC = "Select * From statusCaja where entidad='" . $entidad . "' and usuario='" . $usuario . "' order by keySTC DESC ";
            $resultC = mysql_db_query($basedatos, $sSQLC);
            $myrowC = mysql_fetch_array($resultC);
            $q0 = "UPDATE clientesInternos,cargosCuentaPaciente set \r\nclientesInternos.numRecibo= '" . $myrowC['numRecibo'] . "',\r\ncargosCuentaPaciente.numRecibo= '" . $myrowC['numRecibo'] . "'\r\nwhere\r\n\r\nclientesInternos.keyClientesInternos='" . $_GET['nT'] . "'\r\nand\r\nclientesInternos.keyClientesInternos=cargosCuentaPaciente.keyClientesInternos\r\n\r\n";
            mysql_db_query($basedatos, $q0);
            echo mysql_error();
            //*************************************************************
            if ($_GET['paquete'] == 'si') {
                ?>
<script language="javascript">
ventanaSecundaria2('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/imprimirReciboPaquetes.php?numeroE=<?php 
                echo $myrow3['numeroE'];
                ?>
&nCuenta=<?php 
                echo $myrow3['nCuenta'];
                ?>
&keyClientesInternos=<?php 
                echo $myrow3['keyClientesInternos'];
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&numeroConfirmacion=<?php 
                echo $numeroConfirmacion;
                ?>
&hora1=<?php 
                echo $hora1;
                ?>
&cajero=<?php 
                echo $usuario;
                ?>
&codigoPaquete=<?php 
                echo $myrow3['codigoPaquete'];
                ?>
&numRecibo=<?php 
                echo $myrowC['numRecibo'];
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&cantidadRecibida=<?php 
                echo $_POST['cantidadRecibida'];
                ?>
&folioVenta=<?php 
                echo $myrow3['folioVenta'];
                ?>
');
close();
</script>
<?php 
            } else {
                ?>
<script>
javascript:ventanaSecundaria2('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/imprimirCargosPA.php?numeroE=<?php 
                echo $numeroE;
                ?>
&nCuenta=<?php 
                echo $nCuenta;
                ?>
&keyClientesInternos=<?php 
                echo $nT;
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&numeroConfirmacion=<?php 
                echo $numeroConfirmacion;
                ?>
&hora1=<?php 
                echo $hora1;
                ?>
&cajero=<?php 
                echo $usuario;
                ?>
');
close();
</script>
<?php 
            }
            ?>


<?php 
        }
        ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>






<title></title>
<?php 
        $estilos = new muestraEstilos();
        $estilos->styles();
        ?>
</head>

<h1 align="center" class="titulos">Nota de Venta </h1>
<form id="form1" name="form1" method="post" action="">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="blanco" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Referencia</div></th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco"><?php 
        echo $nCliente = $myrow3['folioVenta'];
        ?>
          <input name="numeroE" type="hidden" class="blanco" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="10" class="normal" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left" class="normal">Paciente: </div></th>
      <th width="408" bgcolor="#FFCCFF"  scope="col"><div align="left" class="normal"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="normal">Compa&ntilde;&iacute;a: </td>
      <td class="normal">
        <label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
        </label>
      </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="normal">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="normal"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
  </table>
  <p align="center">
  <?php 
        if ($_GET['codigoPaquete']) {
            echo 'Paquete: ' . $_GET['codigoPaquete'];
        }
        ?>
  </p>
  

  
  <table width="713" border="0" align="center">
    <tr>
      <th width="140" height="14" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Fecha/Hora </div></th>
      <th width="331" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Descripci&oacute;n/Concepto</div></th>
      <th width="34" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Cant</div></th>
      <th width="80" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Importe</div></th>
      <th width="50" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">IVA</div></th>
      <th width="52" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Convenio</div></th>
    </tr>
    <tr>
    
      <?php 
        //traigo agregados
        if ($_GET['paquete'] == 'si') {
            $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\narticulosPaquetesPacientes \r\n WHERE \r\nkeyClientesInternos='" . $_GET['nT'] . "'\r\n";
        } else {
            $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,tipoConvenio,folioVenta\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nkeyClientesInternos='" . $_GET['nT'] . "'\r\n \r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
        }
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            if ($_GET['paquete'] == 'si') {
                $codigo = $proc = $myrow81['codigo'];
                $chain = $myrow81['hora'] . " " . cambia_a_normal($myrow81['fecha']);
                $sSQL31 = "select * from articulosPaquetes where keyE='" . $myrow81['keyE'] . "'";
                $result31 = mysql_db_query($basedatos, $sSQL31);
                $myrow31 = mysql_fetch_array($result31);
            } else {
                $chain = $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                $art = $myrow81['codProcedimiento'];
                $codigo = $proc = $myrow81['codProcedimiento'];
                $keyCAP = $myrow81['keyCAP'];
            }
            ?>


  <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
	  <?php 
            echo $chain;
            ?>
</td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
      <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
            ?>
         
		
        <?php 
            if ($myrow811['um'] == 's' or $myrow811['um'] == 'S') {
                echo '  ( Servicio )  ';
            }
            ?>

      </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" ><div align="center" class="normal">
          <?php 
            echo $cantidad = $myrow81['cantidad'];
            ?>
      </div></td>

      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
        <?php 
            if ($_GET['paquete'] == 'si') {
                echo '$' . number_format($myrow31['precioPaquete1'], 2);
                $sumatoria[0] += $myrow31['precioPaquete1'] * $myrow31['cantidad'];
            } else {
                $importe = new acumulados();
                echo $importe->importe($keyCAP, $basedatos);
            }
            ?>
   </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
        <?php 
            if ($_GET['paquete'] == 'si') {
                echo '$' . number_format($myrow31['ivaPrecioPaquete1'], 2);
                $sumatoriaIVA[0] += $myrow31['ivaPrecioPaquete1'] * $myrow31['cantidad'];
            } else {
                $mostrarIVA = new articulosDetalles();
                echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
            }
            ?>
      </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
"><div align="center" class="normal">
	   
      
      <?php 
            if ($myrow81['tipoConvenio'] and $myrow81['tipoConvenio'] != 'No') {
                echo 'C';
            } else {
                echo '---';
            }
            ?>
   </div></td>
	</tr>
 
	
	
    <?php 
        }
        ?>
  </table>

  <p>&nbsp;</p>
  <div align="center">
    <table width="558" border="0" align="center">
      <tr>
        <td width="113" class="style12">&nbsp;</td>
        <td width="124" class="style12">&nbsp;</td>
        <td width="97" class="normal">Total Cargos 
          <?php 
        $totalAcumulado = new acumulados();
        if ($_GET['paquete'] == 'si') {
            echo '$' . number_format($sumatoria[0] + $sumatoriaIVA[0], 2);
            $cantidadRecibida = $sumatoria[0] + $sumatoriaIVA[0];
        } else {
            echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), 2);
        }
        ?>
      </td>
        <td width="106" height="23"><div align="left" class="normal">Total Abonos 
            <?php 
        $abonos = new acumulados();
        echo "\$" . number_format($abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), 2);
        ?>
        </div></td>
        <td width="96"><div align="left" class="normal"><strong>Saldo Actual</strong><strong>
          <?php 
        if ($_GET['paquete'] == 'si') {
            $abono = $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta);
            $abono1 = $abono * '-1';
            echo '$' . number_format(round($sumatoria[0] + $sumatoriaIVA[0] - $abono1), 2);
        } else {
            if ($abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta) < 0) {
                $abono = $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta);
                $abono1 = $abono * '-1';
            }
            echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta) - $abono1, 2);
        }
        ?>
        </strong></div></td>
      </tr>
      <tr>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td class="style12"><input name="cantidadRecibida" type="hidden" class="style7" id="cantidadRecibida" value="" /></td>
        <td height="23" class="normal"><div align="right"></div></td>
        <td class="normal"><div align="right"></div></td>
      </tr>
      <tr>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td height="23" class="style23 Estilo24"><div align="right"></div></td>
        <td class="style12"><div align="right"></div></td>
      </tr>
    </table>


  </div>
  <p align="center">
	<?php 
        if ($_GET['paquete'] == 'si') {
            //***********************CALCULAR
            if (round($sumatoria[0] + $sumatoriaIVA[0] - $abono1) == NULL) {
                ?>
    <label>
    <input name="imprimir" type="image" class="style27" id="imprimir" value="Imprimir" src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/btns/printbutton.png"/>
    </label>
	<?php 
            } else {
                ?>
    <input name="Submit" type="image" class="style27" value="Aplicar Pagos" src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/btns/aplicapay.png"  onclick="javascript:ventanaSecundaria7('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?usuario=<?php 
                echo $_GET['usuario'];
                ?>
&numeroE=<?php 
                echo $numeroE;
                ?>
&almacen=<?php 
                echo $_GET['almacenSolicitante'];
                ?>
&almacenFuente=<?php 
                echo $almacen;
                ?>
&seguro=<?php 
                echo $seguroT;
                ?>
&nCuenta=<?php 
                echo $myrow3['keyClientesInternos'];
                ?>
&tipoCliente=<?php 
                echo 'particular';
                ?>
&tipoVenta=<?php 
                echo $_GET['tipoVenta'];
                ?>
&paquete=<?php 
                echo $_GET['paquete'];
                ?>
')"/>
    <input name="keyClientesInternos" type="hidden" class="style7" id="keyClientesInternos" value="<?php 
                echo $_GET['nT'];
                ?>
" />
	<?php 
            }
            //*********************************
        } else {
            if (round($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta) - $abono1) == NULL) {
                ?>
    <label>
    <input name="imprimir" type="image" class="style27" id="imprimir" value="Imprimir" src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/btns/printbutton.png"/>
    </label>
	<?php 
            } else {
                ?>
    <input name="Submit" type="image" class="style27" value="Aplicar Pagos" src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/btns/aplicapay.png"  onclick="javascript:ventanaSecundaria7('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?usuario=<?php 
                echo $_GET['usuario'];
                ?>
&numeroE=<?php 
                echo $numeroE;
                ?>
&almacen=<?php 
                echo $_GET['almacenSolicitante'];
                ?>
&almacenFuente=<?php 
                echo $almacen;
                ?>
&seguro=<?php 
                echo $seguroT;
                ?>
&nCuenta=<?php 
                echo $myrow3['keyClientesInternos'];
                ?>
&tipoCliente=<?php 
                echo 'particular';
                ?>
&tipoVenta=<?php 
                echo $_GET['tipoVenta'];
                ?>
')"/>
    <input name="keyClientesInternos" type="hidden" class="style7" id="keyClientesInternos" value="<?php 
                echo $_GET['nT'];
                ?>
" />
	<?php 
            }
        }
        ?>
  </p>


</form>

<p align="center">&nbsp;</p>

</body>
</html>
<?php 
    }
    public function interpretaRX($ventana, $titulo, $ALMACEN, $fecha1, $hora1, $basedatos)
    {
        ?>
<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana1","width=600,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
  <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>


<!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;}
-->
</style>
</head>
<META HTTP-EQUIV="Refresh"
CONTENT="30"> 
<body>
<form id="form1" name="form1" method="post" action="#">
  <h1 align="center"><?php 
        echo $titulo;
        ?>
</h1>
  <table width="812" border="0" align="center">
    <tr>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">fecha:</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Descripci&oacute;n</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Paciente:</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Ver</span></div></th>
    </tr>
    <tr>
      <?php 
        $sSQL = "SELECT *\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nstatus!='transaccion'\r\nAND\r\nalmacenDestino = '" . $ALMACEN . "'  \r\nAND \r\nstatusDX='standby'\r\n\r\nORDER BY keyCAP DESC\r\n ";
        if ($result = mysql_db_query($basedatos, $sSQL)) {
            while ($myrow = mysql_fetch_array($result)) {
                $bandera += 1;
                if ($col) {
                    $color = '#FFCCFF';
                    $col = "";
                } else {
                    $color = '#FFFFFF';
                    $col = 1;
                }
                $numeroE = $myrow['numeroE'];
                $sSQL34 = "Select max(nCuenta) as maximoNC From clientesInternos WHERE numeroE = '" . $numeroE . "' ";
                $result34 = mysql_db_query($basedatos, $sSQL34);
                $myrow34 = mysql_fetch_array($result34);
                $nCuenta = $myrow34['maximoNC'];
                $sSQL31 = "SELECT *\r\nFROM\r\nclientesInternos\r\nWHERE \r\nnumeroE= '" . $numeroE . "' and nCuenta='" . $nCuenta . "'\r\n ";
                $result31 = mysql_db_query($basedatos, $sSQL31);
                $myrow31 = mysql_fetch_array($result31);
                $E = $myrow['keyCAP'];
                $codigo = $myrow['codProcedimiento'];
                ?>
      <td width="126" height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
<?php 
                echo $myrow['hora1'] . " " . $myrow['fecha1'];
                ?>
      </span></td>
      <td width="304" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
	<?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($numeroE, $nCuenta, $codigo, $basedatos);
                ?>
	  </span></td>
      <td width="301" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                echo $myrow31['paciente'];
                ?>
</span></td>
      <td width="63" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><a href="javascript:ventanaSecundaria('reporteReportes.php?numeroE=<?php 
                echo $numeroE;
                ?>
&amp;nCuenta=<?php 
                echo $nCuenta;
                ?>
&amp;codigoArticulo=<?php 
                echo $myrow['codProcedimiento'];
                ?>
&amp;medico=<?php 
                echo $_POST['medico'];
                ?>
&amp;usuario=<?php 
                echo $usuario;
                ?>
')">
        <label>        </label>
      </a>


<a href="javascript:ventanaSecundaria('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/dx/mostrarImagenRX.php?numeroE=<?php 
                echo $numeroE;
                ?>
&amp;nCuenta=<?php 
                echo $nCuenta;
                ?>
&amp;keyCAP=<?php 
                echo $E;
                ?>
&amp;medico=<?php 
                echo $_POST['medico'];
                ?>
&amp;usuario=<?php 
                echo $usuario;
                ?>
')">
        <img src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/camera.jpg" width="20" height="20" border="0" />
</a>

	  </td>
    </tr>
	    <input name="bandera" type="hidden" id="bandera" value="<?php 
                echo $bandera;
                ?>
" />
    <?php 
            }
        }
        ?>
    <input name="nombres" type="hidden" value="<?php 
        echo $nombrePaciente;
        ?>
" />
  </table>
  <p align="center">&nbsp;  </p>
</form>
<div align="center"><span class="style12">
<a href="javascript:ventanaSecundaria2('<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/cargos/imprimirServicios.php?numeroE=<?php 
        echo $numeroE;
        ?>
&amp;codigo=<?php 
        echo $myrow['codProcedimiento'];
        ?>
&amp;nCuenta=<?php 
        echo $nCuenta;
        ?>
&amp;paciente=<?php 
        echo $_POST['paciente'];
        ?>
&amp;orden=<?php 
        echo $E;
        ?>
')">
</a>
</span>
</div>
</body>
</html>

<?php 
    }
    public function subCuenta($ID_EJERCICIO, $folioFactura, $bali, $tipoCliente, $TITULO, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>







<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        if (!$bali) {
            $bali = $_GET['almacenFuente'];
        }
        $sSQL3 = "Select * From RFC WHERE entidad='" . $entidad . "' and RFC = '" . $_GET['rfc'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        //***************aplicar pago**********************
        if ($_POST['escoje']) {
            $keyCAP = $_POST['keyCAP'];
            $solicita = $_POST['solicita'];
            $solicita1 = $_POST['solicita1'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                $sSQL34 = "Select statusFactura From cargosCuentaPaciente WHERE keyCAP='" . $solicita[$i] . "'  ";
                $result34 = mysql_db_query($basedatos, $sSQL34);
                $myrow34 = mysql_fetch_array($result34);
                if ($solicita[$i]) {
                    if ($myrow34['statusFactura'] == 'solicita') {
                        $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby'\r\nwhere\r\nkeyCAP='" . $solicita[$i] . "' \r\n";
                    }
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
            //cierra for
        }
        //cierra actualizar
        ?>




<?php 
        /*
        echo '<script language="JavaScript" type="text/javascript">
          <!--
        window.opener.document.forms["form1"].submit();
        self.close();
          // -->
        </script>';*/
        if ($_POST['facturar']) {
            if ($_POST['cantidadSolicitada']) {
                if ($_POST['cantidadSolicitada'] <= $_POST['cantidadActual']) {
                    $porcentaje = $_POST['cantidadSolicitada'] / $_POST['cantidadActual'];
                    $agrega = "INSERT INTO cargosFacturados (numFactura,cantidadFacturada,porcentaje,usuario,fecha,tipoCliente,seguro,nT) values('" . $_GET['folioFactura'] . "','" . $_POST['cantidadSolicitada'] . "','" . $porcentaje . "','" . $usuario . "','" . $fecha . "','" . $_GET['tipoCliente'] . "','" . $myrow3['seguro'] . "','" . $_GET['nT'] . "')";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                    echo '<script language="JavaScript" type="text/javascript">
  <!--
window.opener.document.forms["form1"].submit();
self.close();
  // -->
</script>';
                } else {
                    $leyenda = 'La cantidad no debe ser mayor a la q existe!';
                }
            } else {
                $leyenda = 'Escribe la cantidad!';
            }
        }
        ?>





<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style72 {font-size: 10px}
.style72 {font-size: 10px}
.style1 {color: #FF0000}
.style73 {color: #FF0000}
.style73 {color: #FF0000;font-size: 9px}
.style74 {color: #FF0000}
.style74 {color: #FF0000;font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
.style1 {color: #FF0000;font-size: 9px}
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>




<BODY  >
<h1 align="center"><?php 
        echo $TITULO;
        ?>
</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="264" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="134" bgcolor="#660066" class="style14" scope="col"><div align="left">Factura </div></th>
      <th width="408" bgcolor="#660066" class="style14" scope="col">
	
          <div align="left">
            <input name="folioFactura" type="hidden" class="Estilo24" id="folioFactura" 
		  value="<?php 
        echo $_GET['folioFactura'];
        ?>
" readonly=""/>
          <?php 
        echo $_GET['folioFactura'];
        ?>
          </div></th>
    </tr>
  </table>
  <p>
    <label></label><?php 
        $sSQL341 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE numFactura='" . $_GET['folioFactura'] . "'  ";
        $result341 = mysql_db_query($basedatos, $sSQL341);
        $myrow341 = mysql_fetch_array($result341);
        ?>
  </p>
  <p align="center">&nbsp;</p>
  <table width="607" border="0" align="center">
    <tr>
      <th width="54" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 "># Registro </span></div></th>
      <th width="87" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="246" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="56" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Cant</span></div></th>
      <th width="53" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span></div></th>
      <th width="85" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span>Facturado</div></th>
    </tr>
	
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n* FROM\r\ncargosCuentaPaciente \r\n WHERE \r\n entidad='" . $entidad . "'\r\n and\r\n folioFactura='" . $_GET['folioFactura'] . "'\r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            $art = $myrow81['codProcedimiento'];
            $codigo = $proc = $myrow81['codProcedimiento'];
            $keyCAP = $myrow81['keyCAP'];
            ?>
	
	
	
	
    <tr>
<td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
"><?php 
            echo $myrow81['keyCAP'];
            ?>
</span> 
  <label>
  <input name="keyCAP[]" type="hidden" id="keyCAP[]" value="<?php 
            echo $keyCAP;
            ?>
"  />
  </label>
</div></td>





      <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
      <?php 
            echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
            ?>
</span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style12"><span class="style7">
        <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
            if ($myrow81['status'] != 'transaccion') {
                $nombreMed = new nombreMedico();
                echo " " . $myrow81['descripcion'] . $nombreMed->nombreMed($medico, $basedatos);
            }
            ?>
        </span></span>        <span class="style12">
          
          <?php 
            if ($myrow81['gpoProducto']) {
                echo '[' . $myrow81['gpoProducto'] . ']';
            }
            ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
        <?php 
            if ($_POST['tipoVista'] == 'Agrupado') {
                echo $cantidad = $myrow14['cantidad2'];
            } else {
                echo $cantidad = $myrow81['cantidad'];
            }
            ?>
      </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
        <?php 
            if ($myrow81['cargosHospitalarios']) {
                $tipoTransaccion = $myrow81['tipoTransaccion'];
                $sSQL6 = "\r\n\tSELECT \r\nvariable\r\nFROM\r\ncatTTCaja\r\nWHERE \r\ncodigoTT = '" . $tipoTransaccion . "'\r\nand\r\nvariable='si'\r\n";
                $result6 = mysql_db_query($basedatos, $sSQL6);
                $myrow6 = mysql_fetch_array($result6);
                if ($myrow6['variable']) {
                    if ($myrow81['cargosHospitalarios'] == 'si') {
                        $banderaPM = new acumulados();
                        $precioVentaC = $banderaPM->banderaPorcentajeMedicamentos($entidad, $basedatos, $usuario, $numeroE, $nCuenta);
                        $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                    } else {
                        $cargosAseguradora = new acumulados();
                        $precioVentaC = $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta);
                        $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                    }
                    //Actualiza
                    $q1 = "UPDATE cargosCuentaPaciente set \r\nprecioVenta='" . $precioVentaC . "'\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'";
                    //mysql_db_query($basedatos,$q1);
                    echo mysql_error();
                }
            }
            ?>
        <span class="style12"><span class="style7">
      
          <?php 
            $sSQL31 = "Select sum(cantidadFacturada) as sumaFacturada From cargosFacturados WHERE numFactura = '" . $_GET['folioFactura'] . "' ";
            $result31 = mysql_db_query($basedatos, $sSQL31);
            $myrow31 = mysql_fetch_array($result31);
            $cantidadActual[0] += $myrow81['precioVenta'] * $myrow81['cantidad'] + $myrow81['iva'] * $myrow81['cantidad'];
            echo "\$" . number_format($cantidadActual[0] - $myrow31['sumaFacturada'], 2);
            ?>
          
        </span></span> 
		
		</span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $estilo;
            ?>
">	  </td>
    </tr>
 
	
	
    <?php 
        }
        ?>
  </table>


		  <table width="606" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr>
              <th width="92" scope="col">&nbsp;</th>
              <th width="92" scope="col">&nbsp;</th>
              <th width="92" scope="col">&nbsp;</th>
              <th width="170" scope="col">&nbsp;</th>
              <th width="57" scope="col">&nbsp;</th>
              <th width="84" scope="col"><div align="left"><span class="style71">
                <?php 
        echo "\$" . number_format($myrow341['cantidadF'], 2);
        ?>
              </span></div></th>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
		  <p>&nbsp;</p>
		  <table width="53%" border="3" align="center" cellpadding="1" cellspacing="1" class="style71">
            <tr>
              <th width="18%" scope="col"><span class="style72">Cantidad</span></th>
              <th width="23%" scope="col">

			  
<input name="cantidadSolicitada" type="text" class="style71" id="cantidadSolicitada" value="<?php 
        echo $cantidadActual[0] - $myrow31['sumaFacturada'];
        ?>
"></th>
              <th width="59%" scope="col"> <span class="style74"><blink><?php 
        echo $leyenda;
        ?>
</blink></span></th>
            </tr>
          </table>
		  <p align="center">&nbsp;		  </p>
		  <p align="center">
		  <?php 
        if ($myrow341['cantidadF']) {
            echo 'Tienes disponible para facturar: ' . '$' . number_format(ltrim($cantidadActual[0]) - ltrim($myrow31['sumaFacturada']), 2);
            $cActual = number_format(ltrim($cantidadActual[0]) - ltrim($myrow31['sumaFacturada']), 2);
        } else {
            $cActual = $cantidadActual[0] + $cantidadIva[0];
        }
        ?>
		  &nbsp;</p>
  <p align="center">
		    <label>
		    <input name="tipoCliente" type="hidden" id="tipoCliente" value="<?php 
        echo $_GET['tipoCliente'];
        ?>
" />
		    <input name="bandera" type="hidden" id="bandera" value="<?php 
        echo $a;
        ?>
">
		    
		    </label>
		  </p>
		  <p align="center">
	
		  
		    <input name="facturar" type="submit" class="style71" id="nuevo" value="Solicitar Facturar" <?php 
        if (!$cActual) {
            echo 'disabled=""';
        }
        ?>
/>
		
			
<input name="cantidadActual" type="hidden" id="cantidadActual" value="<?php 
        echo $cActual;
        ?>
" />
		
		  </p>
</form>
<p align="center">&nbsp;</p>
</body>
</html>
<?php 
    }
    public function eCuentaE($folioVenta, $usuario, $entidad, $almacen, $fecha1, $hora1, $dia, $usu, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        //**********************************CANDADO PRINCIPAL**********************
        $bali = $almacen;
        $sSQLC = "Select * From statusCaja where entidad='" . $entidad . "' and usuario='" . $usuario . "' order by keySTC DESC ";
        $resultC = mysql_db_query($basedatos, $sSQLC);
        $myrowC = mysql_fetch_array($resultC);
        $sSQL1 = "Select usuario,folioVenta From transacciones WHERE folioVenta ='" . $_GET['folioVenta'] . "' ";
        $result1 = mysql_db_query($basedatos, $sSQL1);
        $myrow1 = mysql_fetch_array($result1);
        echo mysql_error();
        if ($myrow1['folioVenta'] and $myrow1['usuario'] != $usuario) {
            ?>
<script>
window.alert("Este proceso est� siendo utilizado por: (<?php 
            echo $myrow1['usuario'];
            ?>
) y s�lo el puede terminar este proceso");
window.close();
</script>
<?php 
        } else {
            if (!$myrow1['folioVenta']) {
                $agrega = "INSERT INTO transacciones (\r\nfolioVenta,usuario,fecha,hora,keyCatC) \r\nvalues ('" . $_GET['folioVenta'] . "','" . $usuario . "','" . $fecha1 . "','" . $hora1 . "','" . $myrowC['keyCatC'] . "')";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
        }
        //************************************CANDADO DE USUARIO
        ?>




<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 



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

<script>

var win = null;
function nueva(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

</script>








<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        $seguroT = ltrim($myrow3['seguro']);
        //***************aplicar pago**********************
        if ($_POST['actualizar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                if ($aseguradora[$i]) {
                    $status = 'efectivo';
                    $keyCAP[] = $aseguradora[$i];
                } else {
                    $status = 'cxc';
                    $keyCAP[] = $particular[$i];
                }
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusAlta='" . $status . "',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
            //cierra for
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['imprimir']) {
            //*************SACO EL NUMERO DE MOVIMIENTO y lo actualizo*************************
            $actualiza3 = "UPDATE clientesInternos,cargosCuentaPaciente\r\nset\r\ncargosCuentaPaciente.codigoCaja='" . $myrowC['keyCatC'] . "',\r\ncargosCuentaPaciente.numRecibo='" . $myrowCa['numRecibo'] . "',\r\ncargosCuentaPaciente.numCorte='" . $myrowC['numCorte'] . "',\r\nclientesInternos.codigoCaja='" . $myrowC['keyCatC'] . "',\r\nclientesInternos.numRecibo='" . $RECIBO . "',\r\nclientesInternos.numCorte='" . $myrowC['numCorte'] . "',\r\ncargosCuentaPaciente.folioVenta='" . $_GET['folioVenta'] . "',\r\nclientesInternos.folioVenta='" . $_GET['folioVenta'] . "'\r\n\r\n\r\nWHERE \r\nclientesInternos.folioVenta='" . $_GET['folioVenta'] . "'\r\nand\r\nclientesInternos.folioVenta=cargosCuentaPaciente.folioVenta\r\n";
            //mysql_db_query($basedatos,$actualiza3);
            echo mysql_error();
            //*************************************************************
            if ($_GET['paquete'] == 'si') {
                ?>
<script language="javascript">
nueva('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/imprimirReciboPaquetes.php?numeroE=<?php 
                echo $myrow3['numeroE'];
                ?>
&nCuenta=<?php 
                echo $myrow3['nCuenta'];
                ?>
&keyClientesInternos=<?php 
                echo $myrow3['keyClientesInternos'];
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&numeroConfirmacion=<?php 
                echo $numeroConfirmacion;
                ?>
&hora1=<?php 
                echo $hora1;
                ?>
&cajero=<?php 
                echo $usuario;
                ?>
&codigoPaquete=<?php 
                echo $myrow3['codigoPaquete'];
                ?>
&numRecibo=<?php 
                echo $myrowC['numRecibo'];
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&cantidadRecibida=<?php 
                echo $_POST['cantidadRecibida'];
                ?>
&folioVenta=<?php 
                echo $myrow3['folioVenta'];
                ?>
','ventana7','800','600','yes');
//window.opener.document.form10["form10"].submit();
//window.alert("sandra");
window.close();
</script>
<?php 
            } else {
                ?>
<script>
nueva('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/imprimirCargosPA.php?numeroE=<?php 
                echo $numeroE;
                ?>
&nCuenta=<?php 
                echo $nCuenta;
                ?>
&keyClientesInternos=<?php 
                echo $nT;
                ?>
&paciente=<?php 
                echo $_POST['paciente'];
                ?>
&numeroConfirmacion=<?php 
                echo $numeroConfirmacion;
                ?>
&hora1=<?php 
                echo $hora1;
                ?>
&cajero=<?php 
                echo $usuario;
                ?>
','ventana7','800','600','yes');
//window.opener.document.form10["form"].submit();

window.close();
</script>
<?php 
            }
            ?>

<?php 
        }
        ?>







<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>






<title></title>
<?php 
        $link = new ventanasPrototype();
        $link->links();
        $estilo = new muestraEstilos();
        $estilo->styles();
        ?>
  <style type="text/css">
    .popup_effect1 {
      background:#11455A;
      opacity: 0.2;
    }
    .popup_effect2 {
      background:#FF0041;
      border: 3px dashed #000;
    }
    
  </style>	
</head>

<h1 align="center" class="titulos">Nota de Venta </h1>
<form id="form1" name="form1" method="post" action="#">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="blanco" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Folio de Venta</div></th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco"><?php 
        echo $_GET['folioVenta'];
        ?>
         
</label></div>      </th>
    </tr>
    <tr>
      <th width="10" class="normal" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left" class="normal">Paciente: </div></th>
      <th width="408" bgcolor="#FFCCFF"  scope="col"><div align="left" class="normal"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="normal">Compa&ntilde;&iacute;a: </td>
      <td class="normal">
        <label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
        </label>
      </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="normal">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="normal"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
  </table>
  <p align="center">
  <?php 
        if ($_GET['codigoPaquete']) {
            echo 'Paquete: ' . $_GET['codigoPaquete'];
        }
        ?>
</p>
  

  
  <table width="761" border="0" align="center">
    <tr>
      <th width="306" height="14" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Descripci&oacute;n/Concepto</div></th>
      <th width="33" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Cant</div></th>
      <th width="76" bgcolor="#660066" class="blanco" scope="col">P.Unitario</th>
      <th width="76" bgcolor="#660066" class="blanco" scope="col"><div align="left">Particular</div></th>
      <th width="76" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Aseguradora</div></th>
      <th width="47" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">IVA</div></th>
      <th width="96" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">Convenio</div></th>
      <th width="17" bgcolor="#660066" class="blanco" scope="col"><div align="left" class="blanco">N</div></th>
    </tr>
    <tr>
    
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\n \r\n \r\n \r\n  order by folioVenta asc\r\n";
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            $chain = $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
            $art = $myrow81['codProcedimiento'];
            $codigo = $proc = $myrow81['codProcedimiento'];
            $keyCAP = $myrow81['keyCAP'];
            if ($myrow81['naturaleza'] == 'A') {
                $abonos[0] += $myrow81['precioVenta'];
            } else {
                $abonos[0] = '0.00';
            }
            ?>

  <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
      <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
            if ($myrow81['tipoPago']) {
                echo '(' . $myrow81['tipoPago'] . ')';
            }
            ?>
         
		
        <?php 
            if ($myrow811['um'] == 's' or $myrow811['um'] == 'S') {
                echo '  ( Servicio )  ';
            }
            ?>
      </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" ><div align="center" class="normal">
          <?php 
            echo $cantidad = $myrow81['cantidad'];
            ?>
      </div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal"><?php 
            echo '$' . number_format($myrow81['precioVenta'], 2);
            ?>
</td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal"><?php 
            if ($myrow81['naturaleza'] == 'C') {
                $particular[0] += $myrow81['cantidadParticular'] * $myrow81['cantidad'];
            }
            echo '$' . number_format($myrow81['cantidadParticular'] * $myrow81['cantidad'], 2);
            ?>
</td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
        <?php 
            if ($myrow81['naturaleza'] == 'C') {
                $aseguradora[0] += $myrow81['cantidadAseguradora'] * $myrow81['cantidad'];
            }
            echo '$' . number_format($myrow81['cantidadAseguradora'] * $myrow81['cantidad'], 2);
            ?>
   </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
        <?php 
            if ($myrow81['naturaleza'] == 'C') {
                $ivaTotal[0] += $myrow81['iva'] * $myrow81['cantidad'];
            }
            echo '$' . number_format($myrow81['iva'] * $myrow81['cantidad'], 2);
            ?>
      </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
"><span class="normal">
        <?php 
            if ($myrow81['tipoConvenio'] and $myrow81['tipoConvenio'] != 'No') {
                echo '<img src="' . CONSTANT_PATH_SIMA_RAIZ . '/imagenes/cci/grafica.png" width="20" height="20" />';
            } else {
                echo '---';
            }
            ?>
      </span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
"><div align="center" class="normal">
	   
      
        <div align="left">
          <?php 
            echo $myrow81['naturaleza'];
            ?>
             </div>
      </div></td>
	</tr>
 
	
	
    <?php 
        }
        ?>
  </table>

  <p>&nbsp;</p>
  <div align="center">
    <table width="558" border="0" align="center">
      <tr>
        <td width="113" class="style12">&nbsp;</td>
        <td width="124" class="style12">&nbsp;</td>
        <td width="97" class="normal">Total Cargos 
          <?php 
        $suma = $particular[0] + $aseguradora[0] + $ivaTotal[0];
        echo '$' . number_format($suma, 2);
        ?>
      </td>
        <td width="106" height="23"><div align="left" class="normal">Total Abonos 
            <?php 
        echo '$' . number_format($abonos[0], 2);
        ?>
        </div></td>
        <td width="96"><div align="left" class="normal"><strong>Saldo Actual</strong><strong>
          <?php 
        $total = $suma - $abonos[0];
        echo "\$" . number_format($suma - $abonos[0], 2);
        ?>
        </strong></div></td>
      </tr>
      <tr>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td class="style12"><input name="cantidadRecibida" type="hidden" class="style7" id="cantidadRecibida" value="" /></td>
        <td height="23" class="normal"><div align="right"></div></td>
        <td class="normal"><div align="right"></div></td>
      </tr>
      <tr>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td class="style12">&nbsp;</td>
        <td height="23" class="style23 Estilo24"><div align="right"></div></td>
        <td class="style12"><div align="right"></div></td>
      </tr>
    </table>



</div>
  <p align="center">
	<?php 
        //*********************************
        if (round($total) == NULL) {
            ?>
    <label>
    <input name="imprimir" type="image"  id="imprimir" value="Imprimir" src="<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/imagenes/btns/printbutton.png" onclick="Disab (2)"/>
    </label>
	<?php 
        } else {
            ?>
    <input name="cargado" type="image" value="Aplicar Pagos" src="<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/imagenes/btns/aplicapay.png"  onclick="nueva('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?usuario=<?php 
            echo $_GET['usuario'];
            ?>
&numeroE=<?php 
            echo $numeroE;
            ?>
&almacen=<?php 
            echo $_GET['almacenSolicitante'];
            ?>
&almacenFuente=<?php 
            echo $almacen;
            ?>
&seguro=<?php 
            echo $seguroT;
            ?>
&nCuenta=<?php 
            echo $myrow3['keyClientesInternos'];
            ?>
&tipoCliente=<?php 
            echo 'particular';
            ?>
&tipoVenta=<?php 
            echo $_GET['tipoVenta'];
            ?>
&folioVenta=<?php 
            echo $myrow3['folioVenta'];
            ?>
&keyClientesInternos=<?php 
            echo $myrow3['keyClientesInternos'];
            ?>
&rand=<?php 
            echo rand(1000, 10000000);
            ?>
&paquete=<?php 
            echo $_GET['paquete'];
            ?>
','ventana7','500','600','yes')"/>
   
	<?php 
        }
        ?>
  </p>


</form>

<p align="center">&nbsp;</p>

</body>
</html>
<?php 
    }
            }
            ?>
      <td height="24" bgcolor="<?php 
            echo $color;
            ?>
" class="style12"><span class="Estilo24"><span class="style7"><?php 
            echo $code1;
            ?>
</span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="style12"><span class="style7">
        <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($numeroE, $nCuenta, $code1, $basedatos);
            ?>
        <span class="Estilo24">
        <input name="codigoAlfa[]" type="hidden" id="codigoAlfa[]" value="<?php 
            echo $code1;
            ?>
" />
      </span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="style12"><span class="style7">
 
       
<?php 
            if ($myrow7['um']) {
    public function eCuenta($usuario, $fecha1, $hora1, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        if (!$_GET['nT']) {
            $_GET['nT'] = $_GET['nt'];
        }
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=300,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $seguro = $myrow3['seguro'];
        ?>

<?php 
        if ($seguro) {
            $_GET['tipoCliente'] = 'aseguradora';
        } else {
            $_GET['tipoCliente'] = 'particular';
        }
        //*****************************Verificando caja abierta**************************
        $sSQLC = "Select * From aperturaCaja ";
        $resultC = mysql_db_query($basedatos, $sSQLC);
        $myrowC = mysql_fetch_array($resultC);
        if ($poliza = $myrowC['numeroPoliza']) {
            //*******************Comienzo la validaci�n*****************
            if ($_POST['pagar'] and $numeroE and $nCuenta) {
                $numeroConfirmacion = rand();
                $q = "UPDATE clientesInternos set \r\nstatus='cerrada',\r\nstatusDeposito='pagado'\r\n\r\nWHERE numeroE = '" . $numeroE . "' and nCuenta='" . $nCuenta . "'";
                mysql_db_query($basedatos, $q);
                echo mysql_error();
                $sSQL341 = "Select * From catTTCaja WHERE codigoTT = 'PSExt'";
                $result341 = mysql_db_query($basedatos, $sSQL341);
                $myrow341 = mysql_fetch_array($result341);
                $naturaleza = $myrow341['naturaleza'];
                $tipoTransaccion = 'PSExt';
                if ($naturaleza == 'Abono') {
                    $naturaleza = 'A';
                } else {
                    if ($naturaleza == 'Cargo') {
                        $naturaleza = 'C';
                    } else {
                        if ($naturaleza == 'Credito') {
                            $naturaleza = 'A';
                        }
                    }
                }
                if ($_GET['tipoCliente'] == 'aseguradora') {
                    $statusTraslado = 'trasladado';
                    $q1 = "UPDATE cargosCuentaPaciente set \r\nstatusTraslado='trasladado',\r\ntipoTransaccion='" . $_GET['tipoTransaccion'] . "',\r\nusuarioTraslado='" . $usuario . "',tipoCliente='" . $_GET['tipoCliente'] . "',\r\nnumPoliza='" . $poliza . "'\r\nWHERE status='cxc' and statusTraslado='standby'";
                    mysql_db_query($basedatos, $q1);
                    echo mysql_error();
                } else {
                    if ($_GET['tipoCliente'] == 'particular') {
                        $statusTraslado = 'trasladado';
                        $q1 = "UPDATE cargosCuentaPaciente set \r\nstatusTraslado='trasladado',\r\ntipoTransaccion='" . $_GET['tipoTransaccion'] . "',\r\nusuarioTraslado='" . $usuario . "',tipoCliente='" . $_GET['tipoCliente'] . "',\r\nnumPoliza='" . $poliza . "'\r\nWHERE status='particular' and statusTraslado='standby'";
                        mysql_db_query($basedatos, $q1);
                        echo mysql_error();
                    } else {
                        if ($_GET['tipoCliente'] == 'otros') {
                            $statusTraslado = 'trasladado';
                            $q1 = "UPDATE cargosCuentaPaciente set \r\nstatusTraslado='trasladado',\r\ntipoTransaccion='" . $_GET['tipoTransaccion'] . "',\r\nusuarioTraslado='" . $usuario . "',tipoCliente='" . $_GET['tipoCliente'] . "',\r\nnumPoliza='" . $poliza . "'\r\nWHERE status='credito' and statusTraslado='standby'";
                            mysql_db_query($basedatos, $q1);
                            echo mysql_error();
                        }
                    }
                }
                $agrega = "INSERT INTO cargosCuentaPaciente (\r\nnumeroE,nCuenta,status,usuario,fecha1,cantidad,tipoTransaccion,codProcedimiento,hora1,\r\nnaturaleza,ejercicio,statusDeposito,numeroConfirmacion,almacen,usuarioTraslado,precioVenta,seguro,\r\nstatusTraslado,tipoCliente,tipoPaciente,numPoliza) values ('" . $numeroE . "','" . $nCuenta . "','transaccion',\r\n'" . $usuario . "','" . $fecha1 . "','1','" . $tipoTransaccion . "','" . $hora1 . "',\r\n'" . $hora1 . "','" . $naturaleza . "','" . $ID_EJERCICIOM . "','pagado','" . $numeroConfirmacion . "','" . $ALMACEN . "','" . $usuario . "',\r\n'" . $_GET['cantidadRecibida'] . "','" . $seguro . "','" . $statusTraslado . "','" . $_GET['tipoCliente'] . "','" . $tipoPaciente . "','" . $poliza . "'\r\n)";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
                ?>
<script>
javascript:ventanaSecundaria6('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/INGRESOS%20HLC/caja/imprimeCajaExternos.php?numeroE=<?php 
                echo $nCliente5;
                ?>
&amp;nT=<?php 
                echo $numeroCuenta;
                ?>
&amp;paciente=<?php 
                echo $_POST['paciente'];
                ?>
&amp;orden=<?php 
                echo $E;
                ?>
&amp;hora1=<?php 
                echo $hora1;
                ?>
');
</script>
<?php 
            }
            ?>

<!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">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
-->
</style>


</head>

<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>
<BODY >

<h1 align="center">Nota de Venta <?php 
            echo $myrow3['almacen'];
            ?>
</h1>
<form name="form2" id="form2" method="get" action="">
  <table width="43%" height="158" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr bgcolor="#FFFFFF">
      <td width="29%" class="style12">Tipo Pago/Cr&eacute;dito </td>
      <td width="71%" class="style12">
        <?php 
            if (!$_GET['tipoPago']) {
                $_GET['tipoPago'] = 'Efectivo';
            }
            ?>
        <select name="tipoPago" class="style7" id="select2" onchange="javascript:form.submit();">
          <option
				 <?php 
            if ($_GET['tipoPago'] == 'Efectivo') {
                ?>
				 selected="selected"
				  <?php 
            }
            ?>
				 value="Efectivo">Efectivo</option>
          <option
				 <?php 
            if ($_GET['tipoPago'] == 'Tarjeta de Credito') {
                ?>
				 selected="selected"
				  <?php 
            }
            ?>
				 value="Tarjeta de Credito">Tarjeta de Credito</option>
          <option
				<?php 
            if ($_GET['tipoPago'] == 'Cheque') {
                ?>
				 selected="selected"
				  <?php 
            }
            ?>
				 value="Cheque">Cheque</option>
          <option 
				<?php 
            if ($_GET['tipoPago'] == 'Credito') {
                ?>
				 selected="selected"
				 <?php 
            }
            ?>
				value="Credito">Credito</option>
      </select></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <?php 
            if ($_GET['tipoPago'] == 'Tarjeta de Credito') {
                ?>
      <td class="style12">C&oacute;digo de Tarjeta</td>
      <td class="style12"><input name="codigo" type="text" class="style12" id="codigo" 
		 value="<?php 
                if ($_GET['nuevo']) {
                    echo "0000000000";
                } else {
                    if ($myrow2['codigo']) {
                        echo $myrow2['codigo'];
                    }
                }
                ?>
" size="10" readonly=""/>
          <a href="javascript:ventanaSecundaria3('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/ventanaTC.php?nombreCampo=<?php 
                echo "codigo";
                ?>
&amp;descripcion=<?php 
                echo "descripcion";
                ?>
&amp;forma=<?php 
                echo "form1";
                ?>
&amp;comision=<?php 
                echo "comision";
                ?>
')"><img src="<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/imagenes/Save.png" alt="Laboratorio Fabricante" width="15" height="15" border="0" /></a></td>
      <input name="comision" type="hidden" value="" />
    </tr>
    <tr bgcolor="#FFFFFF">
      <td bgcolor="#FFFFFF" class="style12">Banco Tarjeta</td>
      <td bgcolor="#FFFFFF" class="style12"><input name="descripcion" type="text" class="style7" value="<?php 
                echo $_GET['descripcion'];
                ?>
"  readonly=""/></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td class="style12">&Uacute;ltimos 4 D&iacute;gitos</td>
      <td class="style12"><label>

        <input name="ultimosDigitos" type="text" class="style7" id="ultimosDigitos" size="4" maxlength="4" value="<?php 
                echo $_GET['ultimosDigitos'];
                ?>
" onkeypress="return checkIt(event)"/>
        
</label></td>
    </tr>
    <tr bgcolor="#FFFFFF">    </tr>
    <?php 
            }
            ?>
    <?php 
            //descuentos pacientes internos
            $sSQL18 = "SELECT *\r\nFROM\r\ndescuentos\r\nWHERE \r\nnumeroE='" . $numeroE . "' AND nCuenta ='" . $nCuenta . "' and nCuenta <>null\r\nand \r\nstatus='activo' and\r\nfechaFinal <= '" . $fecha1 . "'";
            $result18 = mysql_db_query($basedatos, $sSQL18);
            $myrow18 = mysql_fetch_array($result18);
            echo mysql_error();
            //descuentos pacientes ambulatorios
            $sSQL19 = "SELECT *\r\nFROM\r\ndescuentos\r\nWHERE \r\nnumeroE='" . $nCliente . "' \r\nand status='activo' and\r\nfechaFinal <= '" . $fecha1 . "'\r\n ";
            $result19 = mysql_db_query($basedatos, $sSQL19);
            $myrow19 = mysql_fetch_array($result19);
            //******************
            if ($myrow19['cantidad']) {
                $descuento = $myrow19['cantidad'];
            } else {
                if ($myrow19['descuento']) {
                    $TOTAL1 = $myrow19['descuento'] / 100 * $TOTAL;
                    $descuento = $TOTAL1 - $descuento;
                }
            }
            if ($myrow18['cantidad']) {
                $descuento = $myrow18['cantidad'];
            } else {
                if ($myrow18['descuento']) {
                    $TOTAL1 = $myrow18['descuento'] / 100 * $TOTAL;
                    $descuento = $TOTAL1 - $descuento;
                }
            }
            $TOTAL -= $descuento;
            ?>
  </table>
  <input name="nT" type="hidden" class="style12" id="nT" 
		  value="<?php 
            echo $_GET['nT'];
            ?>
" readonly=""/>
</form>
<p align="center">&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
            echo $nCliente = $myrow3['keyClientesInternos'];
            ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
            echo $nCliente = $_POST['numeroE'];
            ?>
" readonly=""/>
</label></div>
      </th>
    </tr>
    <tr>      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>          <label> </label>
      </strong> <?php 
            echo $myrow3['paciente'];
            ?>
 </div></th>
    </tr>
    <tr>      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
            echo $traeSeguro = $myrow3['seguro'];
            ?>
        <?php 
            $sSQL212 = "SELECT *\r\nFROM\r\nclientes\r\nWHERE \r\nnumCliente='" . $traeSeguro . "'\r\n ";
            $result212 = mysql_db_query($basedatos, $sSQL212);
            $myrow212 = mysql_fetch_array($result212);
            ?>
        <input name="seguro2" type="hidden" id="seguro2" value="<?php 
            echo $traeSeguro;
            ?>
" />
      </label></td>
    </tr>
    <tr>      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
            echo $myrow3['credencial'];
            ?>
 </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  

  
  <table width="672" border="0" align="center">
    <tr>
      <th width="104" height="14" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Fecha/Hora (Cargo)</span></th>
      <th width="405" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Descripci&oacute;n</span></th>
      <th width="21" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Cant</span></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Importe IC </span></th>
      <th width="61" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">IVA</span></th>
    </tr>
    <tr>
      <?php 
            //traigo agregados
            $sSQL81 = "\r\nSELECT \r\n *,((precioVenta*cantidad)+iva) as sumaTres\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n\r\n order by fecha1,hora1 asc\r\n";
            if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
                while ($myrow81 = mysql_fetch_array($result81)) {
                    $keyCAP = $myrow81['keyCAP'];
                    $a = $a + 1;
                    $art = $myrow81['codProcedimiento'];
                    $proc = $myrow81['codProcedimiento'];
                    $codigo = $myrow81['codProcedimiento'];
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = "";
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    ?>




      <td height="23" bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7"><?php 
                    echo $myrow81['fecha1'] . " " . $myrow81['hora1'];
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7"><span class="style12"><span class="<?php 
                    echo $estilo;
                    ?>
">
        <?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($numeroE, $nCuenta, $codigo, $basedatos);
                    ?>
      </span></span>        <span class="style12">
        <?php 
                    if ($myrow81['um'] == 's' or $myrow81['um'] == 'S') {
                        echo '  ( Servicio )  ';
                    }
                    ?>
        <?php 
                    if ($myrow81['status'] == 'cerrada') {
                        echo '<blink>' . "[Cerrada]" . '</blink>';
                    } else {
                        //echo '<blink>'."[CxC]".'</blink>';
                    }
                    ?>
 </span> </span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
        <?php 
                    if ($_POST['tipoVista'] == 'Agrupado') {
                        echo $cantidad = $myrow14['cantidad2'];
                    } else {
                        echo $cantidad = $myrow81['cantidad'];
                    }
                    ?>
      </span></td>
	
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
          
      <span class="style12"><span class="<?php 
                    echo $estilo;
                    ?>
">
  
       <?php 
                    $importe = new acumulados();
                    $importe->importe($keyCAP, $basedatos);
                    ?>
		
      </span></span> </span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
        <?php 
                    $mostrarIVA = new articulosDetalles();
                    echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
                    ?>
      </span></td>
	   <?php 
                    if ($tipoTrans and !$myrow81['sumaTres']) {
                        //echo "$".number_format("-".$myrow81['cantidadRecibida'],2);
                        $TOTAL += "-" . $myrow81['cantidadRecibida'];
                    } else {
                        //echo "$".number_format($costoProcedimientos[0],2);
                        //$TOTAL+=$costoProcedimientos[0];
                        //echo "$".number_format($myrow81['sumaTres'],2);
                    }
                    ?>
    </tr>
 
	
	
    <?php 
                }
                ?>
  </table>
  <p>
    <input name="paso_bandera1" type="hidden" id="paso_bandera1" value="<?php 
                echo $bandera;
                ?>
" />
    <input name="recibo" type="hidden" id="recibo" value="<?php 
                echo $nCliente = $_POST['numeroE'];
                ?>
" />
    <input name="nCliente" type="hidden" id="nCliente" value="<?php 
                echo $nCliente;
                ?>
" />
    <input name="almacen" type="hidden" id="almacen" value="<?php 
                echo $ALMACEN;
                ?>
" /><?php 
                //echo "$".number_format($TOTAL,2);
                ?>
  </p>
  <div align="center">
    <p>&nbsp;</p>
    
    <table width="679" border="0" align="center" class="style12">
      <tr>
        <td width="139" class="style12">&nbsp;</td>
        <td width="139" class="style12">&nbsp;</td>
        <td width="139" class="style12">&nbsp;</td>
        <td width="139" height="23" class="style12">IVA</td>
        <td width="90" class="style12"><div align="right">
            <?php 
                $iva = new acumulados();
                $iva = $iva->ivaAcumulado($basedatos, $usuario, $numeroE, $nCuenta);
                echo "\$" . number_format($iva, 2);
                ?>
        </div></td>
      </tr>
      <tr bgcolor="#FFCCFF">
        <td bgcolor="#FFFFFF" class="style12">&nbsp;</td>
        <td bgcolor="#FFFFFF" class="style12">&nbsp;</td>
        <td bgcolor="#FFFFFF" class="style12">&nbsp;</td>
        <td height="23" class="style12">Total Cargos </td>
        <td class="style12"><div align="right">
            <?php 
                $totalAcumulado = new acumulados();
                echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), 2);
                ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
	
	
	
	
	
    <p>
      <input name="pagar" type="submit" class="style7" id="pagar" value="Aplicar Pago" />
      <input name="Submit" type="submit" class="style7" value="Trasladar a Compa&ntilde;ia" />
</p>
  </div>
  <p>&nbsp;</p>
</form>
<?php 
            }
            ?>
<p align="center">&nbsp;</p>
<?php 
            if ($_POST['banderaFecha']) {
                ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
            }
        }
        ?>
</body>
</html>
<?php 
    }
    public function eCuenta($tipoFacturacion, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=560,height=280,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=800,height=600,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

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






<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_GET['escoje'] and !$_GET['quitar']) {
            $keyCAP = $_GET['keyCAP'];
            for ($i = 0; $i <= $_GET['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    $sql = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='solicita',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "',\r\nfolioFactura='" . $_GET['folioFactura'] . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    mysql_db_query($basedatos, $sql);
                    echo mysql_error();
                }
            }
        }
        if ($_GET['quitar'] and !$_GET['escoje']) {
            $keyCAP = $_GET['quita'];
            for ($i = 0; $i <= $_GET['bandera']; $i++) {
                if ($keyCAP) {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "',\r\nfolioFactura=''\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
        }
        if ($_GET['folioFactura'] == '') {
            $sql = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "',\r\nfolioFactura=''\r\n\r\nwhere\r\n\r\n\r\nfolioFactura='" . $_GET['folioFactura'] . "'\r\n";
            mysql_db_query($basedatos, $sql);
            echo mysql_error();
        }
        if ($_GET['facturar']) {
            $sql = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='facturado',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "'\r\n\r\n\r\nwhere\r\nentidad='" . $entidad . "'\r\nand\r\n\r\nfolioFactura='" . $_GET['folioFactura'] . "'\r\n";
            mysql_db_query($basedatos, $sql);
            echo mysql_error();
            $agrega = "UPDATE clientesInternos\r\nset\r\nstatusFactura='facturado',\r\npagoFactura='standby'\r\nwhere \r\nkeyClientesInternos='" . $_GET['nT'] . "' \r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            echo 'Se facturo el folio: ' . $_GET['nT'];
        }
        ?>













<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
-->
</style>




<BODY  >

<h1 align="center">Solicitar servicios/art&iacute;culos Facturaci&oacute;n </h1>
<form id="form1" name="form1" method="GET" action="">
  <table width="413" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">Introduce el FOLIO </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        // echo $keyClientesInternos=$nCliente=$myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_GET['numeroE'];
        ?>
" readonly=""/>
</label>
<label>
<input name="nt" type="text" class="style7" id="nt" value="<?php 
        echo $_GET['nT'];
        ?>
" autocomplete="off" />
</label>
</div>      </th>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th class="Estilo24" scope="col"><div align="left"><strong># Factura </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
        <label>
        <input name="folioFactura" type="text" class="style7" id="numeroFactura" value="<?php 
        echo $_GET['folioFactura'];
        ?>
" 
		<?php 
        if ($_GET['folioFactura']) {
            echo 'readonly=""';
        }
        ?>
 />
        </label>
        <label>
        <input name="numeroFactura" type="submit" class="style7" id="numeroFactura" value="&gt;" />
        </label>

	  
	  </div></th>
	        
	  <?php 
        if ($myrow3['seguro']) {
            echo '<blink>' . 'Este folio es de aseguradora, y solo se admiten clientes particulares..!' . '</blink>';
        }
        ?>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left">RFC</div></th>
      <th bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left">
	<?php 
        $sSQL21 = "Select RFC,keyRFC \r\n\t  From RFC where\r\n\r\nkeyRFC='" . $myrow3['keyRFC'] . "'\r\n";
        $result21 = mysql_db_query($basedatos, $sSQL21);
        $myrow21 = mysql_fetch_array($result21);
        echo mysql_error();
        ?>
	  
        <input name="rfc" type="text" class="style71" id="folioFactura" value="<?php 
        echo $myrow21['RFC'];
        ?>
" 
		readonly=""/>
        <a href="#" onClick="javascript:ventanaSecundaria2('<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/cargos/ventanaFacturacionDirecta.php?folioFactura=<?php 
        echo $_GET['folioFactura'];
        ?>
&nT=<?php 
        echo $_GET['nT'];
        ?>
')"><img src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/imagenes/modificascl.png" alt="RFC" width="12" height="12" border="0" /></a></div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
  </table>
  <p align="center" class="style7"><em>(nota: Puedes escojer varios para el proceso de cierre) </em></p>



 <?php 
        if (!$myrow3['seguro']) {
            ?>

    


  <table width="682" height="0" border="0" align="center" class="style7">
    <tr>
      <th width="62" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">#MOV </span></div></th>
      <th width="100" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="282" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span></div></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Facturado</span></div></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Escojer</span></div></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Quitar</span></div></th>
    </tr>
	
<?php 
            //traigo agregados
            $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n and\r\n statusCargo='cargado'\r\n and\r\n naturaleza='C'\r\n and\r\n (seguro='0' or seguro='')\r\n order by hora1 asc\r\n";
            if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
                while ($myrow81 = mysql_fetch_array($result81)) {
                    $a += '1';
                    $art = $myrow81['codProcedimiento'];
                    $codigo = $proc = $myrow81['codProcedimiento'];
                    $keyCAP = $myrow81['keyCAP'];
                    ?>
	

	
	
    <tr>
<td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><div align="left"><span class="<?php 
                    echo $estilo;
                    ?>
"><?php 
                    echo $myrow81['keyCAP'];
                    ?>
</span></div></td>





      <td height="21" bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><div align="left"><span class="<?php 
                    echo $estilo;
                    ?>
">
      <?php 
                    echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                    ?>
</span></div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><div align="left"><span class="<?php 
                    echo $estilo;
                    ?>
"><span class="style12">
        <?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                    ?>
        </span>        <span class="style12">
          
          <?php 
                    if ($myrow81['gpoProducto']) {
                        echo '[' . $myrow81['gpoProducto'] . ']';
                    }
                    ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="<?php 
                    echo $estilo;
                    ?>
">
        <?php 
                    if ($myrow81['naturaleza'] == 'C') {
                        $suma[0] = $myrow81['precioVenta'] * $myrow81['cantidad'] + $myrow81['iva'] * $myrow81['cantidad'];
                        $sumaImporte[0] += $suma[0];
                        echo "\$" . number_format($suma[0], 2);
                    } else {
                        echo 'N/A';
                    }
                    ?>
      </span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24">
	  
	  <div align="left">
<?php 
                    $sSQL31 = "Select sum(cantidadFacturada) as sumaFacturada From cargosFacturados WHERE numFactura = '" . $_GET['folioFactura'] . "' and\r\nnT='" . $keyCAP . "' ";
                    $result31 = mysql_db_query($basedatos, $sSQL31);
                    $myrow31 = mysql_fetch_array($result31);
                    echo "\$" . number_format($myrow31['sumaFacturada'], 2);
                    $sumaFacturada[0] += $myrow31['sumaFacturada'];
                    ?>
	  
	  </div>
	  </td>
	  
	  
	  
	  <?php 
                    if (!$myrow31['sumaFacturada']) {
                        ?>
      <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="<?php 
                        echo $estilo;
                        ?>
">
	  <div align="center">
        <?php 
                        if ($myrow81['statusFactura'] == 'standby') {
                            ?>
<input name="keyCAP[]" type="checkbox" id="keyCAP[]" value="<?php 
                            echo $myrow81['keyCAP'];
                            ?>
"  />
        <?php 
                        } else {
                            echo '---';
                        }
                        ?>
      </div></td>
	  
	   
  
      <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="<?php 
                        echo $estilo;
                        ?>
">
	  
	  <?php 
                        if ($myrow81['statusFactura'] == 'solicita') {
                            $c += 1;
                            ?>
	
	  <input name="quita[]" type="checkbox" id="quita[]" value="<?php 
                            echo $myrow81['keyCAP'];
                            ?>
">
	  <?php 
                        } else {
                            echo '---';
                        }
                        ?>
	  </td>
	  <?php 
                    }
                    ?>
	  
	  
	  
    </tr>
 
	
	
    <?php 
                }
                ?>
  </table>
<?php 
                if ($a) {
                    ?>

<?php 
                    if ($_GET['nt'] and $_GET['folioFactura']) {
                        ?>
  <p align="center">
    <label>
    
    </label>
  </p>
  <p align="center">
         <label>
		   <?php 
                        if (!$myrow31['sumaFacturada']) {
                            ?>
      <input name="escoje" type="submit" class="style7" id="escoje" value="Escojer Elementos" />
      <input name="quitar" type="submit" class="style71" id="quitar" value="Quitar Elementos" />
	  <?php 
                        }
                        ?>
      </label>
      <label></label>
    <label>
	
	</label>
  </p>
 
  <div align="center">
  <input name="bandera" type="hidden" value="<?php 
                        echo $a;
                        ?>
" />
  
  <?php 
                        $suma = number_format($sumaImporte[0], 2) - number_format($sumaFacturada[0], 2);
                        if ($c >= 1) {
                            if ($suma != '0' or $suma != NULL) {
                                ?>
  <input name="nuevo" type="button" class="style71" id="nuevo" value="Escoje Cantidad a Facturar"
	  onclick="ventanaSecundaria1('<?php 
                                echo CONSTANT_PATH_SIMA_RAIZ;
                                ?>
/cargos/desplegarFacturaParticular.php?folioFactura=<?php 
                                echo $_GET['folioFactura'];
                                ?>
&nT=<?php 
                                echo $_GET['nT'];
                                ?>
')" />
	  <?php 
                            }
                        }
                        ?>
	  
	  
  </div>
  
   <div align="center">
     <?php 
                        if (($suma == '0' or $suma == NULL) and $_GET['rfc'] and $myrow3['statusFactura'] != 'facturado') {
                            ?>
     <input name="facturar" type="submit" class="style71" id="facturar" value="facturar" />
     <?php 
                        }
                        ?>

	 <?php 
                        if ($myrow3['statusFactura'] == 'facturado') {
                            ?>
     <input name="imprimeFactura" type="submit" class="style7" id="imprimeFactura" value="Imprimir Factura" />
	 <?php 
                        }
                        ?>

   </div>
   
   
   <?php 
                    }
                    ?>
    <?php 
                }
                //cierra validacion de solo seguro
                ?>
</form>

<p align="center">&nbsp;</p>


<?php 
            }
        }
        ?>
</body>
</html>
<?php 
    }
    public function revisarCuenta($bali, $transacciones, $TITULO, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        if (!$bali) {
            $bali = $_GET['almacenFuente'];
        }
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['actualizar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                if ($aseguradora[$i]) {
                    $status = 'efectivo';
                    $keyCAP[] = $aseguradora[$i];
                } else {
                    $status = 'cxc';
                    $keyCAP[] = $particular[$i];
                }
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusAlta='" . $status . "',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
            //cierra for
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['cerrar'] and $cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $otros->otros($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) == NULL) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatus='cerrada',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nnumeroE='" . $numeroE . "' \r\nand\r\nnCuenta='" . $nCuenta . "'\r\nand statusAlta='efectivo'\r\n";
                //mysql_db_query($basedatos,$agrega);
                echo mysql_error();
            }
            //cierro cuenta
            $agrega = "UPDATE clientesInternos set \r\nstatus='cerrada',\r\nstatusCuenta='cerrada',\r\nusuarioCierre='" . $usuario . "',\r\nfechaCierre='" . $fecha1 . "',\r\nhoraCierre='" . $hora1 . "'\r\n\r\nwhere\r\nkeyClientesInternos='" . $_GET['nT'] . "' \r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            //cierro cuarto a sucio
            $agrega = "UPDATE cuartos set \r\nstatus='sucio',\r\nusuarioSalida='" . $usuario . "',\r\nfechaSalida='" . $fecha1 . "',\r\nhoraSalida='" . $hora1 . "'\r\n\r\nwhere\r\ncodigoCuarto='" . $cuarto . "' \r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            $leyenda = 'Se cerr� la cuenta';
            ?>
<script type="text/vbscript">
msgbox "LA CUENTA <?php 
            echo $_GET['nT'];
            ?>
 ESTA CERRADA!"
</script>';

<script>
javascript:ventanaSecundaria6('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/INGRESOS%20HLC/caja/imprimirCierreCuenta.php?numeroE=<?php 
            echo $nCliente5;
            ?>
&amp;nT=<?php 
            echo $numeroCuenta;
            ?>
&amp;paciente=<?php 
            echo $_POST['paciente'];
            ?>
&amp;orden=<?php 
            echo $E;
            ?>
&amp;hora1=<?php 
            echo $hora1;
            ?>
');
</script>

<script>
close();
   </script>
   <script language="JavaScript" type="text/javascript">
  <!--
    opener.location.reload(true);
    self.close();
  // -->
</script>
   
   
<?php 
        }
        if (!$_POST['tipoVista']) {
            $_POST['tipoVista'] = 'Detalle';
        }
        ?>
<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>




<BODY  >
<?php 
        //ventanasPrototype::links();
        ?>
<h1 align="center"><?php 
        echo $TITULO;
        ?>
</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>
      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Fecha</td>
      <td class="Estilo24"><span class="style12">
        <label>
        <input type="checkbox" name="banderaFecha" value="checkbox" onClick="javascript:this.form.submit();" 
		<?php 
        if ($_POST['banderaFecha']) {
            echo 'checked="checked"';
        }
        ?>
		/>
        </label>
		
		
		<?php 
        if ($_POST['banderaFecha']) {
            ?>
        <input name="fecha" type="text" class="style12" id="campo_fecha"
	  value="<?php 
            if ($_POST['fecha']) {
                echo $_POST['fecha'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button" type="button" class="style12" id="lanzador" value="..." />
        Entre </label>
      <input name="fecha2" type="text" class="style12" id="campo_fecha1"
	  value="<?php 
            if ($_POST['fecha2']) {
                echo $_POST['fecha2'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button2" type="button" class="style12" id="lanzador1" value="..." />
        <input name="show" type="submit" class="style7" id="show" value="&gt;" />
        
        <?php 
        } else {
            ?>
        <input name="fecha3" type="hidden" class="style12" id="fecha2" value="<?php 
            echo 'all';
            ?>
"/>
		<?php 
        }
        ?>
</label>
</span></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th class="Estilo24" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
          <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
          <label> </label>
          <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">Tipo de Vista: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><label>
        <select name="tipoVista" class="style7" id="tipoVista" onChange="javascript:form1.submit();">
          <option>Escoje la Opci&oacute;n</option>
          <option
		  <?php 
        if ($_POST['tipoVista'] == 'Agrupado') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Agrupado">Agrupado</option>
          
		  
		  <option
		  <?php 
        if ($_POST['tipoVista'] == 'Detalle') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Detalle">Detalle</option>
        </select>
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>



  
  
 
    


  <table width="751" border="0" align="center">
    <tr>
      <th width="60" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">#MOV </span></div></th>
      <th width="96" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="300" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="21" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Cant</span></div></th>
      <th width="27" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Status</span></div></th>
      <th width="47" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">D Solicita</span></div></th>
      <th width="52" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">D Cargo.</span></div></th>
      <th width="72" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Tipo P </span></div></th>
      <th width="38" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">N </span></div></th>
    </tr>
	
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,gpoProducto,naturaleza,tipoTransaccion,porcentajeVariable,cargosHospitalarios,descripcion\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nnumeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n\r\n\r\n \r\n group by codProcedimiento \r\n order by fecha1,hora1 asc\r\n";
        if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
            while ($myrow81 = mysql_fetch_array($result81)) {
                $a += '1';
                $art = $myrow81['codProcedimiento'];
                $codigo = $proc = $myrow81['codProcedimiento'];
                $keyCAP = $myrow81['keyCAP'];
                if ($_POST['tipoVista'] == 'Agrupado') {
                    $sSQL14 = "\r\nSELECT \r\nsum(cantidad) as cantidad2\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\ncodProcedimiento = '" . $proc . "' and  numeroE = '" . $numeroE . "'\r\n";
                    $result14 = mysql_db_query($basedatos, $sSQL14);
                    $myrow14 = mysql_fetch_array($result14);
                }
                ?>
	
	
	
	
    <tr>
<td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow81['keyCAP'];
                ?>
</span></div></td>





      <td height="21" bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
      <?php 
                echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                ?>
</span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><span class="style12"><span class="style7">
        <?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                $medico = $myrow81['almacenDestino'];
                $nombreMed = new nombreMedico();
                echo " " . $myrow81['descripcion'] . $nombreMed->nombreMed($medico, $basedatos);
                ?>
        </span></span>        <span class="style12">
          
          <?php 
                if ($myrow81['gpoProducto']) {
                    echo '[' . $myrow81['gpoProducto'] . ']';
                }
                ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
        <?php 
                if ($_POST['tipoVista'] == 'Agrupado') {
                    echo $cantidad = $myrow14['cantidad2'];
                } else {
                    echo $cantidad = $myrow81['cantidad'];
                }
                ?>
      </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><div align="left"><span class="style7">
        
        
        
        <span class="style12">
          <?php 
                $status = new acumulados();
                echo $status->status($keyCAP, $basedatos, $usuario, $numeroE, $nCuenta);
                ?>
        </span></span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><div align="left"><span class="style7"><span class="style12">
      <?php 
                echo $myrow81['almacenSolicitante'];
                ?>
</span></span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><div align="left"><span class="style7"><span class="style12"><?php 
                echo $myrow81['almacenDestino'];
                ?>
</span></span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><span class="Estilo24"><?php 
                echo $myrow81['tipoCliente'];
                ?>
</span></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
">
	
        <div align="left"><span class="style7"><span class="style12">
          <?php 
                echo $myrow81['naturaleza'];
                ?>
</span>
        </span></div></td>
	</tr>
 
	
	
    <?php 
            }
        }
        ?>
  </table>


  <p align="center">
		    <input name="recibo" type="hidden" id="recibo" value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" />
            <input name="nCliente" type="hidden" id="nCliente" value="<?php 
        echo $nCliente;
        ?>
" />
            <input name="almacen" type="hidden" id="almacen" value="<?php 
        echo $ALMACEN;
        ?>
" />
  </p>
  <p align="center">&nbsp;</p>
</form>
<p align="center">&nbsp;</p>
</body>
</html>
<?php 
    }
    public function coaseguro($ALMACEN, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $cargosCia = new acumulados();
        $UserType = new tipoUsuario();
        $UserType = $UserType->tipoDeUsuario($usuario, $basedatos, $ALMACEN);
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria10 (URL){ 
   window.open(URL,"ventana10","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=350,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iván Nieto Pérez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El Código: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo sólo acepta números."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>



 <?php 
        if ($_POST['aplicar']) {
            //*********************** coaseguro 1**********************************
            $sSQL31 = "Select * From avisos WHERE entidad='" . $entidad . "' AND numeroE = '" . $numeroE . "' AND nCuenta='" . $nCuenta . "'";
            $result31 = mysql_db_query($basedatos, $sSQL31);
            $myrow31 = mysql_fetch_array($result31);
            if (!$myrow31['statusAviso']) {
                $agrega = "INSERT INTO avisos (\r\nnumeroE,nCuenta,tipoAviso,usuario,fecha,hora,statusAviso,keyCI,\r\nporcentajeDeducible1,\r\nporcentajeCoaseguro1,\r\nporcentajeDeducible2,\r\nporcentajeCoaseguro2,\r\nimporteDeducible1,\r\nimporteCoaseguro1,\r\nimporteDeducible2,\r\nimporteCoaseguro2,\r\nentidad\r\n) \r\nvalues \r\n('" . $numeroE . "','" . $nCuenta . "','caja',\r\n'" . $usuario . "','" . $fecha1 . "','" . $hora1 . "','standby','" . $_GET['nT'] . "',\r\n'" . $_POST['porcentajeDeducible1'] . "',\r\n'" . $_POST['porcentajeCoaseguro1'] . "',\r\n'" . $_POST['porcentajeDeducible2'] . "',\r\n'" . $_POST['porcentajeCoaseguro2'] . "',\r\n\r\n'" . $_POST['importeDeducible1'] . "',\r\n'" . $_POST['importeCoaseguro1'] . "',\r\n'" . $_POST['importeDeducible2'] . "',\r\n'" . $_POST['importeCoaseguro2'] . "',\r\n'" . $entidad . "'\r\n)";
                //mysql_db_query($basedatos,$agrega);
                echo mysql_error();
                $leyenda = "Se solicit&oacute; la transacci&oacute;n de cargo de Coaseguro a Paciente";
            } else {
                $agrega = "UPDATE avisos set \r\nporcentajeDeducible1='" . $_POST['porcentajeDeducible1'] . "',\r\nporcentajeCoaseguro1='" . $_POST['porcentajeCoaseguro1'] . "',\r\nporcentajeDeducible2='" . $_POST['porcentajeDeducible2'] . "',\r\nporcentajeCoaseguro2='" . $_POST['porcentajeCoaseguro2'] . "',\r\n\r\nimporteDeducible1='" . $_POST['importeDeducible1'] . "',\r\nimporteCoaseguro1='" . $_POST['importeCoaseguro1'] . "',\r\nimporteDeducible2='" . $_POST['importeDeducible2'] . "',\r\nimporteCoaseguro2='" . $_POST['importeCoaseguro2'] . "'\r\n\r\nwhere\r\nentidad='" . $entidad . "' AND\r\nnumeroE='" . $numeroE . "' AND\r\nnCuenta='" . $nCuenta . "'\r\n\r\n";
                //mysql_db_query($basedatos,$agrega);
                echo mysql_error();
                $leyenda = "Se actualizaron registros";
            }
            //********************************CIERRA COASEGURO 1
        }
        ?>
<!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();
        ?>




<BODY >

<h1 align="center"> Coaseguro / Deducible</h1>
<form id="form1" name="form1" method="post" action="">
  <img src="../../imagenes/bordestablas/borde1.png" alt="bo1" width="549" height="24" />
  <table width="549" border="0" align="center" cellpadding="4" cellspacing="0" bordercolor="#990099" class="none">
    <tr>
      <th bgcolor="#CCCCCC" class="none" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#CCCCCC" class="none" scope="col"><div align="left"><?php 
        echo $myrow3['folioVenta'];
        $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="134" bgcolor="#CCCCCC" class="Estilo24" scope="col">
      <div align="left" class="none"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#CCCCCC" class="Estilo24" scope="col">
      <div align="left"><strong>
      
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <td bgcolor="#CCCCCC" class="none">Compa&ntilde;&iacute;a: </td>
<td bgcolor="#CCCCCC" class="none"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#CCCCCC" class="none">N&deg; Credencial: </td>
      <td bgcolor="#CCCCCC" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
  </table>
  <img src="../../imagenes/bordestablas/borde2.png" alt="bo1" width="549" height="24" />
<p>&nbsp;</p>
  <img src="../../imagenes/bordestablas/borde1.png" alt="bo1" width="723" height="24" />
  <table width="723" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr bgcolor="#FFFF00">
      <th width="60" class="style14" scope="col"><div align="left" class="none">#Movto.</div></th>
      <th width="112" height="14" class="style14" scope="col"><div align="left" class="none">Fecha/Hora</div></th>
      <th width="270" class="style14" scope="col"><div align="left" class="none">Descripci&oacute;n/Concepto</div></th>
      <th width="44" class="style14" scope="col"><div align="left" class="none">Status</div></th>
      <th width="33" class="style14" scope="col"><div align="left" class="none">Cant</div></th>
      <th width="61" class="style14" scope="col"><div align="left" class="none">Importe</div></th>
      <th width="40" class="style14" scope="col"><div align="left" class="none">IVA</div></th>
      <th width="69" class="style14" scope="col"><div align="left" class="none">Natura</div></th>
    </tr>
    <tr>
      
      <?php 
        //traigo agregados
        $mostrarIVA = new articulosDetalles();
        $status = new acumulados();
        $importe = new acumulados();
        $sSQL81 = "\r\nSELECT *\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n folioVenta='" . $_GET['folioVenta'] . "'\r\nand\r\nstatusCargo!='cancelado'\r\n\r\n \r\n  order by fecha1,hora1 asc\r\n";
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            $art = $myrow81['codProcedimiento'];
            $codigo = $proc = $myrow81['codProcedimiento'];
            $keyCAP = $myrow81['keyCAP'];
            ?>



<td bgcolor="<?php 
            echo $color;
            ?>
" class="codigos"><?php 
            echo $myrow81['keyCAP'];
            ?>
</span></td>
	
      <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="normal">
	  <?php 
            echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
            ?>
</span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="normal"><span class="style12"><span class="style7">
      <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
            ?>
      </span></span>        <span class="style12">
		
        <?php 
            if ($myrow81['um'] == 's' or $myrow81['um'] == 'S') {
                echo '  ( Servicio )  ';
            }
            ?>

      </span> </span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><?php 
            echo $status->status($keyCAP, $basedatos, $usuario, $numeroE, $nCuenta);
            ?>
</td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="center" class="normal">
          <?php 
            echo $cantidad = $myrow81['cantidad'];
            ?>
      </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="precionormal1" align="right">
      
	  <?php 
            echo "\$" . number_format($myrow81['precioVenta'], 2);
            if ($myrow81['naturaleza'] == 'C' or $myrow81['naturaleza'] == 'coaseguro') {
                $cargos[0] += $myrow81['precioVenta'] * $myrow81['cantidad'];
            } else {
                if ($myrow81['naturaleza'] == 'A') {
                    $abonos[0] += $myrow81['precioVenta'] * $myrow81['cantidad'];
                }
            }
            ?>
      </span></span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="precionormal2" align="right">
	  
        <?php 
            echo "\$" . number_format($myrow81['iva'], 2);
            if ($myrow81['tipoCliente'] == 'aseguradora' or $myrow81['naturaleza'] == 'coaseguro') {
                $SUMAIVA[0] += $myrow81['iva'] * $myrow81['cantidad'];
            }
            ?>
      </span></span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="precionormal2"><div align="center"><span class="<?php 
            echo $estilo;
            ?>
">
	   
      <span class="style12"><span class="style7">
      <?php 
            if ($myrow81['statusDevolucion'] == 'si' and $myrow81['naturaleza'] == 'A') {
                print '-';
            } else {
                print $myrow81['naturaleza'];
            }
            ?>
    </span></span> </span></div></td>
	</tr>
 
	
	<?php 
            if ($myrow81['statusDescuento'] == 'si') {
                $statusD = 'disabled';
            }
            ?>
    <?php 
        }
        //cierra while
        ?>
	
	
	
  </table>
  <img src="../../imagenes/bordestablas/borde2.png" alt="bo1" width="723" height="24" />


  
  
  
  
  
  
  
  
  
  
  
  <table width="723" border="0" align="center">

    <tr>
      <td width="83" class="style12">&nbsp;</td>
      <td width="83" class="style12">&nbsp;</td>
      <td width="83" class="style12">&nbsp;</td>
      <td width="83" class="style12">&nbsp;</td>
      <td width="179" class="style12">&nbsp;</td>
      <td width="60" class="style12">&nbsp;</td>
      <td width="43" class="style12">&nbsp;</td>
      <td width="57" class="style12">&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <?php 
        $mostrarCuadroGP = new cuadritoAcumuladoGPO();
        echo $mostrarCuadroGP->mostrarCuadrito($_POST['fecha'], $_POST['fecha2'], 'precionormal1', $entidad, $myrow3['folioVenta'], $basedatos);
        ?>
  
  
  
<?php 
        $iva = new acumulados();
        $ivaD = new acumulados();
        $iva = $iva->ivaAcumulado($basedatos, $usuario, $nT) - $ivaD->ivaAcumuladoD($basedatos, $usuario, $nT);
        ?>
  <div align="center">
    <table width="396" border="1" align="center" class="style12">
      <tr>
        <td height="23" colspan="3" class="style12"><div align="center" class="style25">Cargos Globales </div></td>
      </tr>
      <tr>
        <td width="119" class="style12"><span class="style7">Total Cargos </span>
        <?php 
        $coaseguroN = new acumulados();
        $coa = $coaseguroN->cargosCoaseguroN($basedatos, $usuario, $nT);
        $totalAcumulado = new acumulados();
        $totalDevoluciones = new acumulados();
        $cargos = $totalAcumulado->totalAcumulado($basedatos, $usuario, $nT) - $totalDevoluciones->dev($basedatos, $usuario, $myrow3['folioVenta']) + $iva + $coa;
        echo "\$" . number_format($cargos, 2);
        ?>
        
        </td>
        <td width="111" height="23" class="style12"><span class="style7">Total Abonos     
           <?php 
        $abonos = new acumulados();
        $abonoS = $abonos->abonos($basedatos, $usuario, $myrow3['folioVenta']);
        echo "\$" . number_format($abonos->abonos($basedatos, $usuario, $myrow3['folioVenta']), 2);
        ?>
        </span></td>
        <td width="152" class="style12"><div align="right">
        Saldo Actual 
          <?php 
        if ($abonoS < 0) {
            $STotal = $cargos + $abonoS;
        } else {
            $STotal = $cargos - $abonoS;
        }
        echo "\$" . number_format($STotal, 2);
        ?>
		
        </div></td>
      </tr>
    </table>


  </div>
  <p align="center" class="style7">
  
<?php 
        $sSQL811 = "\r\nSELECT statusCargo\r\n\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n keyClientesInternos='" . $_GET['nT'] . "'\r\nand\r\nstatusCargo='standby'\r\n\r\n \r\n \r\n";
        $result811 = mysql_db_query($basedatos, $sSQL811);
        $myrow811 = mysql_fetch_array($result811);
        if ($myrow811['statusCargo']) {
            ?>
 <input name="nuevo" type="button" class="style7" id="nuevo" value="Falta Surtir Articulos" disabled=""/>

<?php 
        } else {
            ?>
    <input name="nuevo" type="button" class="style7" id="nuevo" value="Cargar Deducible/Coaseguro"
	  onclick="ventanaSecundaria10('aplicarDeducibleVentana.php?numeroE=<?php 
            echo $numeroE;
            ?>
&nCuenta=<?php 
            echo $nCuenta;
            ?>
&almacen=<?php 
            echo $_GET['almacen'];
            ?>
&almacenFuente=<?php 
            echo $_GET['almacen'];
            ?>
&nT=<?php 
            echo $_GET['nT'];
            ?>
&folioVenta=<?php 
            echo $myrow3['folioVenta'];
            ?>
&cantidadTotal=<?php 
            echo $STotal;
            ?>
')" />
	
	     
	  <?php 
        }
        ?>
  </p>
</form>

<p align="center">&nbsp;</p>

</body>
</html>
<?php 
    }
    public function aplicaPaquete($entidad, $almacenSolicitante, $ID_EJERCICIOM, $dia, $fecha1, $hora1, $usuario, $numeroPaciente, $seguro, $credencial, $medico, $almacenSolicitante, $nCuenta, $tipoCargo, $almacenDestino, $tipoPaciente, $basedatos)
    {
        $almacenPrincipal = 'HALM';
        //necesitamos definirlo desde el cat�logo de almacenes
        ?>


<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=420,height=350,scrollbars=YES") 
} 
</script> 

<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 
  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
<script language="javascript" type="text/javascript">   

function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.almacen.value) == false ) {   
                alert("Por Favor, escoje el departamento!")   
                return false   
        } else if( vacio(F.tipoUM.value) == false ) {   
                alert("Por Favor, escoje si es un servicio o si son art�culos lo que vas a cargar!")   
                return false   
        } else if( vacio(F.nomArticulo.value) == false ) {   
                alert("Por Favor, escoje el art�culo o servicio para solicitar!")   
                return false   
        }            
}   
  
  
  
  
</script> 
<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<?php 
        if ($_POST['entidades']) {
            $entidad = $_POST['entidades'];
        } else {
            $_POST['entidades'] = $entidad;
        }
        if (!$_POST['buscar'] and $_POST['insertarArticulos']) {
            if ($_POST['insertarArticulos']) {
                $numeroE = $numeroPaciente;
                $nCuenta = $nCuenta;
                $convenios = new validaConvenios();
                $global = new validaConvenios();
                $tipoConvenioS = new validaConvenios();
                $traeConvenio = new validaConvenios();
                $vConvenio = new validaConvenios();
                $verificaSaldos1 = new verificaSeguro1();
                if ($_POST['almacenDestino1']) {
                    $almacen = $_POST['almacenDestino1'];
                } else {
                    $almacen = $_POST['almacenDestino'];
                }
                $traeSeguro = new verificaSeguro1();
                $verificaSaldosInternos = new verificaSeguro1();
                //*************************PRESIONO INSERTAR ARTICULOS******************
                $aux = traeAuxiliar::auxiliar($fecha1, $hora1, $almacen, $basedatos, $ID_EJERCICIOM, $db_conn);
                $codigo = $_POST['codigoArt'];
                $cantidad = $_POST['cantidad'];
                $agregarA = $_POST['agregarA'];
                $codigoBeta = $_POST['codigoBeta'];
                $laboratorioReferido = $_POST['laboratorioReferido'];
                for ($i = 0; $i <= $_POST['bandera']; $i++) {
                    //********************FOR
                    $b += 1;
                    $codigo[$i] = $codigoBeta[$i];
                    $grupoProducto = new articulosDetalles();
                    $gpoProducto = $grupoProducto->grupoProducto($codigo[$i], $basedatos);
                    $costoHospital = costoHospital($codigo[$i], $basedatos);
                    $ctaContable = centroCosto($medico, $basedatos);
                    $centroCostoAlmacen = centroCostoAlmacen($almacen, $basedatos);
                    $medico = devuelveMedico::regresaMedico($codigo[$i], $basedatos);
                    $seguro = $traeSeguro->traeSeguro($numeroPaciente, $nCuenta, $basedatos);
                    //$priceLevel=$convenios->validacionConvenios($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                    $priceLevel = new articulosDetalles();
                    $priceLevel = $priceLevel->precioVenta($paquete, $_POST['generico'], $cantidad[$i], $numeroE, $nCuenta, $codigo[$i], $almacen, $basedatos);
                    if ($verificaSaldos1->verificaSaldos1($cantidad[$i], $iva, $priceLevel, $dia, $fecha1, $hora1, $seguro, $credencial, $leyenda, $basedatos) == true and $verificaSaldosInternos->verificaSaldosInternos($numeroPaciente, $nCuenta, $hora1, $seguro, $credencial, $basedatos) == true) {
                        $leyenda = "Se agregaron art�culos";
                        if ($cantidad[$i]) {
                            $um = new articulosDetalles();
                            $um = $um->um($codigo[$i], $basedatos);
                            $keyClientesInternos = new articulosDetalles();
                            $keyClientesInternos = $keyClientesInternos->keyClientesInternos($numeroE, $nCuenta, $basedatos);
                            $cargoAuto = new articulosDetalles();
                            $cargoAuto = $cargoAuto->cargoAuto($entidad, $codigo[$i], $basedatos);
                            $ajusteExistencias = new existencias();
                            $error = $ajusteExistencias->ajusteExistencias($um, $cantidad[$i], $codigo[$i], $almacen, $usuario, $fecha1, $error, $basedatos);
                            $informacionExistencias = new existencias();
                            $existenciasAjuste = $informacionExistencias->informacionExistencias($codigo[$i], $almacen, $usuario, $fecha, $basedatos);
                            $acumuladoGlobal = $global->precioGlobal($precioLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                            $cargos = $convenios->validacionConveniosNivel($precioLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                            //$traeConvenio=$traeConvenio->traeConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                            $tipoConvenio = $tipoConvenioS->tipoConvenio($precioLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                            //$vConvenio=$vConvenio->vConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                            if ($error != 'faked') {
                                if ($tipoConvenio == 'cantidad') {
                                    $cantidadAseguradora = $convenios->validacionConvenios($cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                                    //aqui ninguna aseguradora absorbe nada, solo paga porque es fijo
                                    $acumulado = $cantidadAseguradora * $cantidad[$i];
                                    $priceLevel = $acumulado;
                                } else {
                                    if ($tipoConvenio == 'grupoProducto') {
                                        $cantidadAseguradora = $convenios->validacionConvenios($cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                                        $priceLevel = $cantidadParticular = $cantidadAseguradora - ($priceLevel * $cantidad[$i] + $iva * $cantidad[$i]);
                                    } else {
                                        if ($tipoConvenio == 'global') {
                                            $cantidadAseguradora = $convenios->validacionConvenios($cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                                            $priceLevel = $cantidadParticular = $priceLevel * $cantidad[$i] + $iva * $cantidad[$i] - $cantidadAseguradora;
                                        } else {
                                            $cantidadParticular = NULL;
                                            $cantidadAseguradora = NULL;
                                        }
                                    }
                                }
                                $iva = new articulosDetalles();
                                $iva = $iva->iva($cantidad[$i], $codigo[$i], $priceLevel, $basedatos);
                                if ($seguro) {
                                    $status = 'cxc';
                                    $statusAlta = 'standby';
                                    $tipoCliente = 'aseguradora';
                                } else {
                                    $status = 'particular';
                                    $statusAlta = 'standby';
                                    $tipoCliente = 'particular';
                                }
                                $statusCargo = new articulosDetalles();
                                if ($statusCargo->cargosDirectos($almacen, $gpoProducto, $entidad, $codigo[$i], $basedatos)) {
                                    $statusCargo = 'cargado';
                                } else {
                                    $statusCargo = 'standby';
                                }
                                if ($acumuladoGlobal > $priceLevel) {
                                    //$acumulado=$acumuladoGlobal-$priceLevel;
                                    $acumulado = $priceLevel;
                                } else {
                                    $acumulado = $priceLevel;
                                }
                                $agrega1 = "INSERT INTO cargosCuentaPaciente (\r\nnumeroE,\r\nnCuenta,\r\ncodProcedimiento,\r\ncantidad,\r\nusuario,\r\nfecha1,\r\nip,\r\nstatus,\r\nalmacen,\r\nprecioVenta,\r\n\r\nctaMayor,\r\nctoCosto,\r\nauxiliar,\r\n\r\nejercicio,\r\nseguro,iva,dia,costoHospital,hora1,existencias,um,\r\nmedico,tipoPaciente,prioridad,horaSolicitud,fechaSolicitud,laboratorioReferido,\r\ncredencial,banderaCXC,statusCargo,almacenDestino,almacenSolicitante,naturaleza,statusTraslado,tipoCliente,\r\nstatusEstudio,entidad,gpoProducto,statusFactura,keyClientesInternos\r\n\r\n) values (\r\n'" . $numeroPaciente . "',\r\n'" . $nCuenta . "',\r\n'" . $codigo[$i] . "',\r\n'" . $cantidad[$i] . "',\r\n'" . $usuario . "',\r\n'" . $fecha1 . "',\r\n'" . $ip . "',\r\n'" . $status . "',\r\n'" . $almacen . "',\r\n'" . $acumulado . "',\r\n\r\n'" . $ctaMayor . "',\r\n'" . $centroCostoAlmacen . "',\r\n'" . $aux . "',\r\n\r\n'" . $ID_EJERCICIOM . "',\r\n'" . $seguro . "','" . $iva . "','" . $dia . "','" . $costoHospital . "','" . $hora1 . "','" . $existenciasAjuste . "','" . $um . "',\r\n'" . $medico . "','interno','" . $_POST['prioridad'] . "',\r\n'" . $_POST['horaSolicitud'] . "','" . $_POST['fechaSolicitud'] . "','" . $laboratorioReferido[$i] . "','" . $credencial . "',\r\n'" . $_POST['banderaCXC'] . "','" . $statusCargo . "','" . $almacen . "','" . $almacenSolicitante . "','C','standby','" . $tipoCliente . "','standby','" . $entidad . "','" . $gpoProducto . "','standby','" . $keyClientesInternos . "'\r\n\r\n)";
                                mysql_db_query($basedatos, $agrega1);
                                echo mysql_error();
                                //*********************************agregar faltantes**********************
                                $agrega1 = "INSERT INTO faltantes (\r\n\r\n\r\n\r\n\r\nnumeroE,nCuenta,\r\ncodigo,\r\ncantidad,\r\nusuario,\r\nfecha1,\r\nhora1,\r\nalmacen,\r\nejercicio,\r\ndia,\r\nstatus,entidad,almacenDestino\r\n) values (\r\n'" . $numeroPaciente . "','" . $nCuenta . "',\r\n'" . $codigoBeta[$i] . "',\r\n'" . $cantidad[$i] . "',\r\n'" . $usuario . "',\r\n'" . $fecha1 . "',\r\n'" . $hora1 . "',\r\n'" . $almacen . "',\r\n'" . $ID_EJERCICIOM . "',\r\n'" . $dia . "',\r\n'sinsurtir','" . $entidad . "','" . $almacenPrincipal . "'\r\n)";
                                mysql_db_query($basedatos, $agrega1);
                                echo mysql_error();
                                //****************saco la cuenta contable de la forma en que ingresa*****************
                                insertarRegistros($agregarA[$i], $almacen, $cantidad[$i], $fecha1, $ID_EJERCICIOM, $usuario, $basedatos);
                            }
                        } else {
                            $leyenda = "Se hicieron cargos..";
                        }
                        //validacion de seguros
                    }
                }
                //validacion de seguros
                //*****************************************************CIERRO ALMA**************************************************
            }
            //cierro buscar
        }
        //verificaSeguro::verificaSaldos($dia,$fecha1,$hora1,$seguro,$credencial,$basedatos);
        ?>



<?php 
        $sSQL311 = "Select  * From clientesInternos WHERE numeroE = '" . $numeroPaciente . "' and status='activa'";
        $result311 = mysql_db_query($basedatos, $sSQL311);
        $myrow311 = mysql_fetch_array($result311);
        $paciente = $myrow31['nombre1'] . " " . $myrow31['nombre2'] . " " . $myrow31['apellido1'] . " " . $myrow31['apellido2'] . " " . $myrow31['apellido3'];
        if ($myrow311['paciente']) {
            $paciente = $myrow311['paciente'];
        }
        ?>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=600,height=600,scrollbars=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria20 (URL){ 
   window.open(URL,"ventana20","width=50,height=10,scrollbars=YES") 
} 
</script>

<script language="javascript">

function enableField()
{
document.form2.insertarArticulos.disabled=false;
}

</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">
<style type="text/css">
<!--
.Estilo25 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style15 {color: #0000FF}
.Estilo25 {
	color: #FF0000;
	font-weight: bold;
}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
-->
</style>
</head>

<body>

  <?php 
        $sSQL31 = "Select  * From pacientes WHERE entidad='" . $entidad . "' AND numCliente = '" . $numeroPaciente . "' ";
        $result31 = mysql_db_query($basedatos, $sSQL31);
        $myrow31 = mysql_fetch_array($result31);
        ?>
<p align="center"><label></label></p>
<form id="form2" name="form2" method="post" action="" >
  <table width="546" border="0" align="center">

    <tr>
      <th colspan="2" bgcolor="#660066" scope="col"><div align="center"><span class="style11">Solicitudes a otros departamentos </span></div></th>
    </tr>
	  <tr bgcolor="#FFCCFF" class="style7">
      <th scope="col"><div align="left">Paciente: </div></th>
      <th bgcolor="#FFCCFF" scope="col"><div align="left"><?php 
        echo $paciente;
        ?>
      </div></th>
    </tr>
     <tr class="style7">
       <th scope="col"><div align="left">Cuarto:</div></th>
       <th scope="col">
         <div align="left"><?php 
        echo $myrow311['cuarto'];
        ?>
</div></th>
     </tr>

     <tr class="style7">
       <th bgcolor="#FFCCFF" scope="col"><div align="left">Departamento</div></th>
       <th bgcolor="#FFCCFF" scope="col">
         <div align="left">
           <?php 
        require CONSTANT_PATH_CONFIGURACION . "/componentes/comboAlmacen.php";
        $comboAlmacen = new comboAlmacen();
        $comboAlmacen->despliegaAlmacenAAV($entidad, 'style7', $almacenSolicitante, $almacenDestino, $basedatos);
        ?>
       </div></th>
     </tr>
	 
	 
	
     <tr class="style7">
       <th class="style7" scope="col"><div align="left">Mini Almac&eacute;n </div></th>
       <th scope="col">
         <div align="left">
           <?php 
        $comboAlmacen1 = new comboAlmacen();
        if (!$almacenDestino) {
            $almacenDestino = $almacenSolicitante;
        }
        $comboAlmacen1->despliegaMiniAlmacen($entidad, 'style7', $almacenDestino, $almacenDestino, $basedatos);
        ?>
       </div></th>
     </tr>
	 

	 
    <tr>
	
      <th bgcolor="#FFCCFF" scope="col"><div align="left"><span class="Estilo24">Mostrar Todo (*) </span></div></th>
      <th bgcolor="#FFCCFF" scope="col"><div align="left">
        <label>
        <input name="todo" type="checkbox" id="todo" value="todo" />
        </label>
      </div></th>
    </tr>
    
	
	
    <tr>
      <th scope="col"><div align="left"><span class="Estilo24">Prioridad</span></div></th>
      <th scope="col"><div align="left">
        <select name="prioridad" class="style71" id="select">
          <option
			 <?php 
        if ($_POST['prioridad'] == 'baja') {
            ?>
			 selected="selected"
			 <?php 
        }
        ?>
			 value="baja">baja</option>
          <option
			 <?php 
        if ($_POST['prioridad'] == 'alta') {
            ?>
			 selected="selected"
			 <?php 
        }
        ?>
			 value="alta">alta</option>
        </select>
      </div></th>
    </tr>
	
	
	
	

	
	
	
    <tr>
      <th width="101" scope="col"><div align="left"><span class="style12">Cargar Art&iacute;culos/Serv. </span></div></th>
      <th width="435" scope="col"><div align="left"><span class="style12">
          <input name="nomArticulo" type="text" class="style12" id="nomArticulo" size="60" value="<?php 
        if ($_POST['nomArticulo']) {
            //echo $_POST['nomArticulo'];
        }
        ?>
"/>
      </span>
          <input name="buscar" type="submit" class="Estilo24" id="buscar" value="buscar" />
      </div></th>
    </tr>
  </table>
  <p align="center"><span class="Estilo24"><span class="style7"><input name="almacenCargo" type="hidden" id="almacenCargo" value="<?php 
        echo $_POST['almacen'];
        ?>
" />
  </span></span>
    <input name="nombrePaciente3" type="hidden" id="nombrePaciente3" value="<?php 
        echo $nombrePaciente1;
        ?>
" />
    <input name="medico1" type="hidden" id="medico1" value="<?php 
        echo $medico1;
        ?>
" />
    <input name="tipoSeguro1" type="hidden" id="tipoSeguro1" value="<?php 
        echo $seguro;
        ?>
" />
    <input name="almacenP1" type="hidden" id="almacenP1" value="<?php 
        echo $almacenPrincipal;
        ?>
" />
    <input name="numPoliza1" type="hidden" id="numPoliza1" value="<?php 
        echo $numPoliza;
        ?>
" />
    <input name="nCuenta1" type="hidden" id="nCuenta1" value="<?php 
        echo $nCuenta;
        ?>
" />
    <span class="style15"><?php 
        echo $leyenda;
        ?>
</span>  </p>
    <div align="center">
<?php 
        if ($_POST['almacenDestino1']) {
            $almacen = $_POST['almacenDestino1'];
        } else {
            $almacen = $_POST['almacenDestino'];
        }
        //*********************NUCLEO***********************
        if ($_POST['todo'] == 'todo') {
            $sSQL = "SELECT \r\narticulos.codigo,articulos.gpoProducto,articulos.laboratorioReferido\r\nFROM articulos,existencias\r\nWHERE\r\narticulos.entidad='" . $entidad . "' AND \r\narticulos.activo='A'\r\nand\r\narticulos.codigo=existencias.codigo and\r\nexistencias.almacen='" . $almacen . "'\r\nand\r\narticulos.paquete='no'\r\norder by articulos.descripcion ASC\r\n";
            $_POST['nomArticulo'] = 'todo';
        } else {
            if ($_POST['buscar'] or ($_POST['nomArticulo'] or $_POST['cbarra'])) {
                $articulo = $_POST['nomArticulo'];
                $sSQL = "SELECT \r\narticulos.codigo,articulos.gpoProducto,articulos.laboratorioReferido\r\nFROM articulos,existencias\r\nWHERE\r\narticulos.entidad='" . $entidad . "' AND \r\narticulos.activo='A' and\r\narticulos.descripcion like '%{$articulo}%'\r\n\r\nand\r\narticulos.codigo=existencias.codigo and\r\nexistencias.almacen='" . $almacen . "'\r\nand\r\narticulos.paquete='no'\r\n";
            }
        }
        //****************CIERRA NUCLEO****************
        if ($_POST['nomArticulo']) {
            if ($result = mysql_db_query($basedatos, $sSQL)) {
                ?>
      
   
      
      
      
      
           
      
<table width="364" border="0" align="center" class="style71">


  <tr>
    <th width="105" bgcolor="#FFCCFF" scope="col"><div align="left"><span class="Estilo26">Hora de Estudio</span></div></th>
    <th width="249" bgcolor="#FFCCFF" scope="col"><div align="left"><span class="Estilo26">
        <label>
        <input name="horaSolicitud" type="text" class="style71"   value="<?php 
                if ($_POST['horaSolicitud']) {
                    echo $_POST['horaSolicitud'];
                }
                ?>
" size="10"/>
        </label>
        <input name="H2" type="button" class="style71" id="H2"  onclick="javascript:ventanaSecundaria3(
		'<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/citas.php?numeroE=<?php 
                echo $numeroPaciente;
                ?>
&amp;forma=<?php 
                echo "form2";
                ?>
		&amp;campoDespliega=<?php 
                echo "horaSolicitud";
                ?>
		&amp;almacenSolicitante=<?php 
                echo $_POST['almacenDestino1'];
                ?>
		&amp;campoDespliegaFecha=<?php 
                echo "fechaSolicitud";
                ?>
		&amp;nCuenta=<?php 
                echo $nCuenta;
                ?>
')" value="H" />
</span></div></th>
  </tr>
  
  
  
  
  
  <tr>
    <th scope="col"><div align="left"><span class="Estilo26">Fecha del Estudio </span></div></th>
    <th scope="col"><span class="Estilo26">
      <label></label>
      </span>
        <div align="left"><span class="Estilo26">
          <input name="fechaSolicitud" type="text" class="style71" id="fechaSolicitud"
	  value="<?php 
                if ($_POST['fechaSolicitud']) {
                    echo $_POST['fechaSolicitud'];
                } else {
                    if ($myrow3['fechaSolicitud']) {
                        echo $myrow3['fechaSolicitud'];
                    } else {
                        echo $fecha1;
                    }
                }
                ?>
" size="10" readonly="" onChange="javascript:this.form.submit();"/>
          <input name="button2" type="button" class="style71" id="lanzador" value="..." />
      </span></div></th>
  </tr>

</table>
<p>&nbsp;</p>
  </div>
    <table width="681" border="0" align="center">
      <tr>
        <th width="65" height="19" bgcolor="#660066" scope="col"><div align="left"><span class="style11">C&oacute;digo </span></div></th>
        <th width="332" bgcolor="#660066" scope="col"><span class="style11">Descripci&oacute;n</span></th>
         <?php 
                if ($myrow['laboratorioReferido'] == 'si') {
                    ?>
		<th width="145" bgcolor="#660066" scope="col"><span class="style11">Ref.</span></th>
		<?php 
                }
                ?>
        <th width="17" bgcolor="#660066" scope="col"><span class="style11">UM</span></th>
        <th width="58" bgcolor="#660066" scope="col"><span class="style11">Precio sin/IVA</span></th>
      
        <th width="17" bgcolor="#660066" scope="col"><span class="style11">C</span></th>
        <th width="17" bgcolor="#660066" scope="col"><span class="style11">D</span></th>
      </tr>
      <tr>
        <?php 
                while ($myrow = mysql_fetch_array($result)) {
                    $bandera += "1";
                    $i += 1;
                    $code1 = $myrow['codigo'];
                    $codigo = $myrow['codigo'];
                    //*************************************CONVENIOS********************************************
                    //cierro descuento
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = '';
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    //*******************************CONVENIOS*******************************
                    $numeroE = $numeroPaciente = $myrow311['numeroE'];
                    $nCuenta = $myrow311['nCuenta'];
                    $convenios = new validaConvenios();
                    $global = new validaConvenios();
                    $tipoConvenioS = new validaConvenios();
                    $traeConvenio = new validaConvenios();
                    $vConvenio = new validaConvenios();
                    $um = new articulosDetalles();
                    $um = $um->um($codigo[$i], $basedatos);
                    $cantidad = 1;
                    $traeSeguro = new verificaSeguro1();
                    $verificaSaldosInternos = new verificaSeguro1();
                    $seguro = $traeSeguro->traeSeguro($numeroPaciente, $nCuenta, $basedatos);
                    //$priceLevel=$convenios->validacionConvenios($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                    $priceLevel = new articulosDetalles();
                    $priceLevel = $priceLevel->precioVenta($paquete, $_POST['generico'], $cantidad, $numeroE, $nCuenta, $codigo, $almacen, $basedatos);
                    $acumuladoGlobal = $global->precioGlobal($precioLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                    $cargos = $convenios->validacionConveniosNivel($precioLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                    //$traeConvenio=$traeConvenio->traeConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                    $tipoConvenio = $tipoConvenioS->tipoConvenio($precioLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                    //$vConvenio=$vConvenio->vConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$seguro,$basedatos);
                    if ($tipoConvenio == 'cantidad') {
                        $cantidadAseguradora = $convenios->validacionConvenios($cantidad, $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                        //aqui ninguna aseguradora absorbe nada, solo paga porque es fijo
                        $acumulado = $cantidadAseguradora * $cantidad;
                        $priceLevel = $acumulado;
                    } else {
                        if ($tipoConvenio == 'grupoProducto') {
                            $cantidadAseguradora = $convenios->validacionConvenios($cantidad, $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                            $priceLevel = $cantidadParticular = $cantidadAseguradora - ($priceLevel * $cantidad + $iva * $cantidad);
                        } else {
                            if ($tipoConvenio == 'global') {
                                $cantidadAseguradora = $convenios->validacionConvenios($cantidad, $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                                $priceLevel = $cantidadParticular = $priceLevel * $cantidad + $iva * $cantidad - $cantidadAseguradora;
                            } else {
                                $cantidadParticular = NULL;
                                $cantidadAseguradora = NULL;
                            }
                        }
                    }
                    $iva = new articulosDetalles();
                    $iva = $iva->iva($cantidad, $codigo, $priceLevel, $basedatos);
                    //**********************************************************************************************************
                    $gpoProducto = $myrow['gpoProducto'];
                    $sSQL39 = "\r\n\tSELECT \r\nprefijo\r\nFROM\r\ngpoProductos\r\nWHERE codigoGP='" . $gpoProducto . "'";
                    $result39 = mysql_db_query($basedatos, $sSQL39);
                    $myrow39 = mysql_fetch_array($result39);
                    ?>
		        <td height="24" bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
          <label><?php 
                    echo $myrow39['prefijo'] . $myrow['codigo'];
                    ?>
</label>

        
          <input name="codigoArt[]" type="hidden" id="codigoArt[]" value="<?php 
                    echo $myrow['codigo'];
                    ?>
" />
          <input name="codigoBeta[]" type="hidden" id="codigoBeta[]" value="<?php 
                    echo $myrow['codigo'];
                    ?>
" />
        </span></td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
		<?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                    ?>
		<?php 
                    if ($myrow['paquete'] == 'si') {
                        echo '<img src="' . CONSTANT_PATH_SIMA_RAIZ . '/imagenes/p.jpeg" width="12" height="12" alt="ES UN PAQUETE" />';
                    }
                    if ($myrow['gpoProducto']) {
                        echo '[' . $myrow['gpoProducto'] . ']';
                    }
                    ?>
		
              		<?php 
                    if ($myrow['generico'] == 'si') {
                        ?>
					<blink>
		<img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/g.jpg" alt="MEDICAMENTO GENERICO..." width="12" height="12" border="0" />		</blink>
		<?php 
                    } else {
                        echo '';
                    }
                    ?>
		
		
		
        </span>		</td>
<?php 
                    if ($myrow['laboratorioReferido'] == 'si') {
                        ?>
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><span class="Estilo241"><span class="style72">
         
        </span><span class="style72">
        <?php 
                        $aCombo = "Select distinct * From catLabRef where\r\nactivo='activo'\r\n ORDER BY descripcionLF ASC ";
                        $rCombo = mysql_db_query($basedatos, $aCombo);
                        ?>
        <select name="laboratorioReferido[]" class="style72" onChange="javascript:enableField();" />
        
       
        <option>---</option>
        
        <?php 
                        while ($resCombo = mysql_fetch_array($rCombo)) {
                            ?>
        <option value="<?php 
                            echo $resCombo['id_LF'];
                            ?>
"><?php 
                            echo $resCombo['descripcionLF'];
                            ?>
</option>
        <?php 
                        }
                        ?>
        </select>
        <?php 
                        $sqlNombre18 = "SELECT * From catLabRef\r\n\t\t\tWHERE \r\n\t\t\tid_LF= '" . $_POST['laboratorioReferido'] . "'\r\n\t\t\t\r\n\t\t\t";
                        $resultaNombre18 = mysql_db_query($basedatos, $sqlNombre18);
                        $rNombre18 = mysql_fetch_array($resultaNombre18);
                        echo $rNombre18['descripcionLF'];
                        ?>
        <?php 
                    } else {
                        ?>
        <?php 
                        //echo "---";
                        ?>
 
		<span class="Estilo26"><span class="style71">
        <input name="laboratorioReferido[]" type="hidden" value="" />
        </span></span>
        <?php 
                    }
                    ?>
        </span></span></td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
          <label>
          <label>
<?php 
                    $unidadMedida = new articulosDetalles();
                    echo $unidadMedida->unidadMedida($codigo, $basedatos);
                    ?>
         </label>
          </label>
        </span></td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
<?php 
                    echo "\$" . number_format($priceLevel, 2);
                    ?>
        </span></td>
		


<td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24">
		
<?php 
                    $statusExistencias = new articulosDetalles();
                    ?>


<input name="cantidad[]" type="text" class="Estilo24" id="cantidad" 
onKeyPress="return checkIt(event)" size="2" maxlength="2"
autocomplete="off" <?php 
                    echo $statusExistencias->statusExistencias($unidadMedida->unidadMedida($codigo, $basedatos), $almacen, $codigo, $basedatos);
                    ?>
/> </td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><label>
		
		<?php 
                    if ($myrow['gpoProducto']) {
                        $errores1 = 'No tiene grupo de producto';
                    }
                    if ($statusExistencias->statusExistencias($myrow['servicio'], $almacen, $myrow['codigo'], $basedatos) == 'readonly' and $myrow['gpoProducto']) {
                        $errores = 'No hay existencias en el almacen: ' . $almacen;
                        ?>
		<a href="javascript:ventanaSecundaria20('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/cargos/ventanaErrores.php?codigo=<?php 
                        echo $code;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&medico=<?php 
                        echo $_POST['medico'];
                        ?>
&error=<?php 
                        echo $errores;
                        ?>
&error1=<?php 
                        echo $errores1;
                        ?>
')">
		<img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/pregunta.png" width="12" height="12" border="0" alt="ERRORES" /></a>		
		<?php 
                    } else {
                        echo '<img src="' . CONSTANT_PATH_SIMA_RAIZ . '/imagenes/ok.jpeg" width="12" height="12" alt="OK" />';
                    }
                    ?>
		</label></td>
      </tr>

      <?php 
                }
            }
            ?>
    </table>
    <p>
      <?php 
            //*********************************************TERMINA TABLA**************************************************
            ?>
</p>
    <p>
      <label>
      <div align="center">
        <hr width="600" size="0" />
        <div align="center">
	  <input name="insertarArticulos" type="submit" class="Estilo24" id="insertarArticulos" value="Agregar" 
  <?php 
            if ($myrow['laboratorioReferido'] == 'si') {
                echo 'disabled="disabled"';
            }
            ?>
/>
          </label>
  </div>
        <p align="center">&nbsp; </p>
    <?php 
        }
        ?>
    <input name="gpoProducto" type="hidden" id="numPaciente2" value="<?php 
        echo $gpoProducto;
        ?>
" />
    <input name="numeroMedico1" type="hidden" id="numeroMedico1" value="<?php 
        echo $numeroMedico;
        ?>
" />
    <input name="nombreDelPaciente2" type="hidden" id="nombreDelPaciente2" value="<?php 
        echo $nombreDelPaciente;
        ?>
" />
    <input name="extension2" type="hidden" id="extension2" value="<?php 
        echo $extension;
        ?>
" />
    <input name="segu1" type="hidden" id="segu1" value="<?php 
        echo $segu;
        ?>
" />
    <input name="bandera" type="hidden" id="numPaciente22" value="<?php 
        echo $bandera;
        ?>
" />
</form>
  <p>
 
  </p>
    
 <?php 
        if ($bandera > 1) {
            echo 'Se encontraron ' . $bandera . ' registros';
        }
        if ($result) {
            ?>
      <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 

<?php 
        }
        ?>

</body>
</html>


<?php 
    }
    public function eCuenta($nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        if (!$_GET['nT']) {
            $_GET['nT'] = $_GET['nt'];
        }
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=300,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO PRECIOS**********************
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        //***************aplicar pago**********************
        if (!$_POST['tipoVista']) {
            $_POST['tipoVista'] = 'Detalle';
        }
        ?>
<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></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">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
-->
</style>


</head>

<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>
<BODY >

<h1 align="center">Estado de Cuenta </h1>
<form id="form1" name="form1" method="post" action="">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>
      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th class="Estilo24" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
          <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
          <label> </label>
          <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        $sSQL212 = "SELECT *\r\nFROM\r\nclientes\r\nWHERE \r\nnumCliente='" . $traeSeguro . "'\r\n ";
        $result212 = mysql_db_query($basedatos, $sSQL212);
        $myrow212 = mysql_fetch_array($result212);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Fecha</td>
      <td class="Estilo24"><span class="style12">
        <label>
        <input type="checkbox" name="banderaFecha" value="checkbox" onClick="javascript:this.form.submit();" 
		<?php 
        if ($_POST['banderaFecha']) {
            echo 'checked="checked"';
        }
        ?>
		/>
        </label>
		
		
		<?php 
        if ($_POST['banderaFecha']) {
            ?>
        <input name="fecha" type="text" class="style12" id="campo_fecha"
	  value="<?php 
            if ($_POST['fecha']) {
                echo $_POST['fecha'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button" type="button" class="style12" id="lanzador" value="..." />
        Entre </label>
      <input name="fecha2" type="text" class="style12" id="campo_fecha1"
	  value="<?php 
            if ($_POST['fecha2']) {
                echo $_POST['fecha2'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button2" type="button" class="style12" id="lanzador1" value="..." />
        <input name="show" type="submit" class="style7" id="show" value="&gt;" />
        
        <?php 
        } else {
            ?>
        <input name="fecha3" type="hidden" class="style12" id="fecha2" value="<?php 
            echo 'all';
            ?>
"/>
		<?php 
        }
        ?>
</label>
</span></td>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">Tipo de Vista: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><label>
        <select name="tipoVista" class="style7" id="tipoVista" onChange="javascript:form1.submit();">
          <option>Escoje la Opci&oacute;n</option>
          <option
		  <?php 
        if ($_POST['tipoVista'] == 'Agrupado') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Agrupado">Agrupado</option>
          
		  
		  <option
		  <?php 
        if ($_POST['tipoVista'] == 'Detalle') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Detalle">Detalle</option>
        </select>
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  
    <?php 
        if ($_POST['tipoVista']) {
            ?>
  
  <table width="672" border="0" align="center">
    <tr>
      <th width="104" height="14" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Fecha/Hora (Cargo)</span></th>
      <th width="405" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Descripci&oacute;n</span></th>
      <th width="21" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Cant</span></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Importe IC </span></th>
      <th width="61" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">IVA</span></th>
    </tr>
    <tr>
      <?php 
            //traigo agregados
            if ($_POST['tipoVista'] == 'Agrupado' and $_POST['banderaFecha']) {
                $sSQL81 = "\r\nSELECT \r\n  *,((precioVenta*cantidad)+iva) as sumaTres\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n  and (status!='standby' and statusCargo!='standby')\r\n  and\r\n(fecha1 between'" . $_POST['fecha'] . "' and '" . $_POST['fecha2'] . "')\r\n\r\n\r\n \r\n group by codProcedimiento \r\n order by fecha1,hora1 asc\r\n";
            } else {
                if ($_POST['tipoVista'] == 'Detalle' and $_POST['banderaFecha']) {
                    $sSQL81 = "\r\nSELECT \r\n  *,((precioVenta*cantidad)+iva) as sumaTres\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n \r\n and (status!='standby' and statusCargo!='standby')\r\n   and \r\n (fecha1 between'" . $_POST['fecha'] . "' and '" . $_POST['fecha2'] . "')\r\n\r\n order by fecha1,hora1 asc\r\n";
                } else {
                    if ($_POST['tipoVista'] == 'Agrupado' and !$_POST['banderaFecha']) {
                        $sSQL81 = "\r\nSELECT \r\n  *,((precioVenta*cantidad)+iva) as sumaTres\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nnumeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n\r\n\r\n \r\n group by codProcedimiento \r\n order by fecha1,hora1 asc\r\n";
                    } else {
                        if ($_POST['tipoVista'] == 'Detalle' and !$_POST['banderaFecha']) {
                            $sSQL81 = "\r\nSELECT \r\n *,((precioVenta*cantidad)+iva) as sumaTres\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n\r\n\r\n \r\n \r\n \r\n order by fecha1,hora1 asc\r\n";
                        }
                    }
                }
            }
            if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
                while ($myrow81 = mysql_fetch_array($result81)) {
                    $keyCAP = $myrow81['keyCAP'];
                    $a = $a + 1;
                    $art = $myrow81['codProcedimiento'];
                    $proc = $myrow81['codProcedimiento'];
                    $codigo = $myrow81['codProcedimiento'];
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = "";
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    if ($_POST['tipoVista'] == 'Agrupado') {
                        $sSQL14 = "\r\nSELECT \r\nsum(cantidad) as cantidad2\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\ncodProcedimiento = '" . $proc . "' and  numeroE = '" . $numeroE . "'\r\n";
                        $result14 = mysql_db_query($basedatos, $sSQL14);
                        $myrow14 = mysql_fetch_array($result14);
                    }
                    ?>




      <td height="23" bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7"><?php 
                    echo $myrow81['fecha1'] . " " . $myrow81['hora1'];
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7"><span class="style12"><span class="<?php 
                    echo $estilo;
                    ?>
">
        <?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($numeroE, $nCuenta, $codigo, $basedatos);
                    ?>
      </span></span>        <span class="style12">
        <?php 
                    if ($myrow81['um'] == 's' or $myrow81['um'] == 'S') {
                        echo '  ( Servicio )  ';
                    }
                    ?>
        <?php 
                    if ($myrow81['status'] == 'cerrada') {
                        echo '<blink>' . "[Cerrada]" . '</blink>';
                    } else {
                        //echo '<blink>'."[CxC]".'</blink>';
                    }
                    ?>
 </span> </span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
        <?php 
                    if ($_POST['tipoVista'] == 'Agrupado') {
                        echo $cantidad = $myrow14['cantidad2'];
                    } else {
                        echo $cantidad = $myrow81['cantidad'];
                    }
                    ?>
      </span></td>
	
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
          
      <span class="style12"><span class="<?php 
                    echo $estilo;
                    ?>
">
      <?php 
                    $importe = new acumulados();
                    echo $importe->importe($keyCAP, $basedatos);
                    ?>
</span></span> </span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="Estilo24"><span class="style7">
        <?php 
                    $mostrarIVA = new articulosDetalles();
                    echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
                    ?>
      </span></td>
	   <?php 
                    if ($tipoTrans and !$myrow81['sumaTres']) {
                        //echo "$".number_format("-".$myrow81['cantidadRecibida'],2);
                        $TOTAL += "-" . $myrow81['cantidadRecibida'];
                    } else {
                        //echo "$".number_format($costoProcedimientos[0],2);
                        //$TOTAL+=$costoProcedimientos[0];
                        //echo "$".number_format($myrow81['sumaTres'],2);
                    }
                    ?>
    </tr>
 
	
	
    <?php 
                }
            }
            ?>
  </table>
  <p>
    <input name="paso_bandera1" type="hidden" id="paso_bandera1" value="<?php 
            echo $bandera;
            ?>
" />
    <input name="recibo" type="hidden" id="recibo" value="<?php 
            echo $nCliente = $_POST['numeroE'];
            ?>
" />
    <input name="nCliente" type="hidden" id="nCliente" value="<?php 
            echo $nCliente;
            ?>
" />
    <input name="almacen" type="hidden" id="almacen" value="<?php 
            echo $ALMACEN;
            ?>
" /><?php 
            //echo "$".number_format($TOTAL,2);
            ?>
  </p>
  <div align="center">
    <p>&nbsp;</p>
    
    <table width="239" border="0" align="left" class="style12">
      <tr>
        <td width="139" height="23" bgcolor="#FFCCFF" class="style12">Medicamentos</td>
        <td width="90" bgcolor="#FFCCFF" class="style12"><div align="right"><?php 
            echo $Tmedicamentos;
            ?>
 </div></td>
      </tr>
      <tr>
        <td height="23" class="style12">Material Quir&uacute;rgico </td>
        <td class="style12"><div align="right"><?php 
            echo $TPAT;
            ?>
 </div></td>
      </tr>
      <tr bgcolor="#FFCCFF">
        <td height="23" class="style12">Servicios Hospitalarios </td>
        <td class="style12"><div align="right"><?php 
            echo "\$" . number_format($servicios[0], 2);
            ?>
 </div></td>
      </tr>
      <tr>
        <td height="23" class="style12">IVA</td>
        <td class="style12"><div align="right">
            <?php 
            $iva = new acumulados();
            $iva = $iva->ivaAcumulado($basedatos, $usuario, $numeroE, $nCuenta);
            echo "\$" . number_format($iva, 2);
            ?>
        </div></td>
      </tr>
      <tr bgcolor="#FFCCFF">
        <td height="23" class="style12">Total Cargos </td>
        <td class="style12"><div align="right">
            <?php 
            $totalAcumulado = new acumulados();
            echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), 2);
            ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
	
	
	
	
	
    <table width="239" border="0" align="center" class="style12">
      <tr bgcolor="#FFCCFF">
        <td width="141" height="23" bgcolor="#FFCCFF" class="style12"><span class="style7">Total Abonos</span></td>
        <td width="88" class="style12">
          <div align="right">
            <?php 
            $abonos = new acumulados();
            echo "\$" . number_format($abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), 2);
            ?>
        </div></td>
      </tr>
      <tr>
        <td height="23" class="style12">Saldo Actual </td>
        <td class="style12"><div align="right">
            <?php 
            $totalCargos = new acumulados();
            $totalCargos = $totalCargos->total($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), $numeroE1, $nCuenta1);
            echo "\$" . number_format($totalCargos, 2);
            ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
  </div>
  <p>&nbsp;</p>
</form>
<?php 
        }
        ?>
<p align="center">&nbsp;</p>
<?php 
        if ($_POST['banderaFecha']) {
            ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
        }
        ?>
</body>
</html>
<?php 
    }
    public function subCuenta($bali, $tipoCliente, $TITULO, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        if (!$bali) {
            $bali = $_GET['almacenFuente'];
        }
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['escoje']) {
            $keyCAP = $_POST['keyCAP'];
            $solicita = $_POST['solicita'];
            $solicita1 = $_POST['solicita1'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                $sSQL34 = "Select statusFactura From cargosCuentaPaciente WHERE keyCAP='" . $solicita[$i] . "'  ";
                $result34 = mysql_db_query($basedatos, $sSQL34);
                $myrow34 = mysql_fetch_array($result34);
                if ($solicita[$i]) {
                    if ($myrow34['statusFactura'] == 'standby') {
                        $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='request'\r\nwhere\r\nkeyCAP='" . $solicita[$i] . "' \r\n";
                    }
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
            //cierra for
        }
        //cierra actualizar
        if ($_POST['quitar']) {
            $keyCAP = $_POST['keyCAP'];
            $solicita1 = $_POST['solicita1'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                $sSQL34 = "Select statusFactura From cargosCuentaPaciente WHERE keyCAP='" . $solicita1[$i] . "'  ";
                $result34 = mysql_db_query($basedatos, $sSQL34);
                $myrow34 = mysql_fetch_array($result34);
                if ($solicita1[$i]) {
                    if ($myrow34['statusFactura'] == 'request') {
                        $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusFactura='standby'\r\nwhere\r\nkeyCAP='" . $solicita1[$i] . "' \r\n";
                    }
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
            //cierra for
        }
        //cierra quitar
        ?>




<?php 
        if ($_POST['facturar']) {
            if ($_POST['cantidadSolicitada']) {
                if ($_POST['cantidadSolicitada'] <= $_POST['cantidadActual']) {
                    $porcentaje = $_POST['cantidadSolicitada'] / $_POST['cantidadActual'];
                    $agrega = "INSERT INTO cargosFacturados (nt, cantidadFacturada,porcentaje,usuario,fecha,tipoCliente,seguro) values('" . $_GET['nT'] . "','" . $_POST['cantidadSolicitada'] . "','" . $porcentaje . "','" . $usuario . "','" . $fecha . "','" . $_GET['tipoCliente'] . "','" . $myrow3['seguro'] . "')";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                    ?>

<script>
javascript:ventanaSecundaria6('<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/cargos/applyInvoice.php?nT=<?php 
                    echo $nT;
                    ?>
&tipoFacturacion=<?php 
                    echo $tipoFacturacion;
                    ?>
&tipoCliente=<?php 
                    echo $_POST['tipoCliente'];
                    ?>
&porcentaje=<?php 
                    echo $porcentaje;
                    ?>
');
</script>



<?php 
                    /* <script>
                    javascript:ventanaSecundaria6('/sima/cargos/applyInvoice.php?nT=<?php echo $nT;?>&tipoFacturacion=<?php echo $tipoFacturacion;?>&tipoCliente=<?php echo $_POST['tipoCliente'];?>&porcentaje=<?php echo $porcentaje;?>');
                    </script> */
                } else {
                    $leyenda = 'La cantidad no debe ser mayor a la q existe!';
                }
            } else {
                $leyenda = 'Escribe la cantidad!';
            }
        }
        ?>





<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style72 {font-size: 10px}
.style72 {font-size: 10px}
.style1 {color: #FF0000}
.style73 {color: #FF0000}
.style73 {color: #FF0000;font-size: 9px}
.style74 {color: #FF0000}
.style74 {color: #FF0000;font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
.style1 {color: #FF0000;font-size: 9px}
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>




<BODY  >
<h1 align="center"><?php 
        echo $TITULO;
        ?>
</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="549" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
          <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
          <label> </label>
          <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
  </table>
  
  <p>&nbsp;</p>
  <p align="center">
    <label></label>
	
  </p>
  
  <?php 
        $sSQL341 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE nT='" . $_GET['nT'] . "'  ";
        $result341 = mysql_db_query($basedatos, $sSQL341);
        $myrow341 = mysql_fetch_array($result341);
        ?>
  <p align="center">&nbsp;</p>
  <table width="669" border="0" align="center">
    <tr>
      <th width="54" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">#MOV </span></div></th>
      <th width="87" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="246" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="56" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Cant</span></div></th>
      <th width="53" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span></div></th>
      <th width="85" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span>Facturado</div></th>
      <th width="34" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Escojer </span></div></th>
      <th width="20" bgcolor="#660066" class="style14" scope="col"><div align="left"></div></th>
    </tr>
	
      <?php 
        //traigo agregados
        if ($tipoCliente == 'aseguradora') {
            $sSQL81 = "\r\nSELECT \r\n* FROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\nand\r\nstatus!='transaccion'\r\nand \r\nstatusTraslado='trasladado'\r\nand\r\ntipoCliente='" . $tipoCliente . "'\r\n\r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
        } else {
            $sSQL81 = "\r\nSELECT \r\n* FROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\nand\r\nstatus!='transaccion'\r\n\r\n\r\n\r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
        }
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            $art = $myrow81['codProcedimiento'];
            $codigo = $proc = $myrow81['codProcedimiento'];
            $keyCAP = $myrow81['keyCAP'];
            ?>
	
	
	
	
    <tr>
<td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
"><?php 
            echo $myrow81['keyCAP'];
            ?>
</span> 
  <label>
  <input name="keyCAP[]" type="hidden" id="keyCAP[]" value="<?php 
            echo $keyCAP;
            ?>
"  />
  </label>
</div></td>





      <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
      <?php 
            echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
            ?>
</span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style12"><span class="style7">
        <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
            if ($myrow81['status'] != 'transaccion') {
                $nombreMed = new nombreMedico();
                echo " " . $myrow81['descripcion'] . $nombreMed->nombreMed($medico, $basedatos);
            }
            ?>
        </span></span>        <span class="style12">
          
          <?php 
            if ($myrow81['gpoProducto']) {
                echo '[' . $myrow81['gpoProducto'] . ']';
            }
            ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
        <?php 
            if ($_POST['tipoVista'] == 'Agrupado') {
                echo $cantidad = $myrow14['cantidad2'];
            } else {
                echo $cantidad = $myrow81['cantidad'];
            }
            ?>
      </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="left"><span class="<?php 
            echo $estilo;
            ?>
">
        <?php 
            if ($myrow81['cargosHospitalarios']) {
                $tipoTransaccion = $myrow81['tipoTransaccion'];
                $sSQL6 = "\r\n\tSELECT \r\nvariable\r\nFROM\r\ncatTTCaja\r\nWHERE \r\ncodigoTT = '" . $tipoTransaccion . "'\r\nand\r\nvariable='si'\r\n";
                $result6 = mysql_db_query($basedatos, $sSQL6);
                $myrow6 = mysql_fetch_array($result6);
                if ($myrow6['variable']) {
                    if ($myrow81['cargosHospitalarios'] == 'si') {
                        $banderaPM = new acumulados();
                        $precioVentaC = $banderaPM->banderaPorcentajeMedicamentos($entidad, $basedatos, $usuario, $numeroE, $nCuenta);
                        $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                    } else {
                        $cargosAseguradora = new acumulados();
                        $precioVentaC = $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta);
                        $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                    }
                    //Actualiza
                    $q1 = "UPDATE cargosCuentaPaciente set \r\nprecioVenta='" . $precioVentaC . "'\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'";
                    //mysql_db_query($basedatos,$q1);
                    echo mysql_error();
                }
            }
            ?>
        <span class="style12"><span class="style7">
      
          <?php 
            $cantidadActual[0] += $myrow81['precioVenta'] * $myrow81['cantidad'] + $myrow81['iva'] * $myrow81['cantidad'];
            echo "\$" . number_format($cantidadActual[0], 2);
            ?>
          
        </span></span> 
		
		</span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $estilo;
            ?>
">
	  </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $estilo;
            ?>
">
	  
	  <?php 
            if ($myrow81['statusFactura'] == 'standby') {
                ?>
	  <input name="solicita[]" type="checkbox" id="solicita[]" value="<?php 
                echo $keyCAP;
                ?>
" />
	  <?php 
            }
            ?>
	  </td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $estilo;
            ?>
">
	
        <div align="left">
          <label>
		  <?php 
            if ($myrow81['statusFactura'] == 'request') {
                $b += 1;
                ?>
          <input name="solicita1[]" type="checkbox" id="solicita1[]" value="<?php 
                echo $keyCAP;
                ?>
" />
		  <?php 
            }
            ?>
          </label>
        </div></td>
	</tr>
 
	
	
    <?php 
        }
        ?>
  </table>


		  <table width="671" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr>
              <th width="92" scope="col">&nbsp;</th>
              <th width="92" scope="col">&nbsp;</th>
              <th width="92" scope="col">&nbsp;</th>
              <th width="170" scope="col">&nbsp;</th>
              <th width="57" scope="col">&nbsp;</th>
              <th width="84" scope="col"><div align="left"><span class="style71">
                <?php 
        echo "\$" . number_format($myrow341['cantidadF'], 2);
        ?>
              </span></div></th>
              <th width="37" scope="col">&nbsp;</th>
              <th width="22" scope="col">&nbsp;</th>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
		  <p>&nbsp;</p>
		  <table width="53%" border="3" align="center" cellpadding="1" cellspacing="1" class="style71">
            <tr>
              <th width="18%" scope="col"><span class="style72">Cantidad</span></th>
              <th width="23%" scope="col">
<input name="cantidadSolicitada" type="text" class="style71" id="cantidadSolicitada" value="<?php 
        echo $cantidadActual[0];
        ?>
"></th>
              <th width="59%" scope="col"> <span class="style74"><blink><?php 
        echo $leyenda;
        ?>
</blink></span></th>
            </tr>
          </table>
		  <p align="center">&nbsp;		  </p>
		  <p align="center">
		  <?php 
        if ($myrow341['cantidadF']) {
            echo 'Tienes disponible para facturar: ' . '$' . number_format(ltrim($cantidadActual[0]) - ltrim($myrow341['cantidadF']), 2);
            $cActual = number_format(ltrim($cantidadActual[0]) - ltrim($myrow341['cantidadF']), 2);
        } else {
            $cActual = $cantidadActual[0] + $cantidadIva[0];
        }
        ?>
		  &nbsp;</p>
		  <p align="center">
		    <label>
		    <input name="tipoCliente" type="hidden" id="tipoCliente" value="<?php 
        echo $_GET['tipoCliente'];
        ?>
" />
		    <input name="bandera" type="hidden" id="bandera" value="<?php 
        echo $a;
        ?>
">
		    <input name="escoje" type="submit" class="style7" id="escoje" value="Escoje" />
		    </label>
		    <input name="quitar" type="submit" class="style71" id="quitar" value="Quitar" />
		  </p>
		  <p align="center">
	
		  <?php 
        if ($b > 0) {
            ?>
		    <input name="facturar" type="submit" class="style71" id="nuevo" value="Solicitar Facturar" <?php 
            if (!$cActual) {
                echo 'disabled=""';
            }
            ?>
/>
			<?php 
        }
        ?>
			
<input name="cantidadActual" type="hidden" id="cantidadActual" value="<?php 
        echo $cActual;
        ?>
" />
		
		  </p>
</form>
<p align="center">&nbsp;</p>
</body>
</html>
<?php 
    }
    public function eCuenta($bali, $transacciones, $TITULO, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        if (!$bali) {
            $bali = $_GET['almacenFuente'];
        }
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['actualizar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                if ($aseguradora[$i]) {
                    $status = 'efectivo';
                    $keyCAP[] = $aseguradora[$i];
                } else {
                    $status = 'cxc';
                    $keyCAP[] = $particular[$i];
                }
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusAlta='" . $status . "',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
            //cierra for
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['cerrar'] and $cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $otros->otros($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) == NULL) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            //********************CIERRO STATUS CUENTA***********************
            $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusCuenta='cerrada'\r\n\r\n\r\nwhere\r\nnumeroE='" . $numeroE . "' \r\nand\r\nnCuenta='" . $nCuenta . "'\r\n\r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            //*********************************************
            //cierro cuenta
            $agrega = "UPDATE clientesInternos set \r\nstatus='cerrada',\r\nstatusCuenta='cerrada',\r\nusuarioCierre='" . $usuario . "',\r\nfechaCierre='" . $fecha1 . "',\r\nhoraCierre='" . $hora1 . "'\r\n\r\nwhere\r\nkeyClientesInternos='" . $_GET['nT'] . "' \r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            //cierro cuarto a sucio
            $agrega = "UPDATE cuartos set \r\nstatus='sucio',\r\nusuarioSalida='" . $usuario . "',\r\nfechaSalida='" . $fecha1 . "',\r\nhoraSalida='" . $hora1 . "'\r\n\r\nwhere\r\ncodigoCuarto='" . $cuarto . "' \r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            $leyenda = 'Se cerr� la cuenta';
            ?>

   
   
<?php 
        }
        if (!$_POST['tipoVista']) {
            $_POST['tipoVista'] = 'Detalle';
        }
        ?>

<?php 
        if ($_POST['imprimir']) {
            ?>
<script>
javascript:ventanaSecundaria2('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/cargos/imprimirCargosInternosCC.php?numeroE=<?php 
            echo $numeroE;
            ?>
&nCuenta=<?php 
            echo $nCuenta;
            ?>
&paciente=<?php 
            echo $_POST['paciente'];
            ?>
&numeroConfirmacion=<?php 
            echo $numeroConfirmacion;
            ?>
&hora1=<?php 
            echo $hora1;
            ?>
&keyClientesInternos=<?php 
            echo $myrow3['keyClientesInternos'];
            ?>
');
  <!--
window.opener.document.forms["form1"].submit();
self.close();
  // -->
</script>

<?php 
        }
        ?>
<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">



<head>
<?php 
        $showStyles = new muestraEstilos();
        $showStyles->styles();
        ?>
</head>



<BODY  >
<?php 
        //ventanasPrototype::links();
        ?>
<h1 align="center"><?php 
        echo $TITULO;
        ?>
</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="549" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="normal">
    <tr>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="normal" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="134" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <td class="normal">Compa&ntilde;&iacute;a: </td>
      <td class="normal"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF" class="normal">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="normal"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <td class="normal">Fecha</td>
      <td class="normal"><span class="normal">
        <label>
        <input type="checkbox" name="banderaFecha" value="checkbox" onClick="javascript:this.form.submit();" 
		<?php 
        if ($_POST['banderaFecha']) {
            echo 'checked="checked"';
        }
        ?>
		/>
        </label>
		
		
		<?php 
        if ($_POST['banderaFecha']) {
            ?>
        <input name="fecha" type="text" class="normal" id="campo_fecha"
	  value="<?php 
            if ($_POST['fecha']) {
                echo $_POST['fecha'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button" type="button" class="normal" id="lanzador" value="..." />
        Entre </label>
      <input name="fecha2" type="text" class="normal" id="campo_fecha1"
	  value="<?php 
            if ($_POST['fecha2']) {
                echo $_POST['fecha2'];
            } else {
                if ($myrow3['hoy']) {
                    echo $myrow3['hoy'];
                } else {
                    echo $fecha1;
                }
            }
            ?>
" size="9" readonly="" />
        <label>
        <input name="button2" type="button" class="normal" id="lanzador1" value="..." />
        <input name="show" type="submit" class="normal" id="show" value="&gt;" />
        
        <?php 
        } else {
            ?>
        <input name="fecha3" type="hidden" class="normal" id="fecha2" value="<?php 
            echo 'all';
            ?>
"/>
		<?php 
        }
        ?>
</label>
</span></td>
    </tr>
    <tr>
      <th class="normal" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="normal" scope="col"><div align="left">
          <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
          <label> </label>
          <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF" class="normal">Tipo de Vista: </td>
      <td bgcolor="#FFCCFF" class="normal"><label>
        <select name="tipoVista" class="normal" id="tipoVista" onChange="javascript:form1.submit();">
          <option>Escoje la Opci&oacute;n</option>
          <option
		  <?php 
        if ($_POST['tipoVista'] == 'Agrupado') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Agrupado">Agrupado</option>
          
		  
		  <option
		  <?php 
        if ($_POST['tipoVista'] == 'Detalle') {
            ?>
		  selected="selected"
		  <?php 
        }
        ?>
		   value="Detalle">Detalle</option>
        </select>
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  
  
  
  
  
  
  
  
  
  
  <?php 
        //compruebo el proceso de alta
        $sSQL32 = "Select * From procesoAlta WHERE (status='request' or status='cargado')\r\nand\r\nkeyClientesInternos='" . $_GET['nT'] . "'";
        $result32 = mysql_db_query($basedatos, $sSQL32);
        $myrow32 = mysql_fetch_array($result32);
        ?>
  
  
  
  <?php 
        if ($myrow32['numeroE']) {
            ?>
  <table width="471" border="0" align="center">
    <tr>
      <th width="420" height="15" bgcolor="#660066" scope="col"><div align="left"><span class="blanco">Departamento </span></div></th>
      <th width="58" bgcolor="#660066" scope="col"><div align="left"><span class="blanco">Fecha</span></div></th>
      <th width="76" bgcolor="#660066" scope="col"><div align="left"><span class="blanco">Hora</span></div></th>
      <th width="37" bgcolor="#660066" scope="col"><div align="left"><span class="blanco">Usuario</span></div></th>
      <th width="56" bgcolor="#660066" scope="col"><div align="left"><span class="blanco">Status </span></div></th>
    </tr>
    <tr>
      <?php 
            $sSQL = "Select * From almacenes WHERE entidad='" . $entidad . "'\r\n  and\r\naltaPaciente='si'\r\norder by descripcion ASC\r\n";
            if ($sSQL) {
                $result = mysql_db_query($basedatos, $sSQL);
                while ($myrow = mysql_fetch_array($result)) {
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = "";
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    $A = $myrow['almacen'];
                    $sSQL661 = "Select * From procesoAlta \r\nWHERE\r\nentidad='" . $entidad . "'\r\nand\r\nstatus='cargado'\r\nand\r\nalmacen='" . $A . "'\r\nand\r\nkeyClientesInternos='" . $_GET['nT'] . "'";
                    $result661 = mysql_db_query($basedatos, $sSQL661);
                    $myrow661 = mysql_fetch_array($result661);
                    ?>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><span class="style71"><?php 
                    if ($myrow661['status']) {
                        echo $myrow['descripcion'];
                    } else {
                        echo $myrow['descripcion'] . ' [No se ha completado el proceso de Cierre]';
                    }
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><span class="style71"><?php 
                    if ($myrow661['fecha']) {
                        echo cambia_a_normal($myrow661['fecha']);
                    }
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><span class="style71"><?php 
                    echo $myrow661['hora'];
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><span class="style71"><?php 
                    echo $myrow661['usuario'];
                    ?>
</span></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><span class="style71"><?php 
                    if (!$myrow661['status']) {
                        echo '<img src="' . CONSTANT_PATH_SIMA_RAIZ . '/imagenes/candado.png" alt="LA CUENTA ESTA EN REVISION" width="12" height="12" border="0">';
                    } else {
                        echo '<img src="' . CONSTANT_PATH_SIMA_RAIZ . '/imagenes/solicitado.png" alt="LA CUENTA ESTA EN REVISION" width="12" height="12" border="0">';
                    }
                    ?>
      <span class="normal"></span></span></td>
    </tr>
    <?php 
                }
            }
            ?>
  </table>
  <?php 
        }
        ?>
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  <p>
    <?php 
        if ($_POST['tipoVista']) {
            ?>
  </p>



  
  
    <table width="847" border="0" align="center">
    <tr>
     
      <th width="96" height="14" bgcolor="#660066" class="blanco" scope="col"><div align="left"><span class="blanco ">Fecha/Hora </span></div></th>
      <th width="300" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="21" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">Cant</span></div></th>
      <th width="55" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">P.U.</span></div></th>
      <th width="55" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">Importe</span></div></th>
      <th width="33" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">IVA</span></div></th>
      <th width="27" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">Status</span></div></th>
      <th width="47" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">D Solicita</span></div></th>
      <th width="52" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">D Cargo.</span></div></th>
      <th width="72" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">Tipo P </span></div></th>
      <th width="38" bgcolor="#660066"  scope="col"><div align="left"><span class="blanco ">N </span></div></th>
    </tr>
	
      <?php 
            //traigo agregados
            if ($_POST['tipoVista'] == 'Agrupado' and $_POST['banderaFecha']) {
                $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,gpoProducto,naturaleza,tipoTransaccion,porcentajeVariable,cargosHospitalarios,descripcion,status,almacen,statusDevolucion\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE keyClientesInternos='" . $_GET['nT'] . "'\r\n  \r\n  and\r\n(fecha1 between'" . $_POST['fecha'] . "' and '" . $_POST['fecha2'] . "')\r\n\r\n\r\n \r\n group by codProcedimiento \r\n order by fecha1,hora1 asc\r\n";
            } else {
                if ($_POST['tipoVista'] == 'Detalle' and $_POST['banderaFecha']) {
                    $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,gpoProducto,naturaleza,tipoTransaccion,porcentajeVariable,cargosHospitalarios,descripcion,status,almacen,statusDevolucion\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nkeyClientesInternos='" . $_GET['nT'] . "'\r\n \r\n and \r\n (fecha1 between '" . $_POST['fecha'] . "' AND '" . $_POST['fecha2'] . "')\r\n \r\n order by hora1 asc\r\n";
                } else {
                    if ($_POST['tipoVista'] == 'Agrupado' and !$_POST['banderaFecha']) {
                        $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,gpoProducto,naturaleza,tipoTransaccion,porcentajeVariable,cargosHospitalarios,descripcion,status,almacen,statusDevolucion\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nkeyClientesInternos='" . $_GET['nT'] . "'\r\n \r\n group by codProcedimiento \r\n order by fecha1,hora1 asc\r\n";
                    } else {
                        if ($_POST['tipoVista'] == 'Detalle' and !$_POST['banderaFecha']) {
                            $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,gpoProducto,naturaleza,tipoTransaccion,porcentajeVariable,cargosHospitalarios,descripcion,status,almacen,statusDevolucion\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nkeyClientesInternos='" . $_GET['nT'] . "'\r\nand \r\nstatus!='cancelado'\r\n \r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
                        }
                    }
                }
            }
            if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
                while ($myrow81 = mysql_fetch_array($result81)) {
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = "";
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    $a += '1';
                    $art = $myrow81['codProcedimiento'];
                    $codigo = $proc = $myrow81['codProcedimiento'];
                    $keyCAP = $myrow81['keyCAP'];
                    if ($_POST['tipoVista'] == 'Agrupado') {
                        $sSQL14 = "\r\nSELECT \r\nsum(cantidad) as cantidad2\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\ncodProcedimiento = '" . $proc . "' and  numeroE = '" . $numeroE . "'\r\n";
                        $result14 = mysql_db_query($basedatos, $sSQL14);
                        $myrow14 = mysql_fetch_array($result14);
                    }
                    $style = 'normal';
                    ?>
	
	
	
	
    <tr>






      <td height="21" bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><div align="left"><span class="<?php 
                    echo $estilo;
                    ?>
">
      <?php 
                    echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                    ?>
</span></div></td>
	

	
	
      <td bgcolor="<?php 
                    echo $color;
                    ?>
">
	  <div align="left">
	  
	  <span class="<?php 
                    echo $style;
                    ?>
">
        <?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                    if ($myrow81['status'] != 'transaccion') {
                        $nombreMed = new nombreMedico();
                        //echo " ".$myrow81['descripcion'].$nombreMed->nombreMed($myrow81['almacen'],$basedatos);
                    }
                    ?>
		
  
          
          <?php 
                    if ($myrow81['gpoProducto']) {
                        echo '[' . $myrow81['gpoProducto'] . ']';
                    }
                    ?>
       </span>	   </div></td>
	   
	   
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><div align="left">
        <?php 
                    if ($_POST['tipoVista'] == 'Agrupado') {
                        echo $cantidad = $myrow14['cantidad2'];
                    } else {
                        echo $cantidad = $myrow81['cantidad'];
                    }
                    ?>
     </div></td>
	  
	  
	  
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" ><?php 
                    if ($myrow81['naturaleza'] == 'C') {
                        echo '$' . number_format($myrow81['precioVenta'], 2);
                    } else {
                        echo '---';
                    }
                    ?>
</td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" ><div align="left"><span class="<?php 
                    echo $style;
                    ?>
">
        <?php 
                    if ($myrow81['cargosHospitalarios']) {
                        $tipoTransaccion = $myrow81['tipoTransaccion'];
                        $sSQL6 = "\r\n\tSELECT \r\nvariable\r\nFROM\r\ncatTTCaja\r\nWHERE \r\ncodigoTT = '" . $tipoTransaccion . "'\r\nand\r\nvariable='si'\r\n";
                        $result6 = mysql_db_query($basedatos, $sSQL6);
                        $myrow6 = mysql_fetch_array($result6);
                        if ($myrow6['variable']) {
                            if ($myrow81['cargosHospitalarios'] == 'si') {
                                $banderaPM = new acumulados();
                                $precioVentaC = $banderaPM->banderaPorcentajeMedicamentos($entidad, $basedatos, $usuario, $numeroE, $nCuenta);
                                $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                            } else {
                                $cargosAseguradora = new acumulados();
                                $precioVentaC = $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta);
                                $precioVentaC = porcentaje($precioVentaC, $myrow81['porcentajeVariable'], $a);
                            }
                            //Actualiza
                            $q1 = "UPDATE cargosCuentaPaciente set \r\nprecioVenta='" . $precioVentaC . "'\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'";
                            //mysql_db_query($basedatos,$q1);
                            echo mysql_error();
                        }
                    }
                    ?>
      
          
          <?php 
                    $importe = new acumulados();
                    echo $importe->importe($keyCAP, $basedatos);
                    ?>
          
     
		
		</span></div></td>
		
		
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" >
	  <div align="left">
	  <span class="<?php 
                    echo $style;
                    ?>
">
        <?php 
                    $mostrarIVA = new articulosDetalles();
                    echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
                    ?>
      </span></div></td>
	  
	  
	  
	  
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><div align="left">
        
        
        
    
          <?php 
                    $status = new acumulados();
                    echo $status->status($keyCAP, $basedatos, $usuario, $numeroE, $nCuenta);
                    ?>
        </div></td>
		
		
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><div align="left">
      <?php 
                    echo $myrow81['almacenSolicitante'];
                    ?>
</div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><div align="left"><?php 
                    echo $myrow81['almacenDestino'];
                    ?>
</div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
"><?php 
                    echo $myrow81['tipoCliente'];
                    ?>
</td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $style;
                    ?>
">
	
        <div align="left">
          <?php 
                    echo $myrow81['naturaleza'];
                    ?>
</div></td>
	</tr>
 
	
	
    <?php 
                }
                ?>
  </table>


  <p>&nbsp;</p>
          <p>
    <input name="recibo" type="hidden" id="recibo" value="<?php 
                echo $nCliente = $_POST['numeroE'];
                ?>
" />
    <input name="nCliente" type="hidden" id="nCliente" value="<?php 
                echo $nCliente;
                ?>
" />
    <input name="almacen" type="hidden" id="almacen" value="<?php 
                echo $ALMACEN;
                ?>
" />
  </p>
  <div align="center">
    <div align="left">
      <p>&nbsp;</p>
      
<?php 
                $mostrarCuadroGP = new cuadritoAcumuladoGPO();
                echo $mostrarCuadroGP->mostrarCuadrito($_POST['fecha'], $_POST['fecha2'], 'normal', $entidad, $numeroE, $nCuenta, $basedatos);
                ?>
        
	  <p>&nbsp;</p>
	  <p>&nbsp;</p>
    </div>
   
    
    <p>&nbsp;</p>
    <table width="239" border="0" align="center" class="normal">
      <tr>

	  
        <td width="141" height="23" class="normal">Total por Surtir (iva incluido ) </td>
        <td width="88" class="normal"><div align="right">
            <?php 
                $totalxSurtir = new acumulados();
                echo "\$" . number_format($totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta), 2);
                ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="239" border="0" align="left" class="normal">
      <tr>
        <td width="139" height="23" class="normal">IVA</td>
        <td width="90" class="normal"><div align="right">
            <?php 
                $iva = new acumulados();
                $iva = $iva->ivaAcumulado($basedatos, $usuario, $numeroE, $nCuenta);
                echo "\$" . number_format($iva, 2);
                ?>
        </div></td>
      </tr>
      <tr bgcolor="#FFCCFF">
        <td height="23" class="normal">Total Cargos </td>
        <td class="normal"><div align="right">
            <?php 
                $totalAcumulado = new acumulados();
                $cargoS = $totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta);
                echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta) + $coaseguro, 2);
                ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p align="left">&nbsp;</p>
    <table width="239" border="0" align="left"  >
      <tr bgcolor="#FFCCFF">
        <td width="141" height="23" class="normal"><span class="normal">Total Abonos</span></td>
        <td width="88" class="normal">
		<div align="right">
		<?php 
                $abonos = new acumulados();
                $abonoS = $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta);
                echo "\$" . number_format($abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), 2);
                ?>
          </div>	    </td>
      </tr>
      <tr>
        <td height="23" class="normal">Saldo Actual </td>
        <td class="normal"><div align="right">
        <?php 
                $totalCargos = new acumulados();
                $totalCargos = $totalCargos->total($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), $numeroE1, $nCuenta1);
                if ($abonoS < 0) {
                    $abonoS *= -1;
                }
                $STotal = $cargoS - $abonoS;
                echo "\$" . number_format($cargoS - $abonoS, 2);
                /* if(!$STotal and eregi('-',$STotal)){
                		echo 'step';
                		} */
                /* 	if(($cargoS-$abonoS>0){
                		echo "$".number_format($cargoS-$abonoS,2);
                		} else {
                		echo "$".number_format(($cargoS-$abonoS)*-1,2);
                		} */
                ?>
          </div></td>
      </tr>
    </table>

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	<?php 
                if ($myrow3['status'] != 'cerrada') {
                    ?>
	
	
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
	
	
    <table width="86%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th width="15%" scope="col">
		
		
		
		<table width="94" border="0" align="left">
          <tr bgcolor="#660066">
            <th class="blanco" scope="col">
			
			<span class="blanco">Particular<a href="#" onClick="javascript:ventanaSecundaria7('<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?numeroE=<?php 
                    echo $numeroE;
                    ?>
&amp;almacen=<?php 
                    echo $bali;
                    ?>
&amp;seguro=<?php 
                    echo $_POST['seguro'];
                    ?>
&amp;nCuenta=<?php 
                    echo $myrow3['keyClientesInternos'];
                    ?>
&amp;tipoCliente=<?php 
                    echo 'particular';
                    ?>
')"> </a></span></th>
          </tr>
          <tr>
            <th width="98" bgcolor="#660066" class="blanco" scope="col"><span class="blanco"> <span class="blanco">Total a pagar </span> </span></th>
          </tr>
          <tr>
            <td><div align="center"><span class="normal"> <span class="normal">
                <?php 
                    //echo "$".number_format($cargosParticulares->cargosParticulares($basedatos,$usuario,$numeroE,$nCuenta),2);
                    $cargosParticulares = new acumulados();
                    $T = $cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta);
                    // $T=round($T,$ase);
                    if ($T and $transacciones == 'si') {
                        ?>
                <a href="#" onClick="javascript:ventanaSecundaria7('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?almacenFuente=<?php 
                        echo $bali;
                        ?>
&numeroE=<?php 
                        echo $numeroE;
                        ?>
&almacen=<?php 
                        echo $bali;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&nCuenta=<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
&tipoCliente=<?php 
                        echo 'particular';
                        ?>
&tipoVenta=<?php 
                        echo 'interno';
                        ?>
&tipoMovimiento=<?php 
                        echo 'transaccion';
                        ?>
&tipoPago=Efectivo')">
                <?php 
                        echo "\$" . number_format($cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta), 2);
                        ?>
                </a>
                <?php 
                    } else {
                        echo "\$" . number_format($cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta), 2);
                    }
                    ?>
            </span></span></div></td>
          </tr>
        </table>
		
		
		
		</th>
        <th width="2%" scope="col">&nbsp;</th>
        <th width="15%" scope="col"><table width="94" border="0" align="center">
          <tr>
            <th bgcolor="#660066"  scope="col"><span class="blanco">Otros Clientes </span></th>
          </tr>
          <tr>
            <th width="88" bgcolor="#660066" scope="col"><span class="blanco">Total a pagar </span></th>
          </tr>
          <tr>
            <td><div align="center"><span class="normal">
                <?php 
                    $otros = new acumulados();
                    if ($otros->otros($basedatos, $usuario, $numeroE, $nCuenta) > 0) {
                        ?>
                <a href="#" onClick="javascript:ventanaSecundaria7('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?numeroE=<?php 
                        echo $numeroE;
                        ?>
&almacen=<?php 
                        echo $bali;
                        ?>
&almacenFuente=<?php 
                        echo $bali;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&nCuenta=<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
&tipoCliente=<?php 
                        echo 'otros';
                        ?>
&tipoVenta=<?php 
                        echo 'interno';
                        ?>
&tipoMovimiento=<?php 
                        echo 'transaccion';
                        ?>
')">
                <?php 
                        echo "\$" . number_format($otros->otros($basedatos, $usuario, $numeroE, $nCuenta), 2);
                        ?>
                </a>
                <?php 
                    } else {
                        echo "\$" . number_format($otros->otros($basedatos, $usuario, $numeroE, $nCuenta), 2);
                    }
                    ?>
            </span></div></td>
          </tr>
        </table></th>
        <th width="31%" scope="col">&nbsp;</th>
        <th width="2%" scope="col">&nbsp;</th>
        <th width="5%" scope="col">&nbsp;</th>
        <th width="16%" scope="col"><table width="94" border="0">
          <tr>
            <th bgcolor="#660066"  scope="col"><span class="blanco">D.Coaseguro </span></th>
          </tr>
          <tr>
            <th width="88" bgcolor="#660066"  scope="col"><span class="blanco">Total a pagar </span></th>
          </tr>
          <tr>
            <td><div align="center"><span class="normal">
                <?php 
                    $coaseguro = new acumulados();
                    if ($coaseguro->cargosCoaseguro($basedatos, $usuario, $numeroE, $nCuenta) > 0) {
                        ?>
                <a href="#" onClick="javascript:ventanaSecundaria7('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?numeroE=<?php 
                        echo $numeroE;
                        ?>
&almacen=<?php 
                        echo $bali;
                        ?>
&almacenFuente=<?php 
                        echo $bali;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&nCuenta=<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
&tipoCliente=<?php 
                        echo 'coaseguro';
                        ?>
&tipoVenta=<?php 
                        echo 'interno';
                        ?>
&tipoMovimiento=<?php 
                        echo 'transaccion';
                        ?>
')">
                <?php 
                        echo "\$" . number_format($coaseguro->cargosCoaseguro($basedatos, $usuario, $numeroE, $nCuenta), 2);
                        ?>
                </a>
                <?php 
                    } else {
                        echo "\$" . number_format($coaseguro->cargosCoaseguro($basedatos, $usuario, $numeroE, $nCuenta), 2);
                    }
                    ?>
            </span></div></td>
          </tr>
        </table></th>
        <th width="14%" scope="col"><table width="94" border="0" align="right">
          <tr>
            <th bgcolor="#660066"  scope="col"><span class="blanco"> Compa&ntilde;&iacute;a
                  <?php 
                    //echo "$".number_format($Tcargos,2);
                    ?>
                  <?php 
                    //echo "$".number_format( $Tabonos,2);
                    $t1 = $TOTAL + $Tiva;
                    ?>
                  <?php 
                    //echo "$".number_format($deposito[0],2);
                    //echo "Pago por Otros";
                    $t2 = $Tabonos;
                    ?>
            </span></th>
          </tr>
          <tr>
            <th width="172" bgcolor="#660066" class="blanco" scope="col">Saldo Cia. </th>
          </tr>
          <tr>
            <td><span class="normal">
              <?php 
                    $cargosAseguradora = new acumulados();
                    if ($cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) != null and $transacciones == 'si') {
                        ?>
              <a href="#" onClick="javascript:ventanaSecundaria7('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?numeroE=<?php 
                        echo $numeroE;
                        ?>
		&almacen=<?php 
                        echo $bali;
                        ?>
&almacenFuente=<?php 
                        echo $bali;
                        ?>
&seguro=<?php 
                        echo $_POST['seguro'];
                        ?>
&nCuenta=<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
&tipoCliente=<?php 
                        echo 'aseguradora';
                        ?>
&tipoVenta=<?php 
                        echo 'interno';
                        ?>
')">
              <?php 
                        echo "\$" . number_format($cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta), 2);
                        ?>
              </a>
              <?php 
                    } else {
                        echo "\$" . number_format($cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta), 2);
                    }
                    ?>
            </span> </td>
          </tr>
        </table></th>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <p>&nbsp;</p>
  </div>
  <?php 
                    if (($cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta) == NULL or $cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta) == 0) and ($totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta) == NULL or $totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta) == 0) and ($otros->otros($basedatos, $usuario, $numeroE, $nCuenta) == NULL or $otros->otros($basedatos, $usuario, $numeroE, $nCuenta) == 0) and ($cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) == NULL or $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) == 0)) {
                        ?>
  <p align="center">
    
	<?php 
                        if (!$myrow661['status']) {
                            ?>
	<input name="faltan" type="submit" class="normal" id="cerrar" value="Faltan Departamentos" disabled=""/>	
	<?php 
                        } else {
                            ?>
	<input name="cerrar" type="submit" class="normal" id="cerrar" value="Cerrar Cuenta" />
	<?php 
                        }
                        //cierra validaciones de proceso de cierre de departamentos
                        ?>
	
	
    <input name="keyClientesInternos" type="hidden" id="keyClientesInternos" value="<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
" />
  </p>
  <div align="center">
    <?php 
                    }
                    ?>
    
    <?php 
                } else {
                    echo "LA CUENTA DEL PACIENTE " . $myrow3['paciente'] . " ESTA CERRADA...";
                    ?>
    <input name="imprimir" type="submit" class="normal" id="imprimir" value="Imprimir" />
    <?php 
                }
                ?>
  </div>
</form>
<?php 
            }
            ?>
<p align="center">&nbsp;</p>
<?php 
            if ($_POST['banderaFecha']) {
                ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
            }
        }
        ?>
</body>
</html>
<?php 
    }
    public function facturaCoaseguro($tipoFacturacion, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' or keyClientesInternos='" . $_GET['nT1'] . "'";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        $seguro = $myrow3['seguro'];
        //***************aplicar pago**********************
        if ($_GET['facturar'] and $_GET['numFactura'] and $_GET['flag'] == 'standby') {
            $keyCAP = $_GET['keyCAP'];
            for ($i = 0; $i <= $_GET['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    //**********************
                    $sSQL31 = "Select statusFactura From cargosCuentaPaciente WHERE keyCAP = '" . $keyCAP[$i] . "'";
                    $result31 = mysql_db_query($basedatos, $sSQL31);
                    $myrow31 = mysql_fetch_array($result31);
                    //verifico q ya esta facturado
                    if ($myrow31['statusFactura'] == 'standby') {
                        $agrega = "UPDATE cargosCuentaPaciente set \r\nnumFactura='" . $_GET['numFactura'] . "',\r\nstatusFactura='cargado',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "'";
                        mysql_db_query($basedatos, $agrega);
                        echo mysql_error();
                        $leyenda = 'Se factur� con El n�mero de Factura es el ' . $_GET['numFactura'];
                    } else {
                        $leyenda = 'registros ya facturados!';
                    }
                }
            }
            echo $leyenda;
            /* echo '<script language="JavaScript" type="text/javascript">
              <!--
                opener.location.reload(true);
            self.close();
              // -->
            </script>'; */
            $flag = 'load';
        } else {
            $flag = 'standby';
        }
        if ($_GET['quitar']) {
            $keyCAP = $_GET['keyCAP1'];
            for ($i = 0; $i <= $_GET['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    //mysql_db_query($basedatos,$agrega);
                    echo mysql_error();
                }
            }
        }
        ?>













<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>




<BODY  >

<h1 align="center">FACTURACION</h1>
<form id="form1" name="form1" method="get" action="">
  <table width="413" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_GET['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th class="Estilo24" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
        <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
        <label> </label>
        <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
        <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"># de Factura </div></th>
      <th bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left">
        <label>

      <input name="numFactura" type="text" class="style7" id="numFactura" value="<?php 
        if ($_GET['numFactura']) {
            echo $_GET['numFactura'];
        }
        ?>
" <?php 
        if ($_GET['numFactura']) {
            echo 'disabled=""';
        }
        ?>
/>

        </label>
      </div></th>
    </tr>
  </table>
  <p>&nbsp;</p>



 

    


  <table width="597" border="0" align="center">
    <tr>
      <th width="62" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">#MOV </span></div></th>
      <th width="100" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="282" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="25" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Cant</span></div></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span></div></th>
      <th width="43" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">IVA</span></div></th>
    </tr>
	
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n \r\nand\r\nstatus='transaccion'\r\nand\r\nstatusFactura='solicita'\r\nand tipoCliente='coaseguro'\r\n\r\n\r\n order by hora1 asc\r\n";
        if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
            while ($myrow81 = mysql_fetch_array($result81)) {
                $tipoCliente = $myrow81['tipoCliente'];
                $a += '1';
                $art = $myrow81['codProcedimiento'];
                $codigo = $proc = $myrow81['codProcedimiento'];
                $keyCAP = $myrow81['keyCAP'];
                $keyCAP1[] = $myrow81['keyCAP'];
                $fecha1 = $myrow81['fecha1'];
                $fecha2 = $myrow81['fecha1'];
                $sSQL14 = "\r\nSELECT \r\nstatusFactura\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'\r\n\r\n";
                $result14 = mysql_db_query($basedatos, $sSQL14);
                $myrow14 = mysql_fetch_array($result14);
                //****
                $sSQL = "\r\nSELECT sum(precioVenta*cantidad) as precioVentas\r\nfrom \r\ncargosCuentaPaciente\r\nWHERE \r\ngpoProducto= '" . $myrow81['gpoProducto'] . "'\r\nand\r\nkeyCAP='" . $keyCAP . "'\r\n";
                $result = mysql_db_query($basedatos, $sSQL);
                $myrow = mysql_fetch_array($result);
                $sSQL31 = "Select statusFactura From cargosCuentaPaciente WHERE keyCAP = '" . $keyCAP . "'";
                $result31 = mysql_db_query($basedatos, $sSQL31);
                $myrow31 = mysql_fetch_array($result31);
                ?>
	
	
	
	
    <tr>


<td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow81['keyCAP'];
                ?>
</span>
  <input name="keyCAP[]" type="hidden" id="keyCAP[]" value="<?php 
                echo $myrow81['keyCAP'];
                ?>
" />
</div></td>





      <td height="21" bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
      <?php 
                echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                ?>
</span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><span class="style12"><span class="style7">
        <?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                ?>
        </span></span>        <span class="style12">
          
          <?php 
                if ($myrow81['gpoProducto']) {
                    echo '[' . $myrow81['gpoProducto'] . ']';
                }
                if ($myrow31['statusFactura'] == 'cargado') {
                    echo '<blink>' . '[REGISTRO FACTURADO] ' . '</blink>';
                }
                ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">

      </span><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow81['cantidad'];
                ?>
</span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
        
        <span class="style12"><span class="style7">
          	<?php 
                $cantidadRegistros += 1;
                $importes[0] += $myrow81['precioVenta'];
                echo "\$" . number_format($myrow81['precioVenta'], 2);
                $cantidadTransaccion[0] += $myrow81['precioVenta'];
                ?>
          
        </span></span> </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><span class="style71">
        <?php 
                $mostrarIVA = new articulosDetalles();
                echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
                $cantidadIVA[0] += $myrow81['iva'];
                ?>
      </span></td>
    </tr>
 
	
	
    <?php 
                $FECHA[$a] = $myrow81['fecha1'];
            }
            ?>
  </table>

  <p align="center">
    <?php 
            $sSQL74 = "SELECT SUM(precioVenta*cantidad) as acumuladoPrincipal\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE\r\n\r\n(numeroE='" . $numeroE . "' and nCuenta='" . $nCuenta . "')\r\n and  statusCargo='cargado'\r\n and\r\n tipoCliente='aseguradora'\r\n  ";
            $result74 = mysql_db_query($basedatos, $sSQL74);
            $myrow74 = mysql_fetch_array($result74);
            $porcentaje = $cantidadTransaccion[0] / $myrow74[0];
            ?>
<label>
      <input name="facturar" type="submit" class="style7" value="Facturar" <?php 
            if ($_GET['facturar'] or $myrow31['statusFactura'] == 'cargado') {
                echo 'disabled=""';
            }
            ?>
 />
    </label>
      <label>

	  
	  </label>
  </p>
  
  
   
  <?php 
            echo $myrow31['statusFactura'];
            if ($myrow31['statusFactura'] == 'solicita') {
                ?>
		
		
  
  <p align="center" class="style71">
<a href="#"  onClick="javascript:ventanaSecundaria('printInvoice.php?numeroE=<?php 
                echo $numeroE;
                ?>
&nCuenta=<?php 
                echo $nCuenta;
                ?>
&entidad=<?php 
                echo $entidad;
                ?>
&nT=<?php 
                echo $nT;
                ?>
&numFactura=<?php 
                echo $_GET['numFactura'];
                ?>
&porcentaje=<?php 
                echo $porcentaje;
                ?>
')">
	Imprimir Factura 
	</a>
   
   
       <---->  
	    <a href="#"  onClick="javascript:ventanaSecundaria('printDetailsInvoice.php?numeroE=<?php 
                echo $numeroE;
                ?>
&nCuenta=<?php 
                echo $nCuenta;
                ?>
&almacenSolicitante=<?php 
                echo $ALMACEN;
                ?>
&entidad=<?php 
                echo $entidad;
                ?>
&numFactura=<?php 
                echo $_GET['numFactura'];
                ?>
')">
   Imprimir Detalles 
   </a>
  </p>
<?php 
            }
            ?>
  
  
  
  <div align="center">
    <p align="left">
	

    <table width="384" border="0" align="left" cellpadding="1" cellspacing="1" class="style71">
      <tr>
        <th width="216" bgcolor="#FFCCFF" class="<?php 
            echo $estilo;
            ?>
" scope="col"><div align="left">Descripci&oacute;n</div></th>
        <th width="76" bgcolor="#FFCCFF" class="<?php 
            echo $estilo;
            ?>
" scope="col"><div align="left">Importe</div></th>
        <th width="78" bgcolor="#FFCCFF" class="<?php 
            echo $estilo;
            ?>
" scope="col"><div align="left">% Importe aPagar </div></th>
      </tr>
      <tr>
        <?php 
            $sSQL71 = "SELECT sum(precioVenta) as sumaAbonos\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE\r\n(numeroE='" . $numeroE . "' and nCuenta='" . $nCuenta . "')\r\nand\r\ntipoCobro='Efectivo'\r\nand\r\nstatus='transaccion'\r\nand\r\nnaturaleza='A'";
            $result71 = mysql_db_query($basedatos, $sSQL71);
            $myrow71 = mysql_fetch_array($result71);
            $sSQL = "\r\nSELECT codigoGP,descripcionGP FROM gpoProductos\r\nWHERE \r\nentidad='" . $entidad . "' \r\nand\r\nactivo='activo'\r\n";
            if ($result = mysql_db_query($basedatos, $sSQL)) {
                while ($myrow = mysql_fetch_array($result)) {
                    $codigo = $code = $myrow['codigo'];
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = "";
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    $C = $myrow['codigoGP'];
                    $sSQL7 = "SELECT SUM(precioVenta*cantidad) as acumulado,SUM(iva*cantidad) as sumaIVA\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE\r\ngpoProducto='" . $C . "'\r\nand\r\n\r\n\r\n(numeroE='" . $numeroE . "' and nCuenta='" . $nCuenta . "')\r\n and (status!='standby' and statusCargo!='standby'  AND status!='cancelado')\r\n and\r\n tipoCliente='aseguradora'\r\n  ";
                    $result7 = mysql_db_query($basedatos, $sSQL7);
                    $myrow7 = mysql_fetch_array($result7);
                    $sumarIVA[0] += $myrow7['sumaIVA'];
                    $acumulado[0] += $myrow7['acumulado'];
                    ?>
        <td  bgcolor="<?php 
                    echo $color;
                    ?>
" ><div align="left"><span class=""> <?php 
                    echo $myrow['descripcionGP'];
                    ?>
</span></div></td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $estilo;
                    ?>
"><?php 
                    echo "\$" . number_format($myrow7['acumulado'], 2);
                    ?>
</td>
        <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="<?php 
                    echo $estilo;
                    ?>
"><?php 
                    if ($myrow7[0]) {
                        //$porcentaje=$_GET['porcentaje'];
                        $importePorcentaje = $myrow7[0] * $porcentaje;
                        $importeP[0] += $importePorcentaje;
                        echo "\$" . number_format($importePorcentaje, 2);
                    } else {
                        echo '$' . '0.00';
                    }
                    ?>
          &nbsp;</td>
      </tr>
      <?php 
                }
            }
            ?>
    </table>
    �
    </p>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <table width="384" height="0" border="0" align="left" cellpadding="0" cellspacing="1" class="style71">
      <tr>
        <td bgcolor="#660066" class="style14"><span class="Estilo24">IVA (Acumulado) </span></td>
        <td bgcolor="#660066" class="style14"><?php 
            echo "\$" . number_format($sumarIVA[0], 2);
            ?>
 &nbsp;</td>
        <td bgcolor="#660066" class="style14"><?php 
            $sSQL74 = "SELECT SUM(iva*cantidad) as sumaIVA\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE\r\n(numeroE='" . $numeroE . "' and nCuenta='" . $nCuenta . "')\r\nand\r\nstatus!='transaccion'\r\n\r\n and (status!='standby' and statusCargo!='standby'  AND status!='cancelado')\r\n  ";
            $result74 = mysql_db_query($basedatos, $sSQL74);
            $myrow74 = mysql_fetch_array($result74);
            $sumaIVA = $myrow74['sumaIVA'] * $_GET['porcentaje'];
            echo "\$" . number_format($sumaIVA, 2);
            ?>
        </td>
      </tr>
      <tr>
        <td width="46%" bgcolor="#660066" class="style14"><div align="left">TOTALES</div></td>
        <td width="17%" bgcolor="#660066" class="style14"><?php 
            echo "\$" . number_format($acumulado[0] + $sumarIVA[0], 2);
            ?>
</td>
        <td width="16%" bgcolor="#660066" class="style14"><?php 
            echo "\$" . number_format($importeP[0] + $sumaIVA, 2);
            ?>
</td>
      </tr>
      <tr>
        <td class="style71"><?php 
            ?>
          &nbsp;</td>
        <td class="style71">&nbsp;</td>
        <td class="style71">&nbsp;</td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  </div>
  <?php 
            if ($myrow3['status'] != 'cerrada') {
                ?>
  <?php 
                $cargosParticulares = new acumulados();
                $totalxSurtir = new acumulados();
                $cargosAseguradora = new acumulados();
                $otros = new acumulados();
                if ($cargosParticulares->cargosParticulares($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $totalxSurtir->totalxSurtir($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $otros->otros($basedatos, $usuario, $numeroE, $nCuenta) == NULL and $cargosAseguradora->cargosAseguradora($basedatos, $usuario, $numeroE, $nCuenta) == NULL) {
                    ?>
  <?php 
                }
                ?>
  <?php 
            } else {
                echo "LA CUENTA DEL PACIENTE " . $myrow3['paciente'] . " ESTA CERRADA...";
            }
            ?>
   <input name="bandera" type="hidden" value="<?php 
            echo $a;
            ?>
" />
   <input name="flag" type="hidden" value="<?php 
            echo $flag;
            ?>
" />
   <input name="nT1" type="hidden" id="nT1" value="<?php 
            echo $_GET['nT'];
            ?>
" />
</form>
<?php 
        }
        ?>
<p align="center">&nbsp;</p>
<?php 
        if ($_GET['banderaFecha']) {
            ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
        }
        ?>
</body>
</html>
<?php 
    }
    public function consultasAnteriores($ventana, $TITULO, $numeroE, $basedatos)
    {
        ?>

<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana","width=900,height=600,scrollbars=YES") 
} 
</script> 
<style type="text/css">
<!--
.Estilo24 {font-size: 10px}
.style13 {font-size: 10px}
.style12 {font-size: 10px}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
-->
</style>
<p align="center"><?php 
        echo $TITULO;
        ?>
<a href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/movil/principal.php"><span class="style7">Regresar a Men&uacute;</span></a></p>
<form name="form1" method="post" action="">
  <table width="568" border="0" align="center">
      <tr>
        <th width="86" height="16" bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Fecha </span></div></th>
        <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Descripci&oacute;n</span></div></th>
        <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Depto.</span></div></th>
        <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">M&eacute;dico</span></div></th>
      </tr>
      <tr class="style7">
        <?php 
        $sSQL = "SELECT almacen,codProcedimiento,keyCAP,ruta,fecha1,hora1,medico\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nstatusEstudio='cargado'\r\nand\r\nnumeroE='" . $numeroE . "' \r\nand\r\nstatus!='transaccion'\r\nand\r\nstatusCargo='cargado' \r\nand\r\num='s'\r\nORDER BY fecha1,hora1 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;
                }
                $departamento = $myrow['almacen'];
                $numeroE = $myrow['numeroE'];
                $alma = $myrow['almacen'];
                $codigo = $myrow['codProcedimiento'];
                $keyCAP = $myrow['keyCAP'];
                $ruta = $myrow['ruta'];
                ?>
        <td height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"> <?php 
                echo $myrow['hora1'];
                ?>
 <?php 
                echo $myrow['fecha1'];
                ?>
 </span></td>
        <td width="298" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"> <span class="Estilo25">
          <?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($numeroE, $nCuenta, $codigo, $basedatos);
                ?>
        </span> </span></td>
        <td width="47" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
		<a href="javascript:ventanaSecundaria('mostrarDiagnosticos.php?campoDespliega=<?php 
                echo "nomSeguro";
                ?>
&amp;forma=<?php 
                echo "F";
                ?>
&amp;numeroExpediente=<?php 
                echo $myrow['numeroE'];
                ?>
&amp;seguro=<?php 
                echo $_POST['seguro'];
                ?>
')">
        <?php 
                $muestraReporte = new rutaReportes();
                $muestraReporte->sacoRuta($numeroE, $keyCAP, $departamento, $ruta, $basedatos);
                ?>
</a>
		</span></td>
        <td width="45" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"> <?php 
                echo $myrow['medico'];
                ?>
 </span></td>
    </tr>
      <?php 
            }
        }
        ?>
      <input name="numeroE" type="hidden" value="<?php 
        echo $numeroE;
        ?>
" />
  </table>
    <?php 
    }
Example #16
0
    public function eCuenta($tipoFacturacion, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        if (!$_GET['nT']) {
            $_GET['nT'] = $nT;
        }
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['escoje']) {
            $keyCAP = $_POST['keyCAP'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    $sql = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='solicita',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    mysql_db_query($basedatos, $sql);
                    echo mysql_error();
                }
            }
            $_GET['inactiva'] = 'activa';
        }
        if ($_GET['inactiva'] == 'inactiva') {
            $keyCAP = $_GET['keyCAP'];
            if ($keyCAP) {
                $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
                $_GET['inactiva'] == 'activa';
            }
        }
        ?>













<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style71 {font-size: 9px}
.style71 {font-size: 9px}
.style71 {font-size: 9px}
-->
</style>
<head>






<title></title>
<style type="text/css">
<!--
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
-->
</style>




<BODY  >

<h1 align="center">Solicitar servicios/art&iacute;culos Facturaci&oacute;n </h1>
<form id="form1" name="form1" method="post" action="">
  <table width="413" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $keyClientesInternos = $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <th class="Estilo24" scope="col"><div align="left"><strong>M&eacute;dico: </strong></div></th>
      <th class="Estilo24" scope="col"><div align="left">
          <label> <?php 
        echo $medico = $myrow3['medico'];
        ?>
 </label>
          <label> </label>
          <?php 
        $sSQL18 = "Select * From medicos WHERE numMedico ='" . $medico . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
  </table>
  <p align="center" class="style7"><em>(nota: Puedes escojer varios para el proceso de cierre) </em></p>



 

    


  <table width="764" height="0" border="0" align="center" class="style7">
    <tr>
      <th width="62" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">#MOV </span></div></th>
      <th width="100" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha/Hora </span></div></th>
      <th width="282" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="59" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Importe</span></div></th>
      <th width="43" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Facturado</span></div></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Standby</span></div></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Quitar</span></div></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Escojer</span></th>
      <th width="45" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Status</span></div></th>
    </tr>
	
<?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\n and\r\n status='transaccion'\r\n and\r\n naturaleza='A'\r\n \r\n order by hora1 asc\r\n";
        if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
            while ($myrow81 = mysql_fetch_array($result81)) {
                $a += '1';
                $art = $myrow81['codProcedimiento'];
                $codigo = $proc = $myrow81['codProcedimiento'];
                $keyCAP = $myrow81['keyCAP'];
                $sSQL14 = "\r\nSELECT \r\nstatusFactura\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'\r\n\r\n";
                $result14 = mysql_db_query($basedatos, $sSQL14);
                $myrow14 = mysql_fetch_array($result14);
                $statFactura[$a] = $myrow81['statusFactura'];
                if ($statFactura[$a] == 'solicita') {
                    $statFactura[$a] = 'solicita';
                } else {
                    if ($statFactura[$a] == 'standby') {
                        $statFactura[$a] = 'standby';
                    }
                }
                ?>
	

	
	
    <tr>
<td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow81['keyCAP'];
                ?>
</span></div></td>





      <td height="21" bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
      <?php 
                echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                ?>
</span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><span class="style12">
        <?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                ?>
        </span>        <span class="style12">
          
          <?php 
                if ($myrow81['gpoProducto']) {
                    echo '[' . $myrow81['gpoProducto'] . ']';
                }
                ?>
          
      </span> </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
">
        
        <span class="style12">
          
        <?php 
                if ($myrow81['naturaleza'] == 'A') {
                    $suma[0] = $myrow81['precioVenta'];
                    $sumaImporte += $suma[0];
                    echo "\$" . number_format($suma[0], 2);
                } else {
                    echo 'N/A';
                }
                ?>
        </span> </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
">
	    <?php 
                $sSQL341 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE nT='" . $_GET['nT'] . "' and tipoCliente='" . $myrow81['tipoCliente'] . "' ";
                $result341 = mysql_db_query($basedatos, $sSQL341);
                $myrow341 = mysql_fetch_array($result341);
                echo "\$" . number_format($myrow341[0], 2);
                $sumaFacturado += $myrow341[0];
                ?>
	  
	  &nbsp;</td>
     
	 
	  <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
">
	  <div align="center">
        <?php 
                if ($statFactura[$a] == 'standby') {
                    ?>
<input name="keyCAP[]" type="radio" id="keyCAP[]" value="<?php 
                    echo $myrow81['keyCAP'];
                    ?>
" checked="checked"  />
        <?php 
                } else {
                    echo '---';
                }
                ?>
      </div></td>
	  
	   
  
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
">
	  
	  <?php 
                if ($statFactura[$a] == 'solicita') {
                    $dork += 1;
                    ?>
	  <a href="<?php 
                    echo $_SERVER['PHP_SELF'];
                    ?>
?nT=<?php 
                    echo $_GET['nT'];
                    ?>
&keyCAP=<?php 
                    echo $myrow81['keyCAP'];
                    ?>
&seguro=<?php 
                    echo $_POST['seguro'];
                    ?>
&inactiva=<?php 
                    echo 'inactiva';
                    ?>
&tipoAlmacen=<?php 
                    echo $_POST['tipoAlmacen'];
                    ?>
&codigo=<?php 
                    echo $C;
                    ?>
"><img src="<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/imagenes/iconosSima/delete_icon.jpg" alt="Quitar" width="12" height="12" border="0" onClick="if(confirm('&iquest;Est&aacute;s seguro que deseas eliminar la solicitud de factura para este registro?') == false){return false;}" /></a>
	  <?php 
                } else {
                    echo '---';
                }
                ?>
	  </td>
	  
	  
	  
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><div align="center">
	  
	  <?php 
                $diferencia[0] = number_format(ltrim($myrow81['precioVenta']) - ltrim($myrow341[0]), 2);
                if ($diferencia[0] != '0.00') {
                    ?>
	  
	  
	  <?php 
                    if ($myrow81['tipoCliente'] == 'particular' and $statFactura[$a] == 'solicita') {
                        ?>
	  <a href="javascript:ventanaSecundaria7('<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/INGRESOS%20HLC/cxc/subCuentas.php?nRequisicion=<?php 
                        echo $requisicion;
                        ?>
&almacen=<?php 
                        echo $ALMACEN;
                        ?>
&nT=<?php 
                        echo $_GET['nT'];
                        ?>
&keyCAP=<?php 
                        echo $myrow81['keyCAP'];
                        ?>
&aseguradora=<?php 
                        echo $_GET['aseguradora'];
                        ?>
&entidad=<?php 
                        echo $entidad;
                        ?>
&particular=<?php 
                        echo $_GET['particular'];
                        ?>
&referido=<?php 
                        echo $_GET['referido'];
                        ?>
&gpoProducto=<?php 
                        echo $gpoProducto;
                        ?>
&tipoCliente=<?php 
                        echo $myrow81['tipoCliente'];
                        ?>
&codigo=<?php 
                        echo $C;
                        ?>
&almacenes=<?php 
                        echo $Cd;
                        ?>
')"><img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/agregar.gif" alt="Modificar Precios" width="12" height="12" border="0" /></a>
	  <?php 
                    } else {
                        if ($myrow81['tipoCliente'] == 'aseguradora' and $statFactura[$a] == 'solicita') {
                            ?>
	    <a href="" onClick="javascript:ventanaSecundaria6('applyInvoiceEnterprise.php?nT=<?php 
                            echo $keyClientesInternos;
                            ?>
&tipoFacturacion=<?php 
                            echo $tipoFacturacion;
                            ?>
')">
	  <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/agregar.gif" alt="Modificar Precios" width="12" height="12" border="0" /></a>
	  
	  
	  
	  <?php 
                        } else {
                            if ($myrow81['tipoCliente'] == 'coaseguro' and $statFactura[$a] == 'solicita') {
                                ?>
	    <a href="" onClick="javascript:ventanaSecundaria6('applyInvoiceCoaseguro.php?nT=<?php 
                                echo $keyClientesInternos;
                                ?>
&tipoFacturacion=<?php 
                                echo $tipoFacturacion;
                                ?>
')">
	  <img src="<?php 
                                echo CONSTANT_PATH_SIMA_RAIZ;
                                ?>
/imagenes/agregar.gif" alt="Modificar Precios" width="12" height="12" border="0" /></a>
	  <?php 
                            } else {
                                echo '---';
                            }
                        }
                    }
                    ?>
	  <?php 
                } else {
                    echo '---';
                }
                ?>
	  
	  </div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
">
        <div align="left">
          <?php 
                if ($statFactura[$a] == 'solicita') {
                    ?>
          
          <img src="<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/imagenes/letraS.jpg" alt="Solicita Factura" width="12" height="12" border="0" />
          
          <?php 
                } else {
                    if ($statFactura[$a] == 'cargado') {
                        ?>
          
          <img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/letraF.jpg" alt="Solicita Factura" width="12" height="12" border="0" />
          <?php 
                    } else {
                        echo '---';
                    }
                }
                ?>
          </div></td></tr>
 
	
	
    <?php 
            }
            ?>
  </table>

  <p>&nbsp;</p>
  <p align="center">
    <?php 
            if ($dork > 0) {
                $maguila = 1;
            } else {
                $maguila == NULL;
            }
            ?>
    <input name="recibo" type="hidden" id="recibo" value="<?php 
            echo $nCliente = $_POST['numeroE'];
            ?>
" />
    <input name="nCliente" type="hidden" id="nCliente" value="<?php 
            echo $nCliente;
            ?>
" />
    <input name="almacen" type="hidden" id="almacen" value="<?php 
            echo $ALMACEN;
            ?>
" /><?php 
            //echo "$".number_format($TOTAL,2);
            ?>

      <label>
      <input name="escoje" type="submit" class="style7" id="escoje" value="Escojer Elementos" />
      </label>
      <label></label>
    <label></label>
  </p>
 
<input name="bandera" type="hidden" value="<?php 
            echo $a;
            ?>
" />
</form>
<?php 
        }
        ?>
<p align="center">&nbsp;</p>
<?php 
        if ($_POST['banderaFecha']) {
            ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
        }
        ?>
</body>
</html>
<?php 
    }
    public function articulos($entidad, $almacen, $ID_EJERCICIOM, $dia, $fecha1, $hora1, $usuario, $numeroPaciente, $seguro, $credencial, $medico, $almacenSolicitante, $nCuenta, $tipoCargo, $almacenDestino, $tipoPaciente, $basedatos)
    {
        $ventana = 'cambiarPrecio.php';
        $UserType = new tipoUsuario();
        $UserType = $UserType->tipoDeUsuario($usuario, $basedatos, $ALMACEN);
        ?>


<script language=javascript> 
function ventanaSecundaria8 (URL){ 
   window.open(URL,"ventana8","width=400,height=200,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana","width=300,height=200,scrollbars=YES") 
} 
</script> 
<?php 
        $numeroE = $numeroPaciente;
        //aqui estoy
        if ($_POST['borrar'] and $_POST['quitar']) {
            //*****************************************************
            $quitar = $_POST['quitar'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($quitar[$i]) {
                    $sSQL = "SELECT \r\ncodProcedimiento,keyCAP,almacen,numeroE,nCuenta\r\nFROM cargosCuentaPaciente\r\nWHERE keyCAP ='" . $quitar[$i] . "'";
                    $result = mysql_db_query($basedatos, $sSQL);
                    $myrow = mysql_fetch_array($result);
                    $codigo = $myrow['codProcedimiento'];
                    $departamento = $myrow['almacen'];
                    $numeroPaciente = $numeroE = $myrow['numeroE'];
                    $nCuenta = $myrow['nCuenta'];
                    //********************************************
                    $agrega = "INSERT INTO articulosCancelados (\r\ncodigo,fecha,hora,usuario,entidad,departamento,numeroE,nCuenta,keyCAP\r\n) values (\r\n'" . $_GET['codigo3'] . "','" . $fecha1 . "','" . $hora1 . "',\r\n'" . $usuario . "','" . $entidad . "','" . $departamento . "','" . $numeroE . "','" . $nCuenta . "','" . $quitar[$i] . "')";
                    //mysql_db_query($basedatos,$agrega);
                    echo mysql_error();
                    $borrame = "DELETE FROM cargosCuentaPaciente WHERE keyCAP ='" . $quitar[$i] . "'";
                    //mysql_db_query($basedatos,$borrame);
                    echo mysql_error();
                }
            }
        }
        ?>
<!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; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style15 {color: #0000FF}
-->
</style>
</head>

<body>
<p align="center">
  <label></label><label>
  </label> 
  <span class="style15"><?php 
        echo $leyenda;
        ?>
</span></p>
<form id="form1" name="form1" method="post" action="" onSubmit="return valida(this);">
  <div align="center"><span class="Estilo24"><span class="style7">
    <input name="almacenCargo" type="hidden" id="almacenCargo" value="<?php 
        echo $_POST['almacen'];
        ?>
" />
    </span></span>
      <input name="nombrePaciente3" type="hidden" id="nombrePaciente3" value="<?php 
        echo $nombrePaciente1;
        ?>
" />
      <input name="medico1" type="hidden" id="medico1" value="<?php 
        echo $medico1;
        ?>
" />
      <input name="tipoSeguro1" type="hidden" id="tipoSeguro1" value="<?php 
        echo $seguro;
        ?>
" />
      <input name="almacenP1" type="hidden" id="almacenP1" value="<?php 
        echo $almacenPrincipal;
        ?>
" />
      <input name="numPoliza1" type="hidden" id="numPoliza1" value="<?php 
        echo $numPoliza;
        ?>
" />
      <input name="nCuenta1" type="hidden" id="nCuenta1" value="<?php 
        echo $nCuenta;
        ?>
" />
    <span class="style15"><?php 
        echo $leyenda;
        ?>
</span>
    <?php 
        $sSQL31 = "Select paciente From clientesInternos WHERE numeroE = '" . $numeroPaciente . "' and nCuenta='" . $nCuenta . "'";
        $result31 = mysql_db_query($basedatos, $sSQL31);
        $myrow31 = mysql_fetch_array($result31);
        $paciente = $myrow31['paciente'];
        ?>
    </div>
    <p align="center">
      <label><span class="Estilo24">Escoje el Art&iacute;culo</span> 
      <input name="articulo" type="text" class="Estilo24" id="articulo" size="60" />
      </label>
      <label>
       <input name="search" type="submit" class="Estilo24" id="search" value="&gt;" />
      </label>
    </p>
    <table width="601" border="0" align="center" class="style7">
	<tr bgcolor="#FFFFFF" class="style7">
	  <th scope="col">&nbsp;</th>
      <th scope="col"><div align="left">Paciente: </div></th>
      <th scope="col"><div align="left"><?php 
        echo $paciente;
        ?>
</div></th>
      <th scope="col">&nbsp;</th>
	  <th scope="col">&nbsp;</th>
	  <th scope="col">&nbsp;</th>
	  <th scope="col">&nbsp;</th>
    </tr>
      <tr>
        <th width="62" bgcolor="#660066" scope="col"><div align="left"><span class="style11"># Movto. </span></div></th>
<th width="98" height="19" bgcolor="#660066" scope="col"><div align="left"><span class="style11">Hora/Fecha</span></div></th>
        <th width="257" bgcolor="#660066" scope="col"><div align="left"><span class="style11">Descripci&oacute;n</span></div></th>
      

        <th width="51" bgcolor="#660066" scope="col"><div align="left"><span class="style11"> Solicita </span></div></th>
        <th width="47" bgcolor="#660066" scope="col"><div align="left"><span class="style11"> Destino </span></div></th>
        <th width="29" bgcolor="#660066" scope="col"><div align="left"><span class="style11">Cant</span></div></th>
        <th width="27" bgcolor="#660066" scope="col"><div align="left"><span class="style11">Status</span></div></th>
      </tr>
	  
	  
	 <?php 
        $sSQL31 = "Select * From clientesInternos WHERE numeroE = '" . $numeroPaciente . "' and nCuenta='" . $nCuenta . "' ";
        $result31 = mysql_db_query($basedatos, $sSQL31);
        $myrow31 = mysql_fetch_array($result31);
        $articulo = $_POST['articulo'];
        if ($myrow31['tipoPaciente'] == 'interno' or $myrow31['tipoPaciente'] == 'urgencias') {
            $sSQL = "SELECT \r\n*,cargosCuentaPaciente.laboratorioReferido as laboratorioR \r\nFROM cargosCuentaPaciente,articulos\r\nWHERE\r\n\r\narticulos.descripcion like '%{$articulo}%'\r\nand\r\ncargosCuentaPaciente.codProcedimiento=articulos.codigo\r\nAND\r\ncargosCuentaPaciente.numeroE='" . $numeroPaciente . "'\r\nand\r\ncargosCuentaPaciente.nCuenta='" . $nCuenta . "'\r\nand\r\n\r\n\r\ncargosCuentaPaciente.statusCargo='cargado'\r\nand\r\ncargosCuentaPaciente.status!='transaccion'\r\n\r\norder by fecha1,hora1 ASC\r\n\r\n";
        } else {
            $sSQL = "SELECT \r\n*\r\nFROM cargosCuentaPaciente\r\nWHERE\r\ncargosCuentaPaciente.numeroE='" . $numeroPaciente . "'\r\nand\r\ncargosCuentaPaciente.nCuenta='" . $nCuenta . "'\r\nAND\r\ncargosCuentaPaciente.statusCargo='cargado'\r\nand\r\n\r\n\r\ncargosCuentaPaciente.status!='transaccion'\r\nand\r\ncargosCuentaPaciente.um!='s'\r\norder by fecha1,hora1 ASC\r\n\r\n";
        }
        if ($articulo) {
            if ($numeroPaciente) {
                if ($result = mysql_db_query($basedatos, $sSQL)) {
                    while ($myrow = mysql_fetch_array($result)) {
                        $keyCAP = $myrow['keyCAP'];
                        $bandera += 1;
                        $gpoProducto = $myrow['gpoProducto'];
                        $codigo = $myrow['codProcedimiento'];
                        //traigo descuento
                        //cierro descuento
                        if ($col) {
                            $color = '#FFCCFF';
                            $col = '';
                        } else {
                            $color = '#FFFFFF';
                            $col = 1;
                        }
                        if ($myrow['status'] == 'cancelado') {
                            $color = '#FF0000';
                            $col = "";
                        }
                        $sSQL341 = "Select descripcion From articulos WHERE codigo='" . $myrow['codProcedimiento'] . "'";
                        $result341 = mysql_db_query($basedatos, $sSQL341);
                        $myrow341 = mysql_fetch_array($result341);
                        ?>

 <tr>
     <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><?php 
                        echo $myrow['keyCAP'];
                        ?>
</td>
        <td height="24" bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24">
          <label></label>

		 <?php 
                        if ($myrow['fecha1']) {
                            echo $myrow['hora1'] . " " . cambia_a_normal($myrow['fecha1']);
                        }
                        ?>
					
				
		  
		  
		  
		  
		  <input name="codigoArt[]" type="hidden" id="codigoArt[]" value="<?php 
                        echo $myrow['codProcedimiento'];
                        ?>
" />        </td>
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24">
	
			<?php 
                        $descripcion = new articulosDetalles();
                        $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                        if ($myrow['generico'] == 'si') {
                            ?>
					<blink>
		<img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/g.jpg" alt="MEDICAMENTO GENERICO..." width="12" height="12" border="0" />		</blink>
		<?php 
                        } else {
                            echo '';
                        }
                        ?>
		</td>
		
     
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><span class="Estilo28"><span class="Estilo27"><span class="Estilo29"><span class="Estilo26"><?php 
                        echo $myrow['almacenSolicitante'];
                        ?>
</span></span></span></span></td>
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><span class="Estilo27"><span class="Estilo26">
		
		<?php 
                        if ($myrow['laboratorioReferido'] == 'si') {
                            echo $myrow['laboratorioR'];
                        } else {
                            echo $myrow['almacenDestino'];
                        }
                        ?>
</span></span></td>
	
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><label><?php 
                        if ($myrow['cantidad']) {
                            echo $myrow['cantidad'];
                        } else {
                            echo "N/A";
                        }
                        ?>
</label></td>
        <td bgcolor="<?php 
                        echo $color;
                        ?>
" class="Estilo24"><label>
          <div align="center"><span class="">
		  
		  <?php 
                        if ($myrow['statusDevolucion'] == 'no') {
                            ?>
		  <a href="javascript:ventanaSecundaria8('ventanaAplicarDevolucion.php?keyCAP=<?php 
                            echo $keyCAP;
                            ?>
&;seguro=<?php 
                            echo $_GET['seguro'];
                            ?>
&medico=<?php 
                            echo $_GET['medico'];
                            ?>
&usuario=<?php 
                            echo $usuario;
                            ?>
')"><img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/iconosSima/active_icon.jpg" alt="" width="12" height="12" border="0" /></a> 
		  <?php 
                        } else {
                            ?>
		  <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/iconosSima/delete_icon.jpg" alt="" width="12" height="12" border="0" />
		  <?php 
                        }
                        ?>
		  </span>            </div>
        </label></td>
      </tr>
      <?php 
                    }
                }
                ?>
  </table>

    <div align="center">
      <?php 
            }
        }
        ?>
      <input name="gpoProducto" type="hidden" id="numPaciente2" value="<?php 
        echo $gpoProducto;
        ?>
" />
      <input name="numeroMedico1" type="hidden" id="numeroMedico1" value="<?php 
        echo $numeroMedico;
        ?>
" />
      <input name="nombreDelPaciente2" type="hidden" id="nombreDelPaciente2" value="<?php 
        echo $nombreDelPaciente;
        ?>
" />
      <input name="extension2" type="hidden" id="extension2" value="<?php 
        echo $extension;
        ?>
" />
      <input name="segu1" type="hidden" id="segu1" value="<?php 
        echo $segu;
        ?>
" />
      <input name="bandera" type="hidden" id="numPaciente22" value="<?php 
        echo $bandera;
        ?>
" />
  </div>
</form>
  <p></p>
  
  
</body>
</html>


<?php 
    }
Example #18
0
    public function eCuenta($tipoFacturacion, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=800,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 
  <script language=javascript> 
function ventanaSecundaria8 (URL){ 
   window.open(URL,"ventana8","width=500,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['aplicarFactura'] and is_numeric($_POST['folioFactura'])) {
            $keyCAP = $_POST['keyCAP'];
            $importe = $_POST['importe'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                $sSQL37 = "Select statusFactura From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
                $result37 = mysql_db_query($basedatos, $sSQL3);
                $myrow37 = mysql_fetch_array($result37);
                if ($myrow37['statusFactura'] != 'facturado' and $keyCAP[$i]) {
                    $sql = "UPDATE cargosFacturados set \r\n\r\nstatus='facturado'\r\nwhere\r\nstatus='standby'\r\nand\r\nnumFactura='" . $_POST['folioFactura'] . "'\r\nand\r\nnT='" . $keyCAP[$i] . "' and keyClientesInternos='" . $_POST['keyClientesInternos'] . "'\r\n";
                    mysql_db_query($basedatos, $sql);
                    echo mysql_error();
                    $sql = "UPDATE cargosCuentaPaciente set \r\nfolioFactura='" . $_POST['folioFactura'] . "',\r\nstatusFactura='facturado'\r\nwhere\r\nstatus='transaccion'\r\nand\r\nkeyCAP='" . $keyCAP[$i] . "' and folioVenta='" . $_GET['folioVenta'] . "'\r\n";
                    mysql_db_query($basedatos, $sql);
                    echo mysql_error();
                    //****************************************************
                    //compruebo si todavia sigue vigente la factura, si queda algo por facturar
                    $sSQL14 = "\r\nSELECT \r\n(cargosCuentaPaciente.precioVenta-sum(cantidadFacturada)) as cantidadF\r\nFROM\r\ncargosCuentaPaciente,cargosFacturados\r\nWHERE \r\ncargosCuentaPaciente.keyCAP='" . $keyCAP[$i] . "' and\r\ncargosCuentaPaciente.keyCAP=cargosFacturados.nT\r\nand\r\ncargosFacturados.numFactura='" . $_POST['folioFactura'] . "'\r\nand\r\ncargosFacturados.status='facturado'\r\n";
                    $result14 = mysql_db_query($basedatos, $sSQL14);
                    $myrow14 = mysql_fetch_array($result14);
                    if ($myrow3['statusFactura'] != 'facturado' and !$myrow14['cantidad'] and $_POST['disponible'] == $_POST['importe'] or $_POST['disponible'] and !$_POST['solicita']) {
                        //echo 'meto todo';
                        if ($_POST['disponible'] and !$_POST['solicita']) {
                            $_POST['importe'] = $_POST['disponible'];
                            $agrega = "INSERT INTO cargosFacturados (numFactura,cantidadFacturada,porcentaje,usuario,fecha,tipoCliente,seguro,nt,keyClientesInternos,status,statusImpresion) values('" . $_POST['folioFactura'] . "','" . $_POST['importe'] . "','" . $porcentaje . "','" . $usuario . "','" . $fecha1 . "','aseguradora','" . $myrow3['seguro'] . "','" . $keyCAP[$i] . "','" . $_POST['keyClientesInternos'] . "','facturado','standby')";
                            mysql_db_query($basedatos, $agrega);
                            echo mysql_error();
                        }
                    }
                    //cierra validacion del IF
                    //************************lo facturado == importe ***************************
                    $sSQL13 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE numFactura='" . $_POST['folioFactura'] . "' and\r\nnT='" . $keyCAP[$i] . "' and status='facturado'";
                    $result13 = mysql_db_query($basedatos, $sSQL13);
                    $myrow13 = mysql_fetch_array($result13);
                    if (round($myrow13['cantidadF'], 2) == $importe) {
                        $sql = "UPDATE clientesInternos set \r\nnumeroFactura='" . $_POST['folioFactura'] . "',\r\nstatusFactura='facturado'\r\nwhere\r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\n";
                        mysql_db_query($basedatos, $sql);
                        echo mysql_error();
                    }
                    //**************************************************************************
                    //******************************************************
                }
            }
            $_GET['inactiva'] = 'activa';
            $sqla = "UPDATE clientes set \r\nrfc='" . $_POST['rfc'] . "',\r\nrazonSocial='" . $_POST['razonSocial'] . "',\r\ncalle='" . $_POST['calle'] . "',\r\ncolonia='" . $_POST['colonia'] . "',\r\nciudad='" . $_POST['ciudad'] . "',\r\nestado='" . $_POST['estado'] . "',\r\ncp='" . $_POST['cp'] . "',\r\npais='" . $_POST['pais'] . "'\r\nwhere\r\nnumCliente='" . $myrow3['seguro'] . "'\r\n";
            mysql_db_query($basedatos, $sqla);
            echo mysql_error();
            ?>
 <script language="JavaScript" type="text/javascript">
javascript:ventanaSecundaria2('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/cargos/printDetailsInvoice.php?keyClientesInternos=<?php 
            echo $_POST['keyClientesInternos'];
            ?>
&folioFactura=<?php 
            echo $_POST['folioFactura'];
            ?>
&paciente=<?php 
            echo $_POST['paciente'];
            ?>
&usuario=<?php 
            echo $usuario;
            ?>
&hora1=<?php 
            echo $hora1;
            ?>
'); 
window.opener.document.forms["form1"].submit();
window.location = 'ctaTransferidas.php'
self.close();
</script> 
<?php 
        }
        if ($_POST['escoje'] and $_POST['escojer']) {
            $keyCAP = $_POST['escojer'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    $sql = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='request',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "',\r\nfolioFactura='" . $_POST['folioFactura'] . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    mysql_db_query($basedatos, $sql);
                    echo mysql_error();
                }
            }
        }
        if ($_POST['quitar2'] and $_POST['quitar']) {
            $keyCAP = $_POST['quitar'];
            for ($i = 0; $i <= $_GET['bandera']; $i++) {
                if ($keyCAP) {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\n\r\nstatusFactura='standby',\r\nusuarioSolicitudFactura='" . $usuario . "',\r\nfechaSolicitudFactura='" . $fecha1 . "',\r\nhoraSolicitudFactura='" . $hora1 . "',\r\nfolioFactura=''\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
        }
        ?>








<?php 
        $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        ?>
<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
<?php 
        $estilo = new muestraEstilos();
        $estilo->styles();
        ?>

<style type="text/css">
<!--
.Estilo1 {color: #FFFFFF;
          background:#000066;

}
 
-->
</style>

</head>

<BODY  >

<h1 align="center" class="titulos">Solicitar servicios/art&iacute;culos Facturaci&oacute;n </h1>
<form id="form1" name="form1" method="post" action="">
  <table width="413" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left">Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="blanco" scope="col"><div align="left"><?php 
        echo $keyClientesInternos = $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left"><strong>Paciente</strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="normal" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="normal">Folio de Venta</td>
      <td class="normal"><label><?php 
        echo $myrow3['folioVenta'];
        ?>
</label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <table width="697" border="3" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo1">
    <tr>
      <th class="blanco" scope="col"><div align="left">Fecha</div></th>
      <th class="blanco" scope="col"><div align="left">
          <?php 
        echo cambia_a_normal($myrow3['fecha1']);
        ?>
      </div></th>
      <th bgcolor="#660066" class="blanco"  scope="col"></th>
      <th  scope="col" class="blanco"></th>
      <th  scope="col"></th>
    </tr>
    <tr>
      <th class="blanco" scope="col"><div align="left"><strong>Paciente </strong></div></th>
      <th class="blanco" scope="col"><div align="left">
          <?php 
        $keyClientesInternos = $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <?php 
        echo $myrow3['paciente'];
        ?>
          <input name="numeroE2" type="hidden" class="Estilo24" id="numeroE2" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
      </div></th>
      <th bgcolor="#660066" class="blanco"  scope="col">&nbsp;</th>
      <th  scope="col" class="blanco"><div align="left">Compa&ntilde;&iacute;a</div></th>
      <th  scope="col"><div align="left"><span class="blanco">
          <?php 
        $traeSeguro = $myrow3['seguro'];
        ?>
          <?php 
        $sSQL455 = "Select clientePrincipal from clientes where entidad='" . $entidad . "' and numCliente='" . $myrow3['seguro'] . "'";
        $result455 = mysql_db_query($basedatos, $sSQL455);
        $myrow455 = mysql_fetch_array($result455);
        $sSQL455 = "Select * from clientes where entidad='" . $entidad . "' and numCliente='" . $myrow455['clientePrincipal'] . "'";
        $result455 = mysql_db_query($basedatos, $sSQL455);
        $myrow455 = mysql_fetch_array($result455);
        echo $myrow455['nomCliente'];
        ?>
          <input name="seguro" type="hidden" id="seguro" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </span></div></th>
    </tr>
    <tr>
      <th colspan="5" class="blanco" scope="col"> <div align="center"># Factura
        <input autocomplete="off" name="folioFactura" type="text" <?php 
        if ($_POST['folioFactura']) {
            echo 'class="normal"';
        }
        ?>
 id="folioFactura" value="<?php 
        echo $_POST['folioFactura'];
        ?>
"  />
        </div>
          <div align="left"></div>
        <div align="left"></div></th>
    </tr>
  </table>
  <p align="center" class="style7">&nbsp;</p>



 

    

<?php 
        if ($myrow3['statusFactura'] != 'facturado') {
            ?>
  <table width="880" height="0" border="0" align="center" class="style7">
    <tr>
      <th width="45" bgcolor="#660066" class="blanco" scope="col"><div align="left">#Folio </div></th>
      <th width="103" height="14" bgcolor="#660066" class="blanco" scope="col"><div align="left">Fecha/Hora </div></th>
      <th width="260" bgcolor="#660066" class="blanco" scope="col"><div align="left">Descripci&oacute;n/Concepto</div></th>
      <th width="69" bgcolor="#660066" class="blanco" scope="col"><div align="left">Importe</div></th>
      <th width="60" bgcolor="#660066" class="blanco" scope="col"><div align="left">Solicita</div></th>
      <th width="67" bgcolor="#660066" class="blanco" scope="col"><div align="left">Facturado</div></th>
      <th width="71" bgcolor="#660066" class="blanco" scope="col"><div align="left">Disponible</div></th>
      <th width="61" bgcolor="#660066" class="blanco" scope="col"><div align="left">Escojer</div></th>
      <th width="60" bgcolor="#660066" class="blanco" scope="col"><div align="left">Quitar</div></th>
      <th width="42" bgcolor="#660066" class="blanco" scope="col"><div align="left"></div></th>
    </tr>
	
<?php 
            //traigo agregados
            $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\n and\r\n naturaleza='A'\r\n\r\n order by hora1 asc\r\n";
            if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
                while ($myrow81 = mysql_fetch_array($result81)) {
                    $a += '1';
                    $art = $myrow81['codProcedimiento'];
                    $codigo = $proc = $myrow81['codProcedimiento'];
                    $keyCAP = $myrow81['keyCAP'];
                    $sSQL14 = "\r\nSELECT \r\nstatusFactura\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nkeyCAP='" . $keyCAP . "'\r\n\r\n\r\n";
                    $result14 = mysql_db_query($basedatos, $sSQL14);
                    $myrow14 = mysql_fetch_array($result14);
                    ?>
	

	
	
    <tr>
<td bgcolor="<?php 
                    echo $color;
                    ?>
" class="codigos"><div align="left"><?php 
                    echo $myrow81['keyCAP'];
                    ?>
  <input name="keyCAP[]" type="hidden" id="keyCAP" value="<?php 
                    echo $keyCAP;
                    ?>
" />
</div></td>

      <td height="21" bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><div align="left">
      <?php 
                    echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
                    ?>
</div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><div align="left">
        <?php 
                    $descripcion = new articulosDetalles();
                    $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                    ?>
                  
          <?php 
                    if ($myrow81['gpoProducto']) {
                        echo '[' . $myrow81['gpoProducto'] . ']';
                    }
                    ?>
          
 </div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><div align="left">
       

        <?php 
                    if ($myrow81['naturaleza'] == 'A') {
                        $suma[0] = $myrow81['precioVenta'];
                        $sumaImporte[0] += $suma[0];
                        echo "\$" . number_format($suma[0], 2);
                    } else {
                        echo 'N/A';
                    }
                    ?>

          
      </div></td>
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><?php 
                    $sSQL341 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE numFactura='" . $_POST['folioFactura'] . "' and\r\nnT='" . $myrow81['keyCAP'] . "' and status='standby'";
                    $result341 = mysql_db_query($basedatos, $sSQL341);
                    $myrow341 = mysql_fetch_array($result341);
                    $solicita[0] += $myrow341['cantidadF'];
                    echo "\$" . number_format($myrow341['cantidadF'], 2);
                    ?>
</td>
  

  

  
  
      <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal">
	  <?php 
                    $sSQL321 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE numFactura='" . $_POST['folioFactura'] . "' and\r\nnT='" . $myrow81['keyCAP'] . "' and status='facturado'";
                    $result321 = mysql_db_query($basedatos, $sSQL321);
                    $myrow321 = mysql_fetch_array($result321);
                    $myrow321['cantidadF'] = round($myrow321['cantidadF'], 2);
                    $facturado[0] += $suma[0] - $myrow321['cantidadF'];
                    echo "\$" . number_format($myrow321['cantidadF'], 2);
                    ?>
</td>
     
	 
	  <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><?php 
                    $disponible[0] += $suma[0] - $myrow321['cantidadF'];
                    echo "\$" . number_format($suma[0] - $myrow321['cantidadF'], 2);
                    ?>
</td>
	  <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal">
	  
	  
	 
	  
	  <div align="left">
	  <?php 
                    if ($myrow81['statusFactura'] == 'standby' and $myrow81['tipoCobro'] == 'Cuentas por Cobrar') {
                        ?>
        <input name="escojer[]" type="checkbox" id="escojer[]" value="<?php 
                        echo $myrow81['keyCAP'];
                        ?>
" />
		<?php 
                    } else {
                        echo $escojer = '---';
                    }
                    ?>
		
		
      </div>
	  
	 
	  </td>
	  
	  

	  <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal">
	
	 
	 
	    <div align="left">
		 <?php 
                    if ($myrow81['statusFactura'] == 'request') {
                        $quitar += 1;
                        ?>
          <input name="quitar[]" type="checkbox" id="quitar[]" value="<?php 
                        echo $myrow81['keyCAP'];
                        ?>
" />
		  	<?php 
                    } else {
                        echo $quitar = '---';
                    }
                    ?>
        </div>	
		
		</td>
		
		
		
	  <td bgcolor="<?php 
                    echo $color;
                    ?>
" class="normal"><div align="center">
	  
	 
	  <a href="javascript:ventanaSecundaria7('<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/INGRESOS%20HLC/cxc/subCuentasParticular.php?nRequisicion=<?php 
                    echo $requisicion;
                    ?>
&almacen=<?php 
                    echo $ALMACEN;
                    ?>
&nT=<?php 
                    echo $_GET['nT'];
                    ?>
&keyCAP=<?php 
                    echo $myrow81['keyCAP'];
                    ?>
&aseguradora=<?php 
                    echo $_GET['aseguradora'];
                    ?>
&entidad=<?php 
                    echo $entidad;
                    ?>
&particular=<?php 
                    echo $_GET['particular'];
                    ?>
&referido=<?php 
                    echo $_GET['referido'];
                    ?>
&gpoProducto=<?php 
                    echo $gpoProducto;
                    ?>
&tipoCliente=<?php 
                    echo $myrow81['tipoCliente'];
                    ?>
&codigo=<?php 
                    echo $C;
                    ?>
&almacenes=<?php 
                    echo $Cd;
                    ?>
')">
	  <label></label>
	  </a>
	  
	  
	 
	  
	  <?php 
                    $diferiencia = $suma[0] - $myrow341['cantidadF'];
                    if ($_POST['folioFactura'] and $diferiencia != '0' and $myrow81['statusFactura'] == 'request') {
                        ?>
      <a href="#" onClick="javascript:ventanaSecundaria8('ventanaCambiaImporte.php?keyCAP=<?php 
                        echo $myrow81['keyCAP'];
                        ?>
&seguro=<?php 
                        echo $myrow3['seguro'];
                        ?>
&folioFactura=<?php 
                        echo $_POST['folioFactura'];
                        ?>
&keyClientesInternos=<?php 
                        echo $myrow3['keyClientesInternos'];
                        ?>
')"><img src="<?php 
                        echo CONSTANT_PATH_SIMA_RAIZ;
                        ?>
/imagenes/modificascl.png" width="12" height="12" border="0" /></a>
      <?php 
                    }
                    ?>
</div></td>
      </tr>
 
	
	
    <?php 
                }
                ?>
  </table>
<?php 
            }
            ?>


  <p>
  <p>&nbsp;</p>
  <label>
    <div align="center">
      <div align="center">
	
	<input name="importe" type="hidden" class="style71" id="importe" value="<?php 
            echo $sumaImporte[0];
            ?>
" />
	<input name="disponible" type="hidden" class="style71" id="disponible" value="<?php 
            echo $disponible[0];
            ?>
" />
	<input name="solicita" type="hidden" class="style71" id="solicita" value="<?php 
            echo $solicita[0];
            ?>
" />
	<input name="facturado" type="hidden" class="style71" id="facturado" value="<?php 
            echo $facturado[0];
            ?>
" />
	
        <?php 
            if (!$myrow31['sumaFacturada']) {
                ?>
        <input name="escoje" type="submit" class="style71" id="escoje" value="Escojer Elementos" />
        <input name="quitar2" type="submit" class="style71" id="quitar" value="Quitar Elementos" />
          <?php 
            }
            ?>
		        
  </div>
  </label>
  <p align="center">
    <label>
	
	  
	<?php 
            $sSQL331 = "Select sum(cantidadFacturada) as cantidadF From cargosFacturados WHERE numFactura='" . $_POST['folioFactura'] . "' and\r\nnT='" . $myrow81['keyCAP'] . "' and status='standby'";
            $result331 = mysql_db_query($basedatos, $sSQL331);
            $myrow331 = mysql_fetch_array($result331);
            if (!$solicita[0] and $_POST['folioFactura']) {
                ?>
    <input name="aplicarFactura" type="submit" class="style7" id="aplicarFactura" value="Facturar" onClick="if(confirm('Estas seguro que deseas facturar <?php 
                echo "\$" . number_format($disponible[0], 2);
                ?>
 pesos?') == false){return false;}" />

<?php 
            } else {
                ?>
    <input name="aplicarFactura" type="submit" class="style7" id="aplicarFactura" value="Facturar" onClick="if(confirm('Estas seguro que deseas facturar <?php 
                echo "\$" . number_format($solicita[0], 2);
                ?>
 pesos?') == false){return false;}" />
	<?php 
            }
            ?>
	
	

    </label>
  </p>
 
<input name="bandera" type="hidden" value="<?php 
            echo $a;
            ?>
" />

<input name="keyClientesInternos" type="hidden" value="<?php 
            echo $myrow3['keyClientesInternos'];
            ?>
" />
</form>
<?php 
        }
        ?>

	<?php 
        if ($myrow3['statusFactura'] == 'facturado') {
            echo 'Registros ya Facturados';
        }
        ?>

<p align="center">&nbsp;</p>
<?php 
        if ($_POST['banderaFecha']) {
            ?>
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador"     // el id del bot�n que lanzar� el calendario 
}); 
</script> 
  <script type="text/javascript"> 
   Calendar.setup({ 
    inputField     :    "campo_fecha1",     // id del campo de texto 
     ifFormat     :     "%Y-%m-%d",     // formato de la fecha que se escriba en el campo de texto 
     button     :    "lanzador1"     // el id del bot�n que lanzar� el calendario 
}); 
</script>
<?php 
        }
        ?>
</body>
</html>
<?php 
    }
    public function solicitaArticulos($entidad, $almacenSolicitante, $ID_EJERCICIOM, $dia, $fecha1, $hora1, $usuario, $numeroPaciente, $seguro, $credencial, $medico, $almacenSolicitante, $nCuenta, $tipoCargo, $almacenDestino, $tipoPaciente, $basedatos)
    {
        $sSQL6 = "SELECT almacen\r\nFROM\r\nalmacenes\r\nWHERE\r\n\r\nentidad='" . $entidad . "' \r\nand centroDistribucion='si'\r\n  ";
        $result6 = mysql_db_query($basedatos, $sSQL6);
        $myrow6 = mysql_fetch_array($result6);
        $almacenPrincipal = $myrow6['almacen'];
        //necesitamos definirlo desde el cat�logo de almacenes
        ?>


<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=420,height=350,scrollbars=YES") 
} 
</script> 

<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 
  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></script> 
  
<script language="javascript" type="text/javascript">   

function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.almacen.value) == false ) {   
                alert("Por Favor, escoje el departamento!")   
                return false   
        } else if( vacio(F.tipoUM.value) == false ) {   
                alert("Por Favor, escoje si es un servicio o si son art�culos lo que vas a cargar!")   
                return false   
        } else if( vacio(F.nomArticulo.value) == false ) {   
                alert("Por Favor, escoje el articulo o servicio para solicitar!")   
                return false   
        }            
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>


<?php 
        if ($_POST['entidades']) {
            $entidad = $_POST['entidades'];
        } else {
            $_POST['entidades'] = $entidad;
        }
        if (!$_POST['buscar'] and $_POST['insertarArticulos']) {
            if ($_POST['insertarArticulos']) {
                $numeroE = $numeroPaciente;
                $keyClientesInternos = $_GET['keyClientesInternos'];
                $nCuenta = $nCuenta;
                $convenios = new validaConvenios();
                $global = new validaConvenios();
                $tipoConvenioS = new validaConvenios();
                $traeConvenio = new validaConvenios();
                $vConvenio = new validaConvenios();
                $ivaAseguradora = new ivaCierre();
                $ivaParticular = new ivaCierre();
                $tipoVenta = new tipoVentaArticulo();
                $tipoVentaIVA = new tipoVentaArticulo();
                $ventaPieza = new tipoVentaArticulo();
                $verificaSaldos1 = new verificaSeguro1();
                $descripcion = new articulosDetalles();
                $random = rand(10000, 10000000000000.0);
                $porcentajeIVA = new articulosDetalles();
                $validaJubilados = new validaConvenios();
                $porcentajeJubilados = new validaConvenios();
                $grupoProducto = new articulosDetalles();
                $descripcionGrupoProducto = new articulosDetalles();
                $beneficenciaT6 = new articulosDetalles();
                if ($_POST['almacenDestino1']) {
                    $almacen = $_POST['almacenDestino1'];
                } else {
                    $almacen = $_POST['almacenDestino'];
                }
                $traeSeguro = new verificaSeguro1();
                $verificaSaldosInternos = new verificaSeguro1();
                //*************************PRESIONO INSERTAR ARTICULOS******************
                $aux = traeAuxiliar::auxiliar($fecha1, $hora1, $almacen, $basedatos, $ID_EJERCICIOM, $db_conn);
                $codigo = $_POST['codigoArt'];
                $cantidad = $_POST['cantidad'];
                $agregarA = $_POST['agregarA'];
                $codigoBeta = $_POST['codigoBeta'];
                $laboratorioReferido = $_POST['laboratorioReferido'];
                for ($i = 0; $i <= $_POST['bandera']; $i++) {
                    //********************FOR
                    $b += 1;
                    $codigo[$i] = $codigoBeta[$i];
                    $gpoProducto = trim($grupoProducto->grupoProducto($entidad, $codigo[$i], $basedatos));
                    $descripcionGP = $descripcionGrupoProducto->descripcionGrupoProducto($entidad, $gpoProducto, $basedatos);
                    $costoHospital = costoHospital($entidad, $codigo[$i], $basedatos);
                    $ctaContable = centroCosto($medico, $basedatos);
                    $centroCostoAlmacen = centroCostoAlmacen($almacen, $basedatos);
                    //$medico=devuelveMedico::regresaMedico($entidad,$codigo[$i],$basedatos);
                    $cLlave = new articulosDetalles();
                    $keyPA = $cLlave->codigollave($entidad, $codigo[$i], $basedatos);
                    $precioEspecial = new articulosDetalles();
                    $precioEspecial->preciosEspeciales($entidad, $gpoProducto, $keyPA, $codigo[$i], $almacen, $basedatos);
                    $priceLevel = new articulosDetalles();
                    $priceLevel = $priceLevel->precioVenta($entidad, $paquete, $_POST['generico'], $cantidad[$i], $numeroE, $_GET['keyClientesInternos'], $codigo[$i], $almacen, $basedatos);
                    $benT6 = $beneficenciaT6->beneficenciaT6($entidad, $paquete, $myrow['generico'], "1", $numeroPaciente, $_GET['keyClientesInternos'], $codigo[$i], $almacen, $basedatos);
                    if ($benT6 > 0) {
                        $dB = 'si';
                        $caso = 6;
                    }
                    //*************************CONFIGURACIONES DE VENTAS*********************
                    $modoventa = new articulosDetalles();
                    $priceLevel = $modoventa->modoventa($almacen, $priceLevel, $codigo[$i], $entidad, $keyPA, $basedatos);
                    $tventa = new articulosDetalles();
                    $tipoVenta = $tventa->tventa($almacen, $priceLevel, $codigo[$i], $entidad, $keyPA, $basedatos);
                    $cantidadReal = new articulosDetalles();
                    $cantidadReal = $cantidadReal->cantidadReal($almacen, $priceLevel, $codigo[$i], $entidad, $keyPA, $basedatos);
                    //**********************************************************************************
                    $antibiotico = new articulosDetalles();
                    if ($cantidad[$i] > 0) {
                        $cargoAuto = new articulosDetalles();
                        $cargoAuto = $cargoAuto->cargoAuto($entidad, $codigo[$i], $basedatos);
                        $acumuladoGlobal = $global->precioGlobal($entidad, $precioLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                        $cargos = $convenios->validacionConveniosNivel($entidad, $precioLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                        //$traeConvenio=$traeConvenio->traeConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$traeSeguro->traeSeguro($keyClientesInternos,$basedatos),$basedatos);
                        $tipoConvenio = $tipoConvenioS->tipoConvenio($entidad, $precioLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                        //$vConvenio=$vConvenio->vConvenio($precioLevel,$codigo[$i],$almacen,$gpoProducto,$traeSeguro->traeSeguro($keyClientesInternos,$basedatos),$basedatos);
                        if ($error != 'faked') {
                            //aqui voy a meter como se vende por cantidad***********
                            //***********la forma en que se venden los medicamentos********************
                            $iva = new articulosDetalles();
                            $iva = $iva->iva($entidad, $cantidad[$i], $codigo[$i], $priceLevel, $basedatos);
                            //if($ventaPieza->ventaPieza($almacen,$keyPA,$precioVenta,$iva,$cantidad[$i],$entidad,$basedatos)=='si'){
                            //if($tipoVenta->vendoX($almacen,$keyPA,$priceLevel,$iva,$cantidad[$i],$entidad,$basedatos)!=NULL){
                            //$priceLevel=$tipoVentaArticulos=$tipoVenta->vendoX($almacen,$keyPA,$priceLevel,$iva,$cantidad[$i],$entidad,$basedatos);
                            //}
                            //$iva=$tipoVentaIVA->vendoXIVA($almacen,$keyPA,$priceLevel,$iva,$cantidad[$i],$entidad,$basedatos);
                            //}
                            //********************************************
                            $precioOriginal = $priceLevel;
                            $ivaOriginal = $iva;
                            if ($traeSeguro->traeSeguro($keyClientesInternos, $basedatos) and $tipoConvenio == 'No') {
                                //no es necesario la entidad
                                if ($validaJubilados->validacionJubilados($_GET['numeroE'], $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $entidad, $basedatos) == 'si') {
                                    //no es necesario entidad
                                    $percent = $porcentajeJubilados->porcentajeJubilados($_GET['numeroE'], $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $entidad, $basedatos);
                                    $percent *= 0.01;
                                    $porcentajeParticular = (100 - $percent * 100) * 0.01;
                                    $ivaParticulart = $iva * $porcentajeParticular;
                                    $ivaAseguradorat = $iva * $percent;
                                    $cantidadAseguradora = $priceLevel * $percent;
                                    $cantidadParticular = $priceLevel - $cantidadAseguradora;
                                    //$cantidadParticular=(($priceLevel*$cantidad[$i])+($iva*$cantidad[$i]))-$cantidadAseguradora;
                                } else {
                                    //no es jubilado y por tanto verifico si trae algun convenio
                                    $cantidadAseguradora = $priceLevel;
                                    $ivaAseguradorat = $iva;
                                }
                            } else {
                                if ($tipoConvenio == 'cantidad') {
                                    $cantidadAseguradora = $convenios->validacionConvenios($entidad, $cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                                    //aqui ninguna aseguradora absorbe nada, solo paga porque es fijo
                                    $acumulado = $cantidadAseguradora;
                                    $priceLevel = $acumulado;
                                    $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, $cantidad[$i], $keyPA, $priceLevel, $basedatos);
                                } else {
                                    if ($tipoConvenio == 'grupoProducto') {
                                        $cantidadAseguradora = $convenios->validacionConvenios($entidad, $cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                                        $cantidadParticular = $cantidadAseguradora - $priceLevel;
                                        $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, $cantidad[$i], $keyPA, $cantidadAseguradora, $basedatos);
                                        $ivaParticulart = $ivaParticular->ivaParticular($entidad, $cantidad[$i], $keyPA, $cantidadParticular, $basedatos);
                                    } else {
                                        if ($tipoConvenio == 'global') {
                                            $cantidadAseguradora = $convenios->validacionConvenios($entidad, $cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                                            $cantidadParticular = $priceLevel - $cantidadAseguradora;
                                            $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, $cantidad[$i], $keyPA, $cantidadAseguradora, $basedatos);
                                            $ivaParticulart = $ivaParticular->ivaParticular($entidad, $cantidad, $keyPA, $cantidadParticular, $basedatos);
                                        } else {
                                            if ($tipoConvenio == 'precioEspecial') {
                                                $acumulado = $cantidadParticular = $convenios->validacionConvenios($entidad, $cantidad[$i], $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $traeSeguro->traeSeguro($keyClientesInternos, $basedatos), $basedatos);
                                                $cantidadAseguradora = NULL;
                                                $ivaParticulart = $ivaParticular->ivaParticular($entidad, $cantidad[$i], $keyPA, $cantidadParticular, $basedatos);
                                                $ivaAseguradorat = NULL;
                                            } else {
                                                $cantidadParticular = $priceLevel;
                                                $ivaParticulart = $iva;
                                                $cantidadAseguradora = NULL;
                                                $ivaAseguradorat = NULL;
                                            }
                                        }
                                    }
                                }
                            }
                            if ($traeSeguro->traeSeguro($keyClientesInternos, $basedatos)) {
                                $status = 'cxc';
                                $statusAlta = 'standby';
                                $tipoCliente = 'aseguradora';
                            } else {
                                $status = 'particular';
                                $statusAlta = 'standby';
                                $tipoCliente = 'particular';
                            }
                            $statusCargo = 'standbyR';
                            if ($acumuladoGlobal > $priceLevel) {
                                //$acumulado=$acumuladoGlobal-$priceLevel;
                                $acumulado = $priceLevel;
                            } else {
                                $acumulado = $priceLevel;
                            }
                            if ($tipoVentaArticulos) {
                                $formaVenta = 'unidad';
                            } else {
                                $formaVenta = 'normal';
                            }
                            $traeSeguro->traeSeguro($keyClientesInternos, $basedatos);
                            //*****************************cargo clientePrincipal
                            $sSQL455 = "Select clientePrincipal from clientes where entidad='" . $entidad . "' and numCliente='" . $seguro . "'";
                            $result455 = mysql_db_query($basedatos, $sSQL455);
                            $myrow455 = mysql_fetch_array($result455);
                            $sSQL455a = "Select nomCliente from clientes where entidad='" . $entidad . "' and numCliente='" . $myrow455['clientePrincipal'] . "'";
                            $result455a = mysql_db_query($basedatos, $sSQL455a);
                            $myrow455a = mysql_fetch_array($result455a);
                            //****************************************************************
                            $sSQL3115 = "Select folioVenta,status,beneficencia From clientesInternos WHERE keyClientesInternos='" . $keyClientesInternos . "'";
                            $result3115 = mysql_db_query($basedatos, $sSQL3115);
                            $myrow3115 = mysql_fetch_array($result3115);
                            $sSQL3115y = "Select pagoEfectivo From clientes WHERE numCliente='" . $seguro . "' and entidad='" . $entidad . "'";
                            $result3115y = mysql_db_query($basedatos, $sSQL3115y);
                            $myrow3115y = mysql_fetch_array($result3115y);
                            if ($myrow3115y['pagoEfectivo'] == 'si') {
                                $tipoCliente = 'particular';
                                $status = 'particular';
                            }
                            //****************************DESCUENTOS AUTOMATICOS**********
                            $sSQL7ada = "Select * From descuentosAutomaticos where entidad='" . $entidad . "' and departamento='" . $_GET['almacen'] . "' and seguro='" . $myrow455['clientePrincipal'] . "' and\r\n(fechaInicial>='" . $fecha1 . "' and fechaFinal<='" . $fecha1 . "')\r\nand\r\n(tipoPaciente='interno' or tipoPaciente='ambos')\r\n";
                            $result7ada = mysql_db_query($basedatos, $sSQL7ada);
                            $myrow7ada = mysql_fetch_array($result7ada);
                            echo mysql_error();
                            if ($myrow7ada['gpoProducto'] == '*' || $myrow7ada['gpoProducto'] == $gpoProducto) {
                                $descuentoP = $cantidadParticular * ($myrow7ada['porcentaje'] * 0.01);
                                $cantidadParticular -= $descuentoP;
                                $descuentoIvaP = $ivaParticulart * ($myrow7ada['porcentaje'] * 0.01);
                                $ivaParticulart -= $descuentoIvaP;
                                $descuentoA = $cantidadAseguradora * ($myrow7ada['porcentaje'] * 0.01);
                                $cantidadAseguradora -= $descuentoA;
                                $descuentoIvaA = $ivaAseguradorat * ($myrow7ada['porcentaje'] * 0.01);
                                $ivaAseguradorat -= $descuentoIvaA;
                            }
                            //******************************************************************
                            //***************************************************
                            //Clientes que facturan a otros
                            $sSQL3y = "Select * From clientesGrupos WHERE entidad='" . $entidad . "' and seguro='" . $myrow455['clientePrincipal'] . "' and gpoProducto='" . $gpoProducto . "'";
                            $result3y = mysql_db_query($basedatos, $sSQL3y);
                            $myrow3y = mysql_fetch_array($result3y);
                            if ($myrow3y['seguro']) {
                                $seguro2 = $seguro;
                                $seguro = $myrow3y['seguro'];
                                $myrow455['clientePrincipal'] = $seguro;
                            } else {
                                $seguro2 = NULL;
                            }
                            //***************************************************
                            if ($seguro) {
                                $sSQL3113c = "Select * From clientes WHERE  entidad='" . $entidad . "' and numCliente='" . $seguro . "'  ";
                                $result3113c = mysql_db_query($basedatos, $sSQL3113c);
                                $myrow3113c = mysql_fetch_array($result3113c);
                                if ($myrow3113c['pagoEfectivo'] == 'si') {
                                    $cantidadAseguradora = NULL;
                                    $ivaAseguradorat = NULL;
                                    $cantidadParticular = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo[$i], $almacen, $gpoProducto, $seguro, $basedatos);
                                    $ivaParticular = $ivaAseguradora->ivaAseguradora($entidad, "1", $keyPA, $cantidadAseguradora, $basedatos);
                                }
                            }
                            //****************************
                            $pi = $porcentajeIVA->porcentajeIVA($entidad, $cantidad[$i], $codigo[$i], $precioVenta, $basedatos);
                            if ($cantidadParticular > 0) {
                                $pp = $cantidadParticular / ($cantidadParticular + $cantidadAseguradora);
                            }
                            if ($cantidadAseguradora > 0) {
                                $pa = $cantidadAseguradora / ($cantidadParticular + $cantidadAseguradora);
                            }
                            if ($ivaParticulart > 0) {
                                $pip = $ivaParticulart / ($ivaParticulart + $ivaAseguradorat);
                            }
                            if ($ivaAseguradorat > 0) {
                                $pia = $ivaAseguradorat / ($ivaParticulart + $ivaAseguradorat);
                            }
                            //***************************
                            //*****************DATOS ACTA DE NACIMIENTO
                            $sSQLfi = "Select * From OC WHERE entidad='" . $entidad . "' and keyPA='" . $keyPA . "'   ";
                            $resultfi = mysql_db_query($basedatos, $sSQLfi);
                            $myrowfi = mysql_fetch_array($resultfi);
                            $aIngreso = new almacenesIngreso();
                            if ($aIngreso->almacenIngreso($gpoProducto, $entidad, $basedatos) == 'almacenSolicitante') {
                                $almacenIngreso = $almacenSolicitante;
                            } else {
                                if ($aIngreso->almacenIngreso($gpoProducto, $entidad, $basedatos) == 'almacenDestino') {
                                    $almacenIngreso = $almacen;
                                }
                            }
                            //****************
                            $sSQL6ab = "SELECT almacenPadre,descripcion\r\nFROM\r\nalmacenes\r\nWHERE\r\n\r\nentidad='" . $entidad . "' \r\nand\r\nalmacen='" . $almacenIngreso . "'\r\n  ";
                            $result6ab = mysql_db_query($basedatos, $sSQL6ab);
                            $myrow6ab = mysql_fetch_array($result6ab);
                            $almacenIngreso = $myrow6ab['almacenPadre'];
                            //****************
                            //*****************************cargo clientePrincipal
                            $sSQLbeni = "Select * from porcentajeBeneficencias where entidad='" . $entidad . "' and numeroE='" . $_GET['numeroE'] . "' \r\n    and\r\n    departamento='" . $_GET['almacen'] . "'\r\n        and\r\n        (gpoProducto='*' or gpoProducto='" . $gpoProducto . "' )\r\n            and\r\n            status='standby'\r\norder by keyPB DESC    \r\n";
                            $resultbeni = mysql_db_query($basedatos, $sSQLbeni);
                            $myrowbeni = mysql_fetch_array($resultbeni);
                            //****************************************************************
                            //BENEFICENCIAS AQUI EN TRA EL PORCENTAJE DE AYUDA
                            if ($myrow3115['beneficencia'] == 'si' and !$myrow455['clientePrincipal']) {
                                $sSQL10a = "Select * From porcentajeBeneficencias\r\n                where entidad='" . $entidad . "' and numeroE='" . $_GET['numeroE'] . "'\r\n                and\r\n                fecha='" . $fecha1 . "' and status='standby' ";
                                $result10a = mysql_db_query($basedatos, $sSQL10a);
                                $myrow10a = mysql_fetch_array($result10a);
                                $P = 100 - $myrow10a['porcentaje'];
                                if ($myrow10a['numeroE'] != NULL) {
                                    $cantidadParticularOriginal = $cantidadParticular;
                                    $ivaOriginalParticular = $ivaParticulart;
                                    $descuentoP = $cantidadParticular * ($P * 0.01);
                                    $cantidadParticular = $descuentoP;
                                    $descuentoIvaP = $ivaParticulart * ($P * 0.01);
                                    $ivaParticulart = $descuentoIvaP;
                                    $cantidadAseguradora = $cantidadParticularOriginal - $cantidadParticular;
                                    $ivaAseguradorat = $ivaOriginalParticular - $descuentoIvaP;
                                }
                            } elseif ($myrowbeni['numeroE'] != NULL) {
                                $cantidadBeneficencia = $cantidadParticular * ($myrowbeni['porcentaje'] * 0.01);
                                $cantidadParticular = $cantidadParticular - $cantidadBeneficencia;
                                $ivaBeneficenciat = $ivaParticularT * ($myrowbeni['porcentaje'] * 0.01);
                                $ivaBeneficenciaT = $ivaParticuarT - $ivaBeneficenciat;
                            }
                            //CIERRO BENEFICENCIAS
                            //******************************************************
                            $diaNumerico = date("d");
                            $year = date("Y");
                            $mes = date("m");
                            //******************************************************
                            //****************
                            $sSQL6abc = "SELECT medico,descripcion,id_medico,stock\r\nFROM\r\nalmacenes\r\nWHERE\r\n\r\nentidad='" . $entidad . "'\r\nand\r\nalmacen='" . $almacen . "'\r\n  ";
                            $result6abc = mysql_db_query($basedatos, $sSQL6abc);
                            $myrow6abc = mysql_fetch_array($result6abc);
                            $medico = $myrow6abc['id_medico'];
                            $descripcionMedico = $myrow6abc['descripcion'];
                            //****************
                            //
                            //
                            //
                            //
                            $agrega1 = "INSERT INTO cargosCuentaPaciente (\r\nnumeroE,\r\nnCuenta,\r\ncodProcedimiento,\r\ncantidad,\r\nusuario,\r\nfecha1,\r\n\r\nstatus,\r\nalmacen,\r\nprecioVenta,\r\n\r\nctaMayor,\r\nctoCosto,\r\nauxiliar,\r\n\r\nejercicio,\r\nseguro,iva,dia,costoHospital,hora1,existencias,um,\r\nmedico,tipoPaciente,prioridad,horaSolicitud,fechaSolicitud,laboratorioReferido,\r\ncredencial,statusCargo,almacenDestino,almacenSolicitante,naturaleza,statusTraslado,tipoCliente,\r\nstatusEstudio,entidad,gpoProducto,statusFactura,keyClientesInternos,statusDevolucion,keyPA,folioVenta,\r\ncantidadParticular,cantidadAseguradora,ivaParticular,ivaAseguradora,tipoVentaArticulos,clientePrincipal,descripcionArticulo,random,clienteFacturacion,\r\nporcentajeIVA,\r\nporcentajeParticular,\r\nporcentajeAseguradora,\r\nporcentajeIVAParticular,\r\nporcentajeIVAAseguradora,antibiotico,precioOriginal,ivaOriginal,tipoCuenta,almacenIngreso,descripcionAlmacen,descripcionGrupoProducto,\r\n\r\ndiaNumerico,year,mes,descripcionClientePrincipal,descripcionMedico,cantidadBeneficencia,ivaBeneficencia\r\n) values (\r\n'" . $numeroPaciente . "',\r\n'" . $nCuenta . "',\r\n'" . $codigo[$i] . "',\r\n'" . $cantidad[$i] . "',\r\n'" . $usuario . "',\r\n'" . $fecha1 . "',\r\n\r\n'" . $status . "',\r\n'" . $_POST['almacenDestino'] . "',\r\n'" . $cantidadParticular . "'+'" . $cantidadAseguradora . "',\r\n\r\n'" . $ctaMayor . "',\r\n'" . $centroCostoAlmacen . "',\r\n'" . $aux . "',\r\n\r\n'" . $ID_EJERCICIOM . "',\r\n'" . $traeSeguro->traeSeguro($keyClientesInternos, $basedatos) . "','" . $ivaParticulart . "'+'" . $ivaAseguradorat . "',\r\n    '" . $dia . "','" . $costoHospital . "','" . $hora1 . "','" . $existenciasAjuste . "','" . $um . "',\r\n'" . $medico . "','interno','" . $_POST['prioridad'] . "',\r\n'" . $hora1 . "','" . $fecha1 . "','" . $laboratorioReferido[$i] . "','" . $credencial . "',\r\n'standbyR','" . $almacen . "','" . $almacenSolicitante . "','C','standby','" . $tipoCliente . "','standby',\r\n    '" . $entidad . "','" . trim($gpoProducto) . "','standby','" . $keyClientesInternos . "','no','" . $keyPA . "','" . $myrow3115['folioVenta'] . "',\r\n'" . $cantidadParticular . "','" . $cantidadAseguradora . "','" . $ivaParticulart . "','" . $ivaAseguradorat . "',\r\n'" . $formaVenta . "','" . trim($myrow455['clientePrincipal']) . "',\r\n\r\n'" . $descripcion->descripcionArticulo($entidad, $keyCAP, $numeroE, $nCuenta, $codigo[$i], $basedatos) . "','" . $random . "','" . $seguro2 . "',\r\n'" . $pi . "',\r\n'" . $pp . "',\r\n'" . $pa . "',\r\n'" . $pip . "',\r\n'" . $pia . "' ,\r\n\r\n'" . $antibiotico->mostrarAntibiotico($entidad, $codigo[$i], $basedatos) . "' ,\r\n'" . $precioOriginal . "',\r\n'" . $ivaOriginal . "','D','" . $almacenIngreso . "','" . $myrow6ab['descripcion'] . "','" . $descripcionGP . "',\r\n    '" . $diaNumerico . "','" . $year . "','" . $mes . "',\r\n        '" . $myrow455a['nomCliente'] . "','" . $descripcionMedico . "','" . $cantidadBeneficencia . "','" . $ivaBeneficencia . "'\r\n)";
                            mysql_db_query($basedatos, $agrega1);
                            echo mysql_error();
                            //************************VERIFICACION DE STOCK*************************
                            $sSQL455s = "Select stock,medicamentosSueltos from almacenes where entidad='" . $entidad . "' and almacen='" . $almacen . "' and centroDistribucion!='si'";
                            $result455s = mysql_db_query($basedatos, $sSQL455s);
                            $myrow455s = mysql_fetch_array($result455s);
                            if ($myrow455s['stock'] == 'si') {
                                if ($cantidadReal < 1) {
                                    $cantidadReal = 1;
                                }
                                $agrega1 = "INSERT INTO faltantes (\r\n\r\ncodigo,\r\ncantidad,\r\nusuario,\r\nfecha1,\r\nhora1,\r\nalmacen,\r\nejercicio,\r\ndia,\r\nstatus,entidad,almacenSolicitante,folioVenta,keyPA,gpoProducto,\r\nusuarioSolicitante,naturaleza,descripcion,random,\r\nkeyClientesInternos,cantidadTotal,ventaGranel,tipoVenta\r\n) values (\r\n\r\n'" . $codigo[$i] . "',\r\n'" . $cantidad[$i] . "'*'" . $cantidadReal . "',\r\n'" . $usuario . "',\r\n'" . $fecha1 . "',\r\n'" . $hora1 . "',\r\n'" . $_POST['almacenDestino'] . "',\r\n'" . $ID_EJERCICIOM . "',\r\n'" . $dia . "',\r\n'','" . $entidad . "','" . $almacen . "','" . $myrow3115['folioVenta'] . "',\r\n    '" . $keyPA . "','" . trim($gpoProducto) . "',\r\n    '" . $usuario . "','C',\r\n'" . $descripcion->descripcionArticulo($entidad, $keyCAP, $numeroE, $nCuenta, $codigo[$i], $basedatos) . "',\r\n        '" . $random . "',' " . $keyClientesInternos . " ',\r\n            '" . $cantidadTotal . "','" . $vg . "','" . $tipoVenta . "'\r\n)";
                                //mysql_db_query($basedatos,$agrega1);
                                echo mysql_error();
                            }
                            //****************saco la cuenta contable de la forma en que ingresa*****************
                            //insertarRegistros($agregarA[$i],$almacen,$cantidad[$i],$fecha1,$ID_EJERCICIOM,$usuario,$basedatos);
                        }
                    } else {
                        $tipoMensaje = 'success';
                        $encabezado = 'Exito!';
                        $texto = 'Se hicieron Cargos...';
                    }
                    //validacion de seguros
                }
                //*****************************************************CIERRO ALMA**************************************************
            }
            //cierro buscar
        }
        ?>



<?php 
        $sSQL311 = "Select  * From clientesInternos WHERE keyClientesInternos='" . $_GET['keyClientesInternos'] . "'";
        $result311 = mysql_db_query($basedatos, $sSQL311);
        $myrow311 = mysql_fetch_array($result311);
        $paciente = $myrow31['nombre1'] . " " . $myrow31['nombre2'] . " " . $myrow31['apellido1'] . " " . $myrow31['apellido2'] . " " . $myrow31['apellido3'];
        $nuE = $myrow31['numeroE'];
        if ($myrow311['paciente']) {
            $paciente = $myrow311['paciente'];
        }
        ?>









<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=600,height=600,scrollbars=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria20 (URL){ 
   window.open(URL,"ventana20","width=50,height=10,scrollbars=YES") 
} 
</script>

<script language="javascript">

function enableField()
{
document.form2.insertarArticulos.disabled=false;
}

</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" />
<?php 
        $estilos = new muestraEstilos();
        $estilos->styles();
        ?>


</head>

<body>

<?php 
        $sSQL31 = "Select  * From pacientes WHERE entidad='" . $entidad . "' AND numCliente = '" . $numeroPaciente . "' ";
        $result31 = mysql_db_query($basedatos, $sSQL31);
        $myrow31 = mysql_fetch_array($result31);
        ?>

    
    <p>
        <label>
            <?php 
        if ($texto != NULL) {
            $mostrarMensajes = new informacion();
            $mostrarMensajes->mostrarMensajes($encabezado, $tipoMensaje, $id, $texto, $basedatos);
        }
        ?>
    </label>
    </p> 
    
    
  <form id="form2" name="form2" method="post" action="" >
  <p><span  align="center">Solicitudes a Otros Departamentos</span></p>
  <table width="600" class="table-forma">
    <tr>
      <th colspan="7"  ><p align="center" >Paciente: <?php 
        echo $paciente;
        ?>
</p></th>
    </tr>
    <tr>
      <td width="39" height="24" >&nbsp;</td>
      <td colspan="3"  >Seguro: <span ><?php 
        $company = $myrow311['seguro'];
        $sSQL31a = "Select nomCliente From clientes WHERE entidad='" . $entidad . "' AND numCliente = '" . $myrow311['seguro'] . "' ";
        $result31a = mysql_db_query($basedatos, $sSQL31a);
        $myrow31a = mysql_fetch_array($result31a);
        if ($myrow31a['nomCliente'] != '') {
            echo $myrow31a['nomCliente'];
        } else {
            echo 'PARTICULAR';
        }
        ?>
</span>
      </td>
      <td colspan="2"  >Cuarto: <span ><?php 
        echo $myrow311['cuarto'];
        ?>
</span></td>
      <td width="58" >&nbsp;</td>
    </tr>
    <tr >
      <th colspan="7" ><p align="center">ALMACEN A SOLICITAR</p></th>
    </tr>
    <tr>
      <td >&nbsp;</td>
      <td  >Almac&eacute;n</td>
      <td colspan="5"  >Mini Almacen</td>
    </tr>
    <tr>
      <td >&nbsp;</td>
     
      
      
      <td ><?php 
        require CONSTANT_PATH_CONFIGURACION . "/componentes/comboAlmacen.php";
        $comboAlmacen = new comboAlmacen();
        $comboAlmacen->despliegaAlmacenAAV($entidad, 'select', $almacenSolicitante, $almacenDestino, $basedatos);
        ?>
</td>
     
      
      
      
      
      <td colspan="5" ><?php 
        $comboAlmacen1 = new comboAlmacen();
        if (!$almacenDestino) {
            $almacenDestino = $almacenSolicitante;
        }
        $comboAlmacen1->despliegaMiniAlmacen($entidad, 'select', $almacenDestino, $almacenDestino, $basedatos);
        ?>
</td>
      
      
      
    </tr>
    <tr>
      <td height="31" >&nbsp;</td>
      <td colspan="2"  >Mostrar Todo (*)
      <input name="todo" type="checkbox" id="todo" value="todo" /></td>
      <td colspan="4"  >Prioridad: 
        <select name="prioridad"  id="select">
          <option
			 <?php 
        if ($_POST['prioridad'] == 'baja') {
            ?>
			 selected="selected"
			 <?php 
        }
        ?>
			 value="baja">baja</option>
          <option
			 <?php 
        if ($_POST['prioridad'] == 'alta') {
            ?>
			 selected="selected"
			 <?php 
        }
        ?>
			 value="alta">alta</option>
      </select></td>
    </tr>
    <tr>
      <td colspan="7"   align="center">ARTICULO A SOLICITAR</td>
    </tr>
    <tr>
      <td colspan="7"  align="center"><input name="nomArticulo" type="text"  id="nomArticulo" size="60" value="<?php 
        if ($_POST['nomArticulo']) {
            //echo $_POST['nomArticulo'];
        }
        ?>
" autocomplete="off"/></td>
    </tr>
    <tr>
      <td height="38" colspan="7" align="center" ><input name="buscar" type="submit"  id="buscar" value="Buscar" /></td>
    </tr>
    <tr>
      <td height="25" colspan="7" align="center" ><?php 
        echo $leyenda;
        ?>
</td>
    </tr>
    <tr>
      <td height="42" colspan="7" align="center"  valign="middle">
          <input name="insertarArticulos" type="submit"  id="insertarArticulos" value="Agregar Articulo/Servicio" /></td>
    </tr>
    
    
    
    
    
    
    <tr >
      <span ><span >
        <input name="almacenCargo" type="hidden" id="almacenCargo" value="<?php 
        echo $_POST['almacen'];
        ?>
" />
      </span></span>
        <input name="nombrePaciente3" type="hidden" id="nombrePaciente3" value="<?php 
        echo $nombrePaciente1;
        ?>
" />
        <input name="medico1" type="hidden" id="medico1" value="<?php 
        echo $medico1;
        ?>
" />
        <input name="tipoSeguro1" type="hidden" id="tipoSeguro1" value="<?php 
        echo $seguro;
        ?>
" />
        <input name="almacenP1" type="hidden" id="almacenP1" value="<?php 
        echo $almacenPrincipal;
        ?>
" />
        <input name="numPoliza1" type="hidden" id="numPoliza1" value="<?php 
        echo $numPoliza;
        ?>
" />
        <input name="nCuenta1" type="hidden" id="nCuenta1" value="<?php 
        echo $nCuenta;
        ?>
" />

      <?php 
        if ($_POST['almacenDestino1']) {
            $almacen = $_POST['almacenDestino1'];
        } else {
            $almacen = $_POST['almacenDestino'];
        }
        //*********************NUCLEO***********************
        if ($_POST['todo'] == 'todo') {
            $sSQL = "SELECT \r\narticulos.codigo,articulos.gpoProducto,articulos.laboratorioReferido,articulos.ventaPieza,\r\nexistencias.ventaGranel,existencias.tipoVenta,existencias.cantidadSurtir,articulos.cajaCon,existencias.cantidadIndividual,\r\nexistencias.existencia,articulos.descripcion1,articulos.sustancia\r\nFROM articulos,existencias\r\nWHERE\r\n\r\n(articulos.entidad='" . $entidad . "' AND existencias.entidad='" . $entidad . "' )\r\nAND\r\narticulos.activo='A'\r\nand\r\narticulos.codigo=existencias.codigo and\r\nexistencias.almacen='" . $almacen . "'\r\nand\r\narticulos.paquete='no'\r\norder by articulos.descripcion ASC\r\n";
            $_POST['nomArticulo'] = 'todo';
        } else {
            if ($_POST['buscar'] or ($_POST['nomArticulo'] or $_POST['cbarra'])) {
                $articulo = $_POST['nomArticulo'];
                $sSQL = "SELECT\r\narticulos.codigo,articulos.gpoProducto,articulos.laboratorioReferido,articulos.keyPA,articulos.ventaPieza,\r\nexistencias.ventaGranel,existencias.tipoVenta,existencias.cantidadSurtir,articulos.cajaCon,existencias.cantidadIndividual,\r\nexistencias.existencia,articulos.descripcion1,articulos.sustancia\r\n\r\n\r\nFROM articulos,existencias\r\nWHERE\r\n(articulos.entidad='" . $entidad . "' AND existencias.entidad='" . $entidad . "' )\r\nAND\r\narticulos.activo='A' and\r\n\r\n         (articulos.descripcion like '%{$articulo}%' or articulos.descripcion1 like '%{$articulo}%' or articulos.sustancia like '%{$articulo}%')\r\n\r\nand\r\narticulos.codigo=existencias.codigo and\r\nexistencias.almacen='" . $almacen . "'\r\nand\r\narticulos.paquete='no'\r\n";
            }
        }
        //****************CIERRA NUCLEO****************
        if ($_POST['nomArticulo']) {
            if ($result = mysql_db_query($basedatos, $sSQL)) {
                ?>
<td>&nbsp;</td>














<?php 
                $sSQLbeni3 = "Select * from porcentajeBeneficencias where entidad='" . $entidad . "' and numeroE='" . $numeroPaciente . "' \r\n    and\r\n    departamento='" . $_GET['almacen'] . "'\r\n         and\r\n            status='standby'\r\norder by keyPB DESC    \r\n";
                $resultbeni3 = mysql_db_query($basedatos, $sSQLbeni3);
                $myrowbeni3 = mysql_fetch_array($resultbeni3);
                ?>




      <th width="100" >Descripcion</th>


      <th width="51"  align="right">Part</th>
      <?php 
                if ($myrowbeni3['numeroE'] != NULL) {
                    echo '<td width="59"  align="right">Ben</td>';
                }
                ?>
      <th width="59"  align="right">Aseg</th>
      <th width="78"  align="center">Cant</th>
      <th align="center" >Status</th>
    

    </tr>
<?php 
                while ($myrow = mysql_fetch_array($result)) {
                    if (!$seguro) {
                        $seguro = $company;
                    }
                    //*********************************INSTANCIAS
                    $unidadMedida = new articulosDetalles();
                    $statusExistencias = new articulosDetalles();
                    $convenios = new validaConvenios();
                    $global = new validaConvenios();
                    $tipoConvenioS = new validaConvenios();
                    $tipoConvenio = new validaConvenios();
                    $traeConvenio = new validaConvenios();
                    $vConvenio = new validaConvenios();
                    $um = new articulosDetalles();
                    $traeSeguro = new verificaSeguro1();
                    $priceLevel = new articulosDetalles();
                    $verificaSaldosInternos = new verificaSeguro1();
                    $iva = new articulosDetalles();
                    $descripcion = new articulosDetalles();
                    $tipoVenta = new tipoVentaArticulo();
                    $tipoVentaIVA = new tipoVentaArticulo();
                    $aMS = new tipoVentaArticulo();
                    $ivaAseguradora = new ivaCierre();
                    $ivaParticular = new ivaCierre();
                    $ventaPieza = new tipoVentaArticulo();
                    //**********************************CONVENIOS
                    $beneficenciaT6 = new articulosDetalles();
                    $verificaSaldos1 = new verificaSeguro1();
                    $verificaSaldosInternos = new verificaSeguro1();
                    $validaJubilados = new validaConvenios();
                    $porcentajeJubilados = new validaConvenios();
                    //*******************************CIERRA INSTANCIAS
                    $bandera += "1";
                    $i += 1;
                    $code1 = $myrow['codigo'];
                    $codigo = $myrow['codigo'];
                    //*************************************CONVENIOS********************************************
                    $keyPA = $myrow['keyPA'];
                    //cierro descuento
                    if ($col) {
                        $color = '#FFCCFF';
                        $col = '';
                    } else {
                        $color = '#FFFFFF';
                        $col = 1;
                    }
                    //*******************************CONVENIOS*******************************
                    $numeroE = $numeroPaciente = $myrow311['numeroE'];
                    $nCuenta = $myrow311['nCuenta'];
                    $um = $um->um($codigo, $basedatos);
                    $cantidad = 1;
                    //$priceLevel=$convenios->validacionConvenios($precioLevel,$codigo[$i],$almacen,$gpoProducto,$traeSeguro->traeSeguro($keyClientesInternos,$basedatos),$basedatos);
                    $tipoConvenio = $tipoConvenio->tipoConvenio($entidad, $precioLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                    $priceLevel = $priceLevel->precioVenta($entidad, $paquete, $_POST['generico'], $cantidad, $numeroE, $_GET['keyClientesInternos'], $codigo, $almacen, $basedatos);
                    $precioNormal = $priceLevel;
                    $ivaNormal = $iva->iva($entidad, $cantidad, $codigo, $priceLevel, $basedatos);
                    $benT6 = $beneficenciaT6->beneficenciaT6($entidad, $paquete, $myrow['generico'], "1", $numeroPaciente, $_GET['keyClientesInternos'], $codigo[$i], $almacen, $basedatos);
                    if ($benT6 > 0) {
                        $dB = 'si';
                        $caso = 6;
                    }
                    //*************************CONFIGURACIONES DE VENTAS*********************
                    //entra
                    $modoventa = new articulosDetalles();
                    $priceLevel = $modoventa->modoventa($almacen, $priceLevel, $codigo, $entidad, $keyPA, $basedatos);
                    $tventa = new articulosDetalles();
                    $tipoVenta = $tventa->tventa($almacen, $priceLevel, $codigo, $entidad, $keyPA, $basedatos);
                    //**********************************************************************************
                    //IVA
                    $iva = $iva->iva($entidad, $cantidad, $codigo, $priceLevel, $basedatos);
                    if ($company) {
                        //****************************JUBILADOS***********
                        if ($validaJubilados->validacionJubilados($_GET['numeroE'], $company, $entidad, $basedatos) == 'si') {
                            $percent = $porcentajeJubilados->porcentajeJubilados($_GET['numeroE'], $company, $entidad, $basedatos);
                            $percent *= 0.01;
                            $cantidadAseguradora = $priceLevel * $percent;
                            $cantidadParticular = $priceLevel - $cantidadAseguradora;
                            //$cantidadParticular=(($priceLevel*$cantidad[$i])+($iva*$cantidad[$i]))-$cantidadAseguradora;
                        } else {
                            //no es jubilado y por tanto verifico si trae algun convenio
                            //*******************************CONVENIOS**************************************
                            if ($tipoConvenio == 'cantidad') {
                                $cantidadAseguradora = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $company, $basedatos);
                                //aqui ninguna aseguradora absorbe nada, solo paga porque es fijo
                                $acumulado = $cantidadAseguradora;
                                $priceLevel = $acumulado;
                                $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, "1", $keyPA, $priceLevel, $basedatos);
                            } else {
                                if ($tipoConvenio == 'grupoProducto') {
                                    $cantidadAseguradora = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $company, $basedatos);
                                    $cantidadParticular = $cantidadAseguradora - $priceLevel;
                                    $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, "1", $keyPA, $cantidadAseguradora, $basedatos);
                                    $ivaParticulart = $ivaParticular->ivaParticular($entidad, "1", $keyPA, $cantidadParticular, $basedatos);
                                } else {
                                    if ($tipoConvenio == 'global') {
                                        $cantidadAseguradora = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $company, $basedatos);
                                        $cantidadParticular = $priceLevel - $cantidadAseguradora;
                                        $ivaAseguradorat = $ivaAseguradora->ivaAseguradora($entidad, "1", $keyPA, $cantidadAseguradora, $basedatos);
                                        $ivaParticulart = $ivaParticular->ivaParticular($entidad, "1", $keyPA, $cantidadParticular, $basedatos);
                                    } else {
                                        if ($tipoConvenio == 'precioEspecial') {
                                            $cantidadParticular = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $company, $basedatos);
                                            $cantidadAseguradora = NULL;
                                            $ivaParticulart = $ivaParticular->ivaParticular($entidad, "1", $keyPA, $cantidadParticular, $basedatos);
                                        } else {
                                            //no trae convenio pero si seguro
                                            $cantidadAseguradora = $priceLevel;
                                            $ivaAseguradorat = $iva;
                                        }
                                    }
                                }
                            }
                            // cierro convenios
                        }
                        //cierro jubilados
                        //*******************************************************************CIERRO CONVENIOS
                    } else {
                        //solamente abre cuando trae seguro
                        $cantidadParticular = $priceLevel;
                        $ivaParticulart = $iva;
                        $cantidadAseguradora = NULL;
                        $ivaAseguradorat = NULL;
                    }
                    //**********************************************************************************************************
                    $sSQL3113cd = "Select * From gpoProductos WHERE  codigoGP='" . $myrow['gpoProducto'] . "'  ";
                    $result3113cd = mysql_db_query($basedatos, $sSQL3113cd);
                    $myrow3113cd = mysql_fetch_array($result3113cd);
                    $gpoProducto = $myrow3113cd['descripcionGP'];
                    $gpoProducto = $myrow['gpoProducto'];
                    $sSQL39 = "\r\n\tSELECT \r\nprefijo\r\nFROM\r\ngpoProductos\r\nWHERE  codigoGP='" . $gpoProducto . "'";
                    $result39 = mysql_db_query($basedatos, $sSQL39);
                    $myrow39 = mysql_fetch_array($result39);
                    //**********************TIPO PAGO CLIENTES*******************************
                    if ($seguro) {
                        $sSQL3113c = "Select * From clientes WHERE  entidad='" . $entidad . "' and numCliente='" . $seguro . "'  ";
                        $result3113c = mysql_db_query($basedatos, $sSQL3113c);
                        $myrow3113c = mysql_fetch_array($result3113c);
                        if ($myrow3113c['convenioExclusivo'] == 'si') {
                            $sSQL3113cd = "SELECT \r\nkeyPA\r\nFROM convenios\r\nWHERE\r\nkeyPA='" . $myrow['keyPA'] . "'\r\nand\r\ndepartamento='" . $almacenDestinoB . "'";
                            $result3113cd = mysql_db_query($basedatos, $sSQL3113cd);
                            $myrow3113cd = mysql_fetch_array($result3113cd);
                            if (!$myrow3113cd['keyPA']) {
                                $aviso = 'Requiere autorizacion medica!';
                            }
                        } else {
                            $aviso = '';
                        }
                        if ($myrow3113c['pagoEfectivo'] == 'si') {
                            $cantidadAseguradora = NULL;
                            $ivaAseguradorat = NULL;
                            $cantidadParticular = $convenios->validacionConvenios($entidad, "1", $iva, $priceLevel, $codigo, $almacen, $gpoProducto, $seguro, $basedatos);
                            $ivaParticular = $ivaAseguradora->ivaAseguradora($entidad, "1", $keyPA, $cantidadAseguradora, $basedatos);
                        }
                    }
                    //******************************************************************************
                    $informacionExistencias = new existencias();
                    //*****************************cargo clientePrincipal
                    $sSQL455 = "Select clientePrincipal from clientes where entidad='" . $entidad . "' and numCliente='" . $seguro . "'";
                    $result455 = mysql_db_query($basedatos, $sSQL455);
                    $myrow455 = mysql_fetch_array($result455);
                    //****************************************************************
                    //****************************DESCUENTOS AUTOMATICOS**********
                    $sSQL7ada = "Select * From descuentosAutomaticos where entidad='" . $entidad . "' and departamento='" . $_GET['almacen'] . "' and seguro='" . $myrow455['clientePrincipal'] . "' and\r\n(fechaInicial>='" . $fecha1 . "' and fechaFinal<='" . $fecha1 . "')\r\nand\r\n(tipoPaciente='interno' or tipoPaciente='ambos')\r\n";
                    $result7ada = mysql_db_query($basedatos, $sSQL7ada);
                    $myrow7ada = mysql_fetch_array($result7ada);
                    echo mysql_error();
                    if ($myrow7ada['gpoProducto'] == '*' || $myrow7ada['gpoProducto'] == $gpoProducto) {
                        $descuentoP = $cantidadParticular * ($myrow7ada['porcentaje'] * 0.01);
                        $cantidadParticular -= $descuentoP;
                        $descuentoIvaP = $ivaParticulart * ($myrow7ada['porcentaje'] * 0.01);
                        $ivaParticulart -= $descuentoIvaP;
                        $descuentoA = $cantidadAseguradora * ($myrow7ada['porcentaje'] * 0.01);
                        $cantidadAseguradora -= $descuentoA;
                        $descuentoIvaA = $ivaAseguradorat * ($myrow7ada['porcentaje'] * 0.01);
                        $ivaAseguradorat -= $descuentoIvaA;
                        echo 'Descuento Activo';
                    }
                    //******************************************************************
                    //*****************************cargo clientePrincipal
                    $sSQLbeni = "Select * from porcentajeBeneficencias where entidad='" . $entidad . "' and numeroE='" . $numeroE . "' \r\n    and\r\n    departamento='" . $_GET['almacen'] . "'\r\n        and\r\n        (gpoProducto='*' or gpoProducto='" . $gpoProducto . "' )\r\n            and\r\n            status='standby'\r\norder by keyPB DESC    \r\n";
                    $resultbeni = mysql_db_query($basedatos, $sSQLbeni);
                    $myrowbeni = mysql_fetch_array($resultbeni);
                    //****************************************************************
                    //BENEFICENCIAS AQUI EN TRA EL PORCENTAJE DE AYUDA
                    if ($myrow311['beneficencia'] == 'si' and !$myrow455['clientePrincipal']) {
                        $sSQL10a = "Select * From porcentajeBeneficencias\r\n                where entidad='" . $entidad . "' and numeroE='" . $myrow311['numeroE'] . "'\r\n                and\r\n                fecha='" . $fecha1 . "' and status='standby' and departamento='" . $_GET['almacen'] . "'";
                        $result10a = mysql_db_query($basedatos, $sSQL10a);
                        $myrow10a = mysql_fetch_array($result10a);
                        $P = 100 - $myrow10a['porcentaje'];
                        $cantidadParticularOriginal = $cantidadParticular;
                        $ivaOriginalParticular = $ivaParticulart;
                        $descuentoP = $cantidadParticular * ($P * 0.01);
                        $cantidadParticular = $descuentoP;
                        $descuentoIvaP = $ivaParticulart * ($P * 0.01);
                        $ivaParticulart = $descuentoIvaP;
                        $cantidadAseguradora = $cantidadParticularOriginal - $cantidadParticular;
                        $ivaAseguradorat = $ivaOriginalParticular - $descuentoIvaP;
                    } elseif ($myrowbeni['numeroE'] != NULL) {
                        $cantidadBeneficencia = $cantidadParticular * ($myrowbeni['porcentaje'] * 0.01);
                        $cantidadParticular = $cantidadParticular - $cantidadBeneficencia;
                        $ivaBeneficenciat = $ivaParticularT * ($myrowbeni['porcentaje'] * 0.01);
                        $ivaBeneficenciaT = $ivaParticuarT - $ivaBeneficenciat;
                    }
                    //CIERRO BENEFICENCIAS
                    if ($_POST['almacenDestino'] != $_GET['almacen']) {
                        $sSQLnot = "Select almacen From almacenes where entidad='" . $entidad . "' and almacenPadre='" . $_GET['almacen'] . "' and stock='si' and almacenConsumo!='si' ";
                        $resultnot = mysql_db_query($basedatos, $sSQLnot);
                        while ($myrownot = mysql_fetch_array($resultnot)) {
                            echo mysql_error();
                            $sSQLexis = "Select * from existencias where entidad='" . $entidad . "'\r\n    and\r\n    almacen='" . $myrownot['almacen'] . "'\r\n    and\r\n    codigo='" . $codigo . "'\r\n";
                            $resultexis = mysql_db_query($basedatos, $sSQLexis);
                            $myrowexis = mysql_fetch_array($resultexis);
                            if ($myrowexis['codigo']) {
                                $priceLevel = '';
                            }
                        }
                    }
                    if ($priceLevel != NULL) {
                        ?>
        

        
          <input name="codigoArt[]" type="hidden"  value="<?php 
                        echo $myrow['codigo'];
                        ?>
" />
          <input name="codigoBeta[]" type="hidden"  value="<?php 
                        echo $myrow['codigo'];
                        ?>
" />    
    
    
   <tr  bgcolor="#ffffff" onMouseOver="bgColor='#cccccc'" onMouseOut="bgColor='#ffffff'">
    
      <td colspan="2"><span >
        <?php 
                        $descripcion = new articulosDetalles();
                        $descripcion->descripcion($entidad, $keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                        if ($myrow3113cd['afectaExistencias'] == 'si' and $myrow['descripcion1'] != NULL) {
                            echo '</br>';
                            echo '<span >' . 'Sustancia: ' . $myrow['sustancia'] . '</span>';
                        } else {
                            if ($myrow['descripcion1'] != NULL) {
                                echo '</br>';
                                echo '<span >' . 'Sustancia: ' . $myrow['descripcion1'] . '</span>';
                            }
                        }
                        ?>
        <?php 
                        if ($myrow['laboratorioReferido'] == 'si') {
                            echo '<span class="error">' . 'Estudio Referido' . '</span>';
                        }
                        if ($gpoProducto) {
                            echo '</br>';
                            echo '<span class="gpoProducto">' . '[ ' . $gpoProducto . ' ]' . '</span>';
                        } else {
                            echo '<span class="error">' . 'No tiene Grupo de Producto Definido' . '</span>';
                        }
                        //if($informacionExistencias->informacionExistenciasCantidad($entidad,$codigo,$almacen,$usuario,$fecha,$basedatos)<2){
                        //echo '<span class="error">'. '</br>'.'No hay existencia'.'</span>';
                        //}
                        echo '</br>';
                        echo '<span >' . 'Precio Base: $' . number_format($precioNormal + $ivaNormal, 2) . '</span>';
                        if ($myrow['cajaCon'] > 0) {
                            echo '</br>';
                            echo '<span class="informativo">' . 'Caja Con: ' . $myrow['cajaCon'] . ' !</span>';
                        }
                        if ($myrow['ventaGranel'] == 'si' and $myrow['cantidadSurtir'] > 0) {
                            echo '</br>';
                            echo '<span class="informativo">' . 'Venta Granel</span>';
                        }
                        ?>
      </span></td>

      
      
      
      
      
      




      <td  align="left"><?php 
                        if ($cantidadParticular > 0) {
                            echo "\$" . number_format($cantidadParticular + $ivaParticulart, 2);
                        } else {
                            echo '---';
                        }
                        ?>
</td>


      
      
<?php 
                        if ($myrowbeni3['numeroE'] != NULL) {
                            ?>
<td  align="left"><?php 
                            if ($cantidadBeneficencia > 0) {
                                echo "\$" . number_format($cantidadBeneficencia + $ivaBeneficenciat, 2);
                            } else {
                                echo '---';
                            }
                            ?>
</td>
<?php 
                        }
                        ?>


      <td  align="left"><?php 
                        if ($cantidadAseguradora > 0) {
                            echo "\$" . number_format($cantidadAseguradora + $ivaAseguradorat, 2);
                        } else {
                            echo '---';
                        }
                        ?>
</td>
     
      
      
      
      
<td align="left">

          
          
<input name="cantidad[]" type="text"  id="cantidad"  size="4" maxlength="10" class="normal"
autocomplete="off" <?php 
                        if (!$priceLevel) {
                            echo 'readonly=""';
                        }
                        ?>
/>
      
      
      
      
      </td>
      
      
      
      
      <td align="left">
<?php 
                        if ($myrow['gpoProducto']) {
                            $errores1 = 'No tiene grupo de producto';
                        }
                        ?>
        <?php 
                        if ($priceLevel) {
                            ?>
        <a href="javascript:ventanaSecundaria20('<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/cargos/ventanaErrores.php?codigo=<?php 
                            echo $code;
                            ?>
&seguro=<?php 
                            echo $_POST['seguro'];
                            ?>
&medico=<?php 
                            echo $_POST['medico'];
                            ?>
&error=<?php 
                            echo $errores;
                            ?>
&error1=<?php 
                            echo $errores1;
                            ?>
')"> <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/btns/checkbtn.png" width="24" height="24" border="0" alt="ERRORES" /></a>
        <?php 
                        } else {
                            ?>
        <img src="<?php 
                            echo CONSTANT_PATH_SIMA_RAIZ;
                            ?>
/imagenes/candado.png" width="22" height="22" alt="OK" />
        <?php 
                        }
                        ?>
   </td>
      

      
      

      
      
    </tr><?php 
                    }
                }
                ?>
    <tr>
      <td >&nbsp;</td>
      <td colspan="2" >&nbsp;</td>
      <td >&nbsp;</td>
      <td colspan="3" >&nbsp;</td>
    </tr>
    
    <tr>
      <td colspan="7">&nbsp;</td>
    </tr>
  </table>

    <div align="center"></label>
  </div>
    <p align="center">
      <?php 
            }
            ?>
    <input name="gpoProducto" type="hidden" id="numPaciente2" value="<?php 
            echo $gpoProducto;
            ?>
" />
    <input name="numeroMedico1" type="hidden" id="numeroMedico1" value="<?php 
            echo $numeroMedico;
            ?>
" />
    <input name="nombreDelPaciente2" type="hidden" id="nombreDelPaciente2" value="<?php 
            echo $nombreDelPaciente;
            ?>
" />
    <input name="extension2" type="hidden" id="extension2" value="<?php 
            echo $extension;
            ?>
" />
    <input name="segu1" type="hidden" id="segu1" value="<?php 
            echo $segu;
            ?>
" />
    <input name="bandera" type="hidden" id="numPaciente22" value="<?php 
            echo $bandera;
            ?>
" />
</p>
  
<?php 
        }
        //si existe priceLevel aparece
        ?>
  
  
</form>
    
    
    
    
    <div class="notice" align="center">    
<?php 
        if ($bandera) {
            ?>
		 <?php 
            if (is_numeric($_POST['nomArticulo'])) {
                echo "";
            } else {
                echo "Se encontraron {$bandera} articulos con la palabra: {$articulo}";
            }
            ?>
		<?php 
        } else {
            ?>
		<?php 
            //echo "No se encontro el articulo"
            ?>
		<?php 
        }
        ?>
</div>
</body>
</html>


<?php 
    }
Example #20
0
        ?>
">
	  <?php 
        echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
        ?>
</span></td>
      <td bgcolor="<?php 
        echo $color;
        ?>
" class="Estilo24"><span class="<?php 
        echo $estilo;
        ?>
"><span class="style12"><span class="style7">
      <?php 
        $descripcion = new articulosDetalles();
        $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
        ?>
      </span></span>        <span class="style12">
		
        <?php 
        if ($myrow811['um'] == 's' or $myrow811['um'] == 'S') {
            echo '  ( Servicio )  ';
        }
        ?>

      </span> </span></td>
      <td bgcolor="<?php 
        echo $color;
        ?>
" class="Estilo24"><div align="center"><span class="<?php 
        echo $estilo;
            echo $color;
            ?>
" class="style12"><span class="Estilo24"><span class="style7"><?php 
            echo $code1;
            ?>
</span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="style12"><span class="Estilo24"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style7">
        <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($myrow['keyCAP'], $numeroE, $nCuenta, $codigo, $basedatos);
            ?>
      </span></span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="style12"><span class="Estilo24"><span class="style7">
        <?php 
            if ($myrow7['um']) {
                echo $myrow7['um'];
            } else {
                echo "Sin UM";
            }
            ?>
      </span></span></td>
      <td bgcolor="<?php 
Example #22
0
    public function eCuentaE($fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>
<script language=javascript> 
function ventanaSecundaria4 (URL){ 
   window.open(URL,"ventana4","width=800,height=300,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=630,height=500,scrollbars=YES,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria1 (URL){ 
   window.open(URL,"ventana1","width=530,height=300,scrollbars=YES") 
} 
</script> 

<script language=javascript> 
function ventanaSecundaria5 (URL){ 
   window.open(URL,"ventana5","width=500,height=500,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria3 (URL){ 
   window.open(URL,"ventana3","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>

<script language=javascript> 
function ventanaSecundaria6 (URL){ 
   window.open(URL,"ventana6","width=500,height=400,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language=javascript> 
function ventanaSecundaria7 (URL){ 
   window.open(URL,"ventana7","width=500,height=600,scrollbars=YES,resizable=YES, maximizable=YES") 
} 
</script>
<script language="javascript" type="text/javascript">   
//Validacion de campos de texto no vacios by Mauricio Escobar   
//   
//Iv�n Nieto P�rez   
//Este script y otros muchos pueden   
//descarse on-line de forma gratuita   
//en El C�digo: www.elcodigo.com   
  
  
//*********************************************************************************   
// Function que valida que un campo contenga un string y no solamente un " "   
// Es tipico que al validar un string se diga   
//    if(campo == "") ? alert(Error)   
// Si el campo contiene " " entonces la validacion anterior no funciona   
//*********************************************************************************   
  
//busca caracteres que no sean espacio en blanco en una cadena   
function vacio(q) {   
        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true   
                }   
        }   
        return false   
}   
  
//valida que el campo no este vacio y no tenga solo espacios en blanco   
function valida(F) {   
           
        if( vacio(F.campo.value) == false ) {   
                alert("Introduzca un cadena de texto.")   
                return false   
        } else {   
                alert("OK")   
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario   
                return true   
        }   
           
}   
  
  
  
  
</script> 

<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "Este campo s�lo acepta n�meros."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
<script type="text/javascript">
<!-- por carlitos. cualquier duda o pregunta, visita www.forosdelweb.com

var ancho=100
var alto=100
var fin=300
var x=100
var y=100

function inicio()
{
ventana = window.open("cita.php", "_blank", "height=1,width=1,top=x,left=y,screenx=x,screeny=y");
abre();
}
function abre()
{
if (ancho<=fin) {
ventana.moveto(x,y);
ventana.resizeto(ancho,alto);
x+=5
y+=5
ancho+=15
alto+=15
timer= settimeout("abre()",1)
}
else {
cleartimeout(timer)
}
}
// -->
</script>




<?php 
        //************************ACTUALIZO **********************
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['nT'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['actualizar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            for ($i = 0; $i <= $_POST['bandera2']; $i++) {
                if ($aseguradora[$i]) {
                    $status = 'efectivo';
                    $keyCAP[] = $aseguradora[$i];
                } else {
                    $status = 'cxc';
                    $keyCAP[] = $particular[$i];
                }
                $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusAlta='" . $status . "',\r\nusuarioAlta='" . $usuario . "',\r\nfechaAlta='" . $fecha1 . "',\r\nhoraAlta='" . $hora1 . "'\r\n\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "' \r\n";
                mysql_db_query($basedatos, $agrega);
                echo mysql_error();
            }
            //cierra for
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['imprimir']) {
            ?>
<script>
javascript:ventanaSecundaria2('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/INGRESOS%20HLC/caja/imprimeCaja2.php?numeroE=<?php 
            echo $numeroE;
            ?>
&amp;nCuenta=<?php 
            echo $nCuenta;
            ?>
&amp;paciente=<?php 
            echo $_POST['paciente'];
            ?>
&amp;numeroConfirmacion=<?php 
            echo $numeroConfirmacion;
            ?>
&amp;hora1=<?php 
            echo $hora1;
            ?>
');
</script>
<?php 
        }
        ?>
<!-Hoja de estilos del calendario --> 
  <link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-tas.css" title="win2k-cold-1" /> 

  <!-- librer�a principal del calendario --> 
 <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar.js"></script> 

 <!-- librer�a para cargar el lenguaje deseado --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/lang/calendar-es.js"></script> 

  <!-- librer�a que declara la funci�n Calendar.setup, que ayuda a generar un calendario en unas pocas l�neas de c�digo --> 
  <script type="text/javascript" src="<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/calendario/calendar-setup.js"></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>

<script>

function muestra_oculta(id){
if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable "el" igual a nuestro div
el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la funci�n lo que predetermina que div estar� oculto hasta llamar a la funci�n nuevamente*/
muestra_oculta('contenido_a_mostrar');/* "contenido_a_mostrar" es el nombre de la etiqueta DIV que deseamos mostrar */
}
</script>

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


<title></title>
<style type="text/css">
<!--
.style13 {color: #FFFFFF}
.style11 {color: #FFFFFF; font-size: 10px; font-weight: bold; }
.style7 {font-size: 9px}
.Estilo24 {font-size: 10px}
.style19 {color: #000000; font-weight: bold; }
-->
</style>


</head>
<style type="text/css">
<!--
.style12 {font-size: 10px}
.style14 {font-size: 10px; color: #FFFFFF; }
.style21 {color: #FF0000}
-->
</style>




<BODY >

<h1 align="center">Nota de Venta </h1>
<form id="form1" name="form1" method="post" action="">
  <table width="642" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left">N&uacute;mero de Transacci&oacute;n: </div></th>
      <th bgcolor="#660066" class="style14" scope="col"><div align="left"><?php 
        echo $nCliente = $myrow3['keyClientesInternos'];
        ?>
          <input name="numeroE" type="hidden" class="Estilo24" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>
      </th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <th width="134" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>Paciente: </strong></div></th>
      <th width="408" bgcolor="#FFCCFF" class="Estilo24" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <th width="10" class="Estilo24" scope="col">&nbsp;</th>
      <td class="Estilo24">Compa&ntilde;&iacute;a: </td>
      <td class="Estilo24"><label> <?php 
        echo $traeSeguro = $myrow3['seguro'];
        ?>
            <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
            <input name="seguro2" type="hidden" id="seguro2" value="<?php 
        echo $traeSeguro;
        ?>
" />
      </label></td>
    </tr>
    <tr>
      <th class="Estilo24" scope="col">&nbsp;</th>
      <td bgcolor="#FFCCFF" class="Estilo24">N&deg; Credencial: </td>
      <td bgcolor="#FFCCFF" class="Estilo24"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  

  
  <table width="675" border="0" align="center">
    <tr>
      <th width="105" height="14" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Fecha/Hora </span></th>
      <th width="348" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Descripci&oacute;n/Concepto</span></th>
      <th width="21" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Cant</span></th>
      <th width="73" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Importe</span></th>
      <th width="51" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">IVA</span></th>
      <th width="51" bgcolor="#660066" class="style14" scope="col"><span class="style12 ">Convenio</span></th>
    </tr>
    <tr>
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\nkeyCAP,codProcedimiento,um,hora1,fecha1,cantidad,iva,almacenDestino,almacenSolicitante,precioVenta,tipoCliente,tipoConvenio\r\nFROM\r\ncargosCuentaPaciente \r\n WHERE \r\n numeroE = '" . $numeroE . "'\r\n \r\n and nCuenta='" . $nCuenta . "'\r\nand\r\nstatusCargo!='cancelado'\r\n \r\n \r\n \r\n  order by fecha1,hora1 asc\r\n";
        $result81 = mysql_db_query($basedatos, $sSQL81);
        while ($myrow81 = mysql_fetch_array($result81)) {
            $a += '1';
            $art = $myrow81['codProcedimiento'];
            $codigo = $proc = $myrow81['codProcedimiento'];
            $keyCAP = $myrow81['keyCAP'];
            ?>




      <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><span class="<?php 
            echo $estilo;
            ?>
">
	  <?php 
            echo $myrow81['hora1'] . " " . cambia_a_normal($myrow81['fecha1']);
            ?>
</span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style12"><span class="style7">
      <?php 
            $descripcion = new articulosDetalles();
            $descripcion->descripcion($numeroE, $nCuenta, $codigo, $basedatos);
            ?>
      </span></span>        <span class="style12">
		
        <?php 
            if ($myrow811['um'] == 's' or $myrow811['um'] == 'S') {
                echo '  ( Servicio )  ';
            }
            ?>

      </span> </span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="center"><span class="<?php 
            echo $estilo;
            ?>
">
          <?php 
            echo $cantidad = $myrow81['cantidad'];
            ?>
      </span></div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style12"><span class="style7">
        <?php 
            $importe = new acumulados();
            echo $importe->importe($keyCAP, $basedatos);
            ?>
      </span></span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><span class="<?php 
            echo $estilo;
            ?>
"><span class="style12"><span class="style7">
        <?php 
            $mostrarIVA = new articulosDetalles();
            echo $mostrarIVA->mostrarIVA($keyCAP, $basedatos);
            ?>
      </span></span></span></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="Estilo24"><div align="center"><span class="<?php 
            echo $estilo;
            ?>
">
	   
      <span class="style12"><span class="style7">
      <?php 
            if ($myrow81['tipoConvenio'] and $myrow81['tipoConvenio'] != 'No') {
                echo 'C';
            } else {
                echo '---';
            }
            ?>
    </span></span> </span></div></td>

		
	</tr>
 
	
	
    <?php 
        }
        ?>
  </table>

  <p>&nbsp;</p>
  <div align="center">
    <table width="558" border="0" align="center" class="style12">
      <tr>
        <td width="113" class="style12">&nbsp;</td>
        <td width="124" class="style12">&nbsp;</td>
        <td width="97" class="style12"><span class="style7">Total Cargos </span>          <?php 
        $totalAcumulado = new acumulados();
        echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta), 2);
        ?>
</td>
        <td width="106" height="23" class="style12"><span class="style7">Total Abonos     
          <?php 
        $abonos = new acumulados();
        echo "\$" . number_format($abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), 2);
        ?>
        </span></td>
        <td width="96" class="style12"><div align="right">
        Saldo Actual 
          <?php 
        echo "\$" . number_format($totalAcumulado->totalAcumulado($basedatos, $usuario, $numeroE, $nCuenta) - $abonos->abonos($basedatos, $usuario, $numeroE, $nCuenta), 2);
        ?>
          </div></td>
      </tr>
    </table>


  </div>
  <p align="center">
<?php 
        if (!$totalCargos) {
            ?>
    <input name="imprimir" type="submit" class="style7" id="aplicarPago" value="Imprimir" />
	<?php 
        }
        ?>
	<input name="Submit" type="button" class="style7" value="Aplicar Pagos"  onClick="javascript:ventanaSecundaria7('<?php 
        echo CONSTANT_PATH_SIMA_RAIZ;
        ?>
/INGRESOS%20HLC/caja/ventanaAplicaPagoInternos.php?numeroE=<?php 
        echo $numeroE;
        ?>
		&amp;almacen=<?php 
        echo $bali;
        ?>
&amp;seguro=<?php 
        echo $_POST['seguro'];
        ?>
&amp;nCuenta=<?php 
        echo $myrow3['keyClientesInternos'];
        ?>
&amp;tipoCliente=<?php 
        echo 'particular';
        ?>
')"/>
  </p>


</form>

<p align="center">&nbsp;</p>

</body>
</html>
<?php 
    }
    public function serviciosxSurtir($usuario, $entidad, $ventana, $titulo, $ALMACEN, $fecha1, $hora1, $basedatos)
    {
        ?>
<script language=javascript> 
function ventanaSecundaria (URL){ 
   window.open(URL,"ventana1","width=600,height=300,scrollbars=YES") 
} 
</script> 
<script language=javascript> 
function ventanaSecundaria2 (URL){ 
   window.open(URL,"ventana2","width=800,height=300,scrollbars=YES") 
} 
</script> 
  <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>





<?php 
        if ($_POST['surte'] and $_POST['keyCAP']) {
            $keyCAP = $_POST['keyCAP'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                $kC = $keyCAP[$i];
                if ($keyCAP[$i]) {
                    $iS += 1;
                    $q = "UPDATE cargosCuentaPaciente set \r\nstatusCargo = 'cargado',statusTraslado='standby',statusImpresionSolicitud='standby'\r\nwhere\r\n\r\nkeyCAP='" . $keyCAP[$i] . "'\r\n";
                    mysql_db_query($basedatos, $q);
                    echo mysql_error();
                }
            }
            ?>
<script>
javascript:ventanaSecundaria('<?php 
            echo CONSTANT_PATH_SIMA_RAIZ;
            ?>
/cargos/imprimirServiciosPendientes.php?usuario=<?php 
            echo $usuario;
            ?>
&numeroE=<?php 
            echo $numeroE;
            ?>
&nCuenta=<?php 
            echo $nCuenta;
            ?>
&medico=<?php 
            echo $_POST['medico'];
            ?>
&usuario=<?php 
            echo $usuario;
            ?>
&bandera=<?php 
            echo $iS;
            ?>
');
</script>
<?php 
        }
        ?>

<!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;}
-->
</style>
</head>
<META HTTP-EQUIV="Refresh"
CONTENT="30"> 
<body>
<form id="form1" name="form1" method="post" action="#">
  <h1 align="center"><?php 
        echo $titulo;
        ?>
</h1>
  <table width="756" border="0" align="center">
    <tr>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Hora:</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Descripci&oacute;n</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Paciente:</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">TipoPx</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Depto, Solicita</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">Prioridad</span></div></th>
      <th bgcolor="#660066" class="style12" scope="col"><div align="left"><span class="style11 style13">Cargar</span></div></th>
    </tr>
    <tr>
      <?php 
        $sSQL = "SELECT *\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\ncargosCuentaPaciente.entidad='" . $entidad . "' \r\nAND\r\ncargosCuentaPaciente.almacenDestino = '" . $ALMACEN . "'  \r\nAND \r\ncargosCuentaPaciente.fechaSolicitud='" . $fecha1 . "'\r\nand\r\ncargosCuentaPaciente.statusCargo='standby' \r\nAND \r\n(cargosCuentaPaciente.tipoPaciente='interno' or cargosCuentaPaciente.tipoPaciente='urgencias')\r\n\r\n\r\nORDER BY cargosCuentaPaciente.horaSolicitud,cargosCuentaPaciente.prioridad ASC\r\n ";
        if ($result = mysql_db_query($basedatos, $sSQL)) {
            while ($myrow = mysql_fetch_array($result)) {
                $bandera += 1;
                if ($col) {
                    $color = '#FFCCFF';
                    $col = "";
                } else {
                    $color = '#FFFFFF';
                    $col = 1;
                }
                $numeroE = $myrow['numeroE'];
                $sSQL34 = "Select max(nCuenta) as maximoNC From clientesInternos WHERE entidad='" . $entidad . "' AND numeroE = '" . $numeroE . "' ";
                $result34 = mysql_db_query($basedatos, $sSQL34);
                $myrow34 = mysql_fetch_array($result34);
                $nCuenta = $myrow34['maximoNC'];
                $sSQL31 = "SELECT *\r\nFROM\r\nclientesInternos\r\nWHERE \r\nentidad='" . $entidad . "' AND\r\nnumeroE= '" . $numeroE . "' and nCuenta='" . $nCuenta . "'\r\n ";
                $result31 = mysql_db_query($basedatos, $sSQL31);
                $myrow31 = mysql_fetch_array($result31);
                $E = $myrow['keyCAP'];
                $codigo = $myrow['codProcedimiento'];
                ?>
      <td width="70" height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
        <?php 
                echo $myrow['hora1'];
                ?>
       
      </span></td>
      <td width="218" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
	<?php 
                $descripcion = new articulosDetalles();
                $descripcion->descripcion($keyCAP, $numeroE, $nCuenta, $codigo, $basedatos);
                ?>
	  </span></td>
      <td width="202" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                echo $myrow31['paciente'];
                ?>
</span></td>
      <td width="55" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7">
	  <?php 
                echo $myrow['tipoPaciente'];
                ?>
      </span></td>
      <td width="68" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                echo $myrow['almacenSolicitante'];
                ?>
</span></td>
      <td width="29" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><span class="style7"><?php 
                if ($myrow31['cuarto']) {
                    echo $myrow31['cuarto'];
                } else {
                    echo "---";
                }
                ?>
</span></td>
      <td width="40" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><?php 
                echo $myrow['prioridad'];
                ?>
</td>
      <td width="40" bgcolor="<?php 
                echo $color;
                ?>
" class="style12"><a href="javascript:ventanaSecundaria('reporteReportes.php?numeroE=<?php 
                echo $numeroE;
                ?>
&amp;nCuenta=<?php 
                echo $nCuenta;
                ?>
&amp;codigoArticulo=<?php 
                echo $myrow['codProcedimiento'];
                ?>
&amp;medico=<?php 
                echo $_POST['medico'];
                ?>
&amp;usuario=<?php 
                echo $usuario;
                ?>
')">
        <label>        </label>
      </a>


<a href="javascript:ventanaSecundaria('<?php 
                echo CONSTANT_PATH_SIMA_RAIZ;
                ?>
/cargos/imprimirServiciosPendientes.php?numeroE=<?php 
                echo $numeroE;
                ?>
&amp;nCuenta=<?php 
                echo $nCuenta;
                ?>
&amp;keyCAP=<?php 
                echo $E;
                ?>
&amp;medico=<?php 
                echo $_POST['medico'];
                ?>
&amp;usuario=<?php 
                echo $usuario;
                ?>
')"></a>

	  <label>

	  <input name="keyCAP[]" type="checkbox" id="keyCAP" value="<?php 
                echo $myrow['keyCAP'];
                ?>
" />
	  </label></td>
    </tr>
	    <input name="bandera" type="hidden" id="bandera" value="<?php 
                echo $bandera;
                ?>
" />
    <?php 
            }
        }
        ?>
    <input name="nombres" type="hidden" value="<?php 
        echo $nombrePaciente;
        ?>
" />
  </table>
  <p align="center">
    <label>
    <input name="surte" type="submit" class="style7" id="surte" value="Surtir" />
    </label>
</p>
</form>
</body>
</html>

<?php 
    }