<?php include "layouts/menu.php"; ?>
<script type="text/javascript">
function zp(n){
return n<10?("0"+n):n;
}
function insertDate(t,format){
var now=new Date();
var DD=zp(now.getDate());
var MM=zp(now.getMonth()+1);
var YYYY=now.getFullYear();
format=format.replace(/DD/,DD);
format=format.replace(/MM/,MM);
format=format.replace(/YYYY/,YYYY);
t.value=format;
}
</script>
<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("44").value;
var y1 = document.getElementById("33").value;
document.getElementById("txt2").value =(x1*1)-(y1*1);
}
</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>

  <!--  page-wrapper -->
         <div class="right_col" role="main"> <br>
      <h5 class="page-header  alert alert-danger">Purchase Vehicle Entry</h5>   
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                             <div class="page-title">
              <div class="title_left">
                <h3>TASK ENTRY</h3>
              </div>

              <div class="title_right">
                <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                  <div class="input-group">
                  
                    <span class="input-group-btn">
                      <button class="btn btn-primary" type="button"><a href="vopurchase.php"><font color="white">VIEW!</font></a></button>
                
                      <button class="btn btn-info" type="button"><a href="opurchase.php"><font color="white">CREATE!</font></a></button>
                    </span>
                  </div>
                </div>
              </div>
            </div> 
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-2">
                                   <?php	$qry=mysqli_query($conn, "select * from opurchase 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" >Serial No</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>
      <input type="text" class="form-control" id="inputPassword3" name="add" value="" placeholder="Eg: Address">
 <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-success has-feedback">
    <label for="inputPassword3" >Broker Phone Number</label>
      <input type="text" class="form-control" id="inputPassword3" name="bpno" 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="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>
	<div class="col-lg-2">
	 <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" >Color</label>
       <input type="text" class="form-control" id="zxcvb" name="color" 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="zxcvb" name="model" 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" >Sizzing No</label>
      <input type="text" class="form-control" id="didn" name="sizzing_no" value="" onkeyup="autocomp()" placeholder="">
	   <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" >Engine No</label>
      <input type="text" class="form-control" id="inputPassword3" name="engine_no" value="" placeholder=" ">
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" > Remarks :</label>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >RC</label>
      <Select type="text" class="form-control" id="inputPassword3" name="rc" value="" placeholder="">
	  
   <option value="YES">Yes </option>
	  <option value="NO">No </option>
	  
	  </select>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >NOC</label>
      <Select type="text" class="form-control" id="did" name="noc" value="" onkeyup="autocomplet()" placeholder="">
	     <option value="YES">Yes </option>
	  <option value="NO">No </option>
	  
	  </select>
  </div>
	
	
	
  </div>
 <div class="col-lg-2">
	  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >TO</label>
      <Select type="text" class="form-control" id="chqamt" name="chqamt" value="">
     <option value="YES">Yes </option>
	  <option value="NO">No </option>
	  
	  </select>
  </div>
  <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Insurance</label>
      <Select type="text" class="form-control" id="inputPassword3" name="insur" value="" placeholder="">
   <option value="YES">Yes </option>
	  <option value="NO">No </option>
	  
	  </select>
  </div>
     <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Total Amount</label>
      <input type="text" class="form-control" id="44" name="totamt"  value="" placeholder="Total Amount" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

   <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Advace Amount</label>
      <input type="text" class="form-control" id="33" name="adv"  value="" onchange="add11()"  placeholder="Advance" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>

    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Balance Amount</label>
      <input type="text" class="form-control" id="1" name="bal"  value="" placeholder="Balance" >
   <span class="glyphicon glyphicon-usd form-control-feedback"></span>
  </div>
   <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Date</label>
      <input type="text" class="form-control" id="2" name="date"  value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    <span class="glyphicon glyphicon-info-sign form-control-feedback"></span>
  </div>
    <div class="form-group has-warning has-feedback">
    <label for="inputPassword3" >Agent Name</label>
      <select type="text" class="form-control" id="inputPassword3" name="aname" value="" placeholder="Agent Name">
    <span class="glyphicon glyphicon-cloud-download form-control-feedback"></span>
	<option>Select</option>
	<?php 
$qry12=mysqli_query($conn, "select * from magent");
	while($row12=mysqli_fetch_array($qry12))
						{ ?> <option><?php echo $row12['name'];?></option>
						<?php } ?> </select>
    </div> 
								
	  
  </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);
							$insert=mysqli_query($conn, "insert into opurchase(`hpl`,`mfin`,`scode`,`vno`,`model`,`vname`,`color`,`name`,`pno`,`add`,`bname`,`totamt`,`bal`,`adv`,`sizzing_no`,`engg_no`,`rc`,`noc`,`to`,`insur`,`date`,`bpno`,`aname`)
								values('$hpl','$mfin','$scode','$vno','$model','$vname','$color','$name','$pno','$add','$bname','$totamt','$bal','$adv','$sizzing_no','$engine_no','$rc','$noc','$chqamt','$insur','$date','$bpno','$aname')");
									if($insert)
								{
								echo "Registered successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
 
 
</div> 
</div>
</div></div>
</div></div></div><?php include "layouts/footer.php"; ?></body></html>
