<?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');


$message = 'true';
$data    = findQuery("Select 
    tbl_customer.name,Received
    from tbl_transaction
     inner join tbl_customer on tbl_customer.id=tbl_transaction.customerid where tbl_transaction.donation=1 and DATE_FORMAT(dateadded, '%Y-%m-%d')=CURDATE() and Received>0  order by Received desc limit 3");

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



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

];
    }
} else {
    $message = 'false';
    $data2[] = [];
}


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

return;

?>

