<?php require_once('header.php'); ?>
<!--<script src='js/select2.full.min.js' type='text/javascript'></script>-->

<script>
    $(document).ready(function(){
  // Initialize select2
  $("#consignee_city").select2();
  $("#consignee_state").select2();
});
</script>
<section class="content-header">
	<div class="content-header-left">
		<h1>Edit Pickup Entry</h1>
	</div>
	<div class="content-header-right">
		<a href="pending-modicare-pickup-entry.php" class="btn btn-danger btn-sm">View All</a>&emsp;&emsp;
			<a href="pickup-entry-bulk-upload.php" class="btn btn-danger btn-sm">CSCS Bulk Upload</a>
	</div>
</section>


<section class="content">

	<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;
			
			 $statement = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE id=?");
			$statement->execute(array($_REQUEST['id']));
			$result = $statement->fetchAll(PDO::FETCH_ASSOC);
				foreach ($result as $res){
				    
				    if($clientType!="Admin" && $res['status_code']!=1)	 
				    {?>
				        <center style="font-size: 18px;color: red;"><img src="../assets/uploads/logo.png" style="width: 25%;"><br><br>***********Edit Option not Available For After Picked Shipment***********</center>
				    <?php }
				    else
				    {
			?>
			<form class="form-horizontal" action="" method="post" id="add_form" enctype="multipart/form-data">
									<div class="box box-info">
										<div class="box-body">
										    
											<div class="form-group">
												<label for="" class="col-sm-2 control-label">Select Client <span style='color:red;'>*</span></label>
												<div class="col-sm-6">
													<select name="client_id" id="client_id" class="form-control">
														<?php if($clientType=="Admin"){ ?>
															<option value='none'>--Select Client--</option>
															<?php
							        	$statement = $pdo->prepare("SELECT * FROM tbl_user where (role='client' or role='Modicare') and delete_status!=1");
							         }
							         else{
							        	$statement = $pdo->prepare("SELECT * FROM tbl_user where id=$clientId");
							         }
            							$statement->execute();
            							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
            						 foreach($result as $rows)
            						 {?>
														 <option value="<?php echo $rows['id']; ?>" <?php if(isset($res['client_id'])){if($res['client_id']==$rows['id']){ echo 'selected'; } } ?>><?php echo $rows['full_name']; ?></option>
																<?php }
							        ?>
													</select>
												</div>
												<div class="col-sm-4"> <span id="client_id_txt"> </span> </div>
											</div>
											<?php if($clientType=="Admin"){ ?>
												<div class="form-group">
													<label for="" class="col-sm-2 control-label">Select Courier <span style='color:red;'>*</span></label>
													<div class="col-sm-6">
														<select name="courier_id" id="courier_id" class="form-control">
															<?php 
							       $statement = $pdo->prepare("SELECT * FROM `courier_company`");
        							$statement->execute();
        							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
            						 foreach($result as $rows) { ?>
															<option value="<?php echo $rows['id']; ?>" <?php if(isset($res['courier_id'])){if($res['courier_id']==$rows['id']){ echo 'selected'; } } ?>><?php echo $rows['company_name']; ?></option>
																<?php } ?>
														</select>
													</div>
												</div>
												<?php } ?>
													<?php if($clientType=="Admin"){ ?>
													<input type="hidden" name='location' id='location'>
														<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($res['3pl_awb'])){echo $res['3pl_awb'];}?>"> 
																<input type="hidden" name='pl3_service' id='pl3_service' value="yes">
																</div>
															<div class="col-sm-4"> <span id="ncheck1"> </span> </div>
														</div>
                            								<input type="hidden" id="3pl_awb_old" name="3pl_awb_old" value="<?php if(isset($res['3pl_awb'])){echo $res['3pl_awb'];}?>">
                            							
														<?php } ?>
															<div class="form-group" id="cscsAwbDiv">
																<label for="" class="col-sm-2 control-label">CSCS 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="cscs_awb" value="<?php if(isset($res['cscs_awb'])){echo $res['cscs_awb'];} ?>"> 
																		<input type="hidden"  id="old_cscs_awb" name="old_cscs_awb" value="<?php if(isset($res['cscs_awb'])){echo $res['cscs_awb'];} ?>"> 
																		</div>
															<div class="col-sm-4"><input type="hidden" name='cscs_awb_service' id='cscs_awb_service' value="yes"> <span id="cscs_awb_txt"> </span> </div>
														</div>
															<div class="form-group">
																<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="<?php if(isset($res['ref_no'])){echo $res['ref_no'];} ?>">
																	<input type="hidden"  id="old_ref_no" name="old_ref_no" value="<?php if(isset($res['ref_no'])){echo $res['ref_no'];} ?>">
																	<input type="hidden" name='ref_service' id='ref_service' value="yes">
																	</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" <?php if(isset($res['client_id'])){if($res['order_type']=='cod'){ echo 'selected'; } } ?>>COD</option>
        						                                       <option value="prepaid" <?php if(isset($res['client_id'])){if($res['order_type']=='prepaid'){ echo 'selected'; } } ?>>Prepaid</option>
																	</select>
																</div>
															</div>
															<div class="form-group" id="collectable">
																<label for="" class="col-sm-2 control-label">Collectable Amount </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($res['collectable_amount'])){ echo $res['collectable_amount']; } ?>"> </div>
															</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="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='air' <?php if($res['business_mode']=='air'){ echo 'selected'; } ?>>AIR</option>
							                                               <option value='surface' <?php if($res['business_mode']=='surface'){ echo 'selected'; } ?> >SURFACE</option>
																		</select>
																	</div>
																	<label for="" class="col-sm-2 control-label">Business Mode <span style='color:red;'>*</span></label>
																	<div class="col-sm-2">
																		<input type="radio" name='pincode_type' value="b2b" <?php if($res['business_type']=='b2b'){ echo 'checked'; } ?>>&ensp;B2B<br>
							                                            <input type="radio" name='pincode_type' value="b2c" <?php if($res['business_type']=='b2c'){ echo 'checked'; } ?>>&ensp;B2C
																</div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper Name <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" id="shipper_name" name="shipper_name" value="<?php if(isset($res['shipper_name'])){ echo $res['shipper_name']; } ?>"> </div>
																	<div class="col-sm-4"> <span id="shipper_name_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper Address <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<textarea class="form-control" name="shipper_address" id="shipper_address" style="height:100px;">
																		<?php if(isset($res['shipper_address'])){ echo $res['shipper_address'];} ?>
																		</textarea>
																	</div>
																	<div class="col-sm-4"> <span id="shipper_address_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper City <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="shipper_city" id="shipper_city" value="<?php if(isset($res['shipper_city'])){ echo $res['shipper_city']; } ?>"> </div>
																	<div class="col-sm-4"> <span id="shipper_city_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper State <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="shipper_state" id="shipper_state" value="<?php if(isset($res['shipper_state'])){echo $res['shipper_state'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="shipper_state_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper Pincode <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="number" autocomplete="off" class="form-control" name="shipper_pincode" id="shipper_pincode" value="<?php if(isset($res['shipper_pincode'])){echo $res['shipper_pincode'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="shipper_pincode_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Shipper Phone <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="shipper_phone" id="shipper_phone" value="<?php if(isset($res['shipper_phone'])){echo $res['shipper_phone'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="shipper_phone_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Consignee Name <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" id="consignee_name" name="consignee_name" value="<?php if(isset($res['consignee_name'])){echo $res['consignee_name'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="consignee_name_txt"> </span> </div>
																</div>
																<input type="hidden" name='pickup_id' id='pickup_id' value="<?php if(isset($res['id'])){ echo $res['id']; } ?>">
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Consignee Address <span style='color:red;'>*</span></label>
																	<div class="col-sm-6">
																		<textarea class="form-control" id="consignee_address" name="consignee_address" style="height:100px;">
																			<?php if(isset($res['consignee_address'])){echo $res['consignee_address'];} ?>
																		</textarea>
																	</div>
																	<div class="col-sm-4"> <span id="consignee_address_txt"> </span> </div>
																</div>
																<!--<div class="form-group">-->
																<!--	<label for="" class="col-sm-2 control-label">Consignee City <span style='color:red;'>*</span></label>-->
																<!--	<div class="col-sm-6">-->
																<!--		<input type="text" autocomplete="off" class="form-control" id="consignee_city" name="consignee_city" value="<?php if(isset($res['consignee_city'])){echo $res['consignee_city'];} ?>"> </div>-->
																<!--	<div class="col-sm-4"> <span id="consignee_city_txt"> </span> </div>-->
																<!--</div>-->
																
																	<div class="form-group">
													<label for="" class="col-sm-2 control-label">Consignee City <span style='color:red;'>*</span></label>
													<div class="col-sm-6">
														<select name="consignee_city" id="consignee_city" class="form-control">
														    	<option value="<?php echo $res['consignee_city']; ?>" selected><?php echo $res['consignee_city']; ?></option>
															<?php 
							       $statement = $pdo->prepare("SELECT * FROM `tbl_city` ");
        							$statement->execute();
        							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
            						 foreach($result as $rows) { ?>
																<option value="<?php echo $rows['city']; ?>">
																	<?php echo $rows['city']; ?>
																</option>
																<?php } ?>
														</select>
													</div>
													<div class="col-sm-4"> <span id="consignee_city_txt"> </span> </div>
												</div>
															
															<div class="form-group">
													<label for="" class="col-sm-2 control-label">Consignee State <span style='color:red;'>*</span></label>
													<div class="col-sm-6">
														<select name="consignee_state" id="consignee_state" class="form-control">
														    <option value="<?php echo $res['consignee_state']; ?>" selected><?php echo $res['consignee_state']; ?></option>
															<?php 
							       $statement = $pdo->prepare("SELECT * FROM `tbl_state` ");
        							$statement->execute();
        							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
            						 foreach($result as $rows) { ?>
																<option value="<?php echo $rows['state']; ?>">
																	<?php echo $rows['state']; ?>
																</option>
																<?php } ?>
														</select>
													</div>
													<div class="col-sm-4"> <span id="consignee_state_txt"> </span> </div>
												</div>	
																<!--<div class="form-group">-->
																<!--	<label for="" class="col-sm-2 control-label">Consignee State <span style='color:red;'>*</span></label>-->
																<!--	<div class="col-sm-6">-->
																<!--		<input type="text" autocomplete="off" class="form-control" name="consignee_state" id="consignee_state" value="<?php if(isset($res['consignee_state'])){echo $res['consignee_state'];} ?>"> </div>-->
																<!--	<div class="col-sm-4"> <span id="consignee_state_txt"> </span> </div>-->
																<!--</div>-->
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Consignee Pincode <span style='color:red;'>*</span></label>
																	<div class="col-sm-3">
																		<input type="text" autocomplete="off" class="form-control" onkeyup="get_availability()" id="consignee_pincode" name="consignee_pincode" value="<?php if(isset($res['consignee_pincode'])){echo $res['consignee_pincode'];} ?>"> </div>
																		<input type="hidden" name='service' id='service' value="yes">
																	<div class="col-sm-5"> <span id="availability"></span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Consignee Phone <span style='color:red;'>*</span></label>
    																	<div class="col-sm-6">
    																		<input type="number" autocomplete="off" class="form-control" name="consignee_phone" id="consignee_phone"  value="<?php if(isset($res['consignee_phone'])){echo $res['consignee_phone'];} ?>"> </div>
    																	<div class="col-sm-4"> <span id="consignee_phone_txt"> </span>
    																</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($res['product_description'])){echo $res['product_description'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Pickup Entry Date<span></span></label>
																	<div class="col-sm-6">
																		<input type="date" autocomplete="off" class="form-control" name="date_added"  value="<?php $day=date_create($res['date_added']); echo date_format($day,'Y-m-d'); ?>"> </div>
																</div>
																<div class="form-group">
																	<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="<?php if(isset($res['quantity'])){echo $res['quantity'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">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($res['boxes'])){echo $res['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 </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($res['a_weight'])){echo $res['a_weight'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="weight_txt"> </span> </div>
																</div>
																<div class="row">
																	<div class="col-md-12">
																		<div class="form-group">
																			<label for="" class="col-sm-2 control-label">Volumetric Weight </label>
																			<div class="col-sm-2">
																				<input type="text" readonly autocomplete="off" class="form-control" name="v_weight" id="v_weight" value="<?php if(isset($res['v_weight'])){echo $res['v_weight'];} ?> "> </div>
																			<label for="" class="col-sm-1 control-label">Vol.Length</label>
																			<div class="col-sm-1">
																				<input type="number" step=any autocomplete="off" class="form-control" name="vw_length" id="vw_length" value="<?php if(isset($res['vw_length'])){echo $res['vw_length'];} ?>"> </div>
																			<label for="" class="col-sm-1 control-label">Vol.Breadth</label>
																			<div class="col-sm-1">
																				<input type="number" step=any autocomplete="off" class="form-control" name="vw_breadth" id="vw_breadth" value="<?php if(isset($res['vw_breadth'])){echo $res['vw_breadth'];} ?>"> </div>
																			<label for="" class="col-sm-1 control-label">Vol.Height</label>
																			<div class="col-sm-1">
																				<input type="number" step=any autocomplete="off" class="form-control" name="vw_height" id="vw_height" value="<?php if(isset($res['vw_height'])){echo $res['vw_height'];} ?>"> </div>
																		</div>
																	</div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Charged Weight </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($res['c_weight'])){echo $res['c_weight'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<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($res['taxable_value'])){echo $res['taxable_value'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="taxable_value_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<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($res['mrp'])){echo $res['mrp'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">HSN Code <span style='color:red;'>*</span></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($res['hsn_code'])){echo $res['hsn_code'];} ?>">
																		<input type="text" class="form-control" style="padding: 6px;height: 35px;" id="txt_hsncode" autocomplete="off" placeholder="Search HSN Code" value="<?php if(isset($res['hsn_code'])){echo $res['hsn_code'];} ?>">
																		 <input type="hidden"  id="igst"  name="igst"  value="<?php if(isset($res['igst'])){echo $res['igst'];} ?>">
                                                                            <input type="hidden"  id="cgst"  name="cgst" value="<?php if(isset($res['cgst'])){echo $res['cgst'];} ?>" >
                                                                            <input type="hidden"  id="sgst"  name="sgst" value="<?php if(isset($res['sgst'])){echo $res['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">
																	<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($res['discount'])){echo $res['discount'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<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_igst" <?php if(isset($res['gst_rate'])){if($res['gst_rate']=='gr_igst'){ echo 'selected'; } } ?>>IGST</option>
    						                                              <option value="gr_cgst" <?php if(isset($res['gst_rate'])){if($res['gst_rate']=='gr_cgst'){ echo 'selected'; } } ?>>CGST/SGST</option>
																		</select>
																	</div>
																	<div class="col-sm-4"> <span id="gst_rate_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<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($res['gst_amount'])){echo $res['gst_amount']; }?>"> </div>
																	<div class="col-sm-4"> <span id="gst_amount_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">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($res['invoice_value'])){echo $res['invoice_value'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="invoice_value_txt"> </span> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Ewaybill </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control" name="ewaybill" value="<?php if(isset($res['ewaybill'])){echo $res['ewaybill'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Buyer Gst </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control col-sm-4" name="buyer_gst" value="<?php if(isset($res['buyer_gst'])){echo $res['buyer_gst'];} ?>"> </div>
																</div>
																<div class="form-group">
																	<label for="" class="col-sm-2 control-label">Seller Gst </label>
																	<div class="col-sm-6">
																		<input type="text" autocomplete="off" class="form-control " name="seller_gst" value="<?php if(isset($res['seller_gst'])){echo $res['seller_gst'];} ?>"> </div>
																</div>
																	<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO Name <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="rto_name" id="rto_name" value="<?php if(isset($res['rto_name'])){ echo $res['rto_name']; } ?>">
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO Address <span>*</span></label>
							<div class="col-sm-6">
								<textarea class="form-control" name="rto_address" id="rto_address"  style="height:100px;"><?php if(isset($res['rto_address'])){ echo $res['rto_address'];} ?></textarea>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO City <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="rto_city" id="rto_city" value="<?php if(isset($res['rto_city'])){echo $res['rto_city'];} ?>">
							</div>
						</div>
					
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO State <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="rto_state" id="rto_state" value="<?php if(isset($res['rto_state'])){echo $res['rto_state'];} ?>">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO Pincode <span>*</span></label>
							<div class="col-sm-6">
								<input type="number" autocomplete="off" class="form-control" name="rto_pincode" id="rto_pincode" value="<?php if(isset($res['rto_pincode'])){echo $res['rto_pincode'];} ?>">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">RTO Phone <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="rto_phone" id="rto_phone" value="<?php if(isset($res['rto_phone'])){echo $res['rto_phone'];} ?>">
							</div>
						</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'>Update</span><i id='submit_spin'></i></button>
								<button type="reset" class="btn btn-primary pull-right">Reset Changes <i class="fa fa-spin fa-recycle" style="color:white" aria-hidden="true"></i></button>
							</div>
						</div>
                   	</div>
            	</div>
        	</form>
        </div>
	</div>
</section>
<?php }} ?>
<script src="js/validatePickupEdit.js"></script>
	<script>
	$(document).ready(function() {
	     setTimeout(function () {
                     setText2();
                 }, 3000);
	    
// 		$('#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();
		});
		/***********    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 checking Unique CSCS AWB number ***********/
		$("#cscs_awb").keyup(function() {
			checkCscsAwb();
		});
		
		setInterval(function(){
		  //  console.log('3');
		    checkCscsAwb();
		    }, 3000);
		/***********    For fetching gst number ***********/
		$('#client_id').on('change', function() {
			fetch_client();
		});
		/***********    For checking Unique 3PLAWB number ***********/
		$("#3pl_awb").keyup(function() {
			check_3pl();
		});
		/***********    For checking Unique REF Number ***********/
		$("#ref_no").keyup(function() {
			check_ref();
		});
		$("#txt_hsncode").change(function() {
			check_hsncode();
		});
		
		$('#form_submit').on('click', function(e) {
			e.preventDefault();
			$("#form_submit").prop('disabled', true);
			var validate = 1;
			var pl3_awb1 = $('#3pl_awb').val();
			var awb1 = $('#ref_no').val();
			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_edit_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') {
						    $('#3pl_awb_old').val(pl3_awb1);
						    $('#old_ref_no').val(awb1);
							$("#form_submit").prop('disabled', false);
							$('#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);
			});
	});
	</script>

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