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

$id = $_GET['id'];
/*
if ($id){
    echo $id;
}
else {
    echo 'All Items';
}
*/


//$mysqli = new mysqli("localhost", "afxtech1_myori", "myori2017", "afxtech1_myori");
include_once("db_connect.php");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 


//$id = '003';
$query = "SELECT logid, id, rpt_txn, officer, remark, status, action, photo1, photo2
            FROM reports_actions WHERE id = '" .$id. "' ORDER BY rpt_txn DESC ";
$dbresult = $mysqli->query($query);

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

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'logid' => $row['logid'],
        'id' => $row['id'],
        'rpt_txn' => $row['rpt_txn'],
        'officer' => $row['officer'],
        'remark' => $row['remark'],
        'status' => $row['status'],
        'action' => $row['action'],
        'photo1' => $row['photo1'],
        'photo2' => $row['photo2'],
        'toggle' => 'closed',
    );
}

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

echo $result;

?>