<?php require_once('header.php'); 
$uuid=$fn->gen_uuid();
// print_r("session ".$session_branch_ids);
// print_r("clint ".$session_client_ids);
?>


<?php if($session_id==1 || $allPermissions['transaction_booking']['create']=="1"){ ?>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
/*$(document).ready(function(){
  $("#consignee_city").select2();
  $("#consignee_state").select2();
});*/
</script>
<style>
        .status {
            font-weight: bold;
            margin-left: 10px;
        }
        .verified {
            color: green;
        }
        .not-verified {
            color: red;
        }
    
</style>


 
	<section class="content-header" style="background-color: white;">
	    
	<div class="row">
		<div class="col-md-4" style="text-align: left;">
			<h4><i class="fa fa-map-marker"></i> Add Shipment Bookings Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
		    <a href="shipment-create.php" class="btn btn-success btn-sm"><i class="fa fa-plus"></i> Shipment Bulk Upload</a>
	<?php if($allPermissions['pickupentry']['read']=="1"){ ?>	    <a href="booking-list.php" class="btn btn-warning btn-sm"><i class="fa fa-arrow-left"></i> Back to Booking List</a><?php } ?>
		</div>
	</div> 

		<div class="row">
			<div class="col-md-12">
			    
			    
			    
				<?php if($error_message): ?>
					<div class="callout callout-danger">
						<p>
							<?php echo $error_message; ?>
						</p>
					</div>
				<?php endif; ?>
				<?php if($success_message): ?>
					<div class="callout callout-success">
								<p>
									<?php echo $success_message; ?>
								</p>
							</div>
				<?php endif; ?>
							
							
							
								<form class="form-horizontal" action="" method="post" id="add_form" enctype="multipart/form-data">
								    
								    <input type="hidden" id="surface_cal">
								    <input type="hidden" id="air_cal">
								    
									<div class="box box-warning" style="box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;">
										<div class="box-body">
										    
										    <div class="row" style="margin: 20px 0px;">
										        
										        <div class="col-md-3">
										            <label>Select Branch <span style='color:red;'>*</span></label>
										            <select name="branch_id" id="branch_id" class="form-control select2">
															
													</select>
										        </div>
										        
										        <div class="col-md-3">
										            <label>Select Client <span style='color:red;'>*</span></label>
										            <select name="new_client" id="new_client" class="form-control select2">
															
													</select>
													<span id="select_client_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-3">
										            <label class="optional">Pickup Points</label>
										            <select name="pickup_points" id="pickup_points" class="form-control select2">
										            
										            </select>
										        </div>
										        
										        <div class="col-md-3">
										            <label  class="optional">Select Courier</label>
										            <select name="courier_id" id="courier_id" class="form-control select2">
															
													</select>
										        </div>
										        
										        
										        
										        <div class="col-md-3">
										            <label>Shipment Date <span style='color:red;'>*</span></label>
										            <input type="date" autocomplete="off" class="form-control" name="date_added" value="<?php echo date("Y-m-d") ?>">
										        </div>
										        
										        
										    </div>
										    
										    
										    
								    <div class="row">
										    
				<!-- Consignor Details Starts Here -->
										    <div class="col-md-6" style="">
										        
										        
				<div class="row filter" style="margin: 20px 5px 5px 5px; background: darkcyan; color: white; padding: 10px; border-radius: 5px; cursor: pointer; margin-bottom: 29px;">
                                <i class="fa fa-info"></i> <b>Consignor Details</b> <span style="float: right; padding-right: 10px;"></span>
                </div> 
										        
									
										            
										        
										        
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label  class="optional">Select Consignor </label>
										            <select name="client_id" id="client_id" class="form-control select2">
													
        											</select>
        											<span id="client_id_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor Name <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" id="shipper_name" name="shipper_name" value="">
										            <span id="shipper_name_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label >Consignor Phone <span style='color:green;'>Optional</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="shipper_phone" id="shipper_phone" value="">
										            <span id="shipper_phone_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor Address <span style='color:red;'>*</span></label>
										            <textarea class="form-control" name="shipper_address" id="shipper_address" style="" rows="3"></textarea>
										            <span id="shipper_address_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor Pincode <span style='color:red;'>*</span></label>
										            <input type="number" autocomplete="off" class="form-control" name="shipper_pincode" id="shipper_pincode" value="">
										            <span id="shipper_pincode_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor City <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="shipper_city" id="shipper_city" value="">
										            <span id="shipper_city_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor Location <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="shipper_location" id="shipper_location" value="">
										            <span id="shipper_location_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor State <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="shipper_state" id="shipper_state" value="">
										            <span id="shipper_state_txt"> </span>
										        </div>
										        
										        
										        
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignor GST <span style='color: green;'>(optional)</span></label>
										            <input type="text" autocomplete="off" class="form-control " name="seller_gst" value="<?php if(isset($_POST['seller_gst'])){echo $_POST['seller_gst'];} ?>">
										        </div>
										        
										        
										        
										    </div>
				<!-- Consignor Details Endsss Here -->
				
				
				
				
				
				<!-- Consignee Details Starts Here -->
										    <div class="col-md-6" style="">
										        
				<div class="row filter" style="margin: 20px 5px 5px 5px; background: darkcyan; color: white; padding: 10px; border-radius: 5px; cursor: pointer; margin-bottom: 29px;">
                                <i class="fa fa-info"></i> <b>Consignee Details</b> <span style="float: right; padding-right: 10px;"></span>
                </div> 
										        
										        
										        
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label class="optional">Select Consignee </label>
										            <select name="customer_id" id="customer_id" class="form-control select2">
														
        											</select>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee Name <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" id="consignee_name" name="consignee_name" value=""> 
										            <span id="consignee_name_txt"> </span>
										        </div>
										        
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee Phone <span style='color:green;'>Optional</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="consignee_phone" id="consignee_phone" value="">
										            <span id="consignee_phone_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee Address <span style='color:red;'>*</span></label>
										            <textarea class="form-control" id="consignee_address" name="consignee_address" style="" rows="3"></textarea>
										            <span id="consignee_address_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee Pincode <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" oninput="get_availability()" id="consignee_pincode" name="consignee_pincode">
										            <input type="hidden" name='service' id='service' value="no">
										            <span id="availability"></span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee City <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="consignee_city" id="consignee_city">
										            
														<span id="consignee_city_txt"> </span>
										        </div>
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee Location <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="consignee_location" id="consignee_location">
										            
														<span id="consignee_location_txt"> </span>
										        </div>
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee State <span style='color:red;'>*</span></label>
										            <input type="text" autocomplete="off" class="form-control" name="consignee_state" id="consignee_state">
										            
														<span id="consignee_state_txt"> </span>
										        </div>
										        
										        
										        
										        
										        
										        <div class="col-md-12" style="margin-top: 10px;">
										            <label>Consignee GST <span style='color: green;'>(optional)</span></label>
										            <input type="text" autocomplete="off" class="form-control col-sm-4" name="buyer_gst" value="<?php if(isset($_POST['buyer_gst'])){echo $_POST['buyer_gst'];} ?>">
										        </div>
										        
										        
										    </div>
				<!-- Consignee Details Endsss Here -->
										    
									</div>		
											
								
							
							
							
							
							<div class="row filter" style="margin: 20px 5px 5px 5px; background: darkcyan; color: white; padding: 10px; border-radius: 5px; cursor: pointer; margin-bottom: 29px;">
                                <b>Shipment Details </b> <span style="float: right; padding-right: 10px;"><i class="fa fa-caret-down" style="font-size: 18px;"></i></span>
                            </div>
            
            
            
                            
                            
            
							<div style="margin-top: 20px;">			
											
											<?php if($clientType=="Admin"){ ?>
													
													<div style="margin-top: 20px;">
														<div class="form-group" >
															<label for="" class="col-sm-2 control-label">3PL AWB </label>
															<div class="col-sm-6">
																<input type="text" autocomplete="off" class="form-control" id="3pl_awb" name="3pl_awb" value="<?php if(isset($_POST['3pl_awb'])){echo $_POST['3pl_awb'];} ?>"> 
																<input type="hidden" name='pl3_service' id='pl3_service' value="no">
																</div>
															<div class="col-sm-4"> <span id="ncheck1"> </span> </div>
														</div>
													</div>
														
											<?php } ?>
														
														
															<div class="form-group">
																	<label for="" class="col-sm-2 control-label">AWB mode<span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<select class="form-control" name="autoGen" id="autoGen">
																			<option value='1' selected>Auto</option>
																			<option value='2'>Manual</option>
																		</select>
																	</div>
																</div>
																
																
																
															<div class="form-group" style="display:none;" id="cscsAwbDiv">
																<label for="" class="col-sm-2 control-label">AWB No <span style='color:red;'>*</span></label>
																<div class="col-sm-6">
																	<input type="text" autocomplete="off" class="form-control" id="cscs_awb" name="awb_number" value="<?php if(isset($_POST['cscs_awb'])){echo $_POST['cscs_awb'];} ?>"> </div>
																	
															<div class="col-sm-4"><input type="hidden" name='cscs_awb_service' id='cscs_awb_service' value="no"> <span id="cscs_awb_txt"> </span> </div>
														</div>
														
														
															<div class="form-group" hidden>
																<label for="" class="col-sm-2 control-label">Ref No <span style='color:red;'>*</span></label>
																<div class="col-sm-6">
																	<input type="text" autocomplete="off" class="form-control" id="ref_no" name="ref_no" value="<?=$uuid?>"> </div>
																<div class="col-sm-4"> <span id="ncheck2"> </span> </div>
															</div>
															<div class="form-group">
																<label for="" class="col-sm-2 control-label">Order Type </label>
																<div class="col-sm-2">
																	<select name="order_type" class="form-control" id="order_type">
																		<option value="cod">COD</option>
																		<option value="prepaid">Prepaid</option>
																		<option value="tobebilled">To Be Billed</option>
																	</select>
																</div>
															</div>
															
			                                                <div class="form-group">
																<label for="" class="col-sm-2 control-label">Material Type </label>
																<div class="col-sm-6">
																	<select name="material_type" class="form-control select2" id="material_type">
																		<option value="">Select Material Type</option>
																		<?php
																		$statementss = $pdo->prepare("SELECT * FROM tbl_material_type where status=1");
                                                                    	$statementss->execute();
                                                                    	$resultss = $statementss->fetchAll(PDO::FETCH_ASSOC);
																		foreach($resultss as $material_data){  ?>
																	    	<option value="<?=$material_data['name']?>"><?=$material_data['name']?></option>
																	    <?php } ?>	
																	</select>
																</div>
															</div>
			
			
			
                            
                            
                                        
															<input type="hidden" name='location' id='location'>
															<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Invoice No </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="invoice_no" value="<?php if(isset($_POST['invoice_no'])){echo $_POST['invoice_no'];} ?>"> </div>
															</div>
															<div class="form-group" id="collectables">
																<label for="" class="col-sm-2 control-label">Invoice Value <span style='color:red;'>*</span></label>
																<div class="col-sm-3">
																	<input type="number" step='any' autocomplete="off" class="form-control" id="collectable_amount" name="collectable_amount" value="<?php if(isset($_POST['collectable_amount'])){echo $_POST['collectable_amount'];} ?>"> </div>
															</div>
															
															
															
															<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Ewaybill </label>
																	<div class="col-sm-6">
																		<input type="text" id="ewaybill_number" autocomplete="off" class="form-control" name="ewaybill" value="<?php if(isset($_POST['ewaybill'])){echo $_POST['ewaybill'];} ?>"> </div>
														                <span class='btn btn-info' onclick="verifyEwayBill()">Verify</span class='btn btn-info'>
														                <span id="verify_status" class="status"></span>
														                <input type="hidden" name="e-verified" id="e-verified" value='false' />


															</div>
															
															
															
																
																
															<?php 
															if($clientType!="Admin"){ 
                                    						$full_name=$_SESSION['user']['full_name'];
                                    						$address=$_SESSION['user']['address'];
                                    						$city=$_SESSION['user']['city'];
                                    						$state=$_SESSION['user']['state'];
                                    						$pincode=$_SESSION['user']['pincode'];
                                    						$phone=$_SESSION['user']['phone'];	} ?>
                                    						
                                    						
                                    						
                <div class="row filter" style="margin: 20px 5px 5px 5px; background: darkcyan; color: white; padding: 10px; border-radius: 5px; cursor: pointer; margin-bottom: 29px;">
                                <b>Volumetric Details </b> <span style="float: right; padding-right: 10px;"></span>
                </div>                    						
                                    						
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Transportation Mode <span style='color:red;'>*</span></label>
																	<div class="col-sm-2">
																		<select class="form-control" name="pincode_mode" id="pincode_mode">
																			<!--<option value='0'>---Select Mode---</option>-->
													
																			<option value='surface'>SURFACE</option>
																			<option value='air'>AIR</option>
																		</select>
																	</div>
																	<!--<label for="" class="col-sm-2 control-label">Business Mode <span style='color:red;'>*</span></label>-->
																	<div class="col-sm-2" hidden>
																		<input type="radio" name='pincode_type' value="b2b" checked>&ensp;B2B
																		<br>
																		<input type="radio" name='pincode_type' value="b2c">&ensp;B2C </div>
																</div>
																
																
																
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Product Description<span></span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="product_description" value="<?php if(isset($_POST['product_description'])){echo $_POST['product_description'];} ?>"> </div>
																</div>
																
																
																
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Quantity </label>
																	<div class="col-sm-6">
																		<input type="number" step='any' autocomplete="off" class="form-control" name="quantity" id="quantity" value="0"> </div>
																</div>
																
																
												
												
								<div>
                                <div class="form-group">
												<label for="" class="col-sm-2 control-label">Volumetrix Weight </label>
												<div class="col-sm-10">
												   
										            
										            <!-- Volumetric Calculation Table Start Here-->
                                                        <table id="customers">
                                                          <tr>
                                                            <th>Length</th>
                                                            <th>Width</th>
                                                            <th>Height</th>
                                                            <th>No of Box</th>
                                                            <th>Act WT</th>
                                                            <th>Charged WT</th>
                                                            <th><center><span id="add_new_volumentary" class="btn btn-warning btn-sm"><i class="fa fa-plus-circle"></i></span></center></th>
                                                          </tr>
                                                          <tbody id="table_body_codition">
                                                              <tr class="remove_calculation">
                                                                <td><input type="text" placeholder="Length" name="length[]" id="length" class="form-control length" value="0" onkeypress="return isNumberKey(this, event);" ></td>
                                                                <td><input type="text" placeholder="Width" name="width[]" id="width" class="form-control width" value="0" onkeypress="return isNumberKey(this, event);"></td>
                                                                <td><input type="text" placeholder="Height" name="height[]" id="height" class="form-control height" value="0" onkeypress="return isNumberKey(this, event);"></td>
                                                                <td><input type="text" placeholder="No Of Box" name="no_of_box[]" id="no_of_box" class="form-control no_of_box" value="0" onkeypress="return isNumberKey(this, event);"></td>
                                                                <td><input type="text" placeholder="Actual Weight" name="actual_weight[]" id="actual_weight" class="form-control actual_weight" value="0" onkeypress="return isNumberKey(this, event);"></td>
                                                                <td>
                                                                    <input type="text" placeholder="Charged Weight" name="charged_weight[]" id="charged_weight" class="form-control charged_weight" value="0" onkeypress="return isNumberKey(this, event);">
                                                                    <input type="hidden" placeholder="Charged Weight" name="final_total_charges[]" id="final_total_charges" class="form-control final_total_charges" value="0" onkeypress="return isNumberKey(this, event);">
                                                                </td>
                                                                <td>&nbsp;</td>
                                                              </tr>
                                                         </tbody>
                                                        </table>
										            
										            <!-- Volumetric Calculation Table Start Here-->
										        
													</div>
											</div>  
                            </div>
																
																
																
																
															
												
												
												
												
												
												
																
																
																
																
																
																
																
																
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Total No.Of Boxes <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="number" step='any' autocomplete="off" class="form-control" name="boxes" id="boxes" value="<?php if(isset($_POST['boxes'])){echo $_POST['boxes'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="boxes_txt"> </span> </div>
																</div>
																
																
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Actual Weight (Kg)</label>
																	<div class="col-sm-2">
																		<input type="number" step=any autocomplete="off" class="form-control" name="a_weight" id="a_weight" value="<?php if(isset($_POST['a_weight'])){echo $_POST['a_weight'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="weight_txt"> </span> </div>
																</div>
																
																
									
																
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Charged Weight (Kg)</label>
																	<div class="col-sm-2">
																		<input type="number" step=any autocomplete="off" class="form-control" name="c_weight" id="c_weight" value="<?php if(isset($_POST['c_weight'])){echo $_POST['c_weight'];} ?>"> </div>
																</div>
																
																
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Remark </label>
																	<div class="col-sm-6">
																		<textarea class="form-control" name="remak" id="remak" style="height:100px;">
																		</textarea>
																	</div>
															</div>
																
																
																
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Taxable Value <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="number" step='any' autocomplete="off" class="form-control" onkeyup="cal_gst()" name="taxable_value" id="taxable_value" value="<?php if(isset($_POST['taxable_value'])){echo $_POST['taxable_value'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="taxable_value_txt"> </span> </div>
																</div>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">MRP </label>
																	<div class="col-sm-6">
																		<input type="number" step='any' autocomplete="off" class="form-control" name="mrp" value="<?php if(isset($_POST['mrp'])){echo $_POST['mrp'];} ?>"> </div>
																</div>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label optional">HSN Code</label>
																	<div class="col-sm-6">
																		<input type="hidden" class="form-control" style="padding: 6px;height: 35px;" id="hsn_code" name="hsn_code" value="<?php if(isset($_POST['hsn_code'])){echo $_POST['hsn_code'];} ?>">
																		<input type="text" class="form-control" style="padding: 6px;height: 35px;" id="txt_hsncode" autocomplete="off" placeholder="Search HSN Code">
																		<input type="hidden" id="igst" name="igst">
																		<input type="hidden" id="cgst" name="cgst">
																		<input type="hidden" id="sgst" name="sgst"> </div>
																	<div class="col-sm-4"><span id="hsn_code_txt"> </span>&emsp;<span id="ncheckhsn"> </span>  </div>
																	
																</div>
																<ul id="searchResult"></ul>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Discount (if any)<span></span></label>
																	<div class="col-sm-6">
																		<input type="number" step='any' autocomplete="off" class="form-control" name="discount" value="<?php if(isset($_POST['discount'])){echo $_POST['discount'];} ?>"> </div>
																</div>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Gst Type <span style='color:red;'>*</span></label>
																	<div class="col-sm-2">
																		<select name="gst_rate" onchange="cal_gst()" class="form-control" id="gst_rate">
																			<!--<option value="none">Select Type</option>-->
																			<option value="gr_cgst">CGST/SGST</option>
																			<option value="gr_igst">IGST</option>
																			<!--<option value="gr_cgst">CGST/SGST</option>-->
																		</select>
																	</div>
																	<div class="col-sm-4"> <span id="gst_rate_txt"> </span> </div>
																</div>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Gst Amount </label>
																	<div class="col-sm-6">
																		<input type="number" step=any autocomplete="off" class="form-control" name="gst_amount" id="gst_amount" value="<?php if(isset($_POST['gst_amount'])){echo $_POST['gst_amount'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="gst_amount_txt"> </span> </div>
																</div>
																<div class="form-group" hidden>
																	<label for="" class="col-sm-2 control-label">Total Invoice Value </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="invoice_value" id="invoice_value" value="<?php if(isset($_POST['invoice_value'])){echo $_POST['invoice_value'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="invoice_value_txt"> </span> </div>
																</div>
																
																
																
																
				<div class="row filter" style="margin: 20px 5px 5px 5px; background: darkcyan; color: white; padding: 10px; border-radius: 5px; cursor: pointer; margin-bottom: 29px;">
                                <b style="font-size: 16px;">RTO Details</b> 
                            <span style="float: right; padding-right: 10px;">
                                <select class="form-control" id="same_as_rto">
                                    <option value="1">Same As Consignor Details</option><!--
                                    <option value="2">Same As Consignee Details</option>-->
                                    <option value="3">Same As Pickup Points details</option>
                                </select>
                            </span>
                </div>
                
                
                
                
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO Name </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="rto_name" id="rto_name" value="<?php if(isset($full_name)){ echo $full_name; } ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO Address </label>
																	<div class="col-sm-6">
																		<textarea class="form-control" name="rto_address" id="rto_address" style="height:100px;">
																			<?php if(isset($address)){ echo $address;} ?>
																		</textarea>
																	</div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO City </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="rto_city" id="rto_city" value="<?php if(isset($city)){echo $city;} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO State </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="rto_state" id="rto_state" value="<?php if(isset($state)){echo $state;} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO Pincode </label>
																	<div class="col-sm-6">
																		<input type="number" autocomplete="off" class="form-control" name="rto_pincode" id="rto_pincode" value="<?php if(isset($pincode)){echo $pincode;} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">RTO Phone </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="rto_phone" id="rto_phone" value="<?php if(isset($phone)){echo $phone;} ?>"> </div>
																</div>
																
																	<div class="alert alert-success alert-dismissible fade in" id="status_success" style="display:none;"> 
																	<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Success!</strong> Pick Entry Added ! &emsp;&emsp;&emsp; 
																	<a href="#" id='btn_awb' class="btn btn-md btn-primary" >Print AWB Number</a> 
																<!--	<a href="#" id='btn_label' class="btn btn-md btn-primary">Print Label</a> 
																	<a href="#" id='btn_label_address' class="btn btn-md btn-warning">Print Label With Address</a>--> </div>
										                           	<div class="alert alert-danger alert-dismissible fade in" id="status_failure" style="display:none;"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Failed!</strong> Please Check the Form ! </div>
											
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label"></label>
																	<div class="col-sm-6">
																		<button type="submit" id='form_submit' class="btn btn-success pull-left" name="form1"><span id='submit_txt'>Submit</span><i id='submit_spin'></i></button>
																		<button type="reset" id='form_reset' class="btn btn-primary pull-right">Reset <i class="fa fa-spin fa-recycle" style="color:white" aria-hidden="true"></i></button>
																	</div>
																</div>
																
																
							</div>
							
							
							
							
							
									                       	</div>
								                    	</div>
							                    	</form>
		                                    	</div>
	    </div>
	</section>
	
	
	
	
	<script src="js/validatePickupAdd.js"></script>
	
	
	
<script>
$(document).ready(function() {
    get_branch();
    get_pickup_points();
    get_courier();
    
    $('#pickup_points').select2();
    
    $("#branch_id").change(function() {
	    get_client();
	    get_new_client();
    });
    
    $("#shipper_pincode").keyup(function() {
	    pincode_base_details();
    });
    
    $("#consignee_pincode").keyup(function() {
	    consignee_pincode_base_details();
    });
    
    $("#get_client").change(function() {
	    get_customer();
    });
    $("#new_client").change(function() {
	    get_client();
    });
     $("#client_id").change(function() {
	    get_customer();
	    get_client_volumetric();
	    calculate_volu();
    });
    $("#new_client").change(function() {
	    get_client_volumetric();
    });
    
    
    
});




function get_branch(){
    $('#branch_id').empty();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_branch_dropdown', isbooking:1},
         success:function(response){
            $('#branch_id').empty();
            $('#branch_id').append(response);
            get_client();
            get_new_client();
        }
    });
}

function pincode_base_details(){
    var shipper_pincode=$('#shipper_pincode').val();
    console.log(shipper_pincode);
    if(shipper_pincode.length==6){
        $.ajax({
            url: 'apis/get-drop-down-list.php',
            type: 'post',
            dataType: 'json',
            data: {type:'get_pincode_details', shipper_pincode:shipper_pincode},
             success:function(response){
               $('#shipper_city').val(response['data'][0]['city']);
               $('#shipper_state').val(response['data'][0]['state']);
               $('#shipper_location').val(response['data'][0]['location']);
            }
        });
    }
}

function consignee_pincode_base_details(){
    var shipper_pincode=$('#consignee_pincode').val();
    console.log(consignee_pincode);
    if(shipper_pincode.length==6){
        $.ajax({
            url: 'apis/get-drop-down-list.php',
            type: 'post',
            dataType: 'json',
            data: {type:'get_pincode_details', shipper_pincode:shipper_pincode},
             success:function(response){
               $('#consignee_city').val(response['data'][0]['city']);
               $('#consignee_state').val(response['data'][0]['state']);
               $('#consignee_location').val(response['data'][0]['location']);
            }
        });
    }
}

function get_pickup_points(){
    $('#pickup_points').empty();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_pickup_points_dropdown', isbooking:1},
         success:function(response){
            $('#pickup_points').empty();
            $('#pickup_points').append(response);
             // Reinitialize select2 after updating the options
            $('#pickup_points').select2();
            get_client();
        }
    });
}



function get_new_client(){
    $('#new_client').empty();
     
    var branch_id=$('#branch_id').val();
    console.log('New Client Id Change');
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_new_client_dropdown',branch_id:branch_id},
         success:function(response){
            $('#new_client').empty();
            $('#new_client').append(response);
            get_client();
            get_client_volumetric();
        }
    });
}


function get_client(){
    $('#client_id').empty();
     
    var new_client=$('#new_client').val();
    var branch_id=$('#branch_id').val();
    console.log("Get Client Working: Branch ID: "+branch_id);
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_client_dropdown',branch_id:branch_id, isbooking:1,new_client:new_client},
         success:function(response){
            $('#client_id').empty();
            $('#client_id').append(response);
            get_customer();
            calculate_volu();
            fetch_client();
        }
    });
}


function get_client_volumetric(){
    console.log("Ganesan");
    $('#air_cal').val(''); 
    $('#surface_cal').val('');  
    var client_id=$('#new_client').val();
    if(client_id!=''){
            $.ajax({
                    url: 'get-client-details.php',
                    type: 'post',
                    dataType: 'json',
                    data: {type:'get_client',client_id:client_id},
                    success: function (response) {
                        console.log(response);
                         if(response['error']==false){
                                  $('#air_cal').val(response['data'][0]['air_amt']);
                                  $('#surface_cal').val(response['data'][0]['surface_amt']);
                                  calculate_volu();
                        }else{
                             $('#air_cal').val(0);
                             $('#surface_cal').val(0);
                             calculate_volu();
                        }
                    }
                });
    }
}
function get_courier(){
    $('#courier_id').empty();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_courier_dropdown', isbooking:1},
         success:function(response){
            $('#courier_id').empty();
            $('#courier_id').append(response);
        }
    });
}
function get_customer(){
    
   // console.log('Customer Details Fetched Successfully');
    
    $('#customer_id').empty();
    var client_id=$('#client_id').val();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_customer_dropdown',client_id:client_id,isbooking:1},
         success:function(response){
            // console.log('Customer Details Fetched '+response);
            $('#customer_id').empty();
            $('#customer_id').append(response);
        }
    });
}


function fetch_Customer() {
	var customer_id = $('#customer_id').val();
	if (customer_id != 'none') {
		$.ajax({
			type: 'POST',
			url: 'api/get-customer-details.php',
			data: {id: customer_id},
			dataType: 'json',
			success: function(response) {
			 //   console.log(response);
				var len = response.length;
				$('#consignee_name').val(response[0]['full_name']);
				$('#consignee_phone').val(response[0]['phone']);

				$('#consignee_address').val(response[0]['address']);

				$('#consignee_city').val(response[0]['city']);
				$('#consignee_city').trigger('change');

				$('#consignee_state').val(response[0]['state']);

				$('#consignee_pincode').val(response[0]['pincode']);

				$('#consignee_location').val(response[0]['destination_city']);
				
				get_availability();
			}
		});
		
		
	}
}






	$(document).ready(function() {
	    fetch_client();
	    fetch_Customer();
	    get_rto_details();
	    
	    
// 		$('#vw_length').keyup(calculate);
// 		$('#vw_breadth').keyup(calculate);
// 		$('#vw_height').keyup(calculate);
// 		$('#quantity').keyup(calculate);
// 		$('#a_weight').keyup(type);
// 		$('#vw_length').change(calculate);
// 		$('#quantity').change(calculate);
// 		$('#vw_breadth').change(calculate);
// 		$('#vw_height').change(calculate);
// 		$('#a_weight').change(type);


		$("#txt_hsncode").keyup(function() {
			get_hsncode();
		});
		$("#txt_hsncode").change(function() {
			check_hsncode();
		});
		
	/*	$("#same_as_rto").change(function() {
		    
		    var same_as_rto = $('#same_as_rto').val();
		    
		    if(same_as_rto ==1){
		        
		        
		    }
		    
		    
		    
		    
		    
		
		});*/
		
		
		
		 $("#same_as_rto").change(function() {
        	    get_rto_details();
            });
    
		
		function get_rto_details(){
		    
		     $('#rto_name').val('');
		        $('#rto_phone').val('');
		        $('#rto_address').val('');
		        $('#rto_city').val('');
		        $('#rto_state').val('');
		        $('#rto_pincode').val('');
		    
		    //console.log('RTO Details Fetched Successfully');
		    
		    var same_as_rto = $('#same_as_rto').val();
		    
		    var shipper_name = $('#shipper_name').val();
		    var shipper_phone = $('#shipper_phone').val(); 
		    var shipper_address = $('#shipper_address').val();
		    var shipper_city = $('#shipper_city').val();
		    var shipper_state = $('#shipper_state').val();
		    var shipper_pincode = $('#shipper_pincode').val();
		    
            var consignee_name = $('#consignee_name').val();
		    var consignee_phone = $('#consignee_phone').val();
		    var consignee_address = $('#consignee_address').val();
		    var consignee_city = $('#consignee_city').val();
		    var consignee_state = $('#consignee_state').val();
		    var consignee_pincode = $('#consignee_pincode').val();		
		    //  console.log(same_as_rto);
		    
		    if(same_as_rto==1){
		        
		        $('#rto_name').val(shipper_name);
		        $('#rto_phone').val(shipper_phone);
		        $('#rto_address').val(shipper_address);
		        $('#rto_city').val(shipper_city);
		        $('#rto_state').val(shipper_state);
		        $('#rto_pincode').val(shipper_pincode);
		       // console.log(shipper_name);
		    }else if(same_as_rto==2){
		        
		        $('#rto_name').val(consignee_name);
		        $('#rto_phone').val(consignee_phone);
		        $('#rto_address').val(consignee_address);
		        $('#rto_city').val(consignee_city);
		        $('#rto_state').val(consignee_state);
		        $('#rto_pincode').val(consignee_pincode);
		        
		    }
		    else{
		        
		        var pickup_points = $('#pickup_points').val();
		        if(pickup_points==''){
		            alert('Please Select First Pickup Point');
		                $('#rto_name').val('');
        		        $('#rto_phone').val('');
        		        $('#rto_address').val('');
        		        $('#rto_city').val('');
        		        $('#rto_state').val('');
        		        $('#rto_pincode').val('');
		        }else{
		            
		             var shipper_pincode = $('#shipper_pincode').val();
		             var consignee_name = $('#pickup_points option:selected').attr('data-name');
		             var consignee_phone = $('#pickup_points option:selected').attr('data-mobileno');
		             var consignee_address = $('#pickup_points option:selected').attr('data-address');
		             var consignee_city = $('#pickup_points option:selected').attr('data-city');
		             var consignee_state = $('#pickup_points option:selected').attr('data-state');
		             var consignee_pincode = $('#pickup_points option:selected').attr('data-pincode');
		             
		            $('#rto_name').val(consignee_name);
    		        $('#rto_phone').val(consignee_phone);
    		        $('#rto_address').val(consignee_address);
    		        $('#rto_city').val(consignee_city);
    		        $('#rto_state').val(consignee_state);
    		        $('#rto_pincode').val(consignee_pincode);
		            
		        }
		    }
		    
		    
		    
		    
		    
		    
		}
		
// 		/***********    For fetching customer address and phone number ***********/


		$('#order_type').on('change', function() {
			var type = $(this).val();
			if(type == 'prepaid') {
				$('#collectable_amount').val('0');
				$('#collectable').hide();
			} else {
				$('#collectable_amount').val('');
				$('#collectable').show();
			}
		});
		
		$('input[type=radio][name=pincode_type]').change(function() {
            get_availability()
        });
        $('#pincode_mode').on('change', function() {
			get_availability();
		});
		
		/***********    For fetching gst number ***********/
		$('#client_id').on('change', function() {
			fetch_client();
		});
		$('#customer_id').on('change', function() {
			fetch_Customer();
			get_availability();
		});
		
		
		
		/***********    For Generationg CSCS AWB ***********/
		$('#autoGen').on('change', function() {
			var autoGen_id=$(this).val();
			$('#cscs_awb_txt').text('');
			if(autoGen_id==2){
			$('#cscsAwbDiv').show();
			}
			else
			{
			    $('#cscsAwbDiv').hide();
			    $('#cscs_awb').val('');
			}
		});
		
		/***********    For checking Unique CSCS AWB number ***********/
		$("#cscs_awb").keyup(function() {
			checkCscsAwb();
		});
		
		setInterval(function(){
		    checkCscsAwb();
		    }, 3000);
		/***********    For checking Unique 3PL AWB number ***********/
		$("#3pl_awb").keyup(function() {
			check_3pl();
		});
		/***********    For checking Unique REF Number ***********/
		$("#ref_no").keyup(function() {
			check_ref();
		});
		
/*	Old Ganeshan form Submit Ajax Starts Here	*/

    // Prevent form submission when Enter key is pressed inside input fields
    $('form').on('keydown', 'input,textarea', function(e) {
        if (e.which == 13) {
            e.preventDefault();  // Prevent the form from being submitted on Enter key press
        }
    });


$('#form_submit').on('click', function(e) {
            e.preventDefault();
			$("#form_submit").prop('disabled', true);
			
			
			var validate = 1;var validate1 = 1;
			
			/*stephen starts*/
            var everified = $('#e-verified').val();
            var ewaybill_number = $('#ewaybill_number').val();
            
            
            if (ewaybill_number != '' && everified != 'true') {
                var validate = 0;
                var validate1 = 0;
                alert('Eway Bill not valid');
            }
			
			validate = formValidate();
			validate1 = formValidate_updated();
			//	alert(validate);
			if(validate && validate1) {
				$('#form_submit').removeClass('btn-danger');
				$('#form_submit').addClass('btn-success');
				$('#submit_txt').text('Wait');
			$.ajax({
					type: 'POST',
					url: 'pk_add_ajax.php',
					data: $("form").serialize(),
					beforeSend: function() {
						// setting a timeout
						$('#submit_spin').addClass('fa fa-spinner fa-spin');
					},
					dataType: 'json',
					success: function(response) {
						console.log(response);
						var res_text = response[0]['txt'];
						
						if(response[0]['error'] == '1') {
							var awb_num = response[0]['awb_number'];
							var p_id = response[0]['p_id'];
							$('#status_success').show();
							$('#status_failure').hide();
							$("#btn_awb").attr('href', 'awb_number_print.php?list_id=' + p_id);
							$("#btn_label").attr('href', 'sls-shipment-invoice-label.php?list_id=' + p_id);
						/*	$("#btn_label_address").attr('href', 'lable-print-with-address.php?list_id=' + p_id);*/
							$('#form_submit').removeClass('btn-danger');
							$('#form_submit').addClass('btn-success');
							$('#submit_txt').text(res_text);
							$("#submit_spin").removeClass("fa fa-spinner fa-spin");
						} else {
							$('#status_success').hide();
							$('#status_failure').show();
							$("#form_submit").prop('disabled', false);
							$('#form_submit').removeClass('btn-success');
							$('#form_submit').addClass('btn-danger');
							$('#submit_txt').text(res_text);
							$("#submit_spin").removeClass("fa fa-spinner fa-spin");
						}
					}
				});
				
			} else {
				$('#status_success').hide();
				$('#status_failure').show();
				$("#form_submit").prop('disabled', false);
				window.scrollTo(0, 0);
				$('#form_submit').removeClass('btn-success');
				$('#form_submit').addClass('btn-danger');
				$('#submit_txt').text('Failed');
			}
		});
		$('#form_reset').on('click', function(e) {
			$("#form_submit").prop('disabled', false);
			$('#status_success').hide();
			$('#status_failure').hide();
		});


		
	/*	$('#form_submit').on('click', function(e) {
			e.preventDefault();
			$("#form_submit").prop('disabled', true);
			var validate = 1;
			validate = formValidate();
// 			alert(validate);
			if(validate) {
				$('#form_submit').removeClass('btn-danger');
				$('#form_submit').addClass('btn-success');
				$('#submit_txt').text('Wait');
				$.ajax({
					type: 'POST',
					url: 'pk_add_ajax.php',
					data: $("form").serialize(),
					beforeSend: function() {
						// setting a timeout
						$('#submit_spin').addClass('fa fa-spinner fa-spin');
					},
					dataType: 'json',
					success: function(response) {
					   // console.log(response);
						var res_text = response[0]['txt'];
						if(response[0]['error'] == '0') {
							$('#form_submit').removeClass('btn-danger');
							$('#form_submit').addClass('btn-success');
							$('#submit_txt').text(res_text);
							$("#submit_spin").removeClass("fa fa-spinner fa-spin");
						} else {
						    $("#form_submit").prop('disabled', false);
							$('#form_submit').removeClass('btn-success');
							$('#form_submit').addClass('btn-danger');
							$('#submit_txt').text(res_text);
							$("#submit_spin").removeClass("fa fa-spinner fa-spin");
						}
					}
				});
			} else {
			    $("#form_submit").prop('disabled', false);
				window.scrollTo(0, 0);
				$('#form_submit').removeClass('btn-success');
				$('#form_submit').addClass('btn-danger');
				$('#submit_txt').text('Please Fill Required Inputs');
			}
		});
		$('#form_reset').on('click', function(e) {
			    $("#form_submit").prop('disabled', false);
			});
			*/
			
/*	Old Ganeshan form Submit Ajax Ends Here	*/

	});
	
	function formValidate_updated() {
	var valid = 1;
	if ($('#client_id').val() == 'none') {
		$('#client_id_txt').text('Please select the Client');
		$('#client_id_txt').css('color', 'red');
		valid=0;
	} else {
		$('#client_id_txt').text('');
	}
	if ($('#customer_id').val() == 'none') {
		$('#customer_id_txt').text('Please select the Customer');
		$('#customer_id_txt').css('color', 'red');
		valid=0;
	} else {
		$('#customer_id_txt').text('');
	}
	if ($('#awb_value').val() == 'no') {
		$('#awb_txt').text('Please Enter Valid AWB Number');
		$('#awb_txt').css('color', 'red');
		valid=0;
	} else {
		$('#awb_txt').text('');
	}
	if ($('#pics').val() == '' || $('#pics').val()==0) {
		$('#awb_txt').text('Please Enter Number Of Box...');
		$('#awb_txt').css('color', 'red');
		valid=0;
	} else {
		$('#awb_txt').text('');
	}
	
	return valid;
}	
	
	
	
	</script>
	<?php }else{ ?>
<center><h4 style="color:red;">You don't have permission to add pickup entry add </h4></center>
<?php } ?>
	<?php require_once('footer.php'); ?>
	
	
	
	
<script>

$('#collectable_amount').on('input', function() {
    var collectable_amount = $('#collectable_amount').val();
    //console.log('Taxable Value Calculate '+taxable_value);
    $('#taxable_value').val(collectable_amount);
    gst_by_ganesan();
});


<?php
$cal_function = "   var tr = $(this).closest('tr');
            
            var entry_source = $('#pincode_mode').val();
            
            
            var surface_cal =$('#surface_cal').val()|| 4500;
            var air_cal = $('#air_cal').val()|| 5500;
            
            
           
        var length = tr.find('.length').val() || 0;
        var width = tr.find('.width').val() || 0;
        var height = tr.find('.height').val() || 0;
        var no_of_box = tr.find('.no_of_box').val() || 0;
        var actual_weight = tr.find('.actual_weight').val() || 0;
        
        if(entry_source == 'air'){
          var tot_lhw  = length*width*height*no_of_box;
          var charged_weight =   tot_lhw/air_cal || 0;
          
          if(actual_weight >charged_weight){
              
              var final_charged_weight  = actual_weight;
          }else{
              var final_charged_weight =   tot_lhw/air_cal;
          }
          tr.find('.charged_weight').val(charged_weight.toFixed(2));
          tr.find('.final_total_charges').val(final_charged_weight);
          
        }else{
          var tot_lhw  = length*width*height*no_of_box;
          var charged_weight =   tot_lhw/surface_cal;
          
          if(actual_weight >charged_weight){
              
              var final_charged_weight  = actual_weight;
          }else{
              var final_charged_weight =   tot_lhw/surface_cal;
          }
          
          tr.find('.charged_weight').val(charged_weight.toFixed(2));
          tr.find('.final_total_charges').val(final_charged_weight);
        }";
?>

$(document).on('click', '.remove_product', function() {
        $(this).closest('.remove_calculation').remove();
        final_calculation();
    });
  
    
$('#add_new_volumentary').on('click', function() {
    html = ` <tr class="remove_calculation">
                <td><input type="text" placeholder="Length" name="length[]" id="length" class="form-control length" value="0" onkeypress="return isNumberKey(this, event);" ></td>
                <td><input type="text" placeholder="Width" name="width[]" id="width" class="form-control width" value="0" onkeypress="return isNumberKey(this, event);"></td>
                <td><input type="text" placeholder="Height" name="height[]" id="height" class="form-control height" value="0" onkeypress="return isNumberKey(this, event);"></td>
                <td><input type="text" placeholder="No Of Box" name="no_of_box[]" id="no_of_box" class="form-control no_of_box" value="0" onkeypress="return isNumberKey(this, event);"></td>
                <td><input type="text" placeholder="Actual Weight" name="actual_weight[]" id="actual_weight" class="form-control actual_weight" value="0" onkeypress="return isNumberKey(this, event);"></td>
                <td>
                  <input type="text" placeholder="Charged Weight" name="charged_weight[]" id="charged_weight" class="form-control charged_weight" value="0" onkeypress="return isNumberKey(this, event);">
                  <input type="hidden" placeholder="Charged Weight" name="final_total_charges[]" id="final_total_charges" class="form-control final_total_charges" value="0" onkeypress="return isNumberKey(this, event);">
                </td>
                <td><center><span class="btn btn-danger btn-sm remove_product"><i class="bi bi-trash3"></i></span></center></td>
          </tr>`;
    $('#table_body_codition').append(html);
});
    
    
function calculate_volu(){
   // console.log('Ganesan');
    $('table#customers tbody tr').each(function() {
         <?=$cal_function?>
         final_calculation();
    });
    
}




function final_calculation(){
         var sum = 0;
         var sum1 = 0;
         var sum3 = 0;
            $(".final_total_charges").each(function(){
                sum += +$(this).val();
            });
            $(".actual_weight").each(function(){
                sum1 += +$(this).val();
            });
            $(".no_of_box").each(function(){
                sum3 += +$(this).val();
            });
            
            $("#c_weight").val(sum.toFixed(2));
            $("#a_weight").val(sum1.toFixed(2));
            $("#boxes").val(sum3);

           // console.log("Total: "+sum)
    }
    

 $(document).ready(function(){
     gst_by_ganesan();
        $('table#customers tbody').on('change keyup', 'tr.remove_calculation', function() {
            
            <?=$cal_function?>
            final_calculation();
        });
 });
 
 
 
 function gst_by_ganesan(){
     var hsn='101010';
     $("#txt_hsncode").val(hsn);
	$("#hsn_code").val(hsn);
     $.ajax({
			url: 'getsearch_hsncode.php',
			type: 'post',
			data: {
				search: hsn
			},
			dataType: 'json',
			success: function(response) {
				var len = response.length;
				for (var i = 0; i < len; i++) {
					var id = response[i]['id'];
					var hsncode = response[i]['hsncode'];
					var igst = response[i]['igst'];
					var cgst = response[i]['cgst'];
					var sgst = response[i]['sgst'];

					$("#igst").val(igst);
					$("#cgst").val(cgst);
					$("#sgst").val(sgst);
					check_hsncode();
					cal_gst();
				}
			}
		});
	check_hsncode();
	cal_gst();
 }
 
</script>


<style>
#customers {
  font-family: Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 80%;
}

 #customers th {
  border: 1px solid #ddd;
  padding: 3px;
}

#customers tr:nth-child(even){background-color: #f2f2f2;}

#customers tr:hover {background-color: #ddd;}

#customers th {
  /*padding-top: 12px;
  padding-bottom: 12px;*/
  text-align: center;
  background-color: #232384;
  color: white;
}
</style>
<script>
function verifyEwayBill() {
    var ewaybill = $('#ewaybill_number').val().trim();
    var verified = false;
    $('#e-verified').val(verified);
    

    if (ewaybill === '') {
        $('#verify_status').html('Please enter a number').removeClass().addClass('status not-verified');
        return;
    }

    $.ajax({
        url: 'apis/ewbn-check.php',
        type: 'POST',
        dataType: 'json',
        data: { ewaybill_number: ewaybill },
        success: function(response) {
            if (response.status === 'success') {  
                verified = true;
                $('#e-verified').val(verified);
                $('#verify_status').html('✅ Verified').removeClass().addClass('status verified');
            } else {
                        verified = false;
                $('#e-verified').val(verified);
                $('#verify_status').html('❌ Not Found').removeClass().addClass('status not-verified');
            }
        },
        error: function() {
                                    verified = false;
                $('#e-verified').val(verified);
            $('#verify_status').html('Error checking').removeClass().addClass('status not-verified');
        }
    });
}
</script>