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;"> </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" > 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>