PHP - Reporte PHP agrupados y con subtotales

 
Vista:

Reporte PHP agrupados y con subtotales

Publicado por anthony (4 intervenciones) el 05/05/2009 19:33:30
Hola.
tengo hasta el momento este resultado:
http://s3.subirimagenes.com/otros/2478385reporte.jpg

como pueden apreciar logro el quiebre por grupo y total general, pero hasta ahora no he podido obtener los subtotales que deberian imprimirse al final de cada detalle de cada grupo, por ejemplo del primer grupo ("A") seria:

Grupo: A
1-------anthony------A-------20.00
2-------rosa-----------A-------50.00
Subtotal:----------------------70.00
Grupo: B
.............................
Grupo:C
.............................

con ese aspecto deberia ser el reporte, no estoy usando array_sum() , y tampoco me serviria por que mis reportes los estoy paginando.

mi codigo es:
[PHP]
<?php
session_start();
include("conexion.php");
$link=Conectarse();
$_pagi_sql="SELECT * from tabla order by grupo";
$_pagi_cuantos=10;
include("paginator.inc.php");
$SqlSumSubTotal=mysql_query($_pagi_sql,$link);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>Reporte</title>
<link href="Styles/OCEF/Style.css" type="text/css" rel="stylesheet">
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top">
<table class="Header" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="HeaderLeft"></td>
<th>Listado de Verificación de Ordenes</th>

<td class="HeaderRight"></td>
</tr>
</table>

<table class="Grid" cellspacing="0" cellpadding="0">
<tr class="Row">
<td colspan="4"><strong>Fecha: </strong><strong><?php echo strftime ("%d/%m/%Y"); ?></td>
</tr>
<tr class="Caption">
<th>Id</th>
<th>Nombre</th>
<th>Grupo</th>
<th>Monto</th>
</tr>
<?php

?>
<?php

while($row=mysql_fetch_assoc($_pagi_result)) {
$grupoant=$grupo;
$grupo=$row['grupo'];
$tot+=$row["monto"];
?>

<?php
if($grupoant != $grupo){

?>
<tr class="Row">
<td colspan="4"><strong>Grupo: <?php echo $row["grupo"]; ?></strong></td>
</tr>
<?php

}
?>
<tr class="Row">
<td>
<p align="center"><?php echo $row["cod"]; ?></p></td>
<td>
<p align="center"><?php echo $row["nombre"]; ?></p></td>
<td>
<p align="center"><?php echo $row["grupo"]; ?></p></td>
<td>
<p align="center"><?php echo $row["monto"]; ?></p></td>
</tr>

<!--<tr class="SubTotal">
<td> </td>
<td> </td>
<td><strong>Subtotal:</strong></td>
<td style="TEXT-ALIGN: right" valign="baseline"><?php
// echo number_format($sub,2); ?></td>

</tr>-->
<?php
}
?>

<tr class="Total">
<td colspan="4" align="right">TOTAL GENERAL: <?php
echo number_format($tot,2); ?></td>
</tr>
<tr class="Footer">
<td style="TEXT-ALIGN: right" colspan="4"><?php printf("<p>Página ".$_pagi_navegacion."</p>"); ?></td>
</tr>
</table>
<p style="PAGE-BREAK-AFTER: always"></p>

<table class="Grid" cellspacing="0" cellpadding="0">
</table>
</td>
</tr>
</table>
</body>
</html>
[/PHP]

Espero su pronta ayuda gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder