<?php
session_start();

$q = strtolower($_GET["q"]);
if (!$q) return;
include 'db_connect.php';
include 'db_table_select.php';


	 if(isset($_GET['mode'])&&$_GET['mode']=='all')
{
	$items = mysqli_query($con,"SELECT compid,telephone FROM commst  order by compid ");

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

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

if(isset($_GET['type'])&&$_GET['type']=='led_det')
//$sql="SELECT DISTINCT(billto) FROM $billreg where billdate between STR_TO_DATE('$_GET[fromdate]','%d/%m/%Y') and STR_TO_DATE('$_GET[todate]','%d/%m/%Y')";
$sql="SELECT alias as billto, ledger as name FROM ledgerreg ";
//where ledtype = 'SUNDRY DEBTORS' or ledtype = 'SUNDRY CREDITORS' or ledtype = 'LOANSANDADVANCE'";
else
$sql="SELECT DISTINCT(billedto) as billto  FROM $bookingreg";
//
//if(isset($_GET['veh_no']))
//$items = mysqli_query($con,"SELECT code FROM master where mstype='vno'");

//else if(isset($_GET['bill_no']))
//$items = mysqli_query($con,"SELECT billno FROM billreg where billdate between '$_GET[fromdate]' and '$_GET[todate]'");



//else if(isset($_GET['billed_to']))
if($items = mysqli_query($con,$sql))
{

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

while($row = mysqli_fetch_array($items)) {
	if (strpos(strtolower($row['billto']), $q) !== false) {
		echo $row['billto']."|".$row['name']."\n";
}
}

}

if(isset($_GET['type'])&&$_GET['type']=='bill_info')


$sql="SELECT compid,name FROM commst  order by compid ";

if($items = mysqli_query($con,$sql))
{


while($row = mysqli_fetch_array($items)) {
	if (strpos(strtolower($row['compid']), $q) !== false) {
		echo $row['compid']."|".$row['name']."\n";
}
}

}
mysqli_close($con);


?>