<style>
    body {
        margin: 0;
        font-family: 'Tahoma';
    }
    table { 
    border: 1px solid #ddd;
    border-collapse: separate;
    border-left: 0;
    border-radius: 4px;
    border-spacing: 0px;
    }
    
</style>
<?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 customer_mst WHERE Lower(customer_name) LIKE Lower('%" . $search . "%') or Lower(cust_place) LIKE Lower('%" . $search . "%') or Lower(cust_mobile) LIKE Lower('%" . $search . "%') or Lower(cust_gstno) 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 customer_mst ORDER BY customer_name limit $noofrow";
}

$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
	$output .= '
	<div class="table-responsive" style="width: 380%; margin-left : 20px; overflow:auto; height: 35%;">
		<table id="tblexportData" style="font-size:18px; width: 99.8%; " class="table table bordered" >
			<tr>
				<th width="80px" style=" text-align: center">Edit</th>
				<!--th width="50px" style=" text-align: center">Delete</th-->
				<th style = "width:50px; text-align: left">acc_type</th>
				<th style = "width:500px; text-align: left">customer_name</th>
				<th style = "width:50px; text-align: left">customer_code</th>
				<th style = "width:500px; text-align: left">cust_address_one</th>
				<th style = "width:500px; text-align: left">cust_address_two</th>
				<th style = "width:500px; text-align: left">cust_address_three</th>
				<th style = "width:200px; text-align: left">cust_place</th>
				<th style = "width:200px; text-align: left">cust_pin_code</th>
				<th style = "width:200px; text-align: left">cust_st_code</th>
				<th style = "width:350px; text-align: left">cust_st_name</th>
				<th style = "width:300px; text-align: left">cont_person</th>
				<th style = "width:200px; text-align: left">cust_phone</th>
				<th style = "width:200px; text-align: left">cust_mobile</th>				
				<th style = "width:200px; text-align: left">cust_email</th>
				<th style = "width:200px; text-align: left">cust_gstno</th>
				<th style = "width:200px; text-align: left">cust_pan_no</th>
				<th style = "width:200px; text-align: left">cust_aadhar_no</th>
				<th style = "width:200px; text-align: left">tax_code</th>
				<th style = "width:100PX; text-align: left">opening</th>
				<th style = "width:100PX; text-align: right">debit</th>
				<th style = "width:100PX; text-align: right">credit</th>				
				<th style = "width:100PX; text-align: right">clbalance</th>
				<th style = "width:200px; text-align: left">transporter_name</th>
				<th style = "width:200px; text-align: left">bankname</th>
				<th style = "width:200px; text-align: left">bankaccno</th>
				<th style = "width:250px; text-align: left">bankaccname</th>
				<th style = "width:200px; text-align: left">ifsccode</th>
				<th style = "width:100PX; text-align: left">due_days</th>
				<th style = "width:350px; text-align: left">remarks</th>
			</tr>';
	while ($row = mysqli_fetch_array($result)) {
	        $acc_type = $row["acc_type"];
		    if($acc_type == "SDE"){
		    $output .= '
			<tr>
				<td style="text-align: center"><button type="button" name="update" id="' . $row["id"] . '" class="update btn btn-success btn-xs">Edit</button></td>  
				<!--td style="text-align: center;"><button type="button" style="width: 60px;" name="delete" id="' . $row["id"] . '" class="delete btn btn-danger btn-xs">Delete</button></td-->
				<td style="text-align: left">' . $row["acc_type"] . '</td>
				<td style="text-align: left">' . $row["customer_name"] . '</td>
				<td style="text-align: left">' . $row["customer_code"] . '</td>
				<td style="text-align: left">' . $row["cust_address_one"] . '</td>
				<td style="text-align: left">' . $row["cust_address_two"] . '</td>
				<td style="text-align: left">' . $row["cust_address_three"] . '</td>
				<td style="text-align: left">' . $row["cust_place"] . '</td>
				<td style="text-align: left">' . $row["cust_pin_code"] . '</td>
				<td style="text-align: left">' . $row["cust_st_code"] . '</td>
				<td style="text-align: left">' . $row["cust_st_name"] . '</td>
				<td style="text-align: left">' . $row["cont_person"] . '</td>
				<td style="text-align: left">' . $row["cust_phone"] . '</td>
				<td style="text-align: left">' . $row["cust_mobile"] . '</td>				
				<td style="text-align: left">' . $row["cust_email"] . '</td>
				<td style="text-align: left">' . $row["cust_gstno"] . '</td>
				<td style="text-align: left">' . $row["cust_pan_no"] . '</td>
				<td style="text-align: left">' . $row["cust_aadhar_no"] . '</td>
				<td style="text-align: left">' . $row["tax_code"] . '</td>
				<td style="text-align: right">' . $row["opening"] . '</td>
				<td style="text-align: right">' . $row["debit"] . '</td>
				<td style="text-align: right">' . $row["credit"] . '</td>				
				<td style="text-align: right">' . $row["clbalance"] . '</td>
				<td style="text-align: left">' . $row["transporter_name"] . '</td>
				<td style="text-align: left">' . $row["bankname"] . '</td>
				<td style="text-align: left">' . $row["bankaccno"] . '</td>
				<td style="text-align: left">' . $row["bankaccname"] . '</td>
				<td style="text-align: left">' . $row["ifsccode"] . '</td>
				<td style="text-align: left">' . $row["due_days"] . '</td>
				<td style="text-align: left">' . $row["remarks"] . '</td>
			</tr>
		';
		        }
	}
	echo $output;
} else {
	echo 'Data Not Found';
}
