<?php require_once('header.php'); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('#country').on('change', function(){
        var countryID = $(this).val();
       
        if(countryID){
            $.ajax({
                type:'POST',
                url:'get_branch_sunit.php',
                data:'country_id='+countryID,
                success:function(html){
                    $('#state').html(html);
                     $('#state1').html(html);
                    $('#city').html('<option value="">Select Franchise first</option>'); 
                     get_branchBase(countryID);
                }
            }); 
        }else{
            $('#state').html('<option value="">Select Branch first</option>');
             $('#city').html('<option value="">Select Franchise first</option>'); 
        }
    });
    $('#state').on('change', function(){
        var stateID = $(this).val();
        if(stateID){
            $.ajax({
                type:'POST',
                url:'get_branch_sunit.php',
                data:'state_id='+stateID,
                success:function(html){
                    $('#city').html(html);
                  
                }
            }); 
        }else{
            $('#city').html('<option value="">Select Franchise first</option>'); 
        }
    });
    $('#city').on('change', function(){
        var CityID = $(this).val();
         if(CityID){
        $(':input[id="btnadd"]').prop('disabled', false);
         }
    });
});
</script>
<script>
    $(document).ready(function(){
        $('#btnadd').click(function(){
         //  var stitching_unit_id=   $('#city').val();
           //alert(stitching_unit_id);
            var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
             if(checkValues!=""){
               // alert(checkValues);
          $.ajax({
        url: 'assign_dealer.php',
        type: 'post',
        data: {search:checkValues},
        dataType: 'json',
        success: function(response)
        {
           // alert(response);
            if(response==1)
            {
           alert('Assigned To Dealer SuccessFully !!'); 
           location.reload();
            }
            else{
               alert('Failed To Assign !!');
               location.reload();
            }
        }

    });
        }
            else{
                alert('No Value Selected');
            }
        });
    });
</script>
<script type="text/javascript">
$(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);
        }
    });
});

    function redirectTo(){
        
         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="pk_awb_number_print.php?list_id="+ids;

}
 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="pk_lable_print.php?list_id="+ids;

}
</script>
<section class="content-header">
	<div class="content-header-left">
		<h1>View Pickup Entry</h1>
	</div>
	<div class="row">
	    <div class="col-md-12">
	 <div class="col-md-2" style="margin-left: 6%;">  
	<div class="content-header-right" >
		<a href="Sample Excel Format/Pickup-Entry-Sample.xlsx" target="_blank" class="btn btn-danger btn-sm">Download Sample File Format </a>
	</div>
	</div>
	<div class="col-md-2">  
	<div class="content-header-right" >
		<a href="pickup-entry-bulk-upload.php" class="btn btn-danger btn-sm">Bulk Upload</a>
	</div>
	</div>
	<div class="col-md-2">  
	<div class="content-header-right" >
		<a href="pickup-entry-add.php" class="btn btn-danger btn-sm">Single Pickup Entry</a>
	</div>
	</div>
	</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="example1" class="table table-bordered table-striped">
						<thead>
							<tr>
								<th width="30">SL</th>
								<th><i class="fa fa-check"></i><input type="checkbox" id="select_all" /></th>
								<th>AWB Number</th>
								<th>Ref Number</th>
								<th>Material</th>
								<th>Company Name</th>
								<th>Address</th>
								<th>Pincode</th>
								<th>Mobile Number</th>
								<th>Actual Weight</th>
								<th>Charged Weight</th>
								<th>No.Of Pics</th>
								<th>Shipping Mode</th>
								<th>Payment Mode</th>
								<!--<th>Invoice value</th>-->
								<th>Customer Name</th>
								
							</tr>
						</thead>
						
						   <tbody>
							<?php
							$i=0;
							$statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name as client_name,material_desc.full_desc as content,tbl_customer.cust_name as cust_name FROM pickup_entry INNER JOIN tbl_user INNER JOIN tbl_customer INNER JOIN material_desc on pickup_entry.client_id=tbl_user.id AND pickup_entry.content_desc=material_desc.id AND pickup_entry.customer_id=tbl_customer.cust_id and pickup_entry.status='picked' and tbl_user.role='client'  order by pickup_entry.id DESC");
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
							foreach ($result as $row) {
								$i++;
								?>
								<tr>
									<td><?php echo $i; ?></td>
									<td><input type="checkbox" class="checkbox" name="checkboxlist" value="<?php echo $row['awb_no']; ?>"/></td>
									<td><?php echo $row['ref_no']; ?></td>
									<td><?php echo $row['awb_no']; ?></td>
									<td><?php echo $row['content']; ?></td>
									<td><?php echo $row['client_name']; ?></td>
									<td><?php echo $row['address']; ?></td>
									<td><?php echo $row['pincode']; ?></td>	
									<td><?php echo $row['phone']; ?></td>
									<td><?php echo $row['a_weight']; ?></td>
									<td><?php echo $row['c_weight']; ?></td>
									<td><?php echo $row['pics']; ?></td>
									<td><?php echo $row['shipping_mode']; ?></td>
									<td><?php echo $row['payment_mode']; ?></td>
									<!--<td>null</td>-->
									<td><?php echo $row['cust_name']; ?></td>
									
									<!--<td>										-->
									<!--	<a href="user-edit.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-xs">Edit</a>-->
									<!--	<a href="#" class="btn btn-danger btn-xs" data-href="user-delete.php?id=<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete">Delete</a>  -->
									<!--</td>-->
								</tr>
								<?php
							}
							?>							
						</tbody>
					
						
						
						
						
						
					</table>
				</div>
			</div>
		</div>
	</div>

	<div class="content-footer-right" style="margin-left:45%">
		<!--<a href="awb_number_print.php" onclick="window.location.href=this.href+'?list_id=100001'" class="btn btn-primary btn-sm">Print AWB Number</a>-->
		<button class="btn btn-success btn-sm" onclick="redirectTo();">Print AWB Number</button>
		<button class="btn btn-success btn-sm" onclick="redirectTolable();">Print Lable</button>

		<!--<a href="awb_number_print.php" onclick="window.location.href=this.href+'?list_id='+checkValues" class="btn btn-primary btn-sm">Print AWB Number</a>-->
              <!--<a href="awb_number_print.php" onclick="window.location=this.href+'?list_id='+checkValues" ><button type="submit" class="btn btn-md btn-primary" >Print AWB Number</button></a>-->

	</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-danger btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>


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