Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
eu estou montando uma relação de recebimentos, elas são separadas por loteamento, só que quando um loteamento não tem recebimento ele mostra o total do anterior, ao invés de zero, ficando assim:
loteamento 1 :
parcela 1 - 2,00
parcela 2 - 3,00
total 5,00
loteamento 2 :
parcela 1 - 3,00
parcela 2 - 3,00
total 6,00
loteamento 3 :
total 6,00
<?php
$dti = implode('-',array_reverse(explode('/',$_GET['dti'])));
$dtf = implode('-',array_reverse(explode('/',$_GET['dtf'])));
//PEGA LOTEAMENTOS EXISTENTES
$Sql = mysql_query("select codigo,loteamento from loteamento");
while($row = mysql_fetch_row($Sql)){
$cod_lot = $row[0]; $loteamento = $row[1];
?>
<strong><?php echo $loteamento;?> </br></strong>
<table width="100%" border="1" style="border-collapse:collapse">
<tr>
<th>Nome</th>
<th>Quadra</th>
<th>Lote</th>
<th>Metragem</th>
<th>Parcela</th>
<th>Vencto</th>
<th>Valor</th>
<th>Data Pgto</th>
<th>Valor Pago</th>
<th>Parcela</th>
</tr>
<?php
//PEGA CLIENTES E PARCELAS DE CADA LOTEAMENTO
$sql = mysql_query("select nome,quadra,lote,metragem,cod_parc,vecto_parc,vltotal,
data_pgto_parcela, valor_pago_parcela from cliente inner join parcelas where
cliente.cod_cliente = parcelas.cliente and data_pgto_parcela!='0000-00-00'
and data_pgto_parcela>='$dti' and data_pgto_parcela<='$dtf'
and loteamento=".$cod_lot);
while($row = mysql_fetch_row($sql)){
$nome = $row[0]; $quadra = $row[1]; $lote = $row[2]; $metragem = $row[3];
$cod_parc = $row[4]; $vecto = implode('/',array_reverse(explode('-',$row[5])));
$vl_parc = $row[6]; $dt_pgto = implode('/',array_reverse(explode('-',$row[7])));
$vl_pago = $row[8]; $acresc = $vl_pago - $vl_parc; $total += $vl_pago;
?>
<tr align="center">
<td><?php echo $nome;?></td>
<td><?php echo $quadra;?></td>
<td><?php echo $lote;?></td>
<td><?php echo number_format($metragem,2,',','.');?></td>
<td><?php echo $cod_parc;?></td>
<td><?php echo $vecto;?></td>
<td>R$ <?php echo number_format($vl_parc,2,',','.');?></td>
<td><?php echo $dt_pgto;?></td>
<td>R$ <?php echo number_format($vl_pago,2,',','.');?></td>
<td>R$ <?php echo number_format($acresc,2,',','.');?></td>
</tr>
<?php
//SOMA AS PARCELAS DE CADA LOTEAMENTO
$SQL = mysql_query("select sum(valor_pago_parcela) from cliente inner join parcelas
where cliente.cod_cliente = parcelas.cliente and data_pgto_parcela!='0000-00-00'
and data_pgto_parcela>='$dti' and data_pgto_parcela<='$dtf'
and loteamento=".$cod_lot);
while($ROW = mysql_fetch_row($SQL)){
$total_lot = $ROW[0];
}
}//while parcelas
?>
<tr>
<td colspan="10" align="right"><strong>Total: <?php echo
number_format($total_lot,2,',','.');?></strong></td>
</tr>
</table>
<?php
}//while loteamento
//QUANTAS PARCELAS FORAM PAGAS
$Sql = mysql_query("select count(cod_parc) from cliente inner join parcelas where
cliente.cod_cliente = parcelas.cliente and data_pgto_parcela!='0000-00-00'
and data_pgto_parcela>='$dti' and data_pgto_parcela<='$dtf' ");
while($Row = mysql_fetch_row($Sql)){
$total_pagos = $Row[0];
}
?>
<br />
<div style="float:left;"><strong>Total Títulos Pagos: <?php echo
$total_pagos;?></strong></div>
<div style="float:right; "><strong>Total Recebido R$ <?php echo
number_format($total,2,',','.');?></strong></div>
Alguém tem uma ideia de como faço ele mostrar que não tem?
Obrigada.
Carregando comentários...