<?php
	require_once 'inc/conx.php';
	
	$item_name = (trim($_POST['item_name']));
	$unit = (trim($_POST['ut']));
	

	$q = $db->query("SELECT * FROM itemsetup WHERE item_name = '".$item_name."'");
	$fetchRm = $q->fetchArray();
	
	if($unit == 'ctn'){
		$price = $fetchRm['ctn'] * $fetchRm['selling_price'];
		$actual = $fetchRm['ctn'] * $fetchRm['purchase_price'];
	}elseif($unit == 'dzn'){
		$price = $fetchRm['dzn'] * $fetchRm['selling_price'];
		$actual = $fetchRm['dzn'] * $fetchRm['purchase_price'];
	}elseif($unit == 'pcs'){
		$price = $fetchRm['selling_price'];
		$actual = $fetchRm['purchase_price'];
	}

	$arr = ['p' => $price, 'a' => $actual];
	echo json_encode($arr);
	die();
?>	
