Example #1
0
    <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'];
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>
Example #2
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 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 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 eCuentaE($entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        $cargosParticularesCC = new cierraCuenta();
        $cargosAseguradoraCC = new cierraCuenta();
        ?>
<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 
        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 
        }
        ?>












<?php 
        //************************ACTUALIZO **********************
        $sSQL3 = "Select * From clientesInternos WHERE entidad='" . $entidad . "' and folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $keyClientesInternos = $myrow3['keyClientesInternos'];
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        $entidad = $myrow3['entidad'];
        if ($myrow3['seguro']) {
            $tipoCliente = 'aseguradora';
            $seguro = $myrow3['seguro'];
        } else {
            $tipoCliente = 'particular';
        }
        //***************aplicar pago**********************
        //transaccion estatica
        if ($_POST['aplicar'] and is_numeric($_POST['porcentaje']) and $_POST['gpoProducto']) {
            $keyCAP = $_POST['keyCAP'];
            $fechaDescuento = $fecha1 . ' ' . $hora1;
            if ($_POST['gpoProducto'] == '*') {
                $sSQL7 = "SELECT keyCAP\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\nand\r\ngpoProducto!=''\r\n\r\n";
            } else {
                $sSQL7 = "SELECT keyCAP\r\nFROM\r\ncargosCuentaPaciente\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\nand \r\ngpoProducto='" . $_POST['gpoProducto'] . "'\r\n";
            }
            $result7 = mysql_db_query($basedatos, $sSQL7);
            while ($myrow7 = mysql_fetch_array($result7)) {
                if ($myrow3['seguro']) {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\nfechaDescuento='" . $fechaDescuento . "',\r\nusuarioDescuento='" . $usuario . "',\r\nstatusDescuento='aplicado',\r\nprecioOriginal=precioVenta,\r\nivaOriginal=iva,\r\nprecioVenta=precioVenta-precioVenta*('" . $_POST['porcentaje'] . "'*0.01),\r\ncantidadAseguradora=cantidadAseguradora-cantidadAseguradora*('" . $_POST['porcentaje'] . "'*0.01),\r\nivaParticular=ivaAseguradora-ivaAseguradora*('" . $_POST['porcentaje'] . "'*0.01),\r\niva=iva-iva*('" . $_POST['porcentaje'] . "'*0.01)\r\n\r\nwhere\r\nkeyCAP='" . $myrow7['keyCAP'] . "'\r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                } else {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\nusuarioDescuento='" . $usuario . "',\r\nfechaDescuento='" . $fechaDescuento . "',\r\nstatusDescuento='aplicado',\r\nprecioOriginal=precioVenta,\r\nivaOriginal=iva,\r\nprecioVenta=precioVenta-precioVenta*('" . $_POST['porcentaje'] . "'*0.01),\r\ncantidadParticular=cantidadParticular-cantidadParticular*('" . $_POST['porcentaje'] . "'*0.01),\r\nivaParticular=ivaParticular-ivaParticular*('" . $_POST['porcentaje'] . "'*0.01),\r\niva=iva-iva*('" . $_POST['porcentaje'] . "'*0.01)\r\n\r\nwhere\r\nkeyCAP='" . $myrow7['keyCAP'] . "'\r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
            $agrega = "UPDATE clientesInternos set \r\ndescuento='si',\r\nporcentajeDescuento='" . $_POST['porcentaje'] . "',\r\nusuarioDescuento='" . $usuario . "'\r\nwhere\r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\n";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            $sSQL7 = "Select descripcionGP From gpoProductos where entidad='" . $entidad . "' and codigoGP='" . $_POST['gpoProducto'] . "'";
            $result7 = mysql_db_query($basedatos, $sSQL7);
            $myrow7 = mysql_fetch_array($result7);
            echo mysql_error();
            ?>
<script>
window.alert("Se le hizo un descuento del <?php 
            echo $_POST['porcentaje'];
            ?>
%");
window.opener.document.forms["form10"].submit();
window.close();
</script>
<?php 
        }
        ?>














<?php 
        if ($_POST['actualiza']) {
            $seguro = $_POST['seguro'];
            $keyCAP = $_POST['keyCAP'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($seguro[$i]) {
                    $agrega = "UPDATE cargosCuentaPaciente set \r\nseguro='" . $seguro[$i] . "'\r\nwhere\r\nkeyCAP='" . $keyCAP[$i] . "'\r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                }
            }
            ?>
<script>
window.alert("Se actualizaron registros!");
</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">



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

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



<BODY  >
<?php 
        //ventanasPrototype::links();
        ?>
<h1 align="center" class="titulos">Estado de Cuenta Informativo</h1>
<p align="center" class="negro">No v&aacute;lido para fines fiscales</p>
<form id="form1" name="form1" method="post" action="">
  <table width="582" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="normal">
    <tr>
      <th bgcolor="#330099" class="blancomid" scope="col"><div align="left">Folio de Venta</div></th>
      <th bgcolor="#330099" class="blanco" scope="col"><div align="left"><?php 
        echo $_GET['folioVenta'];
        $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="168" bgcolor="#330099" class="normal" scope="col"><div align="left" class="blancomid"><strong>Paciente</strong></div></th>
      <th width="407" bgcolor="#FFFFFF" class="normalmid" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Compa&ntilde;&iacute;a</td>
<td bgcolor="#FFFFFF" class="normalmid"><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="#330099" class="blancomid">N&deg; Credencial</td>
      <td bgcolor="#FFFFFF" class="normalmid"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Fecha de Reporte</td>
      <td bgcolor="#FFFFFF" class="normalmid"><span class="normal">
        <label>
        <?php 
        print cambia_a_normal($myrow3['fecha']);
        ?>
        <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 bgcolor="#330099" class="blancomid" scope="col"><div align="left"><strong>M&eacute;dico</strong></div></th>
      <th bgcolor="#FFFFFF" class="normalmid" scope="col"><div align="left">
          <label></label>
          
          <?php 
        $sSQL18 = "Select descripcion From almacenes WHERE entidad='" . $entidad . "' and almacen='" . $myrow3['medico'] . "'";
        $result18 = mysql_db_query($basedatos, $sSQL18);
        $rNombre18 = mysql_fetch_array($result18);
        ?>
          <?php 
        echo $dr = "Dr(a): " . $rNombre18['descripcion'];
        ?>
 </div></th>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Fecha Internamiento</td>
      <td bgcolor="#FFFFFF" class="normalmid"><?php 
        print cambia_a_normal($myrow3['fecha']);
        ?>
</td>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Dx Entrada</td>
      <td bgcolor="#FFFFFF" class="normalmid"><?php 
        print $myrow3['dx'];
        ?>
</td>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Tipo de Vista</td>
      <td bgcolor="#FFFFFF" class="normalmid"><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>
  
  
  
  
  
  
  
  
  
  
  <p>
    <?php 
        if ($_POST['tipoVista']) {
            ?>
  </p>



  
  
  <table width="994" border="0.2" align="center">
    <tr bgcolor="#330099">
      <th width="42" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Ref</div>
      </div></th>
      <th width="42" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Fecha</div>
      </div></th>
      <th width="260" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Descripcion</div>
      </div></th>
      <th width="118" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Departamento/Dr</div>
      </div></th>
      <th width="159" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Tipo</div>
      </div></th>
      <th width="36" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Cant.</div>
      </div></th>
      <th width="70" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">P.Unit.</div>
      </div></th>
      <th width="70" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Part.</div>
      </div></th>
      <th width="67" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">Aseg.</div>
      </div></th>
      <th width="42" bgcolor="#330099" class="blanco" scope="col"><div align="left" class="blancomid">
          <div align="center">IVA</div>
      </div></th>
      <th width="42" bgcolor="#330099" class="blanco" scope="col">N</th>
    </tr>
    <tr>
      <?php 
            $sSQL = "SELECT \r\n* \r\nFROM cargosCuentaPaciente\r\nWHERE\r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'\r\nand\r\n gpoProducto!=''\r\n order by descripcionArticulo\r\n  ASC\r\n";
            $result = mysql_db_query($basedatos, $sSQL);
            while ($myrow = mysql_fetch_array($result)) {
                $bandera += "1";
                $gpoProducto = $myrow['gpoProducto'];
                $code1 = $myrow['codProcedimiento'];
                //*************************************CONVENIOS********************************************
                $sSQL12 = "\r\nSELECT descripcion\r\nFROM\r\n  articulos\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\n(keyPA='" . $myrow['keyPA'] . "' or codigo='" . $myrow['codProcedimiento'] . "')\r\n";
                $result12 = mysql_db_query($basedatos, $sSQL12);
                $myrow12 = mysql_fetch_array($result12);
                //cierro descuento
                if ($myrow['statusDevolucion'] == 'si' and $myrow['naturaleza'] == 'A') {
                    $devolucionFinal[0] += $myrow['precioVenta'] * $myrow['cantidad'] + $myrow['iva'] * $myrow['cantidad'];
                }
                if ($myrow['naturaleza'] == 'C') {
                    $cargosFinal[0] += $myrow['precioVenta'] * $myrow['cantidad'];
                }
                if ($myrow['statusDevolucion'] != 'si') {
                    if ($myrow['naturaleza'] == 'A') {
                        $abonosFinal[0] += $myrow['precioVenta'] * $myrow['cantidad'];
                    }
                }
                ?>
    </tr>
    <tr bgcolor="#FFFFFF" onMouseOver="bgColor='#ffff33'" onMouseOut="bgColor='#ffffff'" >
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="codigos"><?php 
                echo $myrow['keyCAP'];
                ?>
</td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><?php 
                echo cambia_a_normal($myrow['fecha1']);
                ?>
</td>
      <td height="24" bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><?php 
                if ($myrow['status'] == 'transaccion') {
                    $sSQL341 = "Select descripcion From catTTCaja WHERE entidad='" . $entidad . "' and codigoTT = '" . $myrow['tipoTransaccion'] . "'";
                    $result341 = mysql_db_query($basedatos, $sSQL341);
                    $myrow341 = mysql_fetch_array($result341);
                    echo $myrow341['descripcion'];
                } else {
                    echo $myrow['descripcionArticulo'];
                }
                ?>
          <?php 
                echo '</br>';
                if ($myrow['statusDevolucion'] == 'si' and $myrow['naturaleza'] == 'A') {
                    print '<span class="error">' . '[Devolucion Folio: ' . $myrow['folioDevolucion'] . ']' . '</span>';
                } else {
                    if ($myrow['statusCargo'] == 'standbyR') {
                        print '<blink><span  class="error">' . 'El usuario: ' . $myrow['usuario'] . ' no ha enviado la solicitud!' . '</span></blink>';
                    } else {
                        if ($myrow['statusCargo'] == 'standby') {
                            print '<span class="error">' . '[sin surtir]' . '</span>';
                        } else {
                            if ($myrow['statusCargo'] == 'cargado') {
                                print '<span  class="codigos">' . '[cargado]' . '</span>';
                            }
                        }
                    }
                }
                //echo $myrow['statusDevolucion'].$myrow['folioDevolucion'];
                ?>
      </td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center">
          <?php 
                $sSQL12a1 = "\r\nSELECT descripcion\r\nFROM\r\nalmacenes\r\nWHERE\r\nentidad='" . $entidad . "'\r\n and\r\nalmacen='" . $myrow['almacenDestino'] . "'\r\n";
                $result12a1 = mysql_db_query($basedatos, $sSQL12a1);
                $myrow12a1 = mysql_fetch_array($result12a1);
                echo $myrow12a1['descripcion'];
                ?>
      </div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center">
          <?php 
                $sSQL12a = "\r\nSELECT descripcionGP\r\nFROM\r\ngpoProductos\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\ncodigoGP='" . $myrow['gpoProducto'] . "'\r\n";
                $result12a = mysql_db_query($basedatos, $sSQL12a);
                $myrow12a = mysql_fetch_array($result12a);
                echo $myrow12a['descripcionGP'];
                ?>
      </div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center"><?php 
                echo $myrow['cantidad'];
                ?>
</div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center">
        <?php 
                if ($myrow['naturaleza'] == 'C') {
                    echo '$' . number_format($myrow['precioVenta'], 2);
                }
                ?>
      </div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center"><span class="precionormal2">
          <?php 
                if ($myrow['naturaleza'] == 'C') {
                    $particular[0] += $myrow['cantidadParticular'] * $myrow['cantidad'] + $myrow['ivaParticular'] * $myrow['cantidad'];
                    if ($myrow['cantidadParticular'] * $myrow['cantidad'] + $myrow['ivaParticular'] * $myrow['cantidad']) {
                        echo "\$" . number_format($myrow['cantidadParticular'] * $myrow['cantidad'] + $myrow['ivaParticular'] * $myrow['cantidad'], 2);
                    } else {
                        echo "0.00";
                    }
                } else {
                    if ($myrow['naturaleza'] == 'A') {
                        echo '-$' . number_format($myrow['precioVenta'], 2);
                    }
                }
                ?>
      </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center"><span class="precionormal1">
          <?php 
                if ($myrow['naturaleza'] == 'C') {
                    $aseguradora[0] += $myrow['cantidadAseguradora'] * $myrow['cantidad'] + $myrow['ivaAseguradora'] * $myrow['cantidad'];
                    if ($myrow['cantidadAseguradora'] * $myrow['cantidad'] + $myrow['ivaAseguradora'] * $myrow['cantidad']) {
                        echo "\$" . number_format($myrow['cantidadAseguradora'] * $myrow['cantidad'] + $myrow['ivaAseguradora'] * $myrow['cantidad'], 2);
                    } else {
                        echo "0.00";
                    }
                }
                ?>
      </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center"><span class="negro">
          <?php 
                if ($myrow['naturaleza'] == 'C') {
                    $isva[0] += $myrow['iva'] * $myrow['cantidad'];
                    echo '$' . number_format($myrow['iva'] * $myrow['cantidad'], 2);
                }
                ?>
      </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="normal"><div align="center">
        <?php 
                if ($myrow['statusDevolucion'] == 'si' and $myrow['naturaleza'] == 'A') {
                    echo 'A';
                } else {
                    echo $myrow['naturaleza'];
                }
                ?>
      </div></td>
    </tr>
    <?php 
            }
            ?>
  </table>
  <p align="center">&nbsp;</p>
  <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>&nbsp;</p>
    <table width="279" border="0" align="center" class="normal">
      <tr>

	  
        <td width="197" height="23" class="normalmid">Total por Surtir (iva incluido ) </td>
        <td width="72" class="normalmid"><div align="right">
            <?php 
            $totalxSurtir = new acumulados();
            echo "\$" . number_format($totalxSurtir->totalxSurtirFV($entidad, $basedatos, $usuario, $_GET['folioVenta']), 2);
            ?>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p align="left">
    <?php 
            $despliegaTotales = new totales();
            $despliegaTotales->tt($entidad, $class, $estilo, $fechas1, $fechas2, $myrow3['keyClientesInternos'], $_GET['folioVenta'], $basedatos);
            ?>
    </p>
    
    <?php 
        }
        ?>
	
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="379" border="1" align="center" class="style7">
      <tr>
        <th width="91" scope="col"><div align="left"><span class="normal">Grupo de Producto</span></div></th>
        <th width="272" scope="col"><div align="left"><span class="normal">
            <?php 
        //*********gpoProductos
        $sSQL7 = "Select * From gpoProductos where entidad='" . $myrow3['entidad'] . "' AND activo ='activo' ORDER BY descripcionGP ASC ";
        $result7 = mysql_db_query($basedatos, $sSQL7);
        echo mysql_error();
        ?>
            <select name="gpoProducto" class="Estilo24" id="gpoProducto">
              <option value="*">TODOS LOS GRUPOS</option>
              <?php 
        while ($myrow7 = mysql_fetch_array($result7)) {
            ?>
              <option 
		   <?php 
            if ($myrow7['codigoGP'] == $myrow['gpoProducto']) {
                echo 'selected=""';
            }
            ?>
		   value="<?php 
            echo $myrow7['codigoGP'];
            ?>
"><?php 
            echo $myrow7['descripcionGP'];
            ?>
</option>
              <?php 
        }
        ?>
            </select>
        </span></div></th>
      </tr>
      <tr>
        <td><div align="left">Porcentaje: </div></td>
        <td><label>
            <div align="left">
            
            <?php 
        $coaseguroN = new acumulados();
        $coa = $coaseguroN->cargosCoaseguroN($entidad, $basedatos, $usuario, $keyClientesInternos);
        $totalAcumulado = new acumulados();
        $totalDevoluciones = new acumulados();
        $iva = new acumulados();
        $ivaD = new acumulados();
        $iva = $iva->ivaAcumulado($entidad, $basedatos, $usuario, $keyClientesInternos) - $ivaD->ivaAcumuladoD($entidad, $basedatos, $usuario, $keyClientesInternos);
        $cargos = $totalAcumulado->totalAcumulado($basedatos, $usuario, $keyClientesInternos) - $totalDevoluciones->dev($entidad, $basedatos, $usuario, $folioVenta) + $iva + $coa;
        //echo "$".number_format($cargos,2);
        ?>
            
              <input name="porcentaje" type="text" class="style7" id="porcentaje" size="3"  value="<?php 
        echo $_POST['porcentaje'];
        ?>
"  <?php 
        echo $statusD;
        ?>
 autocomplete="off" />
<input name="totalCargos" type="hidden" class="style7" id="porcentaje" 
value="<?php 
        echo $cargos;
        ?>
"/>
              <input name="nT" type="hidden" class="style7" id="porcentaje" value="<?php 
        echo $_GET['nT'];
        ?>
" />
              <input name="bandera" type="hidden" class="style7" id="porcentaje" value="<?php 
        echo $a;
        ?>
" />
            </div>
          </label>
            <label></label></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="aplicar" type="submit" class="style7" id="aplicar" value="Aplicar" <?php 
        echo $statusD;
        ?>
 /></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
	
	
    <p>&nbsp;</p>
  </div>
 

  <p align="center">
    <input name="keyClientesInternos" type="hidden" id="keyClientesInternos" value="<?php 
        echo $myrow3['keyClientesInternos'];
        ?>
" />
  </p>
</form>
<?php 
        if ($_POST['banderaFecha']) {
            ?>
<p align="center">
  <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> 
</p>
<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 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 devolucionInternos($usuario, $folioVenta, $entidad, $basedatos)
    {
        require CONSTANT_PATH_CONFIGURACION . "/clases/generaFolioVenta.php";
        ?>

<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'];
        }
        $dia1 = date("l");
        $hora1 = date("H:i a");
        $fecha1 = date("Y-m-d");
        $sSQL3 = "Select * From clientesInternos WHERE entidad='" . $entidad . "' and folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        $almacenCierreCuenta = $myrow3['almacen'];
        $numeroE = $myrow3['numeroE'];
        $nCuenta = $myrow3['nCuenta'];
        $cuarto = $myrow3['cuarto'];
        //***************aplicar pago**********************
        if ($_POST['aplicar'] and $_POST['keyCAP'] != NULL) {
            $keyCAP = $_POST['keyCAP'];
            //**********GENERO EL NUMERO DE SOLICITUD ************//
            $q = "\r\n\r\n    INSERT INTO solicitudes(numSolicitud,usuario,fecha,entidad,keyClientesInternos,hora)\r\n    SELECT(IFNULL((SELECT MAX(numSolicitud)+1 from solicitudes where entidad='" . $entidad . "'), 1)), '" . $usuario . "',\r\n    '" . $fecha1 . "','" . $entidad . "','" . $_GET['keyClientesInternos'] . "','" . $hora1 . "' ";
            mysql_db_query($basedatos, $q);
            echo mysql_error();
            $sSQL333 = "SELECT\r\n    numSolicitud\r\n    FROM solicitudes\r\n    WHERE\r\n    entidad='" . $entidad . "'\r\n    and\r\n    usuario ='" . $usuario . "'\r\n    order by keySolicitudes DESC\r\n    ";
            $result333 = mysql_db_query($basedatos, $sSQL333);
            $myrow333 = mysql_fetch_array($result333);
            $myrow333['NS'] = $myrow333['numSolicitud'];
            if (!$myrow333['NS']) {
                $myrow333['NS'] = 1;
            }
            //************************************
            //**********************GENERAR FOLIO DE VENTA DEVOLUCION*************
            $generaFolio = new folioVenta();
            $FV = $myrow333['folioVentas'] = $generaFolio->generarFolioVenta(0, $usuario, "interno", $entidad, $tipoFolio, $basedatos);
            //***********************VERIFICO QUE NO SE DUPLIQUE EL FOLIO********************************
            $sSQL3a = "Select * From clientesInternos WHERE entidad='" . $entidad . "' and folioVenta = '" . $FV . "' ";
            $result3a = mysql_db_query($basedatos, $sSQL3a);
            $myrow3a = mysql_fetch_array($result3a);
            if ($myrow3a['keyClientesInternos']) {
                echo '<script>
window.alert("Oops! hay un problema de cache! favor de reportarlo a sistemas");
window.close();
echo </script>';
            }
            //**********************************************************************************************
            //***********************VERIFICO QUE NO SE DUPLIQUE EL FOLIO********************************
            $sSQL3a = "Select status From clientesInternos WHERE entidad='" . $entidad . "' and folioVenta = '" . $FV . "' ";
            $result3a = mysql_db_query($basedatos, $sSQL3a);
            $myrow3a = mysql_fetch_array($result3a);
            if ($myrow3a['status'] == 'cancelado') {
                echo '<script>
window.alert("Oops! este folio esta cancelado!");
window.close();
echo </script>';
            }
            //**********************************************************************************************
            $q4 = "UPDATE clientesInternos set \r\nstatusCargoDevolucion='main',\r\nfolioDevolucion='" . $FV . "',\r\nstatusDevolucion='si',tipoCuenta='D',statusFactura='',numeroFactura='',\r\nusuarioDevolucion='" . $usuario . "',horaDevolucion='" . $hora1 . "',fechaDevolucion='" . $fecha1 . "'\r\nWHERE \r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'";
            mysql_db_query($basedatos, $q4);
            echo mysql_error();
            $agrega = "INSERT INTO clientesInternos ( \r\nnumeroE,nCuenta,\r\nmedico,paciente,\r\nseguro,autoriza,credencial,\r\nfecha,hora,status,cita,almacen,usuario,ip,fecha1,tipoConsulta,medicoForaneo,observaciones,edad,tipoPaciente,nOrden,\r\nstatusExpediente,dependencia,entidad,diagnostico,telefono,folioVenta,clientePrincipal,statusPaciente,\r\ntipoAccidente,\r\nfechaAccidente,\r\nhoraAccidente,\r\nlugarAccidente,\r\nllegoHospital,\r\nministerio,\r\nmotivoConsulta,\r\nalergiaT,\r\nalergiaP,\r\nalergiaR,\r\nalergiaPA,\r\ntiposAlergias,\r\npeso,dx,empleado,statusCuenta,statusCargoDevolucion,tipoCuenta,statusDevolucion,statusCaja,\r\nfolioDevolucion,usuarioDevolucion,horaDevolucion,fechaDevolucion\r\n) values (\r\n'" . $myrow3['numeroE'] . "',\r\n'" . $myrow3['nCuenta'] . "',\r\n'" . $myrow3['medico'] . "',\r\n'" . $myrow3['paciente'] . "',\r\n'" . $myrow3['seguro'] . "',\r\n'" . $myrow3['autoriza'] . "',\r\n'" . $myrow3['credencial'] . "',\r\n'" . $fecha1 . "',\r\n'" . $hora1 . "',\r\n'activa',\r\n'" . $myrow3['cita'] . "',\r\n'" . $myrow3['almacen'] . "',\r\n'" . $myrow3['usuario'] . "',\r\n'" . $ip . "',\r\n'" . $fecha1 . "',\r\n'" . $myrow3['tipoConsulta'] . "',\r\n'" . $myrow3['medicoForaneo'] . "',\r\n'" . $myrow3['observaciones'] . "',\r\n'" . $myrow3['edad'] . "',\r\n'" . $myrow3['tipoPaciente'] . "',\r\n'" . $nOrden . "',\r\n'" . $myrow3['statusExpediente'] . "',\r\n'" . $myrow3['dependencia'] . "',\r\n'" . $entidad . "',\r\n'" . $myrow3['diagnostico'] . "',\r\n'" . $myrow3['telefono'] . "',\r\n'" . $FV . "',\r\n'" . $myrow3['clientePrincipal'] . "',\r\n'" . $myrow3['statusPaciente'] . "',\r\n'" . $myrow3['tipoAccidente'] . "',\r\n'" . $myrow3['fechaAccidente'] . "',\r\n'" . $myrow3['horaAccidente'] . "',\r\n'" . $myrow3['lugarAccidente'] . "',\r\n'" . $myrow3['llegoHospital'] . "',\r\n'" . $myrow3['ministerio'] . "',\r\n'" . $myrow3['motivoConsulta'] . "',\r\n'" . $myrow3['alergiaT'] . "',\r\n'" . $myrow3['alergiaP'] . "',\r\n'" . $myrow3['alergiaR'] . "',\r\n'" . $myrow3['alergiaPA'] . "',\r\n'" . $myrow3['tipoAlergias'] . "',\r\n'" . $myrow3['peso'] . "',\r\n'" . $myrow3['dx'] . "',\r\n'" . $myrow3['empleado'] . "','caja','standby','H','si','standby','" . $FV . "','" . $usuario . "','" . $hora1 . "','" . $fecha1 . "' \r\n)";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            $sSQL3a = "Select keyClientesInternos From clientesInternos WHERE entidad='" . $entidad . "' and folioVenta = '" . $FV . "' ";
            $result3a = mysql_db_query($basedatos, $sSQL3a);
            $myrow3a = mysql_fetch_array($result3a);
            //****************************************************************************************************
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($keyCAP[$i]) {
                    $sSQL1 = "Select * From cargosCuentaPaciente WHERE  keyCAP='" . $keyCAP[$i] . "' ";
                    $result1 = mysql_db_query($basedatos, $sSQL1);
                    while ($myrow1 = mysql_fetch_array($result1)) {
                        //insertar
                        //*****************************KARDEX**************************
                        $karticulos = new kardex();
                        $karticulos->movimientoskardex('entrada', $myrow1['cantidad'], 'ENTRADA POR DEVOLUCION', 'devolucionVenta', $usuario, $fecha1, $hora1, $myrow1['almacenSolicitante'], $myrow1['almacenDestino'], $myrow1['keyPA'], $myrow1['codProcedimiento'], $entidad, $basedatos);
                        //*************************************************************
                        //*********AJUSTE EXISTENCIAS***********
                        //ENTRADA A CENDIS OTRA VEZ
                        $cendis = new whoisCendis();
                        $agrega = "INSERT INTO articulosExistencias (\r\ncodigo,keyPA,gpoProducto,cantidad,tipoVenta,entidad,tipoMov,fecha,hora,usuario,almacen,nOrden,keyClientesInternos,folioVenta)\r\nvalues\r\n('" . $myrow1['codigo'] . "','" . $myrow1['keyPA'] . "','" . $myrow1['gpoProducto'] . "','" . $myrow1['cantidad'] . "','" . $myrow['tipoVenta'] . "','" . $entidad . "','entrada',\r\n    '" . $fecha1 . "','" . $hora1 . "','" . $usuario . "','" . $cendis->cendis($entidad, $basedatos) . "','" . $_GET['nOrden'] . "',\r\n     '" . $myrow1['keyClientesInternos'] . "','" . $myrow1['folioVenta'] . "')";
                        mysql_db_query($basedatos, $agrega);
                        echo mysql_error();
                        //*****************************KARDEX**************************
                        $karticulos = new kardex();
                        $karticulos->movimientoskardex('entrada', $cantidad[$i], 'ENTRADA POR DEVOLUCION', 'devolucionVenta', $usuario, $fecha1, $hora1, $myrow1['almacenSolicitante'], $myrow1['almacenDestino'], $myrow1['keyPA'], $myrow1['codProcedimiento'], $entidad, $basedatos);
                        //*************************************************************
                        //**************************************
                        if ($myrow1['naturaleza'] == '-') {
                            $sSQL317 = "Select * From catTTCaja WHERE entidad='" . $entidad . "' and cancelacionDescuentos = 'si'   ";
                            $result317 = mysql_db_query($basedatos, $sSQL317);
                            $myrow317 = mysql_fetch_array($result317);
                            $tipoTransaccion = $myrow317['codigoTT'];
                            $myrow1['descripcionArticulo'] = 'CANCELACION DE MOVIMIENTO';
                            $naturaleza = $myrow317['naturaleza'];
                            $tipoCuenta = 'D';
                            if ($myrow3a['seguro'] != '') {
                                $myrow1['cantidadAseguradora'] = $myrow1['precioVenta'] * $myrow1['cantidad'];
                                $myrow1['cantidadParticular'] = '';
                            } else {
                                $myrow1['cantidadParticular'] = $myrow1['precioVenta'] * $myrow1['cantidad'];
                                $myrow1['cantidadAseguradora'] = '';
                            }
                        } else {
                            $naturaleza = 'A';
                            $tipoCuenta = 'H';
                        }
                        $agrega = "INSERT INTO cargosCuentaPaciente (\r\nnumeroE,nCuenta,status,usuario,fecha1,dia,cantidad,tipoTransaccion,codProcedimiento,hora1,\r\nnaturaleza,ejercicio,statusDeposito,almacen,usuarioTraslado,precioVenta,iva,seguro,\r\nstatusTraslado,tipoCliente,tipoPaciente,cantidadParticular,cantidadAseguradora,entidad,tipoCobro,statusAuditoria,\r\ntipoPago,statusCargo,porcentajeVariable,cargosHospitalarios,\r\nalmacenSolicitante,almacenDestino,keyClientesInternos,descripcion,statusFactura,horaSolicitud,fechaSolicitud,\r\ncodigoTarjeta,ultimosDigitos,codigoAutorizacion,numeroCheque,bancoTransferencia,bancoCheque,numeroTransferencia,\r\nbanderaPC,statusPC,clientePrincipal,folioVenta,codigoCaja,numRecibo,numCorte,statusDevolucion,keyE,keyPA,numeroConfirmacion,\r\nivaParticular,ivaAseguradora,tipoVentaArticulos,usuarioFactura,\r\nprecioOriginal,ivaOriginal,usuarioDescuento,fechaDescuento,cargoModificable,gpoProducto,numSolicitud,\r\nfolioDevolucion,descripcionArticulo,tipoCuenta,notaCredito,fechaCargo,usuarioCargo,\r\ndescripcionGrupoProducto,descripcionAlmacen,almacenIngreso,\r\n\r\nstatusBeneficencia,\r\n\r\ndiaNumerico,year,mes,\r\n\r\ndescripcionClientePrincipal,descripcionMedico,primeraVez,statusDescuento,medico\r\n)\r\nvalues \r\n('" . $myrow1['numeroE'] . "',\r\n'" . $myrow1['nCuenta'] . "',\r\n'" . $myrow1['status'] . " ',\r\n'" . $usuario . "',\r\n'" . $fecha1 . "',\r\n'" . $dia1 . "',\r\n'" . $myrow1['cantidad'] . "',\r\n'" . $tipoTransaccion . "',\r\n'" . $myrow1['codProcedimiento'] . "',\r\n'" . $hora1 . "',\r\n'" . $naturaleza . "',\r\n'" . $ID_EJERCICIOM . "',\r\n'',\r\n'" . $myrow1['almacen'] . "',\r\n'" . $usuario . "',\r\n'" . $myrow1['precioVenta'] . "',\r\n'" . $myrow1['iva'] . "'\r\n,'" . $myrow1['seguro'] . "',\r\n'" . $myrow1['statusTraslado'] . "',\r\n'',\r\n'" . $myrow1['tipoPaciente'] . "',\r\n'" . $myrow1['cantidadParticular'] . "',\r\n'" . $myrow1['cantidadAseguradora'] . "',\r\n'" . $myrow1['entidad'] . "',\r\n'" . $myrow1['tipoCobro'] . "',\r\n'" . $myrow1['statusAuditoria'] . "'\r\n,'" . $myrow1['tipoPago'] . "',\r\n'cargado',\r\n'" . $myrow1['porcentajeVariable'] . "',\r\n'" . $myrow1['cargosHospitalarios'] . "',\r\n'" . $myrow1['almacenSolicitante'] . "',\r\n'" . $myrow1['almacenDestino'] . "',\r\n\r\n'" . $myrow3a['keyClientesInternos'] . "',\r\n\r\n\r\n'" . $myrow1['descripcion'] . "',\r\n'',\r\n'" . $hora1 . "',\r\n'" . $fecha1 . "',\r\n'" . $fecha1 . "',\r\n'" . $myrow1['codigoTarjeta'] . "',\r\n'" . $myrow1['codigoAutorizacion'] . "',\r\n'" . $myrow1['numeroCheque'] . "',\r\n'" . $myrow1['bancoTransferencia'] . "',\r\n'" . $myrow1['bancoCheque'] . "',\r\n'" . $myrow1['numeroTransferencia'] . "',\r\n'" . $myrow1['banderaPC'] . "',\r\n'" . $myrow1['statusPC'] . "',\r\n'" . $myrow1['clientePrincipal'] . "',\r\n'" . $FV . "',\r\n'" . $myrow1['codigoCaja'] . "',\r\n'" . $myrow1['numRecibo'] . "',\r\n'" . $myrow1['numCorte'] . "',\r\n'si',\r\n'" . $myrow1['keyE'] . "',\r\n'" . $myrow1['keyPA'] . "',\r\n'" . $myrow1['numeroConfirmacion'] . "',\r\n'" . $myrow1['ivaParticular'] . "',\r\n'" . $myrow1['ivaAseguradora'] . "',\r\n'" . $myrow1['tipoVentaArticulos'] . "',\r\n'" . $myrow1['usuarioFactura'] . "',\r\n'" . $myrow1['precioOriginal'] . "',\r\n'" . $myrow1['ivaOriginal'] . "',\r\n'" . $myrow1['usuarioDescuento'] . "',\r\n'" . $myrow1['fechaDescuento'] . "',\r\n'" . $myrow1['cargoModificable'] . "',\r\n'" . $myrow1['gpoProducto'] . "',\r\n\r\n'" . $myrow333['NS'] . "','" . $myrow1['keyCAP'] . "' ,'" . $myrow1['descripcionArticulo'] . "','" . $tipoCuenta . "' ,'si','" . $fecha1 . "',\r\n'" . $usuario . "',\r\n'" . $myrow1['descripcionGrupoProducto'] . "','" . $myrow1['descripcionAlmacen'] . "','" . $myrow1['almacenIngreso'] . "',\r\n\r\n'" . $myrow1['statusBeneficencia'] . "','" . $myrow1['diaNumerico'] . "','" . $myrow1['year'] . "','" . $myrow1['mes'] . "',\r\n\r\n'" . $myrow1['descripcionClientePrincipal'] . "','" . $myrow1['descripcionMedico'] . "','" . $myrow1['primeraVez'] . "','" . $myrow1['statusDescuento'] . "',\r\n    '" . $myrow1['medico'] . "'\r\n)";
                        mysql_db_query($basedatos, $agrega);
                        echo mysql_error();
                    }
                    //while
                }
                //for
                //*******************************************************************************
            }
            //cierra for
            ?>



<script>
window.alert("Se genero el folio de devolucion: <?php 
            echo $FV;
            ?>
");
window.opener.document.forms["form1"].submit();
window.close();
</script>



<?php 
        }
        //cierra actualizar
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        ?>




























<!-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">
.Estilo1 {
	color: #FF0000;
	font-weight: bold;
	font-size: 9px;
}
<!--
-->
</style>
<head>
<?php 
        $showStyles = new muestraEstilos();
        $showStyles->styles();
        ?>
</head>










<BODY  >
<?php 
        //ventanasPrototype::links();
        ?>
<h1 align="center" class="titulos">Devoluciones Px Internos </h1>
<h1 align="center" class="titulos">&nbsp;</h1>
<p align="center" class="codigos">*Si esta deshabilitada la cantidad es porque el almacen no permite tener stock.</p>



<form id="myform" name="myform" method="post" action="">






  <table width="412" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="normal">
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <th bgcolor="#330099" class="blanco" scope="col"><div align="left">Transacci&oacute;n</div></th>
      <th class="normal" scope="col"><div align="left"><?php 
        echo $_GET['folioVenta'];
        ?>
          <input name="numeroE" type="hidden" class="normal" id="numeroE" 
		  value="<?php 
        echo $nCliente = $_POST['numeroE'];
        ?>
" readonly=""/>
</label></div>      </th>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <th width="157" bgcolor="#330099" scope="col"><div align="left" class="blanco"><strong>Paciente</strong></div></th>
      <th width="385" class="normal" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
        echo $myrow3['paciente'];
        ?>
 </div></th>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <td bgcolor="#330099" class="blanco"><div align="left">Compa&ntilde;&iacute;a</div></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 bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <td bgcolor="#330099" class="blanco"><div align="left">N&deg; Credencial</div></td>
      <td class="normal"><?php 
        echo $myrow3['credencial'];
        ?>
 </td>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <th bgcolor="#330099" class="normal" scope="col"><div align="left" class="blanco">
        <div align="left"><strong>M&eacute;dico</strong></div>
      </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 
        $dr = "Dr(a): " . $rNombre18["apellido1"] . " " . $rNombre18["apellido2"] . " " . $rNombre18["apellido3"] . " " . $rNombre18["nombre1"] . " " . $rNombre18["nombre2"];
        ?>
 </div></th>
    </tr>
  </table>
  <p align="center" class="normal"><br />
    <input type="submit" src='../imagenes/btns/cargadevolucion.png' name="aplicar" id="button" value="Aplicar Cambios"  />
  </p>
  
  
  
  
  
  
  
  
  
  
  <table width="988" border="0" align="center">
    <tr bgcolor="#330099">
      <th width="40" class="blanco" scope="col"><div align="center"><span class="blanco ">Ref</span></div></th>
     
      <th width="82" height="14" class="blanco" scope="col"><div align="center"><span class="blanco ">Fecha/Hora </span></div></th>
      <th width="264"  scope="col"><div align="center"><span class="blanco ">Descripci&oacute;n/Concepto</span></div></th>
      <th width="68"  scope="col"><div align="center"><span class="blanco ">Almacen</span></div></th>
      <th width="42"  scope="col"><div align="center"><span class="blanco ">Status</span></div></th>
      <th width="28"  scope="col"><div align="center"><span class="blanco ">N </span></div></th>
      <th width="51"  scope="col"><div align="center"><span class="blanco ">Tipo P </span></div></th>
      <th width="21"  scope="col" class="blanco"><div align="center">C</div></th>
      <th width="66"  scope="col"><div align="center"><span class="blanco ">P.Unit</span></div></th>
      <th width="57"  scope="col"><div align="center"><span class="blanco ">CargosP</span></div></th>
      <th width="59"  scope="col"><div align="center"><span class="blanco ">CargosA</span></div></th>
      <th width="52"  scope="col"><div align="center"><span class="blanco ">IVA</span></div></th>
      <th width="50"  scope="col"><div align="center"><span class="blanco ">Abonos</span></div></th>
      <th width="50"  scope="col"><div align="center"><span class="blanco ">
D
              </span>
          </div>
      </th>
    </tr>
	
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n*,cargosCuentaPaciente.descripcion as descripcionGeneral\r\nFROM\r\ncargosCuentaPaciente\r\n WHERE \r\ncargosCuentaPaciente.folioVenta='" . $_GET['folioVenta'] . "'\r\nand \r\ncargosCuentaPaciente.status!='cancelado'\r\nand\r\ngpoProducto!=''\r\norder by fecha1 DESC\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'];
            $style = 'normal';
            ?>
	
	
	
	

      
      <tr bgcolor="#FFFFFF" onMouseOver="bgColor='#ffff33'" onMouseOut="bgColor='#ffffff'" >
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
"><?php 
            echo $myrow81['keyCAP'];
            ?>
</td>






      <td height="21" bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
"><div align="center"><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 
            echo $myrow81['descripcionArticulo'];
            ?>
		
  
          
          <?php 
            if ($myrow81['gpoProducto']) {
                echo '[' . $myrow81['gpoProducto'] . ']';
            }
            ?>
	  </span>       <span class="Estilo1">
	  <?php 
            //echo $myrow81['statusCargo'];
            if ($myrow81['statusDevolucion'] and $myrow81['statusDevolucion'] != '') {
                echo '</br>';
                if ($myrow81['statusDevolucion'] == 'si' and $myrow81['naturaleza'] == 'C') {
                    echo '   [Hizo el cargo: ' . $myrow81['usuario'] . ']';
                } else {
                    if ($myrow81['statusDevolucion'] == 'si' and $myrow81['naturaleza'] == 'A') {
                        echo '   [Solicito Devolucion: ' . $myrow81['usuario'] . ', Transaccion: ' . $myrow81['folioDevolucion'] . ']';
                    }
                }
            }
            ?>
	  </span> </div></td>
	   
	   
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
"><div align="center"><?php 
            echo $myrow81['almacenDestino'];
            ?>
</div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
">
        
        
        
    
        <div align="center">
          <?php 
            if ($myrow81['statusCargo'] == 'standbyR') {
                echo 'Sin enviar';
            } else {
                if ($myrow81['statusCargo'] == 'standby') {
                    echo 'pendiente surtir';
                } else {
                    if ($myrow81['statusCargo'] == 'cargado') {
                        echo $myrow81['statusCargo'];
                    }
                }
            }
            ?>
        </div></td>
		
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
"> <div align="center"><?php 
            echo $myrow81['naturaleza'];
            ?>
</div></td>
      <td bgcolor="<?php 
            echo $color;
            ?>
" class="<?php 
            echo $style;
            ?>
"><div align="center"><?php 
            echo $myrow81['tipoCliente'];
            ?>
</div></td>
<td class="<?php 
            echo $style;
            ?>
"><div align="center"><?php 
            print $myrow81['cantidad'];
            ?>
</div></td>
      <td class="precionormal2" align="right" ><?php 
            //cargos
            if ($myrow81['naturaleza'] == 'C') {
                echo '$' . number_format($myrow81['precioVenta'], 2);
            } else {
                echo '*';
            }
            ?>
</td>
      <td class="precionormal1" align="right">
	  <?php 
            //cargos
            if ($myrow81['naturaleza'] == 'C') {
                echo '$' . number_format($myrow81['cantidadParticular'] * $myrow81['cantidad'], 2);
            } else {
                echo '*';
            }
            ?>
</td>
      <td class="precionormal1" align="right" ><?php 
            //cargos
            if ($myrow81['naturaleza'] == 'C') {
                echo '$' . number_format($myrow81['cantidadAseguradora'] * $myrow81['cantidad'], 2);
            } else {
                echo '*';
            }
            ?>
</td>
      
	  
	  
	  <td class="normal" align="right">
          <?php 
            if ($myrow81['naturaleza'] == 'C') {
                $sumaIVAS[0] += ($myrow81['ivaAseguradora'] + $myrow81['ivaParticular']) * $myrow81['cantidad'];
                echo '$' . number_format(($myrow81['ivaAseguradora'] + $myrow81['ivaParticular']) * $myrow81['cantidad'], 2);
            } else {
                echo '*';
            }
            ?>
      </span></div></td>
	  
	  
	  
      <td class="precionormal2" ><div align="right">
        <?php 
            if ($myrow81['naturaleza'] == 'A') {
                echo '$' . number_format($myrow81['precioVenta'] * $myrow81['cantidad'], 2);
            }
            ?>
      </div></td>
      <td class="precionormal2" >
        <div align="right">
          <label>
		  <?php 
            if ($myrow81['statusDevolucion'] != 'si') {
                ?>
          <input name="keyCAP[]" type="checkbox" id="keyCAP[]" value="<?php 
                echo $myrow81['keyCAP'];
                ?>
" />
		  <?php 
            } else {
                ?>
		            <input name="keyCAP[]" type="checkbox" id="keyCAP[]" value="<?php 
                echo $myrow81['keyCAP'];
                ?>
" disabled="disabled" />
					<?php 
            }
            ?>
          </label>
        </div></td>
      </tr>
 
	
	
    <?php 
        }
        ?>
  </table>


  <p>
    <label></label>
    <input name="bandera" type="hidden" id="recibo" value="<?php 
        echo $a;
        ?>
" />
  </p>
<div align="center">
            <div align="left">
              <p>&nbsp;</p>
            </div>
  </div>
          <p align="center">
    <input name="keyClientesInternos" type="hidden" id="keyClientesInternos" value="<?php 
        echo $myrow3['keyClientesInternos'];
        ?>
" />
  </p>
</form>

</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();
        $cargosParticularesCC = new cierraCuenta();
        $cargosAseguradoraCC = new cierraCuenta();
        ?>
<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 
        $cargosParticulares = new acumulados();
        $totalxSurtir = new acumulados();
        $cargosAseguradora = new acumulados();
        $otros = new acumulados();
        if ($_POST['cerrar']) {
            $particular = $_POST['particular'];
            $aseguradora = $_POST['aseguradora'];
            //cierro cuenta
            $agrega4 = "UPDATE clientesInternos set \r\ntipoCuenta='H',\r\nstatus='cerrada',\r\nstatusCuenta='cerrada',\r\nusuarioCierre='" . $usuario . "',\r\nfechaCierre='" . $fecha1 . "',\r\nhoraCierre='" . $hora1 . "',\r\nstatusCaja='pagado'\r\nwhere\r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "' ";
            mysql_db_query($basedatos, $agrega4);
            echo mysql_error();
            //********************CIERRO STATUS CUENTA***********************
            $agrega = "UPDATE cargosCuentaPaciente set \r\nstatusCuenta='cerrada',fechaCierre='" . $fecha1 . "'\r\nwhere\r\nentidad='" . $entidad . "'\r\nand\r\nfolioVenta='" . $_GET['folioVenta'] . "'";
            mysql_db_query($basedatos, $agrega);
            echo mysql_error();
            //*********************************************
            //cierro cuarto a sucio
            if ($myrow3['cuarto']) {
                $agregad = "UPDATE cuartos set \r\nstatus='sucio',\r\nusuarioSalida='" . $usuario . "',\r\nfechaSalida='" . $fecha1 . "',\r\nhoraSalida='" . $hora1 . "'\r\n\r\nwhere\r\ncodigoCuarto='" . $myrow3['cuarto'] . "' \r\n";
                //mysql_db_query($basedatos,$agregad);
                echo mysql_error();
            }
            $leyenda = 'Se cerr� la cuenta';
            $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
            $result3 = mysql_db_query($basedatos, $sSQL3);
            $myrow3 = mysql_fetch_array($result3);
            if ($myrow3['status'] == 'cerrada' and $myrow3['statusCuenta'] == 'cerrada') {
                ?>
<script>
window.opener.document.forms["form1"].submit();
window.alert("Cuenta Cerrada");
//window.close();
</script>
<?php 
            } else {
                ?>

<script>
window.opener.document.forms["form1"].submit();
window.alert("Hay un problema con la cuenta");
//window.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> 
  
  
  <?php 
        $sSQL3 = "Select * From clientesInternos WHERE folioVenta = '" . $_GET['folioVenta'] . "' ";
        $result3 = mysql_db_query($basedatos, $sSQL3);
        $myrow3 = mysql_fetch_array($result3);
        //***************aplicar pago**********************
        if ($myrow3['statusCuenta'] == 'cerrada' and $myrow3['status'] == 'cerrada') {
            echo "LA CUENTA DEL PACIENTE " . $myrow3['paciente'] . " ESTA CERRADA...";
            ?>
    <input name="imprimir" type="submit" class="normal" id="imprimir" value="Imprimir" onClick="window.print();return false" />
   
   <?php 
        } else {
            ?>
<!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 bgcolor="#330099">
      <th bgcolor="#330099" class="blancomid" scope="col"><div align="left">Folio de Venta</div></th>
      <th class="blanco" scope="col"><div align="left"><?php 
            echo $_GET['folioVenta'];
            $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="160" bgcolor="#330099" class="blancomid" scope="col"><div align="left"><strong>Paciente</strong></div></th>
      <th width="382" bgcolor="#FFFFFF" class="normal" scope="col"><div align="left"><strong>
          <label> </label>
      </strong> <?php 
            echo $myrow3['paciente'];
            ?>
 </div></th>
    </tr>
    <tr>
      <td bgcolor="#330099" class="blancomid">Compa&ntilde;&iacute;a</td>
  <td bgcolor="#FFFFFF" 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="#330099" class="blancomid">N&deg; Credencial</td>
      <td bgcolor="#FFFFFF" class="normal"><?php 
            echo $myrow3['credencial'];
            ?>
 </td>
    </tr>
    <tr>
      <th bgcolor="#330099" class="blanco" scope="col"><div align="left">Fecha Ingreso</div></th>
      <th bgcolor="#FFFFFF" class="normal" scope="col"><div align="left"><?php 
            echo cambia_a_normal($myrow3['fecha']);
            ?>
</div>      </th>
    </tr>
    <tr>
      <th bgcolor="#330099" class="blanco" scope="col"><div align="left"><strong>M&eacute;dico</strong></div></th>
      <th bgcolor="#FFFFFF" 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>
  </table>
  <p>&nbsp;</p>
  
  
  
  
  
  
  
  
  
  
  <p>

  </p>



  
  
    <?php 
            $content = new contenidos();
            $content->desplegarContenidos($entidad, $class, $estilo, $fechas1, $fechas2, $myrow3['keyClientesInternos'], $_GET['folioVenta'], $basedatos);
            ?>


  <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>
      
      <p>&nbsp;</p>
	  <p>&nbsp;</p>
    </div>
   
<?php 
            $despliegaTotales = new totales();
            $despliegaTotales->tt($entidad, $class, $estilo, $fechas1, $fechas2, $myrow3['keyClientesInternos'], $_GET['folioVenta'], $basedatos);
            ?>
    <p>&nbsp;</p>
    <p>&nbsp;</p>

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

	
	<?php 
            if ($myrow3['status'] != 'cerrada') {
                ?>
	
    <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);
                $ttP = $cargosParticularesCC->cargosParticularesCC($basedatos, $usuario, $myrow3['keyClientesInternos']);
                // $T=round($T,$ase);
                if ($ttP) {
                    if ($cargosParticularesCC->cargosParticularesCC($basedatos, $usuario, $myrow3['keyClientesInternos']) < 0) {
                        $dev = 'si';
                        $cantidadDevolucion = $cargosParticularesCC->cargosParticularesCC($basedatos, $usuario, $myrow3['keyClientesInternos']);
                    } else {
                        $dev = '';
                    }
                    ?>
                <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';
                    ?>
&tipoTransaccion=particular&random=<?php 
                    echo rand(90000, 900000000);
                    ?>
&devolucion=<?php 
                    print $dev;
                    ?>
&cantidadDevolucion=<?php 
                    echo $cantidadDevolucion;
                    ?>
')">
                <?php 
                    echo "\$" . number_format($cargosParticularesCC->cargosParticularesCC($basedatos, $usuario, $myrow3['keyClientesInternos']), 2);
                    ?>
                </a>
                <?php 
                } else {
                    echo "\$" . number_format($cargosParticularesCC->cargosParticularesCC($basedatos, $usuario, $myrow3['keyClientesInternos']), 2);
                }
                ?>
            </span></span></div></td>
          </tr>
        </table>
		
		
		
		</th>
        <th width="2%" scope="col">&nbsp;</th>
        <th width="15%" scope="col">&nbsp;</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();
                $ttCO = $coaseguro->cargosCoaseguro($basedatos, $usuario, $_GET['nT']);
                if ($ttCO) {
                    ?>
                <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';
                    ?>
&tipoTransaccion=coaseguro&random=<?php 
                    echo rand(90000, 900000000);
                    ?>
')">
                <?php 
                    echo "\$" . number_format($coaseguro->cargosCoaseguro($basedatos, $usuario, $_GET['nT']), 2);
                    ?>
                </a>
                <?php 
                } else {
                    echo "\$" . number_format($coaseguro->cargosCoaseguro($basedatos, $usuario, $_GET['nT']), 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 
                $ttCA = $cargosAseguradoraCC->cargosAseguradoraCC($basedatos, $usuario, $_GET['nT']);
                if ($ttCA && !$coaseguro->cargosCoaseguro($basedatos, $usuario, $_GET['nT'])) {
                    ?>
              <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';
                    ?>
&tipoTransaccion=aseguradora&random=<?php 
                    echo rand(90000, 900000000);
                    ?>
')">
              <?php 
                    echo "\$" . number_format($cargosAseguradoraCC->cargosAseguradoraCC($basedatos, $usuario, $_GET['nT']), 2);
                    ?>
              </a>
              <?php 
                } else {
                    echo "\$" . number_format($cargosAseguradoraCC->cargosAseguradoraCC($basedatos, $usuario, $_GET['nT']), 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>
 

  <p align="center">
    
	<?php 
                $variables = round($ttP + $ttO + $ttCO + $ttCA + $totalxSurtir->totalxSurtirFV($basedatos, $usuario, $myrow3['folioVenta']), 2);
                //****************************************
                if (!$myrow661['status'] and !$myrow14a['cierreCuenta'] and $variables) {
                    ?>
	<input name="faltan" type="image" src="<?php 
                    echo CONSTANT_PATH_SIMA_RAIZ;
                    ?>
/imagenes/btns/aplypago.png" id="cerrar" value="Falta Aplicar Pagos" disabled=""/>	
	<?php 
                } else {
                    if (!$variables) {
                        ?>
	<input name="cerrar" type="submit" class="normal" id="cerrar" value="Cerrar Cuenta" onClick="if(confirm('&iquest;Est&aacute;s seguro que deseas cerrar la cuenta?') == false){return false;}" />
	<?php 
                    }
                }
                //cierra validaciones de proceso de cierre de departamentos
                ?>
  </p>
  <div align="center">

    
    <?php 
            } else {
                echo "LA CUENTA DEL PACIENTE " . $myrow3['paciente'] . " ESTA CERRADA...";
                ?>
    <input name="imprimir" type="submit" class="normal" id="imprimir" value="Imprimir" onClick="window.print();return false" />
    <?php 
            }
            ?>
  </div>
</form>

<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 
    }
Example #10
0
    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 
    }
    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 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 
    }
 <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> 
<?php 
echo displaySeguro::despliegaSeguro($_GET['numCliente'], $basedatos);
$_POST['seguro'] = $_GET['numCliente'];
if ($_POST['actualizar'] and $_POST['costo']) {
    $sql5 = "\r\nSELECT *\r\nFROM\r\nconvenios\r\nWHERE\r\nentidad='" . $entidad . "' AND\r\nnumCliente =  '" . $_POST['seguro'] . "'\r\nAND \r\ncodigo ='" . $_POST['codigo'] . "' \r\nAND\r\ntipoConvenio='cantidad'\r\n";
    $result5 = mysql_db_query($basedatos, $sql5);
    $myrow5 = mysql_fetch_array($result5);
    if ($_POST['almacen']) {
        $_POST['almacenDestino'] = '*';
    }
    if (!$myrow5['numCliente']) {
        $agrega = "INSERT INTO convenios (\r\nnumCliente,codigo,fechaInicial,fechaFinal,usuario,departamento,costo,tipoConvenio,entidad) \r\nvalues ('" . $_POST['seguro'] . "','" . $_POST['codigo'] . "',\r\n'" . $_POST['fechaInicial'] . "','" . $_POST['fechaFinal'] . "','" . $usuario . "','" . $_POST['almacenDestino'] . "','" . $_POST['costo'] . "','cantidad','" . $entidad . "')";
        mysql_db_query($basedatos, $agrega);
        echo mysql_error();
        echo '<script type="text/vbscript">
msgbox "SE AGREG� EL CONVENIO"
</script>';
    public function eCuenta($tipoFacturacion, $entidad, $fecha1, $hora1, $dia, $usuario, $nT, $basedatos)
    {
        include CONSTANT_PATH_CONFIGURACION . "/funciones.php";
        $cargosCia = new acumulados();
        ?>



  <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 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;
        }
        //********************Llenado de datos
        $sSQL3 = "Select * From clientesInternos WHERE keyClientesInternos = '" . $_GET['keyClientesInternos'] . "' ";
        $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']) {
            $keyClientesInternos = $_POST['keyClientesInternos'];
            for ($i = 0; $i <= $_POST['bandera']; $i++) {
                if ($keyClientesInternos[$i]) {
                    $agrega = "UPDATE clientesInternos set \r\nstatusFactura='aplicado'\r\n\r\nwhere\r\nkeyClientesInternos='" . $_GET['folioGuia'] . "' ";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                    sleep(1);
                    $agrega = "UPDATE clientesInternos set \r\nstatusFactura='aplicado'\r\n\r\nwhere\r\nkeyClientesInternos='" . $keyClientesInternos[$i] . "' ";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                    sleep(1);
                    $agregaA = "UPDATE cargosCuentaPaciente\r\nset \r\n\r\nstatusFactura='aplicado'\r\n\r\nwhere\r\nkeyClientesInternos='" . $keyClientesInternos[$i] . "' \r\n";
                    mysql_db_query($basedatos, $agregaA);
                    echo mysql_error();
                }
            }
            ?>
<script>
window.opener.document.forms["form2"].submit();
close();
</script>

<?php 
        }
        if ($_POST['quitar']) {
            $keyCAP = $_POST['keyCAP1'];
            for ($i = 0; $i <= $_POST['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();
                }
            }
        }
        ?>








<?php 
        //preparando
        if (!$_POST['aplicarFactura']) {
            if ($_GET['usuario']) {
                $sSQL3 = "Select solicitudes From clientesInternos WHERE keyClientesInternos = '" . $_GET['keyClientesInternos'] . "' ";
                $result3 = mysql_db_query($basedatos, $sSQL3);
                $myrow3 = mysql_fetch_array($result3);
                if ($myrow3['solicitudes'] == '') {
                    $agrega = "UPDATE clientesInternos set \r\n\r\nsolicitudes='request'\r\n\r\nwhere\r\nkeyClientesInternos='" . $_GET['keyClientesInternos'] . "' \r\n";
                    mysql_db_query($basedatos, $agrega);
                    echo mysql_error();
                    $status = 'inactiva';
                } else {
                    if ($myrow3['solicitudes'] == 'request') {
                        $agrega = "UPDATE clientesInternos set \r\n\r\nsolicitudes=''\r\n\r\nwhere\r\nkeyClientesInternos='" . $_GET['keyClientesInternos'] . "' \r\n";
                        mysql_db_query($basedatos, $agrega);
                        echo mysql_error();
                        $status = 'activa';
                    }
                }
            }
        }
        ?>
<!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>








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



</head>





<BODY  >

<h1 align="center">&nbsp;</h1>
<h1 align="center">Escoje la Factura para aplicar <?php 
        echo $myrow3['keyClientesInternos'];
        ?>
</h1>
<form id="form1" name="form1" method="post" >
  <table width="413" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#990099" class="Estilo24">
    <tr>
      <th width="7" bgcolor="#3300FF" class="Estilo24 style13" scope="col">&nbsp;</th>
      <td width="84" bgcolor="#3300FF" class="Estilo24 style13">Compa&ntilde;&iacute;a: </td>
      <td width="312" bgcolor="#3300FF" class="Estilo24"><span class="style13">
        <label><?php 
        echo $traeSeguro = $_GET['numCliente'];
        ?>
        <?php 
        displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
        ?>
        </label>
      </span></td>
    </tr>
  </table>
  
  <p>&nbsp;</p>



 <br />
 <table width="435" border="0" align="center" class="style7">
    <tr>
      <th width="53" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Usuario </span></div></th>
      <th width="69" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">FolioVenta</span></div></th>
      <th width="78" height="14" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Fecha Expedici&ograve;n </span></div></th>
      <th width="71" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Factura Fiscal </span></div></th>
      <th width="53" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Vencimiento</span></div></th>
      <th width="52" bgcolor="#660066" class="style14" scope="col"><div align="left">Facturado</div></th>
      <th width="29" bgcolor="#660066" class="style14" scope="col"><div align="left"><span class="style12 ">Folio  </span></div></th>
    </tr>
	
      <?php 
        //traigo agregados
        $sSQL81 = "\r\nSELECT \r\n*\r\nFROM\r\nclientesInternos\r\n WHERE \r\n entidad='" . $entidad . "'\r\n and\r\n clientePrincipal = '" . $_GET['numCliente'] . "'\r\nand\r\n\r\nstatusFactura='facturado'\r\nand\r\nnumeroFactura!=''\r\nand\r\nfolioVenta!=''\r\n";
        if ($result81 = mysql_db_query($basedatos, $sSQL81)) {
            while ($myrow81 = mysql_fetch_array($result81)) {
                $a += 1;
                $art = $myrow81['codProcedimiento'];
                $codigo = $proc = $myrow81['codProcedimiento'];
                if ($col) {
                    $color = '#FFCCFF';
                    $col = "";
                } else {
                    $color = '#FFFFFF';
                    $col = 1;
                }
                $sSQL3a = "Select plazoPago From clientes WHERE clientePrincipal = '" . $myrow81['seguro'] . "' ";
                $result3a = mysql_db_query($basedatos, $sSQL3a);
                $myrow3a = mysql_fetch_array($result3a);
                $sSQL3b = "Select sum((precioVenta*cantidad)+(iva*cantidad)) as importeTotal,usuarioFactura From cargosCuentaPaciente WHERE keyClientesInternos = '" . $myrow81['keyClientesInternos'] . "' and naturaleza='C' ";
                $result3b = mysql_db_query($basedatos, $sSQL3b);
                $myrow3b = mysql_fetch_array($result3b);
                ?>
	
	
	
	
    <tr>
<td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow3b['usuarioFactura'];
                ?>
</span></div></td>





      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24"><div align="left"><span class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo $myrow81['folioVenta'];
                ?>
</span></div></td>
      <td height="22" 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="style71">
        <?php 
                echo $myrow81['numeroFactura'];
                ?>
        </span>
            
      </span></div></td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="Estilo24">
      <div align="left">
      <?php 
                if ($myrow3a['plazoPago']) {
                    echo $myrow3a['plazoPago'] . ' dias';
                } else {
                    echo '---';
                }
                ?>
      </div>      </td>

<td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><?php 
                echo "\$" . number_format($myrow3b['importeTotal'], 2);
                ?>
</td>
      <td bgcolor="<?php 
                echo $color;
                ?>
" class="<?php 
                echo $estilo;
                ?>
"><div align="left">
	  
<?php 
                if ($myrow81['solicitudes'] == 'request') {
                    $porAplicar[0] += $myrow3b['importeTotal'];
                }
                ?>

<label>
              <a href="<?php 
                echo $_SERVER['PHP_SELF'];
                ?>
?usuario=<?php 
                echo $usuario;
                ?>
&amp;seguro=<?php 
                echo $_POST['seguro'];
                ?>
&amp;status=<?php 
                echo $status;
                ?>
&amp;tipoAlmacen=<?php 
                echo $_POST['tipoAlmacen'];
                ?>
&amp;codigo=<?php 
                echo $C;
                ?>
&amp;raiz=Registro&numCliente=<?php 
                echo $_GET['numCliente'];
                ?>
&keyClientesInternos=<?php 
                echo $myrow81['keyClientesInternos'];
                ?>
&cantidadAplicar=<?php 
                echo $_GET['cantidadAplicar'];
                ?>
&folioGuia=<?php 
                echo $_GET['folioGuia'];
                ?>
">
	  <input type="checkbox" name="keyClientesInternos[]" value="<?php 
                echo $myrow81['keyClientesInternos'];
                ?>
" <?php 
                if ($myrow81['solicitudes'] == 'request') {
                    echo 'checked=""';
                }
                ?>
  />
      </a>
	  </label>
	

</div></td>
    </tr>

	
	
    <?php 
            }
        }
        ?>
  </table>

  <p>&nbsp;</p>
  <p align="center">
  <?php 
        if (round($_GET['cantidadAplicar'], 2) != round($porAplicar[0], 2)) {
            echo '*La cantidad que vas a aplicar debe ser igual a la del pago de la compania';
        }
        ?>
  </p>
  <?php 
        if ($a > 0) {
            ?>
  <table width="301" border="1" align="center" class="style7">
    <tr>
      <td width="89" bgcolor="#0000FF"><span class="style13">Dep&oacute;sito Compa&ntilde;&iacute;a</span></td>
      <td width="95" bgcolor="#0000FF"><span class="style13">Por Aplicar</span></td>
      <td width="95" bgcolor="#0000FF"><span class="style13">Diferencia</span></td>
    </tr>
    <tr>
      <td><?php 
            echo '$' . number_format($_GET['cantidadAplicar'], 2);
            ?>
</td>
      <td><?php 
            echo '$' . number_format($porAplicar[0], 2);
            ?>
</td>
      <td><?php 
            echo '$' . number_format($_GET['cantidadAplicar'] - $porAplicar[0], 2);
            ?>
</td>
    </tr>
  </table>
  <p align="center">&nbsp;</p>
  <p align="center"><label></label>
    <label>
	 <input name="aplicarFactura" type="submit" class="style7" id="aplicarFactura" value="Aplicar folio" onClick="if(confirm('Vas a aplicar el pago de la compa��a <?php 
            displaySeguro::despliegaSeguro($traeSeguro, $basedatos);
            ?>
, la operacion es irreversible, est�s seguro?') == false){return false;}" <?php 
            if (round($_GET['cantidadAplicar'], 2) != round($porAplicar[0], 2)) {
                echo 'disabled=""';
            }
            ?>
 />
	</label>
    <input name="bandera" type="hidden" id="bandera" value="<?php 
            echo $a;
            ?>
" />
    

  </p>
</form>


<p>&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 
    }