<?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  tbl_user.name, sum(tbl_transaction.Received) Received  FROM  tbl_transaction 
inner join tbl_user on tbl_user.id=tbl_transaction.volunteer  group by tbl_user.name order by Received desc');



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



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


];
    }
} else {
    $message = 'false';
    $data2[] = ['error' => 'Not Found'];
}


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

return;

?>

