<?php
require_once 'shikanisha.kts.php';
session_start();

// Set the timezone to Africa/Nairobi
date_default_timezone_set('Africa/Nairobi');

// Get today's date in 'YYYY-MM-DD' format
$today = date('Y-m-d');

// Query to get expenses where the date_incurred is today's date
$sql = "SELECT * FROM expenses WHERE DATE(date_incurred) = '$today'";
$result = mysqli_query($conn, $sql);

$expenses = [];
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        $expenses[] = $row;
    }
}

// Return the expenses as a JSON response
echo json_encode($expenses);
?>
