<?php require_once('header.php'); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<section class="content-header">
		<div class="content-header-left">
			<h1>Add Pickup Entry</h1> </div>
		<div class="content-header-right"> <a href="view-pickup-entry.php?status=1" 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; ?>
								<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 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 echo $rows['company_name']; ?>
																</option>
																<?php } ?>
														</select>
													</div>
												</div>
												<?php }else{ ?>
												<input type="hidden" name="courier_id" value="7">
													<?php }if($clientType=="Admin"){ ?>
													
														<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>
														<?php } ?>
															<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($_POST['ref_no'])){echo $_POST['ref_no'];} ?>"> </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>
																	</select>
																</div>
															</div>
															<input type="hidden" name='location' id='location'>
															<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($_POST['collectable_amount'])){echo $_POST['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' selected>AIR</option>
																			<option value='surface'>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" 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">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($full_name)){ echo $full_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($address)){ echo $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($city)){ echo $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($state)){echo $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($pincode)){echo $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($phone)){echo $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($_POST['consignee_name'])){echo $_POST['consignee_name'];} ?>"> </div>
																	<div class="col-sm-4"> <span id="consignee_name_txt"> </span> </div>
																</div>
																<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($_POST['consignee_address'])){echo $_POST['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($_POST['consignee_city'])){echo $_POST['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 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($_POST['consignee_state'])){echo $_POST['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"> </div>
																		<input type="hidden" name='service' id='service' value="no">
																	<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($_POST['consignee_phone'])){echo $_POST['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($_POST['product_description'])){echo $_POST['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 echo date("Y-m-d") ?>"> </div>
																</div>
																<!--***************************************************************-->
																<div class="row">
																	   <center><div class="col-sm-8">
																	   ***************************************************************<br><p style="color: red;font-size: 20px;">Add Multiple Item Details
																				<a id="add_variation"><label for="" class="btn btn-success pull-right">ADD &ensp;<i class="fa fa-plus" aria-hidden="true"></i></label></a></p>
																			</div></center>
																	<div class="col-md-12">
																		<div class="form-group">
																			<div class="col-sm-2">
																				<label for="" class="col-sm-2 control-label">Item </label>
																			</div>
																			<div class="col-sm-2">
																				<label for="" class="col-sm-2 control-label">HSN Code </label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">GST Type </label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">Gst %</label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">Qty </label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">MRP</label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">Rate</label>
																			</div>
																				<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">GST</label>
																			</div>
																			<div class="col-sm-1">
																				<label for="" class="col-sm-2 control-label">Sub Total </label>
																			</div>
																			
																		</div>
																	</div>
																		<!-------------------------------------->
																		<div class="col-md-12">
																			<div class="form-group">
																			<div class="col-sm-2">
																				<input type="text" autocomplete="off" class="form-control" placeholder="Item Description" name="item_description[]" id="item_description0 " value="">
																			</div>
																		<div class="col-sm-2">
																		<input type="hidden" class="form-control" style="padding: 6px;height: 35px;" id="hsn_code0" 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_hsncode0" onkeyup="get_hsncode(0)" autocomplete="off" placeholder="Search HSN Code">
																		<input type="hidden" id="igst0" name="igst">
																		<input type="hidden" id="cgst0" name="cgst">
																		<input type="hidden" id="sgst0" name="sgst">
																		<div class="col-sm-2"> <span id="hsn_code_txt0"> </span>
																		</div>
																     	
																     	</div>
																     				<ul id="searchResult0"></ul>
																			<div class="col-sm-1">
																				<select class="form-control" name="item_gst[]" id="item_gst0">
																			    <option value="none">Select Type</option>
    																			<option value="gr_igst">IGST</option>
    																			<option value="gr_cgst">CGST/SGST</option>
																			    </select>
																			</div>
																			<div class="col-sm-1">
																				<input type="number" autocomplete="off" placeholder="18%" readonly class="form-control" name="item_gst_per[]" id="item_gst_per0" value="">
																			</div>
																			<div class="col-sm-1">
																				<input type="number" autocomplete="off" placeholder="Qty" class="form-control" name="item_qty[]" id="item_qty0" value="">
																			</div>
																			<div class="col-sm-1">
																				<input type="number" autocomplete="off" placeholder="MRP" class="form-control" name="item_mrp[]" id="item_mrp0" value="">
																			</div>
																			<div class="col-sm-1">
																				<input type="number" autocomplete="off" placeholder="Rate" class="form-control" name="item_rate[]" id="item_rate0" value="">
																			</div>
																			<div class="col-sm-1">
																				<input type="number" autocomplete="off" placeholder="GST" class="form-control" name="item_gst_amount[]" id="item_gst_amount0" value="">
																			</div>
																			<div class="col-sm-1">
																			    <input type="number" autocomplete="off" placeholder="Sub Total" class="form-control" name="item_subtotal[]" id="item_subtotal0" value="">
																			</div>
																		</div>
															        </div>
															        <div id="variations">  </div>
															<!------------------------------------------->
																</div>
															<!--***************************************************************-->
															<!--***************************************************************-->
																<div class="row">
																	<div class="col-md-12">
																	   <center><p style="color: red;font-size: 20px;">Total Details</p></center> 
																		<div class="form-group">
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">Total Qty</label>
																			</div>
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">No.Of Boxes </label>
																			</div>
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">Total Invoice Value </label>
																			</div>
																		</div>
																		<!-------------------------------------->
                                                                            <div class="form-group">
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">35</label>
																			</div>
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">6 </label>
																			</div>
																			<div class="col-sm-4">
																				<label for="" class="col-sm-6 control-label">Rs.245,500</label>
																			</div>
																		</div>
																		<!------------------------------------------->
																		</div>
																		<center>***************************************************************</center>
																</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($_POST['quantity'])){echo $_POST['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($_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 </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="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"  autocomplete="off" class="form-control" name="v_weight" id="v_weight" value="<?php if(isset($_POST['v_weight'])){echo $_POST['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($_POST['vw_length'])){echo $_POST['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($_POST['vw_breadth'])){echo $_POST['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($_POST['vw_height'])){echo $_POST['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($_POST['c_weight'])){echo $_POST['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($_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">-->
																<!--	<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">-->
																<!--	<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($_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> </div>-->
																<!--</div>-->
																<!--<ul id="searchResult0"></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($_POST['discount'])){echo $_POST['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">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">
																	<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">
																	<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="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($_POST['ewaybill'])){echo $_POST['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($_POST['buyer_gst'])){echo $_POST['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($_POST['seller_gst'])){echo $_POST['seller_gst'];} ?>"> </div>
																</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="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>
							                    	</form>
		                                    	</div>
	                                       	</div>
	                    </section>
	<script src="js/validateMultiplePickupAdd.js"></script>
	<script>
	$(document).ready(function() {
	    fetch_client();
	    var k=1;
	    $('#add_variation').on('click', function() {
        html = '<div class="col-md-12"><div class="form-group"><div class="col-sm-3"><input type="text" autocomplete="off" class="form-control" placeholder="Item Description" name="item_description[]" id="item_description'+k+'" value=""></div>' +
            '<div class="col-sm-2"><select class="form-control" name="item_hsn_code[]" id="item_hsn_code"><option>12345</option><option>2345</option></select></div>' +
            '<div class="col-sm-1"><select class="form-control" name="item_gst[]" id="item_gst"><option value="gr_igst">IGST</option><option value="gr_cgst">CGST</option></select></div>' +
            '<div class="col-sm-1"><input type="number" autocomplete="off" placeholder="18%" readonly class="form-control" name="item_gst_per[]" id="item_gst_per" value=""></div>' +
            '<div class="col-sm-1"><input type="number" autocomplete="off" placeholder="Qty" class="form-control" name="item_qty[]" id="" value="item_qty"></div>' +
            '<div class="col-sm-1"><input type="number" autocomplete="off" placeholder="MRP" class="form-control" name="item_mrp[]" id="item_mrp" value=""></div>' +
            '<div class="col-sm-1"><input type="number" autocomplete="off" placeholder="Rate" class="form-control" name="item_rate[]" id="item_rate" value=""></div>' +
            '<div class="col-sm-1"><input type="number" autocomplete="off" placeholder="Sub Total" class="form-control" name="item_subtotal[]" id="item_subtotal" value=""></div>' +
            '<div class="col-md-1" style="display: grid;"><a class="remove_variation text-danger" title="Remove variation of product" style="cursor: pointer;"><i class="fa fa-times fa-2x"></i></a></div>' +
            '</div></div>';
        $('#variations').append(html);
    });
    
    $(document).on('click', '.remove_variation', function() {
        $(this).closest('.col-md-12').remove();
    });
	    
// 		$('#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 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();
		});
		$('#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);
			});
	});
	</script>
	<?php require_once('footer.php'); ?>