<?php include "layouts/menu.php"; ?> <div class="right_col" role="main">
          
            <div class="row">
                <div class="col-lg-12">
	    <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post"  enctype="multipart/form-data">
  <div class="col-md-3"> Date Till <input type="date" class="form-control thicker" id="datepicker" name="tdate" value="<?php echo date("Y-m-d"); ?>" placeholder="From Date" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>

   <div class="col-md-3">      <button type="submit" class="btn btn-info" name="s15">Show It</button></div>
              
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  
                  <div class="x_content">
                    <div class="row">
                      <div class="col-sm-12">
                        <div class="card-box table-responsive">
                          
                                        <?php
		
								if(isset($_POST['s15']))
								{
									extract($_POST);
									$fdate = "1970-01-01";
									?>
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Loan Balance
                        </div>
                        <div class="panel-body">
                            <div class="row">
   
                    <?php
						$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && status='Active'");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
					{ 
						?></p>
					 <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">   
					 <thead>
						<tr class="danger" style="color:purple;">
						<th>A/c No</th>
						<th>Name</th>
						<th>Paid Principle</th>
						<th>Received Principle</th>
						<th>Balance Principle</th>
					</tr> </thead> <tbody>
					<?php  $p1 = 0; $p2 = 0; $p3 = 0;
$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && status='Active'");
				$n=mysqli_num_rows($qry);
				while($row=mysqli_fetch_array($qry))
				{
					$x = $row['hpl'];
						if($n==0)
						{
							$x++;
						}
						else
					{
						$sql = "SELECT SUM(pass) FROM user where mfin='$mfin' &&  hpl='$x' && paydate2 between '$fdate' and '$tdate'";
                                    $q = mysqli_query($conn, $sql);
                                    $row666 = mysqli_fetch_array($q);
									$sql1 = "SELECT SUM(dueamt) FROM net where mfin='$mfin' &&  hpl='$x' && paydate2 between '$fdate' and '$tdate'";
                                    $q1 = mysqli_query($conn, $sql1);
                                    $row6666 = mysqli_fetch_array($q1);
									$hh1 = $row['dueamt'];
									$dd1 = $row['duemnt'];
									$aa = $row['hpamount'];
									$bb = $aa - $row666[0] - $row6666[0];
									$ads =  $row666[0] + $row6666[0] ;
?>				<tr>
			
						<td><?php echo $row['hpl'];?></td>
						<td><?php echo $row['name']; ?></td>
						<td><?php echo $aa;?></td>
						<td><?php echo $ads;?></td>
						<td><?php echo $bb;?></td>
					</tr>
					<?php $p1 = $p1 + $aa;
					$p2 = $p2 + $ads; 
					$p3 = $p3 + $bb;
						$x++;}}
					}
				
					?> </tbody>
					<tfoot>
					<tr class="warning">
					<col width="100px">
						<td></td>
						<td><b>Total</b></td>
						<td><?php echo $p1;?></td>
						<td><?php echo $p2;?></td>
						<td><?php echo $p3;?></td>
					</tr></tfoot>
					</table>
								<?php } ?>
</div>
</div></div>
</div></div></div>   <footer>
          <div class="pull-right">
             <a href="https://infossel.com">Infossel Soft Solution</a>
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <script src="vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="vendors/nprogress/nprogress.js"></script>
    <!-- iCheck -->
    <script src="vendors/iCheck/icheck.min.js"></script>
    <!-- Datatables -->
    <script src="vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
    <script src="vendors/jszip/dist/jszip.min.js"></script>
    <script src="vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="vendors/pdfmake/build/vfs_fonts.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="build/js/custom.min.js"></script>

  </body>
</html>