<?php include "layouts/menu.php";
include_once("init.php");
?>
<!-- <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> -->
<link rel="stylesheet" href="css/style.css">
        <link rel="stylesheet" href="js/date_pic/date_input.css">
        <link rel="stylesheet" href="lib/auto/css/jquery.autocomplete.css">
	
	<!-- Optimize for mobile devices -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
	
	<!-- jQuery & JS files -->
	<?php include_once("tpl/common_js.php"); ?>
	<script src="js/script.js"></script>  
        <script src="js/date_pic/jquery.date_input.js"></script>  
        <script src="lib/auto/js/jquery.autocomplete.js "></script>  
 
		<script>
	/*$.validator.setDefaults({
		submitHandler: function() { alert("submitted!"); }
	});*/
	$(document).ready(function() {
		$("#txtCountry").autocomplete("category.php", {
		width: 160,
		autoFill: true,
		selectFirst: true
	});
		
		// validate signup form on keyup and submit
		$("#form1").validate({
			rules: {
				name: {
					required: true,
					minlength: 1,
					maxlength: 200
				},
				stockid: {
					required: true,
					minlength: 1,
					maxlength: 200
				},
				cost: {
					required: true,
					
				},
				sell: {
					required: true,
					
				}
			},
			messages: {
				name: {
					required: "Please Enter Stock Name",
					minlength: "Category Name must consist of at least 3 characters"
				},
				stockid: {
					required: "Please Enter Stock ID",
					minlength: "Category Name must consist of at least 3 characters"
				},
				sell: {
					required: "Please Enter Selling Price",
					minlength: "Category Name must consist of at least 3 characters"
				},
				cost: {
					required: "Please Enter Cost Price",
					minlength: "Category Name must consist of at least 3 characters"
				}
			}
		});
	
	});
function numbersonly(e){
        var unicode=e.charCode? e.charCode : e.keyCode
        if (unicode!=8 && unicode!=46 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=9){ //if the key isn't the backspace key (which we should allow)
        if (unicode<48||unicode>57)
        return false
    }
    }
	</script>

<div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h4 class="page-header">Hand Loan Payment</h4>
                </div>
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
  
   <form name="form1" class="form-horizontal" method="post" action="hloan.php" enctype="multipart/form-data">
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Date</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="datepicker" name="date" value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')" required>
    </div>
  </div>
  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Agent</label>
    <div class="col-sm-4">
      <select type="text" class="form-control" id="inputPassword3" name="agent" value="" placeholder="" required>
	  <option></option>
	  <?php $sql = mysqli_query($conn, "select * from customer");
	  while($row5 = mysqli_fetch_array($sql)) { ?>
		    <option><?php echo $row5['name']; ?></option>		  
<?php	  } ?> </select>
    </div>
	&nbsp;&nbsp;&nbsp;&nbsp; <button type="submit" class="btn btn-default" name="s1">Save This</button>
  </div>
  
  <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">
				<thead>
  <tr><th>Hpl</th>
						<th>Name</th>
					<th>Model</th>
						<th>Regis No</th>
						<th>Amount</th>
						<th>Type</th>
						<th>Prom Date</th>
						<th>Remark</th>
					</tr> </thead>
					
					   <tbody>
<?php for($i=1;$i<=15;$i++) { ?>
					     <tr>
<td><input type="text" class="form-control" id="aaa" name="hpl<?php echo $i; ?>" value="" placeholder="" ></td>
<td><input type="text" class="form-control" id="name<?php echo $i; ?>" name="name<?php echo $i; ?>" value="" placeholder="" ></td>
<td><input type="text" class="form-control" id="model<?php echo $i; ?>" name="model<?php echo $i; ?>" value="" placeholder="" ></td>
<td><input type="text" class="form-control" id="vno<?php echo $i; ?>" name="vno<?php echo $i; ?>" value="" placeholder="" ></td>
<td><input type="text" class="form-control" id="amt<?php echo $i; ?>" name="amt<?php echo $i; ?>" value="" placeholder="" ></td>
<td>
<select type="text" class="form-control" id="type<?php echo $i; ?>" name="type<?php echo $i; ?>" value="" placeholder="" >
<option>Select </option>
<option>Not Paid</option>
<option>Post Pond</option>
<option>Received</option>
<option>Seized</option>
<option>Spare Veh</option>
<option>Theft Veh</option>

</select>

<td><input type="text" class="form-control" id="pdate<?php echo $i; ?>" name="pdate<?php echo $i; ?>" value="" placeholder="" ></td>
</td>
	
	<td><input type="text" class="form-control" id="remark<?php echo $i; ?>" name="remark<?php echo $i; ?>" value="" placeholder="" ></td>					
</tr>  <?php } ?>
					</tbody></table>
 
      <div class="alert alert-success">
	 <?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
 for($i=1;$i<=15;$i++) { 

	if($i == 1) {
	$hpl = $hpl1;
	$name = $name1;
	$model = $model1;
	$vno = $vno1;
	$amt = $amt1;
	$pdate = $pdate1;
	$type = $type1; 
		$remark = $remark1; 
	}
	
	if($i == 2) {
	$hpl = $hpl2;
	$name = $name2;
	$model = $model2;
	$vno = $vno2;
	$amt = $amt2;
	$pdate = $pdate2;
	$type = $type2;
	$remark = $remark2; 
	}
	
	if($i == 3) {
	$hpl = $hpl3;
	$name = $name3;
	$model = $model3;
	$vno = $vno3;
	$amt = $amt3;
	$pdate = $pdate3;
	$type = $type3;
	$remark = $remark3; 
	}
	
	if($i == 4) {
	$hpl = $hpl4;
	$name = $name4;
	$model = $model4;
	$vno = $vno4;
	$amt = $amt4;
	$pdate = $pdate4;
	$type = $type4; 
	$remark = $remark4; 
		}
	
	if($i == 5) {
	$hpl = $hpl5;
	$name = $name5;
	$model = $model5;
	$vno = $vno5;
	$amt = $amt5;
	$pdate = $pdate5;
	$type = $type5;
	$remark = $remark5; 
	}
	
	if($i == 6) {
	$hpl = $hpl6;
	$name = $name6;
	$model = $model6;
	$vno = $vno6;
	$amt = $amt6;
	$pdate = $pdate6;
	$type = $type6; 
		$remark = $remark6; 
	}
	
	if($i == 7) {
	$hpl = $hpl7;
	$name = $name7;
	$model = $model7;
	$vno = $vno7;
	$amt = $amt7;
	$pdate = $pdate7;
	$type = $type7;
	$remark = $remark7; 
	}
	
	if($i == 8) {
	$hpl = $hpl8;
	$name = $name8;
	$model = $model8;
	$vno = $vno8;
	$amt = $amt8;
	$pdate = $pdate8;
		$remark = $remark8;  }
	
	if($i == 9) {
	$hpl = $hpl9;
	$name = $name9;
	$model = $model9;
	$vno = $vno9;
	$amt = $amt9;
	$pdate = $pdate9;
	$type = $type9;
	$remark = $remark9; 
	}
	
	if($i == 10) {
	$hpl = $hpl10;
	$name = $name10;
	$model = $model10;
	$vno = $vno10;
	$amt = $amt10;
	$pdate = $pdate10;
	$type = $type10; 
		$remark = $remark10; 
	}
	
	if($i == 11) {
	$hpl = $hpl11;
	$name = $name11;
	$model = $model11;
	$vno = $vno11;
	$amt = $amt11;
	$pdate = $pdate11; 	$remark = $remark11; 
	$type = $type11; }
	
	if($i == 12) {
	$hpl = $hpl12;
	$name = $name12;
	$model = $model12;
	$vno = $vno12;
	$amt = $amt12;
	$pdate = $pdate12; 	$remark = $remark12; 
	$type = $type12; }
	
	if($i == 13) {
	$hpl = $hpl13;
	$name = $name13;
	$model = $model13;
	$vno = $vno13;
	$amt = $amt13;
	$pdate = $pdate13; 	$remark = $remark13; 
	$type = $type13; }
	
	if($i == 14) {
	$hpl = $hpl14;
	$name = $name14;
	$model = $model14;
	$vno = $vno14;
	$amt = $amt14;
	$pdate = $pdate14; 	$remark = $remark14; 
	$type = $type14; }
	
	if($i == 15) {
	$hpl = $hpl15;
	$name = $name15;
	$model = $model15;
	$vno = $vno15;
	$amt = $amt15;
	$pdate = $pdate15; 	$remark = $remark15; 
	$type = $type15; }
	
if($hpl!= NULL) {
$insert=mysqli_query($conn, "insert into otherentry(mfin,scode,date,type,hpl,name,model,vno,model2,vno2,pdate,agent)
values('$mfin','$scode','$date','$type','$hpl','$name','$model','$vno','$model','$vno','$date','$agent')");
 } } 	
								if($insert)
								{
									
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
</div>
     	
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
 
 
</div>
</div></div>
</div></div></div>
 <script  src="dist/js/jquery.ui.draggable.js"></script>
<script src="dist/js/jquery.alerts.js"></script>
<script src="dist/js/jquery.js"></script>
<link rel="stylesheet"  href="dist/js/jquery.alerts.css" >
 <?php // include "layouts/footer.php"; ?></body></html>