<?php

include '../../db_connect.php';

$book_type=$_POST['type'];

if($book_type=='finishproduct')
{       
	//$sql="SELECT prodcode, qty FROM `sorderregdet` inner join sorderreg on sorderregdet.orderid = sorderreg.orderid where agentcode = '$_POST[agent]' ";
     $sql="SELECT prodname, SUM(qnty-pissued) as 'pending' FROM `sordervar` group by prodname having SUM(qnty-pissued) >0 ";   
	$items = mysqli_query($con,$sql);
	//if result set is not empty
	if(mysqli_num_rows($items)!=0)
	{
	echo "<table width='100%' cellspacing='0' border='0'><thead><th align='center'>PROD. CODE</th><th align='center'>QTY</th></thead>";
	echo "<tbody>";
while($row = mysqli_fetch_array($items)) {
		
		echo "<tr><td align='center' class='prodcode'>$row[prodname]</td><td align='center' class='qty'>$row[pending]</td></tr>";
}
/*for($i=0;$i<50;$i++)
echo "<tr><td align='center'><a title='Click to View\ Edit Duty' href='carrental_entry.php?bookid=tesr' onClick='positionedPopup(this.href,660);return false'>test</a></td><td align='center'>trst</td><td align='center'>test</td></tr>";*/
	echo "</tbody>";
	}
	else
	{
				echo 0;
		}

}

mysqli_close($con);


?>