<?php
//user_action.php
include('db_con.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')
  {
    $type_id = $_POST['type_id'];
    $item_name = $_POST['item_name'];
    $sql = "select IFNULL(item_id,0) from items where item_name = '".$item_name."' and type_id = '".$type_id."'";
    $statement = $connect->prepare($sql);
    $statement->execute();
    $item_id = $statement->fetchColumn();
    $output['item_id'] = $item_id;
    $sql = "select lp_rate item_cost from items where item_name = '".$item_name."' and type_id = '".$type_id."'";
    $statement = $connect->prepare($sql);
    $statement->execute();
    $item_cost = $statement->fetchColumn();
    $output['item_cost'] = $item_cost;
  }
  
  
  echo json_encode($output);
}
?>