<?php
	require_once 'inc/conx.php';
	
	$code = (trim($_POST['code']));
	
	$countQuery = $db->query("SELECT count(*) totalCount FROM itemsetup WHERE uei = '".$code."'");
 	$rowcount = $countQuery->fetchArray();
 	$totalCount = $rowcount['totalCount'];
 	if ($totalCount < 1) {
 		$countQuery = $db->query("SELECT count(*) totalCount FROM itemsetup WHERE item_name = '".$code."'");
	 	$rowcount = $countQuery->fetchArray();
	 	$totalCount = $rowcount['totalCount'];
	 	if ($totalCount < 1) {
			$countQuery = $db->query("SELECT count(*) totalCount FROM kitsetup WHERE kit_code = '".$code."'");
		 	$rowcount = $countQuery->fetchArray();
		 	$totalCount = $rowcount['totalCount'];
		 	if ($totalCount < 1) {
		 		$countQuery = $db->query("SELECT * FROM kitsetup WHERE kit_name = '".$code."'");
			 	$rowcount = $countQuery->fetchArray();
		 	}else{
		 		$countQuery = $db->query("SELECT * FROM kitsetup WHERE kit_code = '".$code."'");
		 		$rowcount = $countQuery->fetchArray();
		 	}
		}else{
			$countQuery = $db->query("SELECT * FROM itemsetup WHERE item_name = '".$code."'");
 			$rowcount = $countQuery->fetchArray();
		}
	}else{
	$countQuery = $db->query("SELECT * FROM itemsetup WHERE uei = '".$code."'");
 	$rowcount = $countQuery->fetchArray();
	}
	
	echo json_encode($rowcount);
	die();
?>	
