Foros del Web » Programando para Internet » PHP »

Problema con subtotales ....

Estas en el tema de Problema con subtotales .... en el foro de PHP en Foros del Web. buenas tardes antes queda, resulta que estoy ahceidno los subdiarios de ventas y hasta ahora todo iba regio mostrando los encabezados por grupos (se agrupan ...
  #1 (permalink)  
Antiguo 10/06/2009, 14:12
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
Problema con subtotales ....

buenas tardes antes queda, resulta que estoy ahceidno los subdiarios de ventas y hasta ahora todo iba regio mostrando los encabezados por grupos (se agrupan por id_venta).. aca abajo pongo como queda




y bue cuando hago los subtotales no se porque no me funciona.

aca abajo dejo como y en ke lugar deberian ir los subtotales



y aqui abajo pongo el code

Código PHP:
<style type="text/css">
<!--
.Estilo1 {
    font-family: Tahoma;
    font-size: 12px;
    color: #333;
    font-weight: bold;
}
.Estilo2 {
    font-family:"Courier New";
    font-size: 12px;
    color: #333;
    font-weight:normal;
}
.subtotales {
    font-family:"Courier New";
    font-size: 13px;
    color: #000000;
    font-weight:bold;
    border-bottom:1px #000000 solid;
    border-top:1px #000000 solid;
}
.encabezado_subdiario {
    font-family:"Courier New";
    font-size: 12px;
    color: #cc0000;
    font-weight:bold;
}
-->
</style>
<!-- Cabecera -->
<table width="100%" border="0" cellpadding="0" cellspacing="0"  height="50" >
  <tr>
    <td colspan="2"  style=" height:25px;" valign="middle" align="center"><div class="Estilo1">Electromecánica Tacuar</div> </td>
  </tr>
    <tr>
    <td  style=" height:25px;" valign="middle"> <div class="Estilo1">Sub-diario de ventas</div></td>
    <td  style=" height:25px;" valign="middle"> <div class="Estilo1" align="right" style="padding-right:10px;">Fecha: xx/xx/xx</div></td>    
  </tr>
</table>
<!-- Fin Cabecera  -->
<div style="height:5px; border-bottom:#000000 1px dotted;">&nbsp;</div>
<!-- detalles -->
<table width="100%" border="0" cellpadding="0" cellspacing="0"  height="50" >
  <tr>
    <td width="11%" valign="top"  style=" height:25px;"> <div class="Estilo1">Fecha</div></td>
    <td width="19%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left" >Nro.Comprobante</div></td> 
    <td width="10%" valign="top"  style=" height:25px;"> <div class="Estilo1">Código</div></td>
    <td width="36%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left" >Detalle</div></td>  
    <td width="12%" valign="top"  style=" height:25px;"> <div class="Estilo1">DEBE</div></td>
    <td width="12%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left">HABER</div></td>  
  </tr>  
    <?
    $sql 
"
    SELECT    
    subdiario_ventas1.`Id_venta`,
    subdiario_ventas1.`Fecha`,
    subdiario_ventas1.`Cte_codigo`,
    subdiario_ventas1.`tipo_fac`, 
    subdiario_ventas1.`Suc_factura`,
    subdiario_ventas1.`nro_factura`, 
    subdiario_ventas1.`Id_cliente`, 
    subdiario_ventas1.`empresa`,
    subdiario_ventas1.`Emp_cta_deudores`,
    subdiario_ventas1.`Importe`, 
    subdiario_ventas1.`Item`,
    cuentas1.`Cta_detalle`
    FROM
    `db_tacuar`.`subdiario_ventas` subdiario_ventas1 INNER JOIN `db_tacuar`.`cuentas` cuentas1 ON subdiario_ventas1.`Emp_cta_deudores` = cuentas1.`Cta_codigo`
    WHERE
        subdiario_ventas1.Fecha BETWEEN  '2009-05-01' AND '2009-05-31'
    #GROUP BY  Cte_codigo, tipo_fac, nro_factura, Id_cliente
    #GROUP BY  Cta_detalle
    ORDER BY
        subdiario_ventas1.`Fecha` ASC, subdiario_ventas1.`tipo_fac` ASC, subdiario_ventas1.`Suc_factura` ASC, subdiario_ventas1.`nro_factura` ASC, subdiario_ventas1.`Id_venta` ASC,             subdiario_ventas1.`Item` ASC
    #limit 23    
    "
;
    
$result mysql_query($sql);    
    while(
$row mysql_fetch_array($result)) {
        
$Cte_codigo_ante $Cte_codigo;
        
$tipo_fac_ante $tipo_fac;
        
$nro_factura_ante $nro_factura;
        
$Id_cliente_ante $Id_cliente;
        
$Cta_detalle_ante $Cta_detalle;
        
$Emp_cta_deudores_ante $Emp_cta_deudores;
        
$id_venta_anterior $id_venta;
        
        
$Cte_codigo $row['Cte_codigo'];
        
$tipo_fac $row['tipo_fac'];
        
$nro_factura $row['nro_factura'];
        
$Id_cliente $row['Id_cliente'];
        
$Cta_detalle $row['Cta_detalle'];
        
$Emp_cta_deudores $row['Emp_cta_deudores'];        
        
$id_venta $row['Id_venta'];
            
        
        if (
$row[Importe]>0) {
            
#$debe =  number_format(abs($row[Importe]),2,",",".");
            
$debe =  $row[Importe];
            
$suma_debe $suma_debe $debe;
            
$haber "0.00";
        }
        if (
$row[Importe]<0) {
            
$debe "0.00";
            
$haber abs($row[Importe]); //number_format(abs($row[Importe]),2,",",".");
            
$suma_haber $suma_haber $haber;
            
//substr($row2[Importe],-1,0);
        
}
        
?>
        
    <?
        
// $tipo_fac_ante <> $tipo_fac or $nro_factura_ante <> $nro_factura or   $Id_cliente_ante <> $Id_cliente or  $Cte_codigo_ante <> $Cte_codigo
        
if ($id_venta_anterior != $id_venta) {
            
            
?>      
        <tr>
        <td width="11%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><?=cambia_fecha_a_normal($row[Fecha])?></div></td>
        <td width="19%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario" align="left" ><?=$row[Cte_codigo]?> <?=$row[tipo_fac]?> <?=$row[nro_factura]?></div></td> 
        <td width="10%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><?=$row[Id_cliente//."  ".$nro_factura_ante ?></div></td>
        <td width="36%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario" align="left" ><?=$row[empresa]?></div></td>
        <td width="12%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><? //=$c?></div></td>
        <td width="12%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><? ?></div></td>
      </tr>
        <?
        
}
        
?>
        <tr>
      <td width="11%" valign="top"  style=" height:25px;"><div class="Estilo2"> </div></td>
      <td width="19%" valign="top"  style=" height:25px;"><div class="Estilo2" align="left" > <? //=$c_ant?> </div></td>
      <td width="10%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=$row[Emp_cta_deudores//."  ".$nro_factura_ante?></div></td>
      <td width="36%" valign="top"  style=" height:25px;"><div class="Estilo2" align="left" ><?=$row[Cta_detalle]?></div></td>
      <td width="12%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=$debe?></div></td>
      <td width="12%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=$haber ?></div></td> 
    </tr>
    
    <?
        
/*
    if ($id_venta_anterior = $id_venta_anterior) {
      echo' 
      <tr>
        <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" > </div></td> 
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_debe.'</div></td>
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_haber.'</div></td>
      </tr>
      ';
    }
        */        
    
?>
        <?        
    
// FIN ... while($row = mysql_fetch_array($result)) {
    
?>
  <!-- TOTAL GENERAL -->
  <tr>    
    <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" >&nbsp; Totales</div></td> 
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$suma_debe?></div></td>
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$suma_haber?></div></td> 
  </tr>
</table>
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #2 (permalink)  
Antiguo 10/06/2009, 14:32
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Mensajes: 32
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Problema con subtotales ....

no veo diferencias entre ambas fotos.... creo q te equivocaste no?
  #3 (permalink)  
Antiguo 10/06/2009, 14:34
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
De acuerdo Respuesta: Problema con subtotales ....

Cita:
Iniciado por neverhags Ver Mensaje
no veo diferencias entre ambas fotos.... creo q te equivocaste no?
hola, no me equivoqué, en la segunda imagen hay una linea negra gruesa, ahi es a donde irian los subtotales, pero no consigo poder imprimir en ese sector
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #4 (permalink)  
Antiguo 10/06/2009, 14:36
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Mensajes: 32
Antigüedad: 15 años, 4 meses
Puntos: 2
cuando ves el codigo HTML generado simplemente no aparece nada donde deberia haber un resultado? ( a primera vista rapida no veo nada malo)

<tr>
<td width="76%" valign="middle" align="center" colspan="4" style=" height:25px;"><div class="subtotales" align="center" >&nbsp; Totales</div></td>
<td width="12%" valign="middle" style=" height:25px;"><div class="subtotales"><?=$suma_debe?></div></td>
<td width="12%" valign="middle" style=" height:25px;"><div class="subtotales"><?=$suma_haber?></div></td>
</tr>


esa es la parte q no veo, es decir, hay una linea, pero no se ve que diga "&nbsp; Totales".... prueba usando otro navegador a ver si tu problema es de tablas

Última edición por GatorV; 10/06/2009 a las 19:45
  #5 (permalink)  
Antiguo 10/06/2009, 14:48
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
no loco no es eso a lo que te referis... es un tema de que no arma el agrupado en php y despeus muestra cualquier cosa ....

alguna manito por favor ?

buep parace que nadie peude ayudarme :S
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA

Última edición por GatorV; 10/06/2009 a las 19:45
  #6 (permalink)  
Antiguo 10/06/2009, 18:18
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Verificate que tienes sin comillas

$row[Importe]

debe ser

$row["Importe"]

Me dejas saber

Y lo otro te sugiero que no uses <?= ?> sino el completo <?php ?> pero eso queda a tu discreción.

Última edición por GatorV; 10/06/2009 a las 19:45
  #7 (permalink)  
Antiguo 10/06/2009, 19:10
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
De acuerdo Respuesta: Problema con subtotales ....

Cita:
Iniciado por abimaelrc Ver Mensaje
Verificate que tienes sin comillas

$row[Importe]

debe ser

$row["Importe"]

Me dejas saber
loco eso no tiene nada que veeeer. fijate bien que yo quiero mostrar cualquier cosa despues del 4to renglon ... y no se peude.. no que tiene que ver eso que decis. lee antes de responder. BYE
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #8 (permalink)  
Antiguo 10/06/2009, 19:21
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Respuesta: Problema con subtotales ....

Tipo estoy tratando de entender lo que escribiste. En primer lugar las imagenes son iguales no hay nada en bold. 2 vi un error que no te permite hacer el calculo de abajo.

Código PHP:
        if ($row[Importe]<0) { 
            
$debe "0.00"
            
$haber abs($row[Importe]); //number_format(abs($row[Importe]),2,",","."); 
            
$suma_haber $suma_haber $haber
            
//substr($row2[Importe],-1,0); 
        

siempre va a traerte 0.00 porque no pusiste entre comillas. y eso ocaciones que la ultima parte no te salga un total o subtotal

Código PHP:
 <!-- TOTAL GENERAL --> 
  <tr>     
    <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" >&nbsp; Totales</div></td>  
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$suma_debe?></div></td> 
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$suma_haber?></div></td>  
  </tr>
el ultimo campo no te va a salir. Como tambien lo que tienes entre comentarios

Código PHP:
        /* 
    if ($id_venta_anterior = $id_venta_anterior) { 
      echo'  
      <tr> 
        <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" > </div></td>  
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_debe.'</div></td> 
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_haber.'</div></td> 
      </tr> 
      '; 
    } 
        */ 
no te va a salir si lo vas a usar en el futuro

3 si explicas mejor creo que te podemos ayudar porque no encuentro lo que tu te refieres a los subtotales.
  #9 (permalink)  
Antiguo 10/06/2009, 20:02
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
Respuesta: Problema con subtotales ....

no no no.. mira

si el impote es negativo, se acredita (haber) entonces el debe va en cero pro eso va esto:


Código PHP:
if ($row[Importe]<0) { 
            
$debe "0.00"
            
$haber abs($row[Importe]); //number_format(abs($row[Importe]),2,",","."); 
            
$suma_haber $suma_haber $haber
            
//substr($row2[Importe],-1,0); 
        

__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #10 (permalink)  
Antiguo 10/06/2009, 20:04
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Respuesta: Problema con subtotales ....

Ok entiendo pero de verdad que no entiendo la pregunta de arriba porque no veo a lo que te refieres con subtotales podrias indicar en que parte de la tabla no sale lo que quieres?
  #11 (permalink)  
Antiguo 11/06/2009, 01:01
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
Respuesta: Problema con subtotales ....

Cita:
Iniciado por abimaelrc Ver Mensaje
Ok entiendo pero de verdad que no entiendo la pregunta de arriba porque no veo a lo que te refieres con subtotales podrias indicar en que parte de la tabla no sale lo que quieres?
si descmento esta parte.... es a dodne no sale lo que pretendo


esta es la parte a descomentar


Código PHP:
 /* 
    if ($id_venta_anterior = $id_venta_anterior) { 
      echo'  
      <tr> 
        <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" > </div></td>  
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_debe.'</div></td> 
        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'.$suma_haber.'</div></td> 
      </tr> 
      '; 
    } 
        */ 
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #12 (permalink)  
Antiguo 11/06/2009, 08:10
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Respuesta: Problema con subtotales ....

Una de las cosas que veo que puede causar un error en lo que quieres hacer es que en el if no estas verificando si son iguales sino que le estas asignando a $id_venta_anterior el valor de $id_venta_anterior

if ($id_venta_anterior = $id_venta_anterior){

debe ser

if ($id_venta_anterior == $id_venta_anterior)

claro esta si es que quiere verificar si son iguales. Pero ahi no entiendo porque estas verificando la misma variable, siempre te va a traer que son iguales :S
  #13 (permalink)  
Antiguo 11/06/2009, 10:22
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
De acuerdo

Cita:
Iniciado por abimaelrc Ver Mensaje
Una de las cosas que veo que puede causar un error en lo que quieres hacer es que en el if no estas verificando si son iguales sino que le estas asignando a $id_venta_anterior el valor de $id_venta_anterior

if ($id_venta_anterior = $id_venta_anterior){

debe ser

if ($id_venta_anterior == $id_venta_anterior)

claro esta si es que quiere verificar si son iguales. Pero ahi no entiendo porque estas verificando la misma variable, siempre te va a traer que son iguales :S
si, ahi le pifié.. pero de igual modo no hace lo que quiero, ya voy a ver como lo soluciono, gracias de igual modo

Cita:
Iniciado por abimaelrc Ver Mensaje
Una de las cosas que veo que puede causar un error en lo que quieres hacer es que en el if no estas verificando si son iguales sino que le estas asignando a $id_venta_anterior el valor de $id_venta_anterior

if ($id_venta_anterior = $id_venta_anterior){

debe ser

if ($id_venta_anterior == $id_venta_anterior)

claro esta si es que quiere verificar si son iguales. Pero ahi no entiendo porque estas verificando la misma variable, siempre te va a traer que son iguales :S
te corrijo algo man ... dentro de un if ... si el valor es numerico (em mi caso el id de venta es un integer de la db mysql) la comparacion se ahce con =

Código PHP:
$edad=13;
$edad2=13;
if (
$edad $edad2) {
    echo 
"iguales";

__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA

Última edición por GatorV; 11/06/2009 a las 15:01
  #14 (permalink)  
Antiguo 11/06/2009, 12:55
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Respuesta: Problema con subtotales ....

Te corrijo

Código PHP:
$edad=13
$edad2=14
if (
$edad $edad2) { 
    echo 
$edad

No estas verificando si son iguales, sino que le estas asignando la segunda variable a la primera no importa sin son numero o texto. Si usas este ejemplo vas a ver que te va a salir 14 a pesar de que esta declarado edad al principio como 13. Hasta puedes probar esto

Código PHP:
$edad=13
$edad2="algo"
if (
$edad $edad2) { 
    echo 
$edad

Te va a salir un echo de algo. Siempre las comparaciones de igualdad se tienen usar == o === que quiere decir exactamente igual en todos los aspectos, pero no = solo porque eso significa otorgar el valor de la derecha a la variable que esta en la izquierda. Por eso el if siempre te va a traer datos porque no estas comparando. Verifica y me dejas saber.

Última edición por abimaelrc; 11/06/2009 a las 13:05
  #15 (permalink)  
Antiguo 11/06/2009, 14:01
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
Respuesta: Problema con subtotales ....

Cita:
Iniciado por abimaelrc Ver Mensaje
Te corrijo

Código PHP:
$edad=13
$edad2=14
if (
$edad $edad2) { 
    echo 
$edad

No estas verificando si son iguales, sino que le estas asignando la segunda variable a la primera no importa sin son numero o texto. Si usas este ejemplo vas a ver que te va a salir 14 a pesar de que esta declarado edad al principio como 13. Hasta puedes probar esto

Código PHP:
$edad=13
$edad2="algo"
if (
$edad $edad2) { 
    echo 
$edad

Te va a salir un echo de algo. Siempre las comparaciones de igualdad se tienen usar == o === que quiere decir exactamente igual en todos los aspectos, pero no = solo porque eso significa otorgar el valor de la derecha a la variable que esta en la izquierda. Por eso el if siempre te va a traer datos porque no estas comparando. Verifica y me dejas saber.
ja ahi probe y tenes razon ... dado por hecho :d
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #16 (permalink)  
Antiguo 11/06/2009, 14:05
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 10 meses
Puntos: 1517
Respuesta: Problema con subtotales ....

¿Crees que con eso puedas corregir el problema que tienes o todavia no resuelve el problema?
  #17 (permalink)  
Antiguo 11/06/2009, 16:33
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
De acuerdo Respuesta: Problema con subtotales ....

ahi lo pude ahcer :P

pongo el codigo para futuros novatos como yo ajaja

.. falta arreglar los subtotales no mas...

Código PHP:

<style type="text/css">
<!--
.Estilo1 {
    font-family: Tahoma;
    font-size: 12px;
    color: #333;
    font-weight: bold;
}
.Estilo2 {
    font-family:"Courier New";
    font-size: 12px;
    color: #333;
    font-weight:normal;
}
.subtotales {
    font-family:"Courier New";
    font-size: 13px;
    color: #000000;
    font-weight:bold;
    border-bottom:1px #E1E1E1 solid;
    border-top:1px #E1E1E1 solid;
    background-color:#E1E1E1;
}
.encabezado_subdiario {
    font-family:"Tahoma";
    font-size: 12px;
    color: #000000;
    font-weight:bold;
}
-->
</style>
<!-- Cabecera -->
<table width="100%" border="0" cellpadding="0" cellspacing="0"  height="50" >
  <tr>
    <td colspan="2"  style=" height:25px;" valign="middle" align="center"><div class="Estilo1">Electromecánica Tacuar</div> </td>
  </tr>
    <tr>
    <td  style=" height:25px;" valign="middle"> <div class="Estilo1">Sub-diario de ventas</div></td>
    <td  style=" height:25px;" valign="middle"> <div class="Estilo1" align="right" style="padding-right:10px;">Fecha: xx/xx/xx</div></td>    
  </tr>
</table>
<!-- Fin Cabecera  -->
<div style="height:5px; border-bottom:#000000 2px solid;">&nbsp;</div>
<!-- detalles -->
<table width="100%" border="0" cellpadding="0" cellspacing="0"  height="50" >
  <tr>
    <td width="11%" valign="top"  style=" height:25px;"> <div class="Estilo1">Fecha</div></td>
    <td width="19%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left" >Nro.Comprobante</div></td> 
    <td width="10%" valign="top"  style=" height:25px;"> <div class="Estilo1">Código</div></td>
    <td width="36%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left" >Detalle</div></td>  
    <td width="12%" valign="top"  style=" height:25px;"> <div class="Estilo1">DEBE</div></td>
    <td width="12%" valign="top"  style=" height:25px;"> <div class="Estilo1" align="left">HABER</div></td>  
  </tr>
    <?
    $sql_maxGrupos 
"SELECT  subdiario_ventas1.Emp_cta_deudores
                                        FROM
                                        `db_tacuar`.`subdiario_ventas` subdiario_ventas1 INNER JOIN `db_tacuar`.`cuentas` cuentas1 ON subdiario_ventas1.`Emp_cta_deudores` = cuentas1.`Cta_codigo`
                                        GROUP BY  `Emp_cta_deudores`"
;
    
    
$result_maxGrupos mysql_query($sql_maxGrupos);
    
$maximo_grupos mysql_num_rows($result_maxGrupos);
                                                
    
$sql "
    SELECT
    
    subdiario_ventas1.`Id_venta`,
    subdiario_ventas1.`Fecha`,
    subdiario_ventas1.`Cte_codigo`,
    subdiario_ventas1.`tipo_fac`, 
    subdiario_ventas1.`Suc_factura`,
    subdiario_ventas1.`nro_factura`, 
    subdiario_ventas1.`Id_cliente`, 
    subdiario_ventas1.`empresa`,
    subdiario_ventas1.`Emp_cta_deudores`,
    subdiario_ventas1.`Importe`, 
    subdiario_ventas1.`Item`,
    cuentas1.`Cta_detalle`    
    FROM
    `db_tacuar`.`subdiario_ventas` subdiario_ventas1 INNER JOIN `db_tacuar`.`cuentas` cuentas1 ON subdiario_ventas1.`Emp_cta_deudores` = cuentas1.`Cta_codigo`
    WHERE
        subdiario_ventas1.Fecha BETWEEN  '2009-05-01' AND '2009-05-31'    
    GROUP BY  Cte_codigo, tipo_fac, nro_factura, Id_cliente, Cta_detalle
    #GROUP BY  Cta_detalle
    ORDER BY
        subdiario_ventas1.`Fecha` ASC, subdiario_ventas1.`tipo_fac` ASC, subdiario_ventas1.`Suc_factura` ASC, subdiario_ventas1.`nro_factura` ASC, subdiario_ventas1.`Id_venta` ASC,             subdiario_ventas1.`Item` ASC
    #limit 23    
    "
;
    
$result mysql_query($sql);    
    while(
$row mysql_fetch_array($result)) {
    
        
$Cte_codigo_ante $Cte_codigo;
        
$tipo_fac_ante $tipo_fac;
        
$nro_factura_ante $nro_factura;
        
$Id_cliente_ante $Id_cliente;
        
$Cta_detalle_ante $Cta_detalle;
        
$Emp_cta_deudores_ante $Emp_cta_deudores;
        
$id_venta_ante $id_venta;
        
        
$Cte_codigo $row['Cte_codigo'];
        
$tipo_fac $row['tipo_fac'];
        
$nro_factura $row['nro_factura'];
        
$Id_cliente $row['Id_cliente'];
        
$Cta_detalle $row['Cta_detalle'];
        
$Emp_cta_deudores $row['Emp_cta_deudores'];
        
$id_venta $row['Id_venta'];
        
        
        
        
        if (
$row[Importe]>0) { // DEBE
            #$debe =  number_format(abs($row[Importe]),2,",",".");
            
$haber 0;
            
            
$debe =  $row[Importe];
                    
            
$subtotal_debe 0;
            
$subtotal_debe $subtotal_debe $debe;
            
$total_debe $total_debe $subtotal_debe;
            
            
        }
        if (
$row[Importe]<0) { // HABER
            
$debe 0;
            
            
$haber abs($row[Importe]); //number_format($row[Importe],2,",",".");
            
            
$subtotal_haber 0;            
            
$subtotal_haber $subtotal_haber $haber;
            
$total_haber $total_haber $subtotal_haber;
        }
        
        
        
        
        
        
        
        
        
        
        
        
?>        
    <?
        
// $tipo_fac_ante <> $tipo_fac or $nro_factura_ante <> $nro_factura or   $Id_cliente_ante <> $Id_cliente or  $Cte_codigo_ante <> $Cte_codigo
        
if ($id_venta_ante != $id_venta) {            
            
?>
        <tr>
        <td width="11%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><?=cambia_fecha_a_normal($row[Fecha])?></div></td>
        <td width="19%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario" align="left" ><?=$row[Cte_codigo]?> <?=$row[tipo_fac]?> <?=$row[nro_factura]?></div></td> 
        <td width="10%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><?=$row[Id_cliente//."  ".$nro_factura_ante ?></div></td>
        <td width="36%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario" align="left" ><?=$row[empresa]?></div></td>
        <td width="12%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><? //=$suma_debe?></div></td>
        <td width="12%" valign="top"  style=" height:25px;"> <div class="encabezado_subdiario"><? ?></div></td>
      </tr>      
        <?            
        
}
        
?>
    
        <tr>
      <td width="11%" valign="top"  style=" height:25px;"><div class="Estilo2">&nbsp;</div></td>
      <td width="19%" valign="top"  style=" height:25px;"><div class="Estilo2" align="left" >&nbsp;</div></td>
      <td width="10%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=$row[Emp_cta_deudores//."  ".$nro_factura_ante?></div></td>
      <td width="36%" valign="top"  style=" height:25px;"><div class="Estilo2" align="left" ><?=$row[Cta_detalle]?></div></td> 
      <td width="12%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=number_format($debe,2,",",".")?></div></td>
      <td width="12%" valign="top"  style=" height:25px;"><div class="Estilo2"><?=number_format($haber,2,",",".")?></div></td>
    </tr>    
    <?
        
//echo $nro_factura_ante;
        //$c=0;
        
$c=$c+1;
        
//while ($c >= 3 ) {
            
while ($c == $maximo_grupos) {                
                echo 

                    <tr>    
                        <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" >&nbsp;</div></td> 
                        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'
.$subtotal_debe.'</div></td>
                        <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales">$'
.$subtotal_haber.'</div></td>
                    </tr>
                    '
;
                    
                
$c=0;            
        
//}    
            
}        
        
?>
    
        <?        
    
// FIN ... while($row = mysql_fetch_array($result)) {
    
?>
  <!-- TOTAL GENERAL -->
  <tr>    
    <td width="76%" valign="middle" align="center" colspan="4"  style=" height:25px;"><div class="subtotales" align="center" >&nbsp; Totales</div></td> 
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$total_debe?></div></td>
    <td width="12%" valign="middle"  style=" height:25px;"><div class="subtotales"><?=$total_haber?></div></td> 
  </tr>
</table>
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
  #18 (permalink)  
Antiguo 11/06/2009, 16:35
Avatar de aldo1982  
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 19 años, 4 meses
Puntos: 6
De acuerdo Respuesta: Problema con subtotales ....

Cita:
Iniciado por abimaelrc Ver Mensaje
¿Crees que con eso puedas corregir el problema que tienes o todavia no resuelve el problema?
no eso no tiene nada que ver con el problema ... ahi ya postie la solucion... es crear un string sql agrupando los grupos o categorias, luego sacar la cantidad de registros (es decir la cantidad de grupos) y luego poner un contador y hacer if hast que el contador sea == a el maximo de grupos o categorias
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:42.