<?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">
                             Details
                        </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:hpcol2.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;
							$sqll = mysqli_query($conn, "select * from abc where mfin='$mfin'");
	$rowww = mysqli_fetch_array($sqll);
											$fdate1 =  $rowww['date1']; 
										$tdate1 =  $rowww['date2']; 
											$fdate =  date("Y-m-d", strtotime("$fdate1")); 
										$tdate =  date("Y-m-t", strtotime("$fdate")); ?>			
<tr class="danger" style="color:purple;">
						<th colspan="7"><font size="4"><center>Pledge & COLLECTION REPORT From <?php echo $fdate1; ?> To <?php echo $tdate1; ?> </center></font></th>
</tr>
						<tr class="danger" style="color:purple;">
					<th>ID</th>		<th><font size="3">Month</font></th>
						<th><font size="3">Hp Amt</font></th>
				
						<th><font size="3">Prin Received</font></th>
						
						<th><font size="3">Int Received</font></th>
						<th><font size="3">Def Received</font></th>
						<th><font size="3">Tot Received</font></th>
						</tr></thead>
									<tbody>
									<?php
								//$fdate5 =  date("Y-m-d", strtotime("1999-01-01")); 
									 
									//	$fdate5 =  date("Y-m-d", strtotime("2018-03-31")); 
						$obal = 0;
	$qcre =  0;
$qdeb =  0;
				
$quser = 0;
$qnett = 0; $iii = 0;
$qdeff = 0;
$qhpp =0;
$qtot = 0;			//	   $fdate = $fdate;  $tdate = $tdate; 
								while(strtotime($fdate)<=strtotime($tdate1)) { $iii++;
					$monthh = date('F, Y', strtotime($fdate));
//$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin'  && hpdate5 between '$fdate5' and '$tdate5'");
//$row15 = mysqli_fetch_array($qry15);
//$qry45=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin'  &&  paydate2 between '$fdate5' and '$tdate5'");
//$row45 = mysqli_fetch_array($qry45);
//$qry445=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin'  &&  paydate2 between '$fdate5' and '$tdate5'");
//$row445 = mysqli_fetch_array($qry445);
//$qry145=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && par='$led' &&  date between '$fdate5' and '$tdate5'");
//$row145 = mysqli_fetch_array($qry145);
//$qry1455=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && par='$led' &&  date between '$fdate5' and '$tdate5'");
//$row1455 = mysqli_fetch_array($qry1455);						$n=mysqli_num_rows($qry);
//$c1 = $row45[0];	$c2 = $row145[0];  $c3 = $row445[0]; 	$d1 = $row1455[0];	$d2 = $row15[0]; 
//$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin'  && hpdate5 between '$fdate5' and '$tdate5'");
//$row15 = mysqli_fetch_array($qry15);
//$qry45=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin'  &&  paydate2 between '$fdate5' and '$tdate5'");
//$row45 = mysqli_fetch_array($qry45);
//$qry445=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin'  &&  paydate2 between '$fdate5' and '$tdate5'");
//$row445 = mysqli_fetch_array($qry445);
//$c11 = $row45[0];  $c31 = $row445[0]; 		$d21 = $row15[0]; 
	//	$obal = $c1 + $c2 - $d1 - $d2 + $c3 + $c11 - $d21;

$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin'  && hpdate5 between '$fdate' and '$tdate'");
$row15 = mysqli_fetch_array($qry15);
$qry4415=mysqli_query($conn, "select sum(document) from customerdetails where mfin='$mfin'  && hpdate5 between '$fdate' and '$tdate'");
$row4415 = mysqli_fetch_array($qry4415);
$qry45=mysqli_query($conn, "select sum(pass) from user where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row45 = mysqli_fetch_array($qry45);
$qry452=mysqli_query($conn, "select sum(rno) from user where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row452 = mysqli_fetch_array($qry452);
$qry445=mysqli_query($conn, "select sum(dueamt) from net where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row445 = mysqli_fetch_array($qry445);
$qry4451=mysqli_query($conn, "select sum(amt) from net where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row4451 = mysqli_fetch_array($qry4451);

$qry009=mysqli_query($conn, "select sum(fine) from net where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row009 = mysqli_fetch_array($qry009);
$qry0099=mysqli_query($conn, "select sum(fine) from user where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row0099 = mysqli_fetch_array($qry0099);

$qry779=mysqli_query($conn, "select sum(actamt) from hloan where mfin='$mfin' && date2 between '$fdate' and '$tdate'");
$row779 = mysqli_fetch_array($qry779);

$qry001=mysqli_query($conn, "select sum(hpamount) from fincust where mfin='$mfin' && hpdate5 between '$fdate' and '$tdate'");
$row001 = mysqli_fetch_array($qry001);
$qry002=mysqli_query($conn, "select sum(urname) from finuser where mfin='$mfin' &&  paydate2 between '$fdate' and '$tdate'");
$row002 = mysqli_fetch_array($qry002);
$qry003=mysqli_query($conn, "select sum(tot) from finnet where mfin='$mfin' &&  paydate2 between '$fdate' and '$tdate'");
$row003 = mysqli_fetch_array($qry003);



$userr = $row45[0] + $row445[0];	
 $nett = $row452[0] + $row4451[0]; 
  $deff = $row009[0] + $row0099[0]; 
 $hpp = $row15[0]; 
 $tot = $userr + $nett + $deff;

$quser = $quser + $userr;
$qnett = $qnett + $nett;
$qdeff = $qdeff + $deff;
$qhpp = $qhpp + $hpp;
$qtot = $qtot + $tot;
//$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin'  && hpdate5 between '$fdate' and '$tdate'");
//$row15 = mysqli_fetch_array($qry15);
//$qry45=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
//$row45 = mysqli_fetch_array($qry45);
//$qry445=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
//$row445 = mysqli_fetch_array($qry445);
//$c11 = $row45[0];  $c31 = $row445[0]; 		$d21 = $row15[0]; 
	//	$obal2 = $c1 + $c2 + $c4 - $d1 - $d2 - $d3 - $d4 + $c3; 
//$cre = $c1+$c2+$c3+$c4;
//$deb = $d1+$d2+$d3+$d4;

	
						?></p>
						
				<tr> <td><font size="3"><b><?php echo $iii; ?></b></font></td>
<td><font size="3"><b><?php echo $monthh; ?></b></font></td>
					<td><font size="3"><b><?php echo  $hpp ?></b></font></td>
						
						<td><font size="3"><b><?php echo $userr; ?></b></font></td>
						<td><font size="3"><?php echo $nett; ?></b></font></td>
						<td><font size="3"><?php echo $deff; ?></b></font></td>
						<td><font size="3"><?php echo $tot; ?></b></font></td>
						</tr>
		
						<?php 
						$totqaa[$iii] = $hpp;
						$totq[$iii] = $userr;
						$totqq[$iii] = $nett;
						$totqa[$iii] = $deff;
						
						$tott[$iii] = $monthh;
						
						$fdate =  date("Y-m-d", strtotime("$fdate + " . 1 . " month"));

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

						}
						?>
			</tbody> <tfoot>	<tr> <td>-</td>
<td><font size="5"><b>Total</b></font></td>
					<td><font size="4"><b><?php echo  $qhpp ?></b></font></td>
						
						<td><font size="4"><b><?php echo $quser; ?></b></font></td>
						<td><font size="4"><?php echo $qnett; ?></b></font></td>
						<td><font size="4"><?php echo $qdeff; ?></b></font></td>
						<td><font size="4"><?php echo $qtot; ?></b></font></td>
						</tr></tfoot>
					
					</table>	</form>
					
</div>
<?php

	$dataPoints1 = array(
	array("label"=>$tott[1], "y"=>$totq[1]),
	array("label"=>$tott[2], "y"=>$totq[2]),
	array("label"=>$tott[3], "y"=>$totq[3]),
	array("label"=>$tott[4], "y"=>$totq[4]),
	array("label"=>$tott[5], "y"=>$totq[5]),
	array("label"=>$tott[6], "y"=>$totq[6]),
	array("label"=>$tott[7], "y"=>$totq[7]),
	array("label"=>$tott[8], "y"=>$totq[8]),
	array("label"=>$tott[9], "y"=>$totq[9]),
	array("label"=>$tott[10], "y"=>$totq[10]),
	array("label"=>$tott[11], "y"=>$totq[11]),
	array("label"=>$tott[12], "y"=>$totq[12])
	
);

	$dataPoints2 = array(
	array("label"=>$tott[1], "y"=>$totqq[1]),
	array("label"=>$tott[2], "y"=>$totqq[2]),
	array("label"=>$tott[3], "y"=>$totqq[3]),
	array("label"=>$tott[4], "y"=>$totqq[4]),
	array("label"=>$tott[5], "y"=>$totqq[5]),
	array("label"=>$tott[6], "y"=>$totqq[6]),
	array("label"=>$tott[7], "y"=>$totqq[7]),
	array("label"=>$tott[8], "y"=>$totqq[8]),
	array("label"=>$tott[9], "y"=>$totqq[9]),
	array("label"=>$tott[10], "y"=>$totqq[10]),
	array("label"=>$tott[11], "y"=>$totqq[11]),
	array("label"=>$tott[12], "y"=>$totqq[12])
	
);

	$dataPoints3 = array(
	array("label"=>$tott[1], "y"=>$totqa[1]),
	array("label"=>$tott[2], "y"=>$totqa[2]),
	array("label"=>$tott[3], "y"=>$totqa[3]),
	array("label"=>$tott[4], "y"=>$totqa[4]),
	array("label"=>$tott[5], "y"=>$totqa[5]),
	array("label"=>$tott[6], "y"=>$totqa[6]),
	array("label"=>$tott[7], "y"=>$totqa[7]),
	array("label"=>$tott[8], "y"=>$totqa[8]),
	array("label"=>$tott[9], "y"=>$totqa[9]),
	array("label"=>$tott[10], "y"=>$totqa[10]),
	array("label"=>$tott[11], "y"=>$totqa[11]),
	array("label"=>$tott[12], "y"=>$totqa[12])
	
);
$dataPoints4 = array(
	array("label"=>$tott[1], "y"=>$totqaa[1]),
	array("label"=>$tott[2], "y"=>$totqaa[2]),
	array("label"=>$tott[3], "y"=>$totqaa[3]),
	array("label"=>$tott[4], "y"=>$totqaa[4]),
	array("label"=>$tott[5], "y"=>$totqaa[5]),
	array("label"=>$tott[6], "y"=>$totqaa[6]),
	array("label"=>$tott[7], "y"=>$totqaa[7]),
	array("label"=>$tott[8], "y"=>$totqaa[8]),
	array("label"=>$tott[9], "y"=>$totqaa[9]),
	array("label"=>$tott[10], "y"=>$totqaa[10]),
	array("label"=>$tott[11], "y"=>$totqaa[11]),
	array("label"=>$tott[12], "y"=>$totqaa[12])
	
);


 ?>
<script>
window.onload = function () {
 
var chart = new CanvasJS.Chart("chartContainer", {
	title: {
		text: "Pledge & COLLECTION REPORT"
	},
	theme: "light2",
	animationEnabled: true,
	toolTip:{
		shared: true,
		reversed: true
	},
	axisY: {
		title: "Amount In",
		suffix: " Rs"
	},
	legend: {
		cursor: "pointer",
		itemclick: toggleDataSeries
	},
	data: [
		{
			type: "stackedColumn",
			name: "Principle Received",
			showInLegend: true,
			yValueFormatString: "#,##0 Rs",
			dataPoints: <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Interest Received",
			showInLegend: true,
			yValueFormatString: "#,##0 Rs",
			dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Default Received",
			showInLegend: true,
			yValueFormatString: "#,##0 Rs",
			dataPoints: <?php echo json_encode($dataPoints3, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Pledge AMOUNT GIVEN",
			showInLegend: true,
			yValueFormatString: "#,##0 Rs",
			dataPoints: <?php echo json_encode($dataPoints4, JSON_NUMERIC_CHECK); ?>
		}
	]
});
 
chart.render();
 
function toggleDataSeries(e) {
	if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
		e.dataSeries.visible = false;
	} else {
		e.dataSeries.visible = true;
	}
	e.chart.render();
}
 
}
</script>

<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</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>

