<?php
require_once '../config/db.php';

header('Content-Type: application/json');

// ambil email dari GET
$email = $_GET['email'] ?? '';

if (!$email) {
    echo json_encode([
        'status' => false,
        'message' => 'Email kosong'
    ]);
    exit;
}

// ambil data berdasarkan email
$stmt = $conn->prepare("SELECT * FROM deposit WHERE email = ? ORDER BY created_at DESC");
$stmt->bind_param("s", $email);
$stmt->execute();

$result = $stmt->get_result();

$data = [];

while ($row = $result->fetch_assoc()) {
    $data[] = [
        'tanggal' => $row['created_at'],
        'jumlah' => $row['jumlah'],
        'nomor_pembayaran' => $row['id'],
        'status_pengiriman' => $row['status'],
        'url_gambar_produk' => 'https://cdn-icons-png.flaticon.com/512/3135/3135715.png'
    ];
}

echo json_encode([
    'status' => true,
    'data' => $data
]);