<?php require_once('header.php'); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/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);
           if(checkValues==""){
                      alert("pls Select Atleast One Record");
               }
               else
               {     
  var ids=[];
    ids = checkValues; // some thing like this you can set value for 1st Param.

    window.location.href="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="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="excel/excel-all-picked.php" class="btn btn-danger btn-sm">Export as Excel</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">CSCS Bulk Upload</a>
	</div>
	</div>
	<div class="col-md-2">  
	<div class="content-header-right" >
		<a href="modicare-pickup-entry-add.php" class="btn btn-danger btn-sm">CSCS Single Pickup Entry</a>
	</div>
	</div>
	</div>
	</div>
	<br>
	<div class="row">
	    <div class="col-md-12">
	<center><button class="btn btn-danger btn-sm" onclick="redirectTo();">Print AWB Number</button></center>
	</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>
    							<?php  if($clientType=="Admin")	 { ?>	<th>Action</th><?php } ?>
								<th><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>
						
						   <tbody>
							<?php
							$i=0;
							if($clientType=="Admin")
						 { 
							$statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name as client_name FROM `pickup_entry` INNER JOIN tbl_user ON pickup_entry.client_id=tbl_user.id WHERE pickup_entry.status='picked' ORDER BY pickup_entry.id DESC");
						 }
						 else
						 {
						     $statement = $pdo->prepare("SELECT pickup_entry.*,tbl_user.full_name as client_name FROM `pickup_entry` INNER JOIN tbl_user ON pickup_entry.client_id=tbl_user.id WHERE pickup_entry.status='picked' AND pickup_entry.client_id=$clientId 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>
									<?php  if($clientType=="Admin")	 { ?><td>									
										<a href="pickup-entry-edit.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-xs">Edit</a>
										<a href="awb_number_print.php?list_id=<?php echo $row['id']; ?>" class="btn btn-success btn-xs">View/Print AWB</a>
									</td><?php } ?>
									<td><input type="checkbox" class="checkbox" name="checkboxlist" value="<?php echo $row['id']; ?>"/></td>
                    				<?php  if($clientType=="Admin")	 { ?><td><?php echo $row['client_name']; ?></td><?php } ?>
									<td><?php echo $row['cscs_awb']; ?></td>
									<?php  if($clientType=="Admin")	 { ?><td><?php echo $row['3pl_awb']; ?></td><?php } ?>
									<td><?php echo $row['ref_no']; ?></td>
									<td><?php echo $row['order_type']; ?></td>
									<td><?php echo $row['shipper_name']; ?></td>
									<td><?php echo $row['shipper_address']; ?></td>
									<td><?php echo $row['shipper_city']; ?></td>
									<td><?php echo $row['shipper_state']; ?></td>
									<td><?php echo $row['shipper_phone']; ?></td>
									<td><?php echo $row['shipper_pincode']; ?></td>
									<td><?php echo $row['consignee_name']; ?></td>
									<td><?php echo $row['consignee_address']; ?></td>
									<td><?php echo $row['consignee_city']; ?></td>
									<td><?php echo $row['consignee_state']; ?></td>
									<td><?php echo $row['consignee_phone']; ?></td>
									<td><?php echo $row['consignee_pincode']; ?></td>
									<td><?php echo $row['v_weight']; ?></td>	
									<td><?php echo $row['vw_length']; ?></td>	
									<td><?php echo $row['vw_breadth']; ?></td>	
									<td><?php echo $row['vw_height']; ?></td>	
									<td><?php echo $row['collectable_amount']; ?></td>	
									<td><?php echo $row['product_description']; ?></td>
									<td><?php echo $row['quantity']; ?></td>
									<td><?php echo $row['boxes']; ?></td>
									<td><?php echo $row['invoice_value']; ?></td>	
									<td><?php echo $row['taxable_value']; ?></td>
									<td><?php echo $row['hsn_code']; ?></td>
									<td><?php echo $row['discount']; ?></td>
									<td><?php echo $row['gst_amount']; ?></td>
									<td><?php echo $row['mrp']; ?></td>
									<td><?php echo $row['ewaybill']; ?></td>
									<td><?php echo $row['a_weight']; ?></td>
									<td><?php echo $row['c_weight']; ?></td>
									<td><?php if($row['gst_rate']=='gr_igst'){ echo "IGST";}elseif($row['gst_rate']=='gr_cgst'){ echo "CGST";} ?></td>
									<td><?php echo $row['buyer_gst']; ?></td>
									<td><?php echo $row['seller_gst']; ?></td>
									<td><?php echo $row['rto_name']; ?></td>
									<td><?php echo $row['rto_address']; ?></td>
									<td><?php echo $row['rto_city']; ?></td>
									<td><?php echo $row['rto_state']; ?></td>
									<td><?php echo $row['rto_phone']; ?></td>
									<td><?php echo $row['rto_pincode']; ?></td>
									<td><?php 
									$day=date_create($row['date_added']);
									$created=date_format($day,'d-m-Y');
									echo $created; ?>
									</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-danger 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-success btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>


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