<?php
include('../config/dbcon.php');
$output = '';
if(isset($_POST["query"]))
{	
	$search = mysqli_escape_string($connect, $_POST["query"]);
	$query = "SELECT * FROM pinvtotal_mst WHERE Lower(supplier_name) LIKE Lower('%".$search."%') or Lower(supplier_code) LIKE Lower('%".$search."%') or Lower(supplier_gstno) LIKE Lower('%".$search."%') or Lower(supplier_place) LIKE Lower('%".$search."%') or Upper(inv_number) LIKE Upper('%".$search."%') ORDER BY inv_date";}
else
{	
	$query = "SELECT * FROM pinvtotal_mst ORDER BY inv_date,inv_number asc";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
	$output .= '
	<div class="table-responsive" style="font-size:18px; width: 150%;">
		<table id="tblexportData" class="table table bordered" >
			<tr>
				<th style = "text-align: left">inv_number</th>
				<th style = "text-align: left">inv_date</th>
				<th style = "text-align: left">supplier_code</th>
				<th style = "text-align: left">supplier_name</th>
				<th style = "text-align: left">supplier_gstno</th>
				<th style = "text-align: left">supplier_place</th>
				<th style = "text-align: right">total_qty</th>
				<th style = "text-align: right">total_list_value</th>
				<th style = "text-align: right">total_disc_amt</th>
				<th style = "text-align: right">total_sales_val</th>
				<th style = "text-align: right">total_sgstamt</th>
				<th style = "text-align: right">total_cgstamt</th>
				<th style = "text-align: right">total_igstamt</th>
				<th style = "text-align: right">total_val</th>
				<th style = "text-align: right">roundoff</th>
				<th style = "text-align: right">total_inv_val</th>
				<th style = "text-align: left">tax_code</th>
			</tr>';
	while($row = mysqli_fetch_array($result))
	{
		$output .= '
			<tr>
				<td style="text-align: left; width:70px;">' . $row["inv_number"] . '</td>
				<td style="text-align: left; width:70px;">' . date("d-m-Y", strtotime($row["inv_date"])). '</td>
				<td style="text-align: left; width:70px;">' . $row["supplier_code"] . '</td>
				<td style="text-align: left; width:400px;">' . $row["supplier_name"] . '</td>
				<td style="text-align: left; width:100px;">' . $row["supplier_gstno"] . '</td>
				<td style="text-align: left; width:100px;">' . $row["supplier_place"] . '</td>
				<td style="text-align: right; width:100px;">' . $row["total_qty"] . '</td>
				<td style="text-align: right; width:80px;">' . $row["total_list_value"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_disc_amt"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_sales_val"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_sgstamt"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_cgstamt"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_igstamt"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_val"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["roundoff"] . '</td>
				<td style="text-align: right; width:80px;"">' . $row["total_inv_val"] . '</td>
				<td style="text-align: left; width:80px;"">' . $row["tax_code"] . '</td>
			</tr>
		';
	}
	echo $output;
}
else
{
	echo 'Data Not Found';
}
?>
