<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['rm_id'])):
header('Location:../index.php');
endif;



if (isset($_POST['cus_id'])) {
    $cus_id = intval($_POST['cus_id']);

    // Query to fetch vat_required
    $query = mysqli_query($con, "SELECT vat_required,sup_code FROM customer_master WHERE cus_id = $cus_id") or die(mysqli_error($con));

    $result = mysqli_fetch_assoc($query);

    // Return the result as JSON
    //echo json_encode(['vat_required' => $result['vat_required']]);
    echo json_encode([
        'vat_required' => $result['vat_required'],
        'sup_code' => $result['sup_code']
    ]);
     
} else {
    echo json_encode(['vat_required' => 0]);
}
?>