<?php
header('Access-Control-Allow-Origin: *');
//header('Content-Type: application/json');

$offc = $_SESSION['offc'];


include_once("db_connect.php");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 


$query = "SELECT id, rpt_txn, type, status, DATE(rpt_txn) as 'rpt_date', officer 
            FROM reports WHERE status = 'C' ORDER BY rpt_txn ";
            
$dbresult = $mysqli->query($query);

//echo 'Hello...here1';
//die();

$mysqli->close();

$data = [];
while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'id' => $row['id'],
        'rpt_txn' => $row['rpt_txn'],
        'status' => $row['status'],
        'rpt_date' => $row['rpt_date'],
        'officer' => $row['officer'],
        'type' => $row['type']
    );
}

if($dbresult){
    $result = json_encode($data);              
}
else {
    $result = json_encode("{success:false}");
}

echo $result;

?>