<?php include "layouts/menu.php"; ?> <div class="right_col" role="main">
  <script>
function add()
{
var a = document.getElementById("n2000").value;
var b = document.getElementById("n500").value;
var bb = document.getElementById("n200").value;
var c = document.getElementById("n100").value;
var d = document.getElementById("n50").value;
var e = document.getElementById("n10").value;
var f = document.getElementById("coins").value;
document.getElementById("tot").value =(a*2000)+(b*500)+(bb*200)+(c*100)+(d*50)+(e*10)+(f*1);
}
</script>   
   <div class="row">
          
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        
                        <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">BALANCE SHEET </div>
    <form class="form-horizontal" method="post" action="" enctype="multipart/form-data">
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Area</label>
    <div class="col-sm-4">
    <div class="form-group has-success has-feedback">
    <label for="inputPassword3" >Area</label>
      <select style="text-transform:uppercase" type="text" class="form-control" id="didd" name="area" value="" placeholder="Area">
<option></option>
<?php $sql11 = mysqli_query($conn, "select * from msarea order by name asc");
while($row11 = mysqli_fetch_array($sql11)) { ?>
<option><?php echo $row11['name']; ?></option>
<?php } ?>
</select>
 <span class="glyphicon glyphicon-phone-alt form-control-feedback"></span>
  </div>
    </div>
  </div>

			<div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s15">Total</button>
    </div>
  </div>
  
    <div class="alert alert-success">
  <b><p style="color:#1928CF;margin:10px;">
    <input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;"><div id="mydiv">
<?php
								if(isset($_POST['s15']))
								{
									extract($_POST); ?>
   <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">                            <thead>
                             <tr class="alert alert-info">
				        	<th style="width:7%">S.No</th>
					        <th style="width:10%">Group</th>
						    <th style="width:15%">Total Loan Amount</th>
							<th style="width:10%">Paid</th>
					    	<th> Balance</th> </tr> 
							
<?php $i = 0; $tot1 = 0; $tot2 = 0; $tot3 =0;  $i++; $mpay =0; $mpay2 =0; $tot =0; $hpa =0;
 
	$sql1 = mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && area='$area'");
									$row5 = mysqli_fetch_array($sql1);
									$hpa = $row5[0];
		$sql1 = mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && area='$area'");
									while($row55 = mysqli_fetch_array($sql1)) {	
$hpl = $row55['hpl'];									
										$sql1 = mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' &&  hpl='$hpl'");
									$row5 = mysqli_fetch_array($sql1);
									$mpay = $mpay + $row5[0];
									
									} 
										$sql12 = mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && area='$area'");
									while($row552 = mysqli_fetch_array($sql12)) {	
$hpl = $row552['hpl'];									
										$sql122 = mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' &&  hpl='$hpl'");
									$row5222 = mysqli_fetch_array($sql122);
									$mpay2 = $mpay2 + $row522[0];
									
									} 
									$fff = $mpay + $mpay2;
									$tot = $hpa - $mpay - $mpay2;
									$tot1 = $tot1 + $hpa;
									$tot2 = $tot2 + $mpay + $mpay2;
									$tot3 = $tot3 + $tot;
?>
							<tr>
				        	<td> <?php echo $i; ?></td> 
							<td> <?php echo $area; ?></td> 
							<td> <?php echo $hpa; ?> </td> 
							<td> <?php echo $fff; ?> </td> 
					   <td> <?php echo $tot; ?> </td> </tr>
							


<tr>
				        	<td> </td> 
							<td>TOTAL</td> 
							<td> <?php echo $tot1; ?> </td> 
							<td> <?php echo $tot2; ?> </td> 
					   <td> <?php echo $tot3; ?> </td> </tr>
						
								</table> <?php } ?>
</div>
 	
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
 
 
</div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?></body></html>