<?php require_once('header.php'); ?>
<?php
if(isset($_POST['form1'])) {
   // var_dump($_POST);
	$valid = 1;
    if(!empty($_POST['3pl_awb']))
    {
        if($_POST['3pl_awb']!=$_POST['3pl_awb_old'])
        {
        $statement = $pdo->prepare("UPDATE tbl_awb set status=1 WHERE awb_code=?");
		$statement->execute(array($_POST['3pl_awb']));
        }
    }

    if($valid==1)
    {
        date_default_timezone_set('Asia/Kolkata');
        $date = date('Y/m/d h:i:s a', time());
		$statement = $pdo->prepare("UPDATE pickup_entry set courier_id=?,client_id=?,cscs_awb=?,3pl_awb=?,ref_no=?,order_type=?,collectable_amount=?,shipper_name=?,shipper_address=?,shipper_city=?,shipper_state=?,shipper_pincode=?,shipper_phone=?,consignee_name=?,consignee_address=?,consignee_city=?,consignee_state=?,consignee_pincode=?,consignee_phone=?,product_description=?,quantity=?,invoice_value=?,taxable_value=?,hsn_code=?,discount=?,gst_amount=?,mrp=?,ewaybill=?,rto_name=?,rto_address=?,rto_city=?,rto_state=?,rto_pincode=?,rto_phone=?,a_weight=?,vw_length=?,vw_breadth=?,vw_height=?,v_weight=?,c_weight=?,gst_rate=?,buyer_gst=?,seller_gst=?,date_added=?,business_mode=?,business_type=? WHERE id=? ");
		$statement->execute(array($_POST['courier_id'],$_POST['client_id'],$_POST['cscs_awb'],$_POST['3pl_awb'],$_POST['ref_no'],$_POST['order_type'],$_POST['collectable_amount'],$_POST['shipper_name'],$_POST['shipper_address'],$_POST['shipper_city'],$_POST['shipper_state'],$_POST['shipper_pincode'],$_POST['shipper_phone'],$_POST['consignee_name'],$_POST['consignee_address'],$_POST['consignee_city'],$_POST['consignee_state'],$_POST['consignee_pincode'],$_POST['consignee_phone'],$_POST['product_description'],$_POST['quantity'],$_POST['invoice_value'],$_POST['taxable_value'],$_POST['hsn_code'],$_POST['discount'],$_POST['gst_amount'],$_POST['mrp'],$_POST['ewaybill'],$_POST['rto_name'],$_POST['rto_address'],$_POST['rto_city'],$_POST['rto_state'],$_POST['rto_pincode'],$_POST['rto_phone'],$_POST['a_weight'],$_POST['vw_length'],$_POST['vw_breadth'],$_POST['vw_height'],$_POST['v_weight'],$_POST['c_weight'],$_POST['gst_rate'],$_POST['buyer_gst'],$_POST['seller_gst'],$_POST['date_added'],$_POST['business_mode'],$_POST['business_type'],$_REQUEST['id']));
	
			
		$success_message = 'Pickup Entry is updated successfully!';

		unset($_POST['client_id']);
		unset($_POST['cscs_awb']);
		unset($_POST['3pl_awb']);
		unset($_POST['ref_no']);
		unset($_POST['order_type']);
		unset($_POST['collectable_amount']);
		unset($_POST['shipper_name']);
		unset($_POST['shipper_address']);
		unset($_POST['shipper_city']);
		unset($_POST['shipper_state']);
		unset($_POST['shipper_pincode']);
		unset($_POST['shipper_phone']);
		unset($_POST['consignee_name']);
		unset($_POST['consignee_address']);
		unset($_POST['consignee_city']);
		unset($_POST['consignee_state']);
		unset($_POST['consignee_pincode']);
		unset($_POST['consignee_phone']);
		unset($_POST['product_description']);
		unset($_POST['quantity']);
		unset($_POST['invoice_value']);
		unset($_POST['taxable_value']);
		unset($_POST['hsn_code']);
		unset($_POST['discount']);
		unset($_POST['gst_amount']);
		unset($_POST['mrp']);
		unset($_POST['ewaybill']);
		unset($_POST['rto_name']);
		unset($_POST['rto_address']);
		unset($_POST['rto_city']);
		unset($_POST['rto_state']);
		unset($_POST['rto_pincode']);
		unset($_POST['rto_phone']);
		unset($_POST['a_weight']);
		unset($_POST['vw_length']);
		unset($_POST['vw_breadth']);
		unset($_POST['vw_height']);
		unset($_POST['v_weight']);
		unset($_POST['c_weight']);
		unset($_POST['gst_rate']);
		unset($_POST['buyer_gst']);
		unset($_POST['seller_gst']);
		unset($_POST['business_type']);
		unset($_POST['business_mode']);
	
    }
	
}
?>
<?php if(1){ ?>
<br><br><br><br><center><h2 style="color:red;">Pickup Entry Edit Under Construction</h2></center><br><br><br><br>

<?php }else{  ?>
<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" 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>*</span></label>
							<div class="col-sm-6">
							    <select name="client_id" id="client_id" class="form-control">
							       <?php if($clientType=="Admin"){ ?>
							        <option>--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>
							<?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"){ ?>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">CSCS AWB <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" readonly class="form-control" name="cscs_awb" value="<?php if(isset($res['cscs_awb'])){echo $res['cscs_awb'];} ?>">
							</div>
						</div>
							<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'];}?>">
							
							</div>
							<div class="col-sm-4">
							    <span id="ncheck1"> </span>
							</div>
						</div>
							<div class="form-group" style="display:none;" id='old_3pl_div'>
							<label for="" class="col-sm-2 control-label">Old 3PL AWB </label>
							<div class="col-sm-6" >
								<input type="text" autocomplete="off" readonly class="form-control" id="3pl_awb_old" name="3pl_awb_old" value="<?php if(isset($res['3pl_awb'])){echo $res['3pl_awb'];}?>">
							</div>
						</div>
						<?php } ?>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Ref No </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'];} ?>">
							</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 <span>*</span></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 <span>*</span></label>
							<div class="col-sm-3">
								<input type="text" 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">Business Mode </label>
							<div class="col-sm-2">
							    <select class="form-control" name="business_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>
							<div class="col-sm-2">
							   <input type="radio" name='business_type' value="b2b" <?php if($res['business_type']=='b2b'){ echo 'checked'; } ?>>&ensp;B2B<br>
							   <input type="radio" name='business_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>*</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>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Shipper Address <span>*</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>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Shipper City <span>*</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>
					
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Shipper State <span>*</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>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Shipper Pincode <span>*</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>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Shipper Phone <span>*</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>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Consignee Name <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="consignee_name" value="<?php if(isset($res['consignee_name'])){echo $res['consignee_name'];} ?>">
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Consignee Address <span>*</span></label>
							<div class="col-sm-6">
								<textarea class="form-control" name="consignee_address"  style="height:100px;"><?php if(isset($res['consignee_address'])){echo $res['consignee_address'];} ?></textarea>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Consignee City <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="consignee_city" value="<?php if(isset($res['consignee_city'])){echo $res['consignee_city'];} ?>">
							</div>
						</div>
					
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Consignee State <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="consignee_state" value="<?php if(isset($res['consignee_state'])){echo $res['consignee_state'];} ?>">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Consignee Pincode <span>*</span></label>
							<div class="col-sm-3">
								<input type="number" 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>
								<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>*</span></label>
							<div class="col-sm-6">
								<input type="number" autocomplete="off" class="form-control" name="consignee_phone" value="<?php if(isset($res['consignee_phone'])){echo $res['consignee_phone'];} ?>">
							</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 <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" 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">Actual Weight <span>*</span></label>
							<div class="col-sm-2">
								<input type="number" autocomplete="off" class="form-control" name="a_weight" id="a_weight" value="<?php if(isset($res['a_weight'])){echo $res['a_weight'];} ?>">
							</div>
						</div>
						<div class="row">
						    <div class="col-md-12">
						        	<div class="form-group">
							<label for="" class="col-sm-2 control-label">Volumetric Weight <span>*</span></label>
							<div class="col-sm-2">
								<input type="text" 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" 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" 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" 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 <span>*</span></label>
							<div class="col-sm-2">
								<input type="number" 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>*</span></label>
							<div class="col-sm-6">
								<input type="text" 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>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">MRP <span>*</span></label>
							<div class="col-sm-6">
								<input type="number" 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>*</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'];} ?>" required>
                                <input type="text" class="form-control" style="padding: 6px;height: 35px;"  id="txt_hsncode" 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>
						
                        <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="text" 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>*</span></label>
							<div class="col-sm-2">
							    <select name="gst_rate" onchange="cal_gst()" class="form-control" id="gst_rate">
    						     <option value="">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>
						
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Gst Amount <span>*</span></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>
					    <div class="form-group">
							<label for="" class="col-sm-2 control-label">Invoice Value <span>*</span></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>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Ewaybill <span>*</span></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">Update</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</section>
<?php } ?>
<?php }} ?>
<script>
 $(document).ready(function(){
    $("#txt_hsncode").keyup(function(){
        var search = $(this).val();
        if(search != ""){
            $.ajax({
                url: 'getsearch_hsncode.php',
                type: 'post',
                data: {search:search},
                dataType: 'json',
                success:function(response){
                    var len = response.length;
                    $("#searchResult").empty();
                    for( var i = 0; i<len; i++){
                        var id = response[i]['id'];
                        var hsncode = response[i]['hsncode'];
                        $("#searchResult").append("<li value='"+hsncode+"'>"+hsncode+"</li>");
                         }                    
                    // binding click event to li
                    $("#searchResult li").bind("click",function(){
                        setText(this);
                    });
                }
            });
        }
    });
});
function setText(element){
    var value = $(element).text();
    var userid = $(element).val();
    $("#txt_hsncode").val(value);
    $("#hsn_code").val(userid);
    $("#searchResult").empty(); 
     
      if(userid != ""){
            $.ajax({
                url: 'getsearch_hsncode.php',
                type: 'post',
                data: {search:userid},
                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);
                    }                    
                }
            });
         }
      }
</script>

<script>
    $(document).ready(function(){
          /***********    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();
             }
         });
        
        
         /***********    For fetching gst number ***********/
         $('#client_id').on('change',function(){
           var client_id=$(this).val();
         //  alert(client_id);
           if(client_id!=''){
                $.ajax({
                  type:'POST',
                  url:'get_client_data.php',
                  data:{id:client_id},
                   dataType: 'json',
                  success:function(response){
                      var len = response.length;
                      $('#shipper_name').val(response[0]['full_name']);
                      $('#rto_name').val(response[0]['full_name']);
                      
                      $('#shipper_address').val(response[0]['address']);
                      $('#rto_address').val(response[0]['address']);
                      
                      $('#shipper_city').val(response[0]['city']);
                      $('#rto_city').val(response[0]['city']);
                      
                      $('#shipper_state').val(response[0]['state']);
                      $('#rto_state').val(response[0]['state']);
                      
                      $('#shipper_phone').val(response[0]['phone']);
                      $('#rto_phone').val(response[0]['phone']);
                      
                      $('#shipper_pincode').val(response[0]['pincode']);
                      $('#rto_pincode').val(response[0]['pincode']);
                      
                  }
               });
           }
       });
       /***********    For checking Unique 3PLAWB number ***********/
          $("#3pl_awb").keyup(function(){
              var awb=$(this).val();
              var courier_id=$('#courier_id').val();
              var awb_old=$('#3pl_awb_old').val();
              $.ajax({
                  type:'POST',
                  url:'get_unique_awb.php',
                  data:{awb:awb,type:'pl3_awb',courier_id:courier_id},
                   dataType: 'json',
                  success:function(response){
                    //   alert(response);
                    //   console.log(response);
                      if(response[0]['error']=='0')
                      {
                         $("#ncheck1").css('color','green'); 
                         $("#ncheck1").text(response[0]['txt']); 
                         $('#old_3pl_div').show();
                      }
                      else
                      {
                          $('#old_3pl_div').hide();
                          $("#ncheck1").css('color','red'); 
                         $("#ncheck1").text(response[0]['txt']); 
                      }
                      if(awb==awb_old)
                      {
                          $('#old_3pl_div').hide();
                         $("#ncheck1").text('');
                      }
                  }
                });
            });
              /***********    For checking Unique 3PLAWB number ***********/
          $("#courier_id").change(function(){
              var awb=$('#3pl_awb').val();
              var courier_id=$('#courier_id').val();
              $.ajax({
                  type:'POST',
                  url:'get_unique_awb.php',
                  data:{awb:awb,type:'pl3_awb',courier_id:courier_id},
                   dataType: 'json',
                  success:function(response){
                      if(response[0]['error']=='0')
                      {
                          $("#ncheck1").css('color','green'); 
                         $("#ncheck1").text(response[0]['txt']); 
                         $('#old_3pl_div').show();
                      }
                      else
                      {
                          $('#old_3pl_div').hide();
                          $("#ncheck1").css('color','red'); 
                         $("#ncheck1").text(response[0]['txt']); 
                      }
                       if(awb==awb_old)
                      {
                          $('#old_3pl_div').hide();
                         $("#ncheck1").text('');
                      }
                  }
                });
            });
             /***********    For checking Unique CSCS AWB number ***********/
          $("#cscs_awb").keyup(function(){
              var awb=$(this).val();
              $.ajax({
                  type:'POST',
                  url:'get_unique_awb.php',
                  data:{awb:awb,type:'cscs_awb'},
                   dataType: 'json',
                  success:function(response){
                      if(response[0]['error']=='0')
                      {
                          $("#ncheck").css('color','green'); 
                         $("#ncheck").text(response[0]['txt']); 
                      }
                      else
                      {
                          $("#ncheck").css('color','red'); 
                         $("#ncheck").text(response[0]['txt']); 
                      }
                  }
                });
            });
            /***********    For checking Unique REF Number ***********/
          $("#ref_no").keyup(function(){
              var awb=$(this).val();
              $.ajax({
                  type:'POST',
                  url:'get_unique_awb.php',
                  data:{awb:awb,type:'ref_no'},
                   dataType: 'json',
                  success:function(response){
                      if(response[0]['error']=='0')
                      {
                          $("#ncheck2").css('color','green'); 
                         $("#ncheck2").text(response[0]['txt']); 
                      }
                      else
                      {
                          $("#ncheck2").css('color','red'); 
                         $("#ncheck2").text(response[0]['txt']); 
                      }
                  }
                });
            });
            
    });         
</script>         
<script>
    $(document).ready(function(){
       $(function() {    // Makes sure the code contained doesn't run until
            $('#gst_rate').change(function(){
                $('.gs_rate').hide();
                $('#' + $(this).val()).show();
            });
            
            $('#buyer_gst').change(function(){
                $('.buy_gst').hide();
                $('#' + $(this).val()).show();
            });
            
            $('#seller_gst').change(function(){
                $('.sell_gst').hide();
                $('#' + $(this).val()).show();
            });
        
        });
        
    });
    
    $(document).ready(function(){
        $('#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);
    });
    function calculate()
    {
        var qty=$('#quantity').val();
        var v_weight=parseFloat(($('#vw_length').val() * $('#vw_breadth').val() * $('#vw_height').val())/(5000*qty));
        v_weight=v_weight.toFixed(3);
        $('#v_weight').val(v_weight);
        type()
    }
    
    function type(){
        var act_weight=$('#a_weight').val();
        var vol_weight=$('#v_weight').val();
        if(Number(act_weight)>Number(vol_weight))
        {
            $('#c_weight').val(act_weight);
        }
        else
        {
           $('#c_weight').val(vol_weight); 
        }
    }
    
    function get_availability()
{
            var pincode_mode=$('#pincode_mode').val();
             var pincode_type=$('input[name="pincode_type"]:checked').val();
             var pincode=$('#consignee_pincode').val();
            var tot_length= $("#consignee_pincode").val().replace(/ /g,'').length;
             if(tot_length>5){
              $.ajax({
                  type:'POST',
                  url:'get_oda_pincode.php',
                  data:{pincode_mode:pincode_mode,pincode_type:pincode_type,pincode:pincode},
                  success:function(response){
                      if(response==1)
                      {    
                          $('#form_submit').prop('disabled', false);
                          $('#availability').css('color', 'green');
                          $('#availability').html('Service Available !');
                      }
                      else if(response==0)
                      {
                           $('#form_submit').prop('disabled', true);
                           $('#availability').css('color', 'red');
                           $('#availability').html('Service Not Available For Your Pincode !');
                         }
                       }
                    });
                  }
                }   

                function cal_gst()
                {   
                     var taxable=$('#taxable_value').val();
                     var gst_type=$('#gst_rate').val();
                     var igst=$('#igst').val();
                     var cgst=$('#cgst').val();
                     var sgst=$('#sgst').val();
                     if(gst_type=='gr_igst')
                     {
                        var gst_amount=(taxable*igst)/100;
                     }
                     else if(gst_type=='gr_cgst')
                     {
                         var gst=parseFloat(cgst)+parseFloat(sgst);
                         var gst_amount=(taxable*gst)/100;
                     }
                     $('#gst_amount').val(gst_amount);
                     var invoice=0;
                     invoice=parseFloat(taxable)+parseFloat(gst_amount);
                     $('#invoice_value').val(invoice);
                }
</script>

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