<?php
include('../config/dbcon.php');
$output = '';
if(isset($_POST["query"]))
{
	
	$search = mysqli_escape_string($connect, $_POST["query"]);
	$query = "SELECT * FROM invtotal_mst WHERE Lower(customer_name) LIKE Lower('%".$search."%') or customer_code LIKE '%".$search."%' or Lower(cust_gstno) LIKE Lower('%".$search."%') or Lower(cust_place) LIKE Lower('%".$search."%') or Upper(inv_number) LIKE Upper('%".$search."%')";}
else
{
	
	$query = "SELECT * FROM invtotal_mst ORDER BY inv_number";
}
$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">cust_code</th>
				<th style = "text-align: left">customer_name</th>
				<th style = "text-align: left">cust_gstno</th>
				<th style = "text-align: left">cust_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["customer_code"] . '</td>
				<td style="text-align: left; width:400px;">' . $row["customer_name"] . '</td>
				<td style="text-align: left; width:100px;">' . $row["cust_gstno"] . '</td>
				<td style="text-align: left; width:100px;">' . $row["cust_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';
}
?>
