<?php
session_start();
header('Content-Type: application/json');
include "konnection.php";
include "func.php";

if (!isset($_SESSION["user"])) {
    header("location: login.php");
    die(json_encode(array("status" => false, "message" => "Auth Invalid")));
}

$email  = $_SESSION["user"];
//$checkTrans = mysqli_query($conn, "SELECT * FROM transactions WHERE user = '$email' AND type = 'Wallet TopUp' ORDER by id DESC");
$checkTrans = mysqli_query($conn, "SELECT * FROM transactions WHERE user = '$email' ORDER by id DESC");
$cnt = 1;
if (mysqli_num_rows($checkTrans) > 0) {
    while ($row = mysqli_fetch_assoc($checkTrans)) {


        $out["id"] = $row["id"];
        $out["avatar"] = $row["serviceImg"];
        $out["full_name"] = "<img src=\"/{$row['serviceImg']}\" class=\"rounded-circle avatar avatar-md me-3\" />";
        $out["post"] = "₦" . number_format((float)$row["amount_charged"], 2);
        $out["email"] = $row["transaction_id"];
        $out["city"] = $row["amount"];
        $out["start_date"] = date_format(date_create($row["whenn"]), "m/d/Y");;
        //$out["salary"] = "<button type='button' class='btn btn-sm rounded-pill btn-primary'>
        // <span class='tf-icons bx bx-show me-1'></span>View Report
        // </button>";
        $out["salary"] = strtoupper($row["status"]);
        $out["age"] = $row["id"];
        $out["experience"] = $row["id"];
        $out["status"] = $row["id"];
        $rep[] = $out;
        $cnt++;
    }
    die(json_encode(array("status" => true, "data" => $rep)));
} else {
    die(json_encode(array("status" => false, "message" => "No Verifications made, All Verifications will be logged here.")));
}
