<?php
include('../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 party_mst where Lower(party_name) LIKE Lower('%" . $search . "%') or Lower(party_place) 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 party_mst order by party_name limit $noofrow";
}
$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
	$output .= '
	<div class="table-responsive" style="width: 170%; overflow:auto; height: 40%;">
		<table id="tblexportData" style="font-size:18px;" class="table table bordered" >
			<tr>
				<th style="text-align: left">Edit</th>
				<th width="80px" style=" text-align: center">Edit</th>
				<th style = "width:30px; text-align: left">party_code</th>
				<th style = "width:300px; text-align: left">party_name</th>
				<th style = "width:1000px; text-align: left">party_address_one</th>
				<th style = "width:200px; text-align: left">party_address_two</th>
				<th style = "width:200px; text-align: left">party_place</th>
				<th style = "width:200px; text-align: left">party_contact_person</th>
				<th style = "width:200px; text-align: left">party_phone_number</th>
				<th style = "width:200px; text-align: left">party_mobile_number</th>
				<th style = "width:200px; text-align: left">party_gst_number</th>
				<th style = "width:200px; text-align: left">party_pan_number</th>
				<th style = "width:200px; text-align: left">party_aadhar_number</th>
				<th style = "width:200px; text-align: left">party_payment_terms</th>
				<th style = "width:200px; text-align: left">party_goods</th>				
				<th style = "width:200px; text-align: left">party_remarks</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["id"] . '</td>
				<td style="text-align: left">' . $row["party_name"] . '</td>
				<td style="text-align: left">' . $row["party_address_one"] . '</td>
				<td style="text-align: left">' . $row["party_address_two"] . '</td>
				<td style="text-align: left">' . $row["party_place"] . '</td>
				<td style="text-align: left">' . $row["party_contact_person"] . '</td>
				<td style="text-align: left">' . $row["party_phone_number"] . '</td>
				<td style="text-align: left">' . $row["party_mobile_number"] . '</td>
				<td style="text-align: left">' . $row["party_gst_number"] . '</td>
				<td style="text-align: left">' . $row["party_pan_number"] . '</td>
				<td style="text-align: left">' . $row["party_aadhar_number"] . '</td>
				<td style="text-align: left">' . $row["party_payment_terms"] . '</td>
				<td style="text-align: left">' . $row["party_goods"] . '</td>				
				<td style="text-align: left">' . $row["party_remarks"] . '</td>
			</tr>
		';
	}
	echo $output;
} else {
	echo 'Data Not Found';
}
