It worked!!! :) Thank You.
I had to change it a little because of Symfony 1.2
ACTION:
$cu = new Criteria();
$cu->clearSelectColumns();
$cu->add(DokumentLinikiPeer::DOKUMENT_ID,
$this->getUser()->getAttribute('dokument_id'));
$cu->addSelectColumn(DokumentLinikiPeer::STAWKI_VAT);
$cu->addSelectColumn('sum('.DokumentLinikiPeer::KWOTA_NETTO.') as
SumOfNetto');
$cu->addSelectColumn('sum('.DokumentLinikiPeer::KWOTA_BRUTTO.') as
SumOfBrutto');
$cu->addGroupByColumn(DokumentLinikiPeer::STAWKI_VAT);
$sumy = DokumentLinikiPeer::doSelectStmt($cu);
$total = array();
while ($row = $sumy->fetch(PDO::FETCH_NUM)) {
$total[] = array(
'vat' => StawkiVatPeer::retrieveByPK($row[0]), // VAT
'netto' => $row[1], // SumOfNetto
'brutto' => $row[2], // SumOfBrutto
);
}
TEMPLATE:
<?php foreach($sumy as $suma): ?>
<tr>
<td><?php echo $suma['vat']; ?></td>
<td><?php echo $suma['netto']; ?></td>
<td><?php echo $suma['brutto']; ?></td>
</tr>
<?php endforeach ?>
2009/2/7 Sid Bachtiar <[email protected]>
>
> Not sure 100% but may be something like this?
>
> $c->addSelectColumn(TablePeer::VAT);
> $c->addSelectColumn('sum('.TablePeer::NETTO.') as SumOfNetto');
> $c->addSelectColumn('sum('.TablePeer::BRUTTO.') as SumOfBrutto');
> $c->addGroupBy(TablePeer::VAT);
>
> $rs = TablePeer::doSelectRS($c);
>
> $total = array();
> while ($rs->next()) {
> $total[] = array(
> 'vat' => $rs->getInt(1), // VAT
> 'netto' => $rs->getInt(2), // SumOfNetto
> 'brutto' => $rs->getInt(3), // SumOfBrutto
> );
> }
>
> // pass array to the template
> $this->total = $total;
>
> And then you just print $total in the template.
>
> Hope that helps
>
> On Sun, Feb 8, 2009 at 8:33 AM, Tomasz Ignatiuk
> <[email protected]> wrote:
> >
> > Any guess?
> >
> > On 5 Lut, 20:56, Tomasz Ignatiuk <[email protected]> wrote:
> >> Thank you David for your answer but I think we didn't understand each
> >> other, I think I didn't explain my problem well. I don't want to sum
> >> those to values. For example I have this table:
> >>
> >> VAT | NETTO | BRUTTO
> >> -------------------------
> >> 22% | 10 | 12
> >> 22% | 15 | 19
> >> 7% | 35 | 43
> >> 3% | 28 | 30
> >> 7% | 72 | 80
> >> 3% | 11 | 13
> >> 22% | 16 | 20
> >> 7% | 5 | 7
> >>
> >> If I sum it and group by VAT it will be
> >>
> >> VAT | NETTO | BRUTTO
> >> -------------------------
> >> 22% | 42 | 51
> >> 7% | 112 | 143
> >> 3% | 39 | 43
> >>
> >> I know how to show each netto value and each brutto value:
> >> <td><?php echo $row['nettosuma']; ?></td>
> >> <td><?php echo $row['bruttosuma']; ?></td>
> >>
> >> But I need to show VAT value for these sums (22%, 7%, 3%). I have to
> >> know which sum belongs to weach VAT group. Because know I get this and
> >> know one know which some is for which group.
> >> VAT | NETTO | BRUTTO
> >> -------------------------
> >> | 42 | 51
> >> | 112 | 143
> >> | 39 | 43
> > >
> >
>
>
>
> --
> Blue Horn Ltd - System Development
> http://bluehorn.co.nz
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---