<?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 reports 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["placeholder"];
        $out["full_name"] = "<img src={$row['placeholder']} class='rounded-circle avatar avatar-md me-3' />";
        $out["post"] = $row["display_name"];
        $out["email"] = $row["report_id"];
        $out["city"] = $row["report_type"];
        $out["start_date"] = date_format(date_create($row["date_created"]), "m/d/Y");
        //$href = "/verifs/".strtolower($row['report_type'])."/".$row['slip_type']."/?reportID=".$row['report_id'];
        $href = $row["pdf"];
        $out["salary"] = "<a href='$href' target='_blank' class='btn btn-sm rounded-pill btn-primary'>
                <span class='tf-icons bx bx-show me-1'></span> Download Slip
              </a>";
        $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.")));
}
