<?php require_once('header.php');
$total_p=0;
?>
<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);
        }
    });
});
</script>
<script>
    $(document).ready(function(){
        $('#add_manifest').click(function(){
           var transport_name=   $('#courier_name').val();
            var entry_date=   $('#entry_date').val();
            var send_through=   $('#send_through').val();
            var client_id=   $('#client_id').val();
              var origin=  $('#origin').val();   
            var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
            
             if(checkValues!=""){
          $.ajax({
        url: 'assign_manifest.php',
        type: 'post',
        data: {awb_id:checkValues,t_name:transport_name,e_date:entry_date,send:send_through,orig:origin,client_id:client_id},
        // dataType: 'json',
        success: function(response)
        {
         getData();
            $("#res_status_table").show();
            $("#res_status_table_data").html(response);
        }

    });
        }
            else{
                alert('No Value Selected');
            }
        });
			  getData();
			  function getData()
			  {
			    var client_id   = $('#client_id').val();
			    var client_type = $('#client_type').val();
			    var status_code = $('#status_code').val();
				var dataTable = $('#employee-grid').DataTable( {
					"processing": true,
					"serverSide": true,
					"bDestroy": true,
					"ajax":{
						url :"data-tables/pending-pickup-entry-data-table.php", // json datasource
						data: {client_id:client_id,client_type:client_type,status:status_code},
						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");
						}
					}
				});
			  }
	});
</script>

<section class="content-header">
	<div class="content-header-left">
		<h1>Create Manifest</h1>
	</div>
	<div class="content-header-right">
		<a href="manifest.php" class="btn btn-danger btn-sm">View All</a>
	</div>
</section>
    <div id="res_status_table" class="alert alert-info alert-dismissible"  style='display:none;margin-left: 2%;margin-right: 2%;' >
	    <a href="#" class="close" data-dismiss="alert" onclick='location.reload();' aria-label="close">&times;</a>
    	<table id="res_status_table_data" class="table"></table>
	</div>
<section class="content">
    <div class="row">
	     <div class="col-md-3">
		  <select class="form-control" name="send_through" id="send_through">
							      <!-- <option>Select Sending Through</option>-->
							         <?php
									$statement = $pdo->prepare("SELECT * FROM `tbl_mode_transport`");
									$statement->execute();
									$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
									foreach ($result as $row) {
										?>
										<option value="<?php echo $row['id']; ?>"><?php echo $row['transport_mode']; ?></option>
										<?php
									}
									?>
							    </select>
		 </div>
		 <input type='hidden' name="client_id" id="client_id" value="<?php echo $clientId; ?>">
<input type="hidden" id="client_type" name="client_type" value="<?php echo $clientType; ?>">
<input type="hidden" id="status_code" name="status_code" value="2">
		<div class="col-md-3">
		 <input type="date" autocomplete="off" class="form-control" name="entry_date"  id="entry_date" value="<?php echo date("Y-m-d"); ?>">
		 </div>
		 <div class="col-md-3">
		      <select class="form-control" name="courier_name" id="courier_name" required>
							       <!--<option>Select Courier</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>
     <!--<input type="text" autocomplete="off" class="form-control" name="transport_name" id="transport_name" Placeholder="Enter Transport Name" >-->
		 </div>
		  <div class="col-md-3">
		      <button id='add_manifest' class="btn btn-danger btn-sm">Add Manifest</button>
	        </div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-12">
			<div class="box box-info">
			    <input type='hidden' name='origin' id='origin' value='<?php echo $clientLocation; ?>'>
				<div class="box-body table-responsive">
					<table id="employee-grid" class="table table-bordered table-striped">
						<thead>
								<tr>
								<th width="30">SL</th>
								<th data-sortable= false>Action</th>
								<th data-sortable= false><i class="fa fa-check"></i><input type="checkbox" id="select_all" /></th>
								<?php  if($clientType=="Admin")	 { ?>	<th>Client</th><?php } ?>
								<th>CSCS AWB</th>
								<?php  if($clientType=="Admin")	 { ?>	<th>3PL AWB</th><?php } ?>
								<th>Ref No</th>
								<th>Order Type</th>
								<th>Shipper Name</th>
								<th>Shipper Address</th>
								<th>Shipper City</th>
								<th>Shipper State</th>
								<th>Shipper Phone</th>
								<th>Shipper Pincode</th>
								<th>Consignee Name</th>
								<th>Consignee Address</th>
								<th>Consignee City</th>
								<th>Consignee State</th>
								<th>Consignee Phone</th>
								<th>Consignee Pincode</th>
								<th>Volumetric Weight</th>
								<th>Volumetric Length</th>
								<th>Volumetric Breadth</th>
								<th>Volumetric Height</th>
								<th>Collectable Amount</th>
								<th>Product Description</th>
								<th>Quantity</th>
								<th>Boxes</th>
								<th>Invoice Value</th>
								<th>Taxable Value</th>
								<th>Hsn Code</th>
								<th>Discount</th>
								<th>Gst Amount</th>
								<th>MRP</th>
								<th>Ewaybill</th>
								<th>Actual Weight</th>
								<th>Charged Weight</th>
								<th>Gst Type</th>
								<th>Buyer Gst</th>
								<th>Seller Gst</th>
								<th>RTO Name</th>
								<th>RTO Address</th>
								<th>RTO City</th>
								<th>RTO State</th>
								<th>RTO Phone</th>
								<th>RTO Pincode</th>
								<th>Date Added</th>
							</tr>
						</thead>
						
					</table>
				</div>
			</div>
		</div>
	</div>

	<!--<br><br>

	<div class="content-footer-right" style="margin-left:45%">
		<button id='add_manifest' class="btn btn-danger btn-sm">Add Manifest</button>
	</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-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-Success btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>


<?php require_once('footer.php'); ?>