<?php include "layouts/menu.php"; ?>
<script>
	function autocomplet() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#did').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_area.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#country_list_id').show();
				$('#country_list_id').html(data);
			}
		});
	} else {
		$('#country_list_id').hide();
	}
}
function set_item(item) {
	// change input value
	$('#did').val(item);
	// hide proposition list
	$('#country_list_id').hide();
}
	</script>
	 <script>
	function autocomp() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#didn').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_color.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#dname').show();
				$('#dname').html(data);
			}
		});
	} else {
		$('#dname').hide();
	}
}

// set_item : this function will be executed when we select an item
function set_itemm(item) {
	// change input value
	$('#didn').val(item);
	// hide proposition list
	$('#dname').hide();
}
	</script>
 <script>
	function autocomplett() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#zxcvb').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_refreshvname.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#qwertyu').show();
				$('#qwertyu').html(data);
			}
		});
	} else {
		$('#qwertyu').hide();
	}
}
// set_item : this function will be executed when we select an item
function set_itemmm(item) {
	// change input value
	$('#zxcvb').val(item);
	// hide proposition list
	$('#qwertyu').hide();
}
	</script>
 <script>
function add3()
{
var x = document.getElementById("1").value;
var y = document.getElementById("bba").value;
document.getElementById("1").value =(x*1)+(y*1);
}
</script>

 <script>
function add11()
{
var x = document.getElementById("44").value;
var y = document.getElementById("33").value;
document.getElementById("1").value =(x*1)+(y*1);
}
</script>
  <script>
function add()
{
var x = document.getElementById("txt1").value;
var y = document.getElementById("txt2").value;
document.getElementById("tot").value =(x*1)+(y*1);
}
</script>
<script>
function add1()
{
var x1 = document.getElementById("1").value;
var y1 = document.getElementById("2").value;
document.getElementById("txt2").value =(x1*1)*(y1/100);
}
</script>
<script>
function add2()
{
var x1 = document.getElementById("1").value;
var y1 = document.getElementById("3").value;
document.getElementById("txt1").value =parseInt((x1*1)/(y1*1));
}

navigator.geolocation.getCurrentPosition();
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
</script>
<script>
$('body').on('keydown', 'input, select, textarea', function(e) {
    var self = $(this)
      , form = self.parents('form:eq(0)')
      , focusable
      , next
      ;
    if (e.keyCode == 13) {
        focusable = form.find('input,a,select,button,textarea').filter(':visible');
        next = focusable.eq(focusable.index(this)+1);
        if (next.length) {
            next.focus();
        } else {
            form.submit();
        }
        return false;
    }
});
</script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(document).on("keypress", "input", function(e){
        if(e.which == 13){
         event.stopPropagation();
        event.preventDefault();
        $(this).next("input").focus();
        }
    }); </script>
  <!--  page-wrapper -->
         <div class="right_col" role="main">
      <h5 class="page-header  alert alert-danger">New Registration For Auto Due Loan</h5>   
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-2">
                                   <?php	$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin'");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							$rty = 1;
						}
						else
					    {
						while($row=mysqli_fetch_array($qry))
						{
						$sss = $row['hpl'];
						}
						$rtyy = $sss + 1;
						$rty = $rtyy;
						} ?>
						
   <form role="form" name="form1" method="post" action="" enctype="multipart/form-data">
   <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >HPL</label>
      <input type="text" class="form-control" id="inputPassword3" name="hpl" value="<?php echo $rty;?>" placeholder="E.g 1008" required>
<span class="glyphicon glyphicon-user form-control-feedback"></span> 
 </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Name</label>
      <input type="text" class="form-control" id="inputPassword3" name="name" value="" placeholder="Name">
 <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Phone Number</label>
      <input type="text" class="form-control" id="inputPassword3" name="pno" value="" placeholder="Eg: 9876543210">
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
     
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Address</label>
      <textarea class="form-control" rows="3" name="address" value="" placeholder="Address"></textarea>
  <span class="glyphicon glyphicon-home form-control-feedback"></span>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputEmail3" >Vehicle No</label>
      <input type="text" class="form-control" id="inputEmail3" name="vno" value="TN " placeholder="E.g TN 21 S 2676">
  <span class="glyphicon glyphicon-shopping-cart form-control-feedback"></span>
    </div>
 
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Vehicle Name</label>
       <input type="text" class="form-control" id="zxcvb" name="vname" value=""  onkeyup="autocomplett()" placeholder="Vehicle Name">
	    <ul id="qwertyu"></ul>
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>

    </div> 
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Model</label>
      <input type="text" class="form-control" id="inputPassword3" name="model" value="" placeholder="Vehicle Model">
   <span class="glyphicon glyphicon-time form-control-feedback"></span>
  </div>
 <div class="form-group has-success has-feedback">
    <label for="inputEmail3" >Upload Image</label>
    <input type="file" id="exampleInputFile" name="uimg" >
    <p class="help-block">Upload Passport size Photo here.</p>
	<span class="glyphicon glyphicon-cloud-upload form-control-feedback"></span>
  </div> 
    </div>
	<div class="col-lg-2">
	<div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Color</label>
      <input type="text" class="form-control" id="didn" name="color" value="" onkeyup="autocomp()" placeholder="E.g RED">
	   <ul id="dname"></ul>
    <span class="glyphicon glyphicon-tint form-control-feedback"></span>
	</div>
	<div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Office PhoneNo</label>
      <input type="text" class="form-control" id="inputPassword3" name="pnooffice" value="" placeholder="Eg: 9876543210">
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >House Phone No</label>
      <input type="text" class="form-control" id="inputPassword3" name="pnoresi" value="" placeholder="Eg: 9876543210">
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Area</label>
      <input type="text" class="form-control" id="did" name="area" value="" onkeyup="autocomplet()" placeholder="Area">
	   <ul id="country_list_id"></ul>
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Chq Amnt</label>
      <input type="text" class="form-control" id="chqamt" name="chqamt" value="">
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Profession</label>
      <input type="text" class="form-control" id="inputPassword3" name="profession" value="" placeholder="Eg: 9876543210">
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>	
<div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Broker Name</label>
      <select type="text" class="form-control" id="inputPassword3" name="bname" value="" placeholder="Broker Name">
    <span class="glyphicon glyphicon-cloud-download form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mbroker");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
    </div>  
	 <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Dealer Name</label>
      <select type="text" class="form-control" id="inputPassword3" name="dealer" value="" placeholder="Broker Name">
    <span class="glyphicon glyphicon-cloud-download form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mdealer");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
    </div>
 <div class="form-group has-warning has-feedback">
    <label for="inputEmail3" >Upload Image</label>
    <input type="file" id="exampleInputFile" name="imgveh" >
    <p class="help-block">Upload Vehicle Photo here.</p>
	<span class="glyphicon glyphicon-cloud-upload form-control-feedback"></span>
  </div> 	
	
  </div>
 <div class="col-lg-2">
	
     <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >H.P Amount</label>
      <input type="text" class="form-control" id="44" name="totalhpamt"  value="" placeholder="H.P Amount" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

   <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Documentation Charge</label>
      <input type="text" class="form-control" id="33" name="document"  value="" onchange="add11()"  placeholder="Documentation Charge" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

    <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Total H.P Amount</label>
      <input type="text" class="form-control" id="1" name="hpamount"  value="" placeholder="H.P Amount" onChange="add1()">
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
   <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Interest in %</label>
      <input type="text" class="form-control" id="2" name="inter"  value="" placeholder="2" onChange="add1()">
    <span class="glyphicon glyphicon-info-sign form-control-feedback"></span>
  </div>
  
  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" class="control-label">H.P Date</label>
      <input type="text" class="form-control" id="datepicker"  name="hpdate" value="" placeholder="H.P Date" onfocus="insertDate(this,'DD-MM-YYYY')">
 <span class="glyphicon glyphicon-calendar form-control-feedback"></span>
    </div>
	<div class="form-group has-error has-feedback">
    <label for="inputPassword3" class="control-label">Due Date</label>
      <input type="text" class="form-control" id="datepicker"  name="hpdate2" value="" placeholder="H.P Date" onfocus="insertDate(this,'DD-MM-YYYY')">
 <span class="glyphicon glyphicon-calendar form-control-feedback"></span>
    </div>
   <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Due Month</label>
      <input type="text" class="form-control" id="3" name="duemnt" value="" placeholder="Due Month" onchange="add2()";>
  <span class="glyphicon glyphicon-time form-control-feedback"></span>
  </div>
								
	  
  </div>
   <div class="col-lg-2">
  <div class="form-group has-error has-feedback">
    <label for="txt1" >Principle part</label>
      <input type="text" class="form-control" id="txt1"  name="dueamt" value="" placeholder="Due Amount" onChange="add()">
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="txt2" >Interest Part</label>
      <input type="text" class="form-control" id="txt2"  name="interest" value="" placeholder="Interest" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

   <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Total Amount</label>
      <input type="text" class="form-control" id="tot" name="total" value="" placeholder="Total Amount" onClick="add()">
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Default Per Day</label>
      <input type="text" class="form-control" name="defamt" value="" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >IRR %</label>
      <input type="text" class="form-control" name="irr" value="" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Hand Loan</label>
      <input type="text" class="form-control" name="hlamt" value="" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  <div class="form-group has-error has-feedback">
    <label for="inputPassword3" >Hand Loan Remarks</label>
      <input type="text" class="form-control" name="hlreturn" value="" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
   <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Boker Commission</label>
      <input type="text" class="form-control" id="txt3" name="bcommission"  value="" placeholder="Boker Commission" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
  </div>
  
                                <div class="col-lg-2"> 
<div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Remarks</label>
      <textarea class="form-control" rows="1" name="remarks" value="" placeholder=""></textarea>
    <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div> 
<div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Co-Applicant Name</label>
      <input type="text" class="form-control" id="inputPassword3" name="cobname" value="" placeholder="Co-Applicant Name">
 <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
  
		<div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Co-Applicant Phone</label>
      <input type="text" class="form-control" id="inputPassword3" name="cobpno" value="" placeholder="Co-Applicant Phone">
 <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
    <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Co-Applicant Address</label>
      <textarea class="form-control" rows="1" name="co" value="" placeholder=""></textarea>
    <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
  <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Guarantor Name</label>
      <input type="text" class="form-control" id="inputPassword3" name="cobname2" value="" placeholder="Co-Applicant Name">
 <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
  
		<div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Guarantor Phone </label>
      <input type="text" class="form-control" id="inputPassword3" name="cobpno2" value="" placeholder="Co-Applicant Phone">
 <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
    <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Guarantor Address</label>
      <textarea class="form-control" rows="1" name="co2" value="" placeholder=""></textarea>
    <span class="glyphicon glyphicon-user form-control-feedback"></span>
  </div>
	
   
  <input type="hidden" class="form-control" id="lat" name="lat" value="" onclick="getLocation()" placeholder="">
  <input type="hidden" class="form-control" id="lang" name="lang" value="" placeholder="" >
  
<script>
var x = document.getElementById("lat");
var y = document.getElementById("lang");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.watchPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";}
    }
    
function showPosition(position) {
    document.getElementById("lat")="Latitude: " + position.coords.latitude;
	y.innerHTML="Longitude: " + position.coords.longitude;
	
}
</script>

 <div class="form-group has-warning has-feedback">
    <label for="inputEmail3" >Upload Image</label>
    <input type="file" id="exampleInputFile" name="img" >
    <p class="help-block">Upload Co-Applicant Passport size Photo here.</p>
	<span class="glyphicon glyphicon-cloud-upload form-control-feedback"></span>
  </div> 
   </div>
  <div class="col-lg-2">
 
  	    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="gi1" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="g1"  value="" placeholder="Govt ID No" >

    </div>
		    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="gi2" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="g2"  value="" placeholder="Govt ID No" >

    </div>	    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="gi3" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="g3"  value="" placeholder="Govt ID No" >

    </div>
	
    	    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Co-Applicant Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="bi1" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="b1"  value="" placeholder="Govt ID No" >

    </div>
		    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Co-Applicant Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="bi2" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="b2"  value="" placeholder="Govt ID No" >

    </div>	    
	<div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Co-Applicant Govt ID</label>
      <select type="text" class="form-control" id="inputPassword3" name="bi3" value="" placeholder="">
	  
    <span class="glyphicon glyphicon-plane form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from mgovt");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
		<input type="text" class="form-control" id="1" name="b3"  value="" placeholder="Govt ID No" >

    </div>	   

   <input type="hidden" class="form-control" id="balance"  name="nnamef" value="" placeholder=""  onclick="sum()">
  
  </div>

  <div class="col-lg-12">  
  <div class="form-group">
   
      <button type="submit" class="btn btn-success btn-lg btn-block" name="s2">Register</button>

</div>
      <div class="alert alert-success">
	 <?php
							if(isset($_POST['s2']))
							{
								extract($_POST);
								$uimg=$_FILES['uimg']['name'];
								$img=$_FILES['img']['name'];
								$imgveh=$_FILES['imgveh']['name'];
								$insert=mysqli_query($conn, "insert into customerdetails(area,hlamt,hlreturn,hpdate2,cobname2,cobpno2,co2,pnooffice,pnoresi,profession,dealer,chqamt,defamt,irr,remarks,imgveh,mfin,scode,hpl,lat,lang,uimg,vno,model,vname,color,hpamount,inter,hpdate,duemnt,dueamt,interest,total,name,pno,address,cobname,cobpno,co,img,bname,bcommission,document,totalhpamt,g1,g2,g3,gi1,gi2,gi3,b1,b2,b3,bi1,bi2,bi3,nname)
								values('$area','$hlamt','$hlreturn','$hpdate2','$cobname2','$cobpno2','$co2','$pnooffice','$pnoresi','$profession','$dealer','$chqamt','$defamt','$irr','$remarks','$imgveh','$mfin','$scode','$hpl','$lat','$lang','$uimg','$vno','$model','$vname','$color','$hpamount','$inter','$hpdate','$duemnt','$dueamt','$interest','$total','$name','$pno','$address','$cobname','$cobpno','$co','$img','$bname','$bcommission','$document','$totalhpamt','$g1','$g2','$g3','$gi1','$gi2','$gi3','$b1','$b2','$b3','$bi1','$bi2','$bi3','$nnamef')");
									if($insert)
								{
								echo "<script>alert('Register successfully');window.location.href='register1.php'</script><br>";
						//header("location:register1.php");
									$move=move_uploaded_file($_FILES['uimg']['tmp_name'],"user/".$uimg);
									$move1=move_uploaded_file($_FILES['img']['tmp_name'],"user/".$img);
						$move11=move_uploaded_file($_FILES['imgveh']['tmp_name'],"user/".$imgveh);
									if($move&&$move1)
									{
										echo "  Image Upload";
									}
									else
									{
										echo "Image Upload failure";
									}
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
 
 
</div> 
</div>
</div></div>
</div></div></div><?php include "layouts/footer.php"; ?></body></html>
