<?php include "layouts/menu.php"; ?>
		<script type="text/javascript">
	  $(function() {
   $("#datepicker").datepicker({ dateFormat: 'dd-mm-yy' });
  });
</script>
<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_refreshdeb.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#country_list_id').show();
				$('#country_list_id').html(data);
			}
		});
	} else {
		$('#country_list_id').hide();
	}
}

// set_item : this function will be executed when we select an item
function set_item(item) {
	// change input value
	$('#did').val(item);
	// hide proposition list
	$('#country_list_id').hide();
}
	</script>

    <script>
  $(function() {
   $("#datepicker1").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker2").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
      <script>
  $(function() {
   $("#datepicker8").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker9").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
   <script>
function add()
{
var x = document.getElementById("txt1").value;
var y = document.getElementById("txt2").value;
document.getElementById("bal").value =(x*1)-(y*1);
}
</script>
     
  <?php include "layouts/menu1.php"; ?>
            <!-- Right side column. Contains the navbar and content of the page -->
           <div class="right_col" role="main">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                       Loan Details
                      
                    </h1>
                   
                </section>
                   <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">Register Loan Details</div>
   <form name="form1" class="form-horizontal" method="post" action="loan.php" enctype="multipart/form-data">
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">From Customer</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="name" value="" placeholder="" required>
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Loan Amount</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="debit" value="" placeholder="Amount in Rs" required>
    </div>
  </div>
  <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">Details</label>
    <div class="col-sm-4">
      <textarea class="form-control" rows="3" name="details" value="" placeholder=""></textarea>
    </div>
  </div>  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s1">Save This</button>
    </div>
  </div>
      <div class="alert alert-success">
	 <?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
								$insert=mysqli_query($conn, "insert into loan(mfin,scode,name,debit,date,details)
											 values('$mfin','$scode','$name','$debit','$date','$details')");
								
								if($insert)
								{
									
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
</div>
 
 
</div>
  		
				 <div class="alert alert-info">Loan Details</div>
  
                    <?php
					
						$qry=mysqli_query($conn, "select * from loan");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
					{ 
						?></p>
					<table class="table table-striped" table class="table" border="0" align="center" cellspacing="0" cellpadding="10" >
					<col width="100px">
						<tr class="danger" style="color:purple;">
						<th>Id</th>
						<th></th>
						<th>Name</th>
						<th></th>
						<th>Amount</th>
						<th></th>
						<th>Date</th>
						<th></th>
						<th>Purpose</th>
						<th></th>
						<th>More Details</th>
					</tr>
					<?php  $rrt = 0;
					while($row=mysqli_fetch_array($qry))
						{
					?>
					<tr class="warning">
					<col width="100px">
					<td><?php echo $row['did'];?></td>
						<td></td>
						<td><?php echo $row['name'];?></td>
						<td></td>
						<td><?php echo $row['debit'];?></td>
						<td></td>
						<td><?php echo $row['date']; ?></td>
						<td></td>
						<td><?php echo $row['details'];?></td>
						<td></td>
						<td><a href="debitdel.php?did=<?php echo $row['did'];?>&details=<?php echo $row['details'];?>">More Info</a></td>
					</tr>
					<?php
					$rr = $row['debit'];
$rrt = $rrt + $rr;					}
					}
				
					?>
					<tr class="warning">
					<col width="100px">
					<td></td><td></td><td><b>Total amount</td><td></td><td><?php echo $rrt; ?></b></td><td></td><td></td><td></td><td></td><td></td><td></td>
					
					</tr>
					</table>	
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->


        <!-- jQuery 2.0.2 -->
       <?php include "layouts/footer.php"; ?>

    </body>
</html>