<?php
//user_action.php
include('db_con.php');  
include('tax_settings.php');
  if (isset($_SESSION['user_id'])) {
    $user_type = $_SESSION['user_type'];
    $user_id = $_SESSION['user_id'];
    $user_name = $_SESSION['user_name'];
    $branch_id = $_SESSION['branch_id'];
    $branch_name = $_SESSION['branch_name'];
    $store_id = $_SESSION['store_id'];
    $store_name = $_SESSION['store_name'];
}else{
  header('Location: login');
  die();
}
if(isset($_POST['btn_action']))
{
  if($_POST['btn_action']== 'check')
  {
    $item_id = 0;
    $list_rate = 0;
    $type_id = $_POST['type_id'];
    $item_name = $_POST['item_name'];
    $sql = "select * from items where item_name = '".$item_name."' and type_id = '".$type_id."'";
    $statement = $connect->prepare($sql);
    $statement->execute();
    $result = $statement->fetchAll();
    foreach($result as $row)
    {
      $item_id = $row['item_id'];
      $list_rate = $row['list_price'];
       $item_cost = $row['item_cost'];
    }
    
    
    $output['item_id'] = $item_id;
    $output['list_rate'] = $list_rate + $list_rate * $gst_pr / 100;
    $output['item_cost'] = $item_cost;
    
  }
  
  
  echo json_encode($output);
}
?>