With the following function

        function calculate_due(){
                $query = "
                        SELECT i.id, i.client_id, ifnull(total,'0') as 
total_due,
ifnull(i.due,'NA') as due_date, ifnull(sum(p.amount),0) as total_paid,
ifnull(i.total - sum(p.amount),i.total) as total_still_due
                        FROM invoices i LEFT JOIN payments p ON p.invoice_id = 
i.id
                        WHERE total > 0
                        GROUP BY p.client_id
                        ORDER BY due_date";
                $ret = $this->query($query);
                pr($ret);
                die('');
        }

The output I get is

Array
(
    [0] => Array
        (
            [i] => Array
                (
                    [id] => 8
                    [client_id] => 1
                )

            [0] => Array
                (
                    [total_due] => 3.250
                    [due_date] => NA
                    [total_paid] => 0.00
                    [total_still_due] => 3.250
                )

        )

)

In version 1.1.19.6305

Help is greatly appreciated
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to