<?php require_once('header.php'); ?>
<?php if($allPermissions['3plAwbList']['read']=="1"){ ?>

		<script>
		 function get_data()
    {
         var courier_id=  $('#courier_id').val();     
                var set_status=  $('#set_status').val();
                console.log(courier_id,set_status);
				var dataTable = $('#employee-grid').DataTable( {
					"processing": true,
					"serverSide": true,
					 "bDestroy": true,
					"ajax":{
						url :"data-tables/awb-3pl-list-data-table.php", // json datasource
						data:{courier_id:courier_id,status:set_status},
						type: "post",  // method  , by default get
						error: function(){  // error handling
							$(".employee-grid-error").html("");
							$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
							$("#employee-grid_processing").css("display","none");
							
						}
					}
				} );
    }
    
$(document).ready(function(){
    get_data();
    $('#get_awb_list').on('click', function(){
        get_data();
        
    });
});
</script>

<section class="content-header">
	<div class="content-header-left">
		<h1>View AWB </h1>
	</div>
	<?php if($allPermissions['3plAwbList']['create']=="1"){ ?>
	<div class="col-md-2">
	    <div class="form-group">
    		       <a class="btn btn-danger btn-sm" href="awbBulkUpload.php">Bulk Upload</a>
		</div>
	</div>
	<?php } ?>
	<div class="row" >
	    <div class='col-md-2'>
        <label for="to">Courier Company</label>
        <select class="form-control" name="courier_id" id="courier_id">
	        <option value="all">Over All </option>
	        <?php
			$statement = $pdo->prepare("SELECT * FROM `courier_company`");
			$statement->execute();
			$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
			foreach ($result as $row) {
				?>
				<option value="<?php echo $row['id']; ?>"><?php echo $row['company_name']; ?></option>
				<?php
			}
			?>
	    </select>
        </div>
    <div class='col-md-2'>
         <label for="to">Status:</label>
            <select class="form-control" name="set_status" id="set_status">
		        <option value='all'>All</option>
		        <option value='0'>Available</option>
		        <option value='1'>Not Available</option>
		    </select>
    </div>
    <div class='col-md-2' style="margin-top: 2%;">
         <button id="get_awb_list" class="btn btn-md btn-info"><span id='sub_txt'>Submit</span>&ensp;<span id="sub_spin"></span></button>
    </div>
	</div>
	
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-info">
				<div class="box-body table-responsive">
					<table id="employee-grid"  class="table table-bordered table-striped">
						<thead>
							<tr>
								<th width="30">SL</th>
								<th>AWB List</th>
								<th>Courier</th>
								<th>Status</th>
							</tr>
						</thead>
				
					</table>
				</div>
			</div>
		</div>
	</div>


</section>


<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
            </div>
            <div class="modal-body">
                <p>Are you sure want to delete this item?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sucess" data-dismiss="modal">Cancel</button>
                <a class="btn btn-sucess btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>

<?php }else{ ?>
<center><h4 style="color:red;">You don't have permission to view 3PL AWB List </h4></center>
<?php } ?>
<?php require_once('footer.php'); ?>