<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
require_once('../lib/dbclass.php');



$data = findQuery("SELECT sum(tbl_transaction.Received) Received,tbl_ward.ward_name,tbl_ward.id FROM `tbl_transaction` inner join tbl_customer on tbl_customer.id=tbl_transaction.customerid inner join tbl_ward on tbl_ward.id=tbl_customer.Ward
    where tbl_transaction.donation=1 and Received>0 and DATE_FORMAT(dateadded, '%Y-%m-%d')=CURDATE() group by tbl_ward.ward_name,tbl_ward.id order by Received desc limit 3");

if ($data) {
    $message = 'true';
    for ($i = 0;$i < count($data);$i++) {
        $data2[] = [



'name'   => $data[$i]['ward_name'],
'amount' => $data[$i]['Received'],


];
    }
} else {
    $message = 'false';
    $data2[] = [];
}
echo json_encode(['Status' => $message, 'data' => $data2]);

return;

?>

