I have a monthly billing table that shows earnings for January through December. It sums all values in the pagseguro
table ( ProdValor_1
column).
Below is the table code:
<?php
$mes = array("0", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
for($i = 1; $i < count($mes); $i++) {
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='cl' and situacao='3'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$clconf = $result['total'];
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='cl' and situacao='1'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$clnconf = $result['total'];
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='cl' and situacao='2'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$clcanc = $result['total'];
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='pl' and situacao='3'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$cpconf = $result['total'];
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='pl' and situacao='1'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$cpnconf = $result['total'];
$sql = "select sum(ProdValor_1) as total from pagseguro where DtCad between '".$ano."-".$i."-01 00:00:00' and '".$ano."-".$i."-31 23:59:59' and TipoVenda='pl' and situacao='2'";
$query = mysqli_query($con, $sql);
$result = mysqli_fetch_array($query, MYSQLI_ASSOC);
$cpcanc = $result['total'];
echo "
<tr>
<td align='center' style='background-color:#FCFBC5'><strong><center>$mes[$i]</center></strong></td>
<td align='center' style='color:#36B851'><strong>".moeda($clconf)."</strong></td>
<td align='center' style='color:#B17A7B'><strong>".moeda($clnconf)."</strong></td>
<td align='center' style='color:#B17A7B; border-right:2px solid #B3B3B3'><strong>".moeda($clcanc)."</strong></td>
<td align='center' style='color:#36B851'><strong>".moeda($cpconf)."</strong></td>
<td align='center' style='color:#B17A7B'><strong>".moeda($cpnconf)."</strong></td>
<td align='center' style='color:#B17A7B'><strong>".moeda($cpcanc)."</strong></td>
</tr>
";
}
?>
There is another column in the pagseguro
table that registers the fees for each payment. I need to modify it to display the results by discounting these rates.
For example for January had a total of 500.00 reais in sales and, in the same period, of these 500.00 reais 50.00 reais is a rate / discount. Then it should display the actual 450.00.