<?php require_once('header.php'); ?>
<?php if($session_id==1 || $allPermissions['ftl_booking']['read']=="1"){ ?>
<section class="content-header">
    <div class='box-body' style="margin: 0px 0px;box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;background-color: white;">
    <div class="row">
		<div class="col-md-4" style="text-align: left;">
		    <input type="hidden" autocomplete="off" class="form-control" name="pincode" id='pincode'>
			<h4><i class="fa fa-list"></i>FTL Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
		<?php if($session_id==1 || $allPermissions['ftl_booking']['create']=="1"){ ?>
		    <a href="ftl-booking-add.php" class="btn btn-success btn-sm" style="cursor: pointer;"><i class="fa fa-plus"></i> Create FTL DETAILS</a>
		    <?php }?>
		</div>
	</div> 
    </div>
</section>
<section class="content-header">
    <div class='box-body' style="margin: 0px 0px;box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;background-color: white;">
				<div class="box-body table-responsive">
				<table id="employee-grid"  class="table table-bordered table-striped">
						<thead style="color:gray;">
							<tr>
							    <th  data-sortable= false>S.No</th>
							    <th data-sortable= false><i class="fa fa-check"></i><input type="checkbox" id="select_all" /> </th>
								<th data-sortable= false> Action</th>
								<th >FTL Order No</th>
								<th >Consignee Name</th>
								<th>Date</th>
								<th>Deliverd Date</th>
								<th>Status</th>
							</tr>
						</thead>
						
					</table>
				</div>
				 
    <br>
     <div class="content-footer-center" style="text-align:left;">
		<button class="btn btn-success btn-sm" onclick="redirectTo();"><i class="fa fa-print"></i>Print FTL DETAILS</button>
		<button class="btn btn-warning btn-sm" onclick="redirectTolable();" style="display:none;"><i class="fa fa-print"></i> Print Label</button>
		
		
		<button class="btn btn-danger btn-sm" id="btn_delete_shipments" style="display:none;"><i class="fa fa-trash-o" ></i> Delete Pickup Entry</button>
	</div>
   
    </div>
   
</section>
<?php }?>
<?php require_once('footer.php'); ?>
<script>
$(document).ready(function() {
    getData();
});

function getData()
{
   
    var dataTable = $('#employee-grid').DataTable( {
    	"processing": true,
    	"serverSide": true,
    	"bDestroy": true,
    	"aaSorting":[[0,'desc']],
    	"ajax":{
    		url :"data-tables/ftl-details-dt.php", 
    		data: {ftl_details:1},
    		type: "post",
    		error: function(){  
    			$(".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");
    		}
    	}
    });
}


</script>

<script>
$(document).ready(function() {
	      
	$('#select_all').on('click',function(){
        if(this.checked){
            $('.checkbox').each(function(){
                this.checked = true;
            });
        }else{
             $('.checkbox').each(function(){
                this.checked = false;
            });
        }
    });
    
    $('.checkbox').on('click',function(){
        if($('.checkbox:checked').length == $('.checkbox').length){
            $('#select_all').prop('checked',true);
        }else{
            $('#select_all').prop('checked',false);
        }
    });
    
    
    $('#btn_delete_shipments').on('click',function(){
    
    var checkValues = $('input[name=checkboxlist]:checked').map(function(){
                return $(this).val();
            }).get();
    if(checkValues != ''){
        
         var r = confirm("Confirm if You Want to Delete Those Pickup Entry?");
	    
          if (r == true) {
         var ids=[];
            ids = checkValues;
            console.log('Delete ids :'+ids);
            $.ajax({
          url: 'data-tables/custom-function.php',
          type: 'post',
          data: {type:'delete_pickup_entry',delete_id:ids},
          success: function(response){
              console.log(response);
              //alert("test...");
              //$('#status').val(0);
              getData();
          }
        });
          }
            //window.location.href="shipment-picked.php?shipment_id="+ids+"&status="+status;
    }else{
        alert("Pls Select Min One Pickup Entry to Delete...");
    }
    
});
    
    
	    $("#client_id").select2();
	    $("#set_status").select2();
	    
	    
			    getData();
			  $('#get_report').on('click', function(){
			      var from_date=  $('#from').val();
			      if(from_date){
			        getData();
			      } else
                    {
                        alert('Select a Date !!');
                    }
			  } );
			  
	    
     
			} );
			
			
			  function redirectTo(){
        
         var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
  
        if(checkValues != ''){        
            var ids=[];
            ids = checkValues; 
        
            window.open("ftl-booking-print.php?id=" + ids, '_blank');
        }else{
            alert("Pls Select Min One FTL Booking Details ...");
        }
}
 function redirectTolable(){
        
         var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
     //   alert(checkValues);
                
  var ids=[];
    ids = checkValues; // some thing like this you can set value for 1st Param.

    window.location.href="cargo-lable-print.php?list_id="+ids;

}
   
	    
		</script>
	