<?php 
session_start();
include('../includes/dbcon.php');

$str=" ";

$data = array();

$edate=date("Y-m-d");
$userid=$_SESSION['hrm_id'];

 if (isset($_POST['category'])) {
 	$item = trim($_POST['category']);
 	$grnd_no = trim($_POST['grnd_no']);
 	$issue_qty= trim($_POST['issue_qty']);
 	$costprice= trim($_POST['costprice']);


 	
if (empty($costprice)){ $costprice=0;  }  
 	
		if ( mysqli_query($con,"INSERT INTO grn_temp_detail(grnd_no,item_id,issue_qty,cost_price) 
			 VALUES($grnd_no,$item,$issue_qty,$costprice )  ")or die(mysqli_error($con)))
	        {


	        	$sqlsp=mysqli_query($con,"SELECT  * from grn_temp_detail ")or die(mysqli_error($con));
	        	$count=mysqli_num_rows($sqlsp);	
	        	if ($count>0) {
	        		while($rowsp=mysqli_fetch_array($sqlsp)){			
					 $data[]=$rowsp;				
				   }	

				    echo json_encode($data);
	        	}//	if ($count>0) {
exit();
	        	 //echo 'hello';
	        }


} ///// if (isset($_POST['category'])) {

?>