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


$offc = $_SESSION['offc'];


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

$id = $_GET['id'];


//$id = '003';
$query = "SELECT id, name, location, reporter, reporter_phone, reporter_email, assigndt, assignby, 
            photo, photo2, photo3, photo4, remark1, remark2, officer, type, status, rpt_txn, area 
            FROM reports WHERE id = '" .$id. "' LIMIT 1";
$dbresult = $mysqli->query($query);

$mysqli->close();


$data = [];
while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){

    $data[] = array(
        'id' => $row['id'],
        'name' => $row['name'],
        'location' => $row['location'],
        'photo' => $row['photo'],
        'photo2' => $row['photo2'],
        'photo3' => $row['photo3'],
        'photo4' => $row['photo4'],
        'status' => $row['status'],
        'remark1' => $row['remark1'],
        'remark2' => $row['remark2'],
        'officer' => $row['officer'],
        'status' => $row['status'],
        'area' => $row['area'],
        'type' => $row['type'],
        'rpt' => $row['reporter'],
        'rpt_phone' => $row['reporter_phone'],
        'rpt_email' => $row['reporter_email'],
        'assignby' => $row['assignby'],
        'assigndt' => $row['assigndt'],
        'rpt_txn' => $row['rpt_txn']
    );

}


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

echo $result;

?>