<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include_once '../config/database.php';
include_once '../objects/other_income.php';
 
$database = new Database();
$db = $database->getConnection();

$other_income = new OtherIncome($db);
$data = json_decode(file_get_contents("php://input"));

$other_income->invoice_no = $data->ino;

$arr = array();
$stmt = $other_income->getOneRow();
$num = $stmt->rowCount();
if($num>0){
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        extract($row);

		$detail=array(
            "id" => (int)$id,
            "date" => $date,
            "particular" => $particular,
            "quantity" => $quantity,
            "amount" => number_format($amount)
        );
        array_push($arr, $detail);
    }
}


echo json_encode($arr);
?>