<?php include "layouts/menu.php"; ?>    
  <!--  page-wrapper -->
         <div class="right_col" role="main">
       
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Business Report
                        </div>
                        <div class="panel-body">
                            <div class="row">
							
				        <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post"  enctype="multipart/form-data">
  <div class="col-md-3">  <input type="date" class="form-control thicker" id="datepicker" name="fdate" value="<?php echo date("Y-m-d"); ?>" placeholder="From Date" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
    <div class="col-md-3">   <input type="date" class="form-control thicker" id="datepicker" name="tdate" value="<?php echo date("Y-m-d"); ?>" placeholder="To 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="card-box table-responsive">
                          
                                        <?php
		
								if(isset($_POST['s15']))
								{
									extract($_POST);
									
									header("location:brep2.php?fdate=$fdate&&tdate=$tdate");
								} ?></div> </form> </div>
								             <div class="row">
    <?php				
			$led=$_REQUEST['led'];			
									$tr1 = 0; $tr2= 0;$tr3 = 0; $tr4= 0;$tr5 = 0; $tr6= 0;$tr7 = 0; $tr8= 0; ?>
									<div class="table-responsive">
  <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">    <thead>
						
	<?php $e=0;  $s=0;  $r=0;  $t=0; $d=0; $d1=0; $i=1; $iii = 0;
	$sqll = mysqli_query($conn, "select * from abc");
	$rowww = mysqli_fetch_array($sqll);
	//$fdate1=$_REQUEST['fdate'];
   // $tdate1=$_REQUEST['tdate'];
									$fdate1 =  $rowww['date1']; 
										$tdate1 =  $rowww['date2']; 
											$fdate =  $rowww['date1']; 
										$tdate = date("Y-m-t", strtotime("$fdate")); ?>						
<tr class="danger" style="color:purple;">
					
						<th colspan="11"><font color="blue" size="3"><b><center>Business Report From <?php echo $fdate1; ?> To <?php echo $tdate1; ?></b></font></center></th>
						
					
						
					</tr>
										<tr class="danger" style="color:purple;">
						<th>-</th><th>Month</th>
						<th colspan="5"><center>Hp Reciept</center></th>
						
						<th colspan="4"><center>HP Ledger</center></th>
						
					</tr>
						<tr class="danger" style="color:purple;">
						<th>ID</th>	<th>&nbsp;&nbsp;&nbsp;</th>
						<th>Principle</th>
						
						<th>Interest</th>
						<th>default</th>
<th>Hand Loan</th>
						<th>Total</th>
						<th>HP</th>
						<th>Loan Amt</th>
						<th>Doc Charge</th>
						<th>Commission Charge</th>
						
					</tr></thead>
									
								<tbody> <?php $mfin55 = 'MAATHOOR FINANCE';
								//$fdate5 =  date("Y-m-d", strtotime("1999-01-01")); 
									 
									//	$fdate5 =  date("Y-m-d", strtotime("2018-03-31")); 
						$obal = 0; 
	$qcre =  0;
$qdeb =  0;
$atot4 = 0; $afine = 0; $aint = 0; $aprin = 0;	 $adocc2 =0; $adocc = 0; $ahpamt = 0; $ahl = 0;
								while(strtotime($fdate)<=strtotime($tdate1)) { $tot4 = 0; $hl = 0; $fine = 0; $int = 0; $prin = 0;	 $docc2 =0; $docc = 0; $hpamt = 0;
					$monthh = date('F, Y', strtotime($fdate));

//Principle
$qry401=mysqli_query($conn, "select sum(pass) from user where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row401 = mysqli_fetch_array($qry401);
$qry402=mysqli_query($conn, "select sum(dueamt) from net where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row402 = mysqli_fetch_array($qry402);
$qry11402=mysqli_query($conn, "select sum(addless) from net where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row11402 = mysqli_fetch_array($qry11402);
$prin = $row401[0] + $row402[0] - $row11402[0];

//interest
$qry4011=mysqli_query($conn, "select sum(rno) from user where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row4011 = mysqli_fetch_array($qry4011);
$qry4021=mysqli_query($conn, "select sum(amt) from net where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row4021 = mysqli_fetch_array($qry4021);
$int = $row4011[0] + $row4021[0];	

//hl
$qryh4011=mysqli_query($conn, "select sum(hloan) from user where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$rowh4011 = mysqli_fetch_array($qryh4011);
$qryh4021=mysqli_query($conn, "select sum(hloan) from net where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$rowh4021 = mysqli_fetch_array($qryh4021);
$hl = $rowh4011[0] + $rowh4021[0];	

//Fine
$qry4012=mysqli_query($conn, "select sum(fine) from user where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row4012 = mysqli_fetch_array($qry4012);
$qry4022=mysqli_query($conn, "select sum(fine) from net where  mfin!='$mfin55' &&  paydate2 between '$fdate' and '$tdate'");
$row4022 = mysqli_fetch_array($qry4022);
$fine = $row4012[0] + $row4022[0];
				$tot4 = $fine + $int + $prin + $hl;
//HP & Loan Amount
$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where  mfin!='$mfin55' && hpdate5 between '$fdate' and '$tdate'");
$row15 = mysqli_fetch_array($qry15);
$qry15888=mysqli_query($conn, "select * from customerdetails where  mfin!='$mfin55' && hpdate5 between '$fdate' and '$tdate'");
$nh = mysqli_num_rows($qry15888);
$hpamt =$row15[0];
//Document
$qry4415=mysqli_query($conn, "select sum(document) from customerdetails where  mfin!='$mfin55' && hpdate5 between '$fdate' and '$tdate'");
$row4415 = mysqli_fetch_array($qry4415);
$docc = $row4415[0];
$qry44151=mysqli_query($conn, "select sum(bcommission) from customerdetails where  mfin!='$mfin55' && hpdate5 between '$fdate' and '$tdate'");
$row44151 = mysqli_fetch_array($qry44151);
$docc2 = $row44151[0];
$atot4 = $atot4 + $tot4; 
$afine = $afine + $fine; 
$aint = $aint + $int; 
$aprin = $aprin + $prin;	
 $adocc2 =$adocc2 + $docc2; 
 $adocc = $adocc + $docc; 
 $ahpamt = $ahpamt + $hpamt;
  $ahl = $ahl + $hl;
			$iii++;	?></p>
						
				<tr><td><?php echo $iii; ?></td>
<td><font size="3"><b><?php echo $monthh; ?></b></font></td>
						<td><?php echo $prin; ?></td>
			
						<td><?php echo $int; ?></td>
						<td><?php echo $fine; ?></td> <td><?php echo $hl; ?></td>
						<td><?php echo $tot4; ?></td>
						<td><?php echo $nh; ?></td>
						<td><?php echo $hpamt; ?></td>
					
						<td><?php echo $docc; ?></td>
						<td><?php echo $docc2; ?></td>
						
					</tr>
		
						<?php 
						$fdate =  date("Y-m-d", strtotime("$fdate + " . 1 . " month"));

						$tdate = date("Y-m-t", strtotime("$fdate"));

						}
						?>
					<tr><td>-</td>
<td><font size="3"><b>Total</b></font></td>
						<td><font size="3"><b><?php echo $aprin; ?></td>
			
						<td><font size="3"><b><?php echo $aint; ?></td>
						<td><font size="3"><b><?php echo $afine; ?></td> <td><?php echo $ahl; ?></td>
						<td><font size="3"><b><?php echo $atot4; ?></td>
						<td><font size="3"><b><?php echo $anh; ?></td>
						<td><font size="3"><b><?php echo $ahpamt; ?></td>
					
						<td><font size="3"><b><?php echo $adocc; ?></font></td>
						<td><font size="3"><b><?php echo $adocc2; ?></font></td>
						
					</tr>
					 
					
					</tbody></table>	</form>
					
</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>
