<?php 
include("../config.php");

if(isset($_GET['start_date']) && !empty($_GET['start_date'])) {
	$start_date = risFormatDate($_GET['start_date'],'Y-m-d');
}

if(isset($_GET['end_date']) && !empty($_GET['end_date'])) {
	$end_date = risFormatDate($_GET['end_date'],'Y-m-d');
}

$query = mysqli_query($conn, "SELECT * FROM `lr_mst` WHERE DATE(l_date) >= '".$start_date."' AND DATE(l_date) <= '".$end_date."' AND company_id = '".$_SESSION['company_id']."' AND branch_id = '".$_SESSION['branch_id']."'");
$data = array();
while ($rows = mysqli_fetch_assoc($query)) {
	$data[] = $rows;
}
$master_vendor = combine(getAllRecords('vendor_master'), 'id', 'name');
$table =  '';
if(count($data) > 0){
	foreach ($data as $key => $datas) {
		$check_point = mysqli_query($conn, "SELECT * FROM `image_master` WHERE `ref_no` = '".$datas['lr_no']."'");
		if(mysqli_num_rows($check_point) == 0){
			$table .='
			<tr class="text-center">
				<td><a href="index.php?page=lr/permit_add.php&eid='.$datas['lr_no'].'" target="_BLANK">'.$datas["lr_no"].'</a></td>
				<td>'.risFormatDate($datas["l_date"],'d-m-Y').'</td>
				<td>'.$datas["truck_no"].'</td>
				<td>'.@$master_vendor[$datas['consignor_name']].'</td>
				<td>'.@$master_vendor[$datas['consignee_name']].'</td>
				<td>'.$datas['agent'].'</td>
				<td>'.$datas["from_place"].'</td>
				<td>'.$datas["to_place"].'</td>
			</tr>
			';
		}
	}
}else{
	$table .= '<tr>';
	$table .= '<th colspan="7">NO DATA FOUND...!!!</th>';
	$table .= '</tr>';
}
$data = array('status' => 'success', 'total_count' => $total, 'tbody' => $table);
	echo json_encode($data);
    die();
?>