<?php
session_start();
$q = strtolower($_GET["q"]);
include '../db_connect.php';
$cmp=$_SESSION[SESS_CMPC];
$fny=$_SESSION[SESS_FNY];

//$items = mysqli_query($con,"Select billno, pedtotal from billreg where billto = '$_GET[comcode]' and cmp = 'IS' and fny = '12-13' and billno not in (select billno from vchdetails)");

$items = mysqli_query($con,"Select refno, if ( paid != '',  totamount-paid, totamount) as netamount from vchreg where comcode = '$_GET[comcode]' and cmp = '$_SESSION[SESS_CMPC]' and fny = '$_SESSION[SESS_FNY]' and vchtype='PURCHASE' having netamount > 0");

//while($row = mysqli_fetch_array($items))
 // {
 // echo $row['value'];
 
//  }

while($row = mysqli_fetch_array($items)) {
//	if (strpos(strtolower($row['bookid']), $q) !== false) {
		echo "$row[refno]|$row[netamount]\n";
//}
}

mysqli_close($con);


?>