<?php include "layouts/menu.php"; ?>
   <style>
   .button1 {
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}

.button2:hover {
    box-shadow: 0 12px 12px 0 rgba(0,0,0,0.24),0 17px 40px 0 rgba(0,0,0,0.19);
}


.coloramt{
    color:white;
}

.coloramt:hover{
    color:green;
}
   </style>
    <?php
                    	$qry=mysqli_query($conn, "select * from customerdetailsm where mfin='$mfin' && status='Active'");
						$n=mysqli_num_rows($qry);
						
					
					
                        $qry2=mysqli_query($conn, "select * from customer");
                        $nn=mysqli_num_rows($qry2);
                        
                        $qry3=mysqli_query($conn, "select * from netm where mfin='$mfin'");
						$nq=mysqli_num_rows($qry3);
						
					
						
						$qry41=mysqli_query($conn, "select * from sizzing where mfin='$mfin'");
						$nww=mysqli_num_rows($qry41);
						
						$qry5=mysqli_query($conn, "select * from dc where mfin='$mfin'");
						$doc=mysqli_num_rows($qry5);
	$dataPoints = array( 
	array("label"=>"TOTAL LOANS", "y"=>$n),
	array("label"=>"ACTIVE LOANS", "y"=>$ff),
	array("label"=>"CLOSED LOANS", "y"=>$nq),
	array("label"=>"SIZZED LOANS", "y"=>$nww),
	array("label"=>"pendingm DUES", "y"=>0)
	
);

$dataPoints1 = array( 
	array("label" => "RECEIVED PRINCIPLE",  "y" => 95114 ),
	array("label" => "RECEIVED INTEREST", "y" => 50000 ),
	array("label" => "GIVEN LOAN", "isIntermediateSum" => true),
	array("label" => "SALARY", "y" => -2000 ),
	array("label" => "DEBITS",  "y" => -2206 ),
	array("label" => "RECEIVED PENALTY", "y" => 5000 ),
	array("label" => "Operating Income", "isCumulativeSum" => true ),
	array("label" => "Taxes",  "y" => -300 ),
	array("label" => "netm Income",  "isCumulativeSum" => true )
);

 ?>
<script>

window.onload = function() {
 
var chart = new CanvasJS.Chart("chartContainer", {
	theme: "dark2",
	animationEnabled: true,
	title: {
		text: "FINANCE LEDGER DIAGRAM"
	},
	data: [{
		type: "funnel",
		indexLabel: "{label} - {y}",
		yValueFormatString: "#,##0",
		showInLegend: true,
		legendText: "{label}",
		dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
	}]
});
chart.render();
 

 
var chart1 = new CanvasJS.Chart("chartContainer1", {
	animationEnabled: true,
	title: {
		text: "Company Finance"
	},
	axisY: {
		title: "Amount (in INR)",
		prefix: "Rs.",
		suffix: "K",
		gridThickness: 0
	},
	data: [{
		type: "waterfall",
		risingColor: "#428CFF",
		fallingColor: "#FF8C8C",
		indexLabel: "{y}",
		indexLabelFontColor: "#292B2C",
		indexLabelFontWeight: "bolder",
		indexLabelPlacement: "inside",
		yValueFormatString: "$#,##0k",
		dataPoints: <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
	}]
});
chart1.render();
 
}
</script>
        <div class="right_col" role="main">
          <!-- top tiles -->
         
		  <?php if($mfin!='Group') {
			  $tdate = date("d-m-Y");
   $tdate33 = date("Y-m-d");
   $qryfffr=mysqli_query($conn, "select * from customerdetailsm where mfin='$mfin' && status='Active'");
						$n700=mysqli_num_rows($qryfffr);
						
						   $qryfffr=mysqli_query($conn, "select sum(total) from customerdetailsm where mfin='$mfin' && status='Active' && hpdate5='$tdate33'");
						$row44=mysqli_fetch_array($qryfffr);
						$amtt1 = $row44[0];
						
							   $qryfffre=mysqli_query($conn, "select sum(urname) from userm where mfin='$mfin'");
						$row44e=mysqli_fetch_array($qryfffre);
						$amtt12 = $row44e[0];
						
							   $qryfffr1=mysqli_query($conn, "select sum(tot) from netm where mfin='$mfin'");
						$row441=mysqli_fetch_array($qryfffr1);
						$amtt13 = $row441[0];
						$amtt = $amtt12 + $amtt13;
						
						
						 $qryfffrew=mysqli_query($conn, "select sum(urname) from userm where mfin='$mfin' && paydate2='$tdate33'");
						$row44ew=mysqli_fetch_array($qryfffrew);
						$amtt12w = $row44ew[0];
						
							   $qryfffr1w=mysqli_query($conn, "select sum(tot) from netm where mfin='$mfin' && paydate2='$tdate33'");
						$row441w=mysqli_fetch_array($qryfffr1w);
						$amtt13w = $row441w[0];
						
						$amtt11 = $amtt12w + $amtt13w;
						
						$qryfffr1ee=mysqli_query($conn, "select sum(tot) from netm where mfin='$mfin'");
						$row441ee=mysqli_fetch_array($qryfffr1ee);
						$amtt13ee = $row441ee[0];
					
						$qryrr=mysqli_query($conn, "select * from userm where mfin='$mfin' && paydate2='$tdate33'");
						$nrr=mysqli_num_rows($qryrr);

                        $qry3rr=mysqli_query($conn, "select * from netm where mfin='$mfin'&& paydate2='$tdate33'");
						$nqrr=mysqli_num_rows($qry3rr);
					    
					    $ntt = $nrr + $nqrr;	
						
						
						
		$qry707=mysqli_query($conn, "select * from memo where edate='$tdate'");
						$n707=mysqli_num_rows($qry707);					
	
						$qryr=mysqli_query($conn, "select * from userm where mfin='$mfin' && status='Reloan' && paydate='$tdate'");
						$nr=mysqli_num_rows($qryr);

					
					     $qryfffr=mysqli_query($conn, "select * from customerdetailsm where mfin='$mfin' && hpdate5='$tdate33'");
					 	 $lntt=mysqli_num_rows($qryfffr);
					 	 $lntt22 = $lntt[0];
						
						 $qryfffr1=mysqli_query($conn, "select sum(hpamount) from customerdetailsm where mfin='$mfin'");
						 $row441=mysqli_fetch_array($qryfffr1);
					 	 $lntt1 = $row441[0];
						
						$qryfffr33=mysqli_query($conn, "select sum(pass) from userm where mfin='$mfin'");
						$row4433=mysqli_fetch_array($qryfffr33);
						$amtt1233 = $row4433[0];
						
						$qryfffr34=mysqli_query($conn, "select sum(dueamt) from netm where mfin='$mfin'");
						$row4434=mysqli_fetch_array($qryfffr34);
						$amtt1334 = $row4434[0];
						
						$adss = $lntt1 - $amtt1233 - $amtt1334;
						
						
						
						$qry344=mysqli_query($conn, "select * from memo where edate='$tdate' && staff='$staff'");
						$mmm=mysqli_num_rows($qry344);
						
						
						//$ff = $n - $nq;
						$qry4=mysqli_query($conn, "select * from netm2 where mfin='$mfin'&& bmnt='$tdate'");
						$nw=mysqli_num_rows($qry4);
						$qry41=mysqli_query($conn, "select * from sizzing where mfin='$mfin'&& sizdate='$tdate'");
						$nww=mysqli_num_rows($qry41);
						$ii = date("d");
						
						$qry412=mysqli_query($conn, "SELECT * FROM customerdetailsm where mfin='$mfin' && dd=$ii && status='Active' order by id desc");
						$tdue=mysqli_num_rows($qry412);
				        
					
						$qry4000=mysqli_query($conn, "select sum(tot) from netm where mfin='$mfin'&& paydate='$tdate'");
						$row4000=mysqli_fetch_array($qry4000);
						$f2 = $row4000[0];
					
						
						
						
					
						  ?>
						  
				 <div class="row top_tiles">
                 <div class="">
            <div class="row top_tiles">
              <a href="lviewm.php"> <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-check-square-o" ></i></div>
                  <div class="count coloramt"><?php echo $n700; ?> </div>
                  <h3><font color="white"><b>Total Active Loans</b></font></h3>
                  <p>Total</p>
                </div>
              </div></a>
                         <a href="billrep.php">   <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-close"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $ntt; ?></div>
                  <h3><font color="white"><b>Today Recpts</b></font></h3>
                  <p>Today</p>
                </div>
              </div></a>
               <?php 
              $qry15=mysqli_query($conn, "select sum(totalhpamt) from customerdetailsm where mfin='$mfin'");
              $row15 = mysqli_fetch_array($qry15);
              $tothpamt = $row15[0];
               ?>
               
               <a href="allcusca.php">    <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-motorcycle"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $tothpamt; ?></div>
                  <h3><font color="white"><b>Total Loan Amount</b></font></h3>
                  <p>Total</p>
                </div>
              </div></a>
                 <a href="hpbalp.php">     <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-hand-o-left "></"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $adss; ?></div>
                  <h3><font color="white"><b>Principal Balance</b></font></h3>
                  <p>Total</p>
                </div>
              </div></a>
                        <a href="billrepd.php">    <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-motorcycle"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $amtt11; ?></div>
                  <h3><font color="white"><b> Amount Recvd</b></font></h3>
                  <p>Today</p>
                </div>
              </div></a>
                       <a href="lviewc2.php">     <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-hand-o-left "></"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $nq; ?> </div>
                  <h3><font color="white"><b>Closed Loans</b></font></h3>
                  <p>Total</p>
                </div>
              </div>
              </a>
              
              
               <a href="lviewc2.php">     <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-hand-o-left "></"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $amtt13ee; ?> </div>
                  <h3><font color="white"><b>Closed Loans Amount</b></font></h3>
                  <p>Total</p>
                </div>
              </div>
              </a>
             
              
             
             
         
		           <a href="dpending.php">    <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-inr"></i></div>
                  <div class="count coloramt"><font color="white"> <?php
                  
						
						$qry412=mysqli_query($conn, "SELECT * FROM pending where mfin='$mfin'");
						$tdue=mysqli_num_rows($qry412);
                  echo $tdue; ?></div>
                  <h3><font color="white"><b>Today Dues</b></font></h3>
                  <p>Current</p>
                </div>
              </div> </a>
            <a href="billrepd.php">   <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div style="background: linear-gradient(to left, #d9ff00 , #adaf32);" class="tile-stats">
                  <div class="icon"><i class="fa fa-university"></i></div>
                  <div class="count coloramt"><font color="white"><?php echo $amtt; ?></div>
                  <h3><font color="white"><b>Total Collection</b></font></h3>
                  <p>Total</p>
                </div>
              </div> </a>
</div> </div> 
		  

	  
	 	<?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"));
										$obal = 0;
	$qcre =  0;
$qdeb =  0;
				
$quser = 0;
$qnett = 0; $iii = 0;
$qdeff = 0;
$qhpp =0;
$qtot = 0;		
								while(strtotime($fdate)<=strtotime($tdate1)) { $iii++;
					$monthh = date('F, Y', strtotime($fdate));

$qry15=mysqli_query($conn, "select sum(totalhpamt) from customerdetailsm where mfin='$mfin'  && hpdate5 between '$fdate' and '$tdate'");
$row15 = mysqli_fetch_array($qry15);


$tothpamt = $row15[0];
$qry4415=mysqli_query($conn, "select sum(document) from customerdetailsm where mfin='$mfin'  && hpdate5 between '$fdate' and '$tdate'");
$row4415 = mysqli_fetch_array($qry4415);
$qry45=mysqli_query($conn, "select sum(pass) from userm where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row45 = mysqli_fetch_array($qry45);
$qry452=mysqli_query($conn, "select sum(rno) from userm where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row452 = mysqli_fetch_array($qry452);
$qry445=mysqli_query($conn, "select sum(dueamt) from netm where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row445 = mysqli_fetch_array($qry445);
$qry4451=mysqli_query($conn, "select sum(amt) from netm where mfin='$mfin'  &&  paydate2 between '$fdate' and '$tdate'");
$row4451 = mysqli_fetch_array($qry4451);

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




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

$quser = $quser + $userr;
$qnett = $qnetmt + $netmt;
$qdeff = $qdeff + $deff;
$qhpp = $qhpp + $hpp;
$qtot = $qtot + $tot; 
						$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"));

						}
						?>
            <div class="row">
              <div class="col-md-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Transaction Summary <small>Weekly progress</small></h2>
                    <div class="filter">
                      <div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc">
                        <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
                        <span>December 30, 2014 - January 28, 2015</span> <b class="caret"></b>
                      </div>
                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <div class="col-md-9 col-sm-12 col-xs-12">
                     <?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: "MONTHLY - SMART 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: "Loan 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>
                <!-- end of weather widget -->
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
   
	 <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>
    <!-- Chart.js -->
    <script src="vendors/Chart.js/dist/Chart.min.js"></script>
    <!-- jQuery Sparklines -->
    <script src="vendors/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
    <!-- Flot -->
    <script src="vendors/Flot/jquery.flot.js"></script>
    <script src="vendors/Flot/jquery.flot.pie.js"></script>
    <script src="vendors/Flot/jquery.flot.time.js"></script>
    <script src="vendors/Flot/jquery.flot.stack.js"></script>
    <script src="vendors/Flot/jquery.flot.resize.js"></script>
    <!-- Flot plugins -->
    <script src="vendors/flot.orderbars/js/jquery.flot.orderBars.js"></script>
    <script src="vendors/flot-spline/js/jquery.flot.spline.min.js"></script>
    <script src="vendors/flot.curvedlines/curvedLines.js"></script>
    <!-- DateJS -->
    <script src="vendors/DateJS/build/date.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="vendors/moment/min/moment.min.js"></script>
    <script src="vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
    
    <!-- Custom Theme Scripts -->
    <script src="build/js/custom.min.js"></script>
  </body>
</html>
 