<?php
require_once __DIR__ . '/../../config/koneksi.php';

$q = $koneksi->query("SELECT * FROM sumberdaya WHERE id=1");
$data = $q->fetch_assoc();

$air_bersih = $data['vol_in_last'] - $data['vol_out_last'];

echo json_encode([
    "air_masuk" => $data['vol_in_last'],
    "air_keluar" => $data['vol_out_last'],
    "air_bersih" => $air_bersih
]);