<?php

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

$manu = $_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 * FROM invoices WHERE manu = '" .$manu. "' " ;
$dbresult = $mysqli->query($query);

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

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'nfc' => $row['nfc'],
        'sticker' => $row['sticker'],
        'po' => $row['po'],
        'mohon' => $row['tarikh_mohon'],
        'lulus' => $row['tarikh_lulus'],
        'luput' => $row['tarikh_luput'],
        'cetak' => $row['tarikh_cetak'],
        'amaun' => $row['amount'],
        'status' => $row['status']
    );
}

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

echo $result;


?>