<?php
ini_set('memory_limit', '-1');
	require_once("../include/config.php");	
	require_once("../include/startup.php");
	require_once("../include/tax_related_functions.php");
	require_once("../include/classes/alltables.class.php");
	//ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
	$obj  = new Product();
	
	$data = array();
	
	$fromcompanyid 	= $_POST['fromcompanyid'];
	$stateid 			= $_POST[''];
	$tocompanyid 	= $_POST['tocompanyid'];
	$type = $_POST['type'];
	$name = $_POST['name_startsWith'];
	
	$sqltext_company_statecode = "Select * from user_company  where isdeleted = 0 and membercompanyid = $fromcompanyid ";
	$statecode = $obj-> getProduct('',$sqltext_company_statecode);
	
	$statecode		= $statecode[0]['head_Stateid1'];
	
	
	
	$sqltext = "Select * from mstproducts  where isdeleted = 0 and  UPPER(".$type.") LIKE '".strtoupper($name)."%' and membercompanyid = $fromcompanyid order by Product_ID desc";
	
	$row = $obj-> getProduct('',$sqltext);
	
	if(is_array($row))
	{
		$rowcount =count($row);
	}
	$total1 = 0;
	if($tocompanyid > 0)
	{
		$taxtype = CheckTypeOfGST($tocompanyid,$statecode);
	}
	else 
	{
		$taxtype = 'IGST';
	}
	for($i=0;$i<$rowcount;$i++)
	{
		$total = $row[$i]['price'] ;
		$productid = $row[$i]['Product_ID'];
		$hsn_code  = $row[$i]['hsn_code'];
		
		
		
		$taxcal 		= TaxCalculation($total,$productid,$taxtype);
		$total1		=  $taxcal['total_amount_with_tax']; 
		$subtotal   =  $taxcal['amount'];
		$cgst_amt	=  $taxcal['cgstamt']; 
		$sgst_amt	=  $taxcal['sgstamt']; 	
		$igst_amt	=  $taxcal['igstamt']; 
		$name = $row[$i]['itemno'].'|'.$row[$i]['productname'].'|'.$subtotal.'|'.$hsn_code.'|'.$cgst_amt.'|'.$sgst_amt.'|'.$igst_amt.'|'.$total1;
		array_push($data, $name);
	}	
	echo json_encode($data);
?>
