<?php
require('../config/dbcon.php');
$output = '';
if (isset($_POST["query"])) {

	$query = "Select noofrow from noofrow_mst where description='noofrow'";
	$rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
	while ($row = mysqli_fetch_assoc($rs)) {
		$noofrow     = $row['noofrow'];
	}

	$search = mysqli_escape_string($connect, $_POST["query"]);
	$query = "Select * from truck_mst where Lower(truck_number) LIKE Lower('%" . $search . "%') or Lower(truck_owner_name) LIKE Lower('%" . $search . "%') or Lower(truck_address_two) LIKE Lower('%" . $search . "%') limit $noofrow";
} else {

	$query = "Select noofrow from noofrow_mst where description='noofrow'";
	$rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
	while ($row = mysqli_fetch_assoc($rs)) {
		$noofrow     = $row['noofrow'];
	}
	$query = "Select * from truck_mst order by truck_number";
}

$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
	$output .= '
	<div class="table-responsive" style="width: 160%; overflow:auto; height: 100%;">
		<table id="tblexportData" style="font-size:18px;" class="table table bordered" >
			<tr>
				<th width="80px" style=" text-align: center">Edit</th>
				<th style = "width:100px; text-align: left">truck_number</th>
				<th style = "width:200px; text-align: left">truck_owner_name</th>
				<th style = "width:100px; text-align: left">truck_pan_number</th>
				<th style = "width:200px; text-align: left">truck_remarks</th>
				<th style = "width:200px; text-align: left">truck_bank_name</th>
				<th style = "width:200px; text-align: left">truck_bank_acc_number</th>
				<th style = "width:200px; text-align: left">truck_bank_branch</th>
				<th style = "width:200px; text-align: left">truck_ifsc_code</th>
				<th style = "width:200px; text-align: left">truck_address_one</th>
				<th style = "width:200px; text-align: left">truck_address_two</th>
				<th style = "width:200px; text-align: left">truck_place</th>
				<th style = "width:200px; text-align: left">truck_mobile_number</th>
				<th style = "width:200px; text-align: left">truck_aadhar_no</th>
				<th style = "width:30px; text-align: left">truck_code</th>
			</tr>';
	while ($row = mysqli_fetch_array($result)) {
		$output .= '
			<tr>
				<td style="text-align: center"><button type="button" style="width:60px; height:25px;" name="update" id="' . $row["id"] . '" class="update btn btn-success btn-xs">Edit</button></td>  
				<td style="text-align: left">' . $row["truck_number"] . '</td>
				<td style="text-align: left">' . $row["truck_owner_name"] . '</td>
				<td style="text-align: left">' . $row["truck_pan_number"] . '</td>
				<td style="text-align: left">' . $row["truck_remarks"] . '</td>
				<td style="text-align: left">' . $row["truck_bank_name"] . '</td>
				<td style="text-align: left">' . $row["truck_bank_acc_number"] . '</td>
				<td style="text-align: left">' . $row["truck_bank_branch"] . '</td>
				<td style="text-align: left">' . $row["truck_ifsc_code"] . '</td>
				<td style="text-align: left">' . $row["truck_address_one"] . '</td>
				<td style="text-align: left">' . $row["truck_address_two"] . '</td>
				<td style="text-align: left">' . $row["truck_place"] . '</td>
				<td style="text-align: left">' . $row["truck_mobile_number"] . '</td>
				<td style="text-align: left">' . $row["truck_aadhar_no"] . '</td>
				<td style="text-align: left">' . $row["id"] . '</td>
			</tr>
		';
	}
	echo $output;
} else {
    echo '<div style="font-size:24px; font-weight:bold;  color: #000066;">Data Not Found</div>';
}
