<?php include "layouts/menu.php"; ?>
<script>
	function autocomplet() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#did').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_refresh.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#country_list_id').show();
				$('#country_list_id').html(data);
			}
		});
	} else {
		$('#country_list_id').hide();
	}
}
function set_item(item) {
	// change input value
	$('#did').val(item);
	// hide proposition list
	$('#country_list_id').hide();
}
	</script>
	 <script>
	function autocomp() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#didn').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_sname.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#dname').show();
				$('#dname').html(data);
			}
		});
	} else {
		$('#dname').hide();
	}
}

// set_item : this function will be executed when we select an item
function set_itemm(item) {
	// change input value
	$('#didn').val(item);
	// hide proposition list
	$('#dname').hide();
}
	</script>
 <script>
	function autocomplett() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#zxcvb').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_refreshq.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#qwertyu').show();
				$('#qwertyu').html(data);
			}
		});
	} else {
		$('#qwertyu').hide();
	}
}
// set_item : this function will be executed when we select an item
function set_itemmm(item) {
	// change input value
	$('#zxcvb').val(item);
	// hide proposition list
	$('#qwertyu').hide();
}
	</script>
  <!--  page-wrapper -->
           <div class="right_col" role="main">
         


            <div class="clearfix"></div>

            <div class="clearfix"></div>

            <div class="row">
			
           <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title" >
                    <h2>Customer Details <small></small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <div class="row">
                      <div class="col-sm-12">
                        <div class="card-box table-responsive">			
  <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">  
					<thead>
						<tr><th>Due Range</th>
						<th>Live Cust's</th>
						<th>Live Pending</th>
		<th>Ter Cust's</th>
						<th>Ter Pending</th>
						<th>Tot Cust's</th>
						<th>Tot Pending</th>
					</tr></thead>
					<tbody> <?php
					$ff = NULL;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='1'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='1'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='1'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='1'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot = $n + $n1;
$tott = $amt1 + $amt2;
?>			<tr>
				<td><b><b>1</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot;?></b></td>
<td><b><b><?php echo $tott;?></b></td>				
					</tr>
<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='2'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='2'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='2'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='2'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot2 = $n + $n1;
$tott2 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>2</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot2;?></b></td>
<td><b><b><?php echo $tott2;?></b></td>				
					</tr>
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='2'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='2'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='2'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='2'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot2 = $n + $n1;
$tott2 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>2</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot2;?></b></td>
<td><b><b><?php echo $tott2;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='3'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='3'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='3'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='3'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot3 = $n + $n1;
$tott3 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>2</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot3;?></b></td>
<td><b><b><?php echo $tott3;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='4'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='4'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='4'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='4'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot4 = $n + $n1;
$tott4 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>4</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot4;?></b></td>
<td><b><b><?php echo $tott4;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='5'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='5'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='5'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='5'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot5 = $n + $n1;
$tott5 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>5</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot5;?></b></td>
<td><b><b><?php echo $tott5;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='6'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='6'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='6'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='6'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot6 = $n + $n1;
$tott6 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>6</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot6;?></b></td>
<td><b><b><?php echo $tott6;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt='7'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt='7'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt='7'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt='7'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot7 = $n + $n1;
$tott7 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>7</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot7;?></b></td>
<td><b><b><?php echo $tott7;?></b></td>				
					</tr>
					
					
					
					<?php
					$ff = NULL; $amt1 = 0; $amt2 = 0; $n1 = 0; $n = 0;
$qry=mysqli_query($conn, "select * from pending where mfin='$mfin' && star='$ff' && pendmnt>='8'");
$n=mysqli_num_rows($qry);
$qry2=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star='$ff' && pendmnt>='8'");
$row2=mysqli_fetch_array($qry2);
$amt1 = $row2[0];

$qry1=mysqli_query($conn, "select * from pending where mfin='$mfin' && star!='$ff' && pendmnt>='8'");
$n1=mysqli_num_rows($qry1);
$qry21=mysqli_query($conn, "select sum(penamt) from pending where mfin='$mfin' && star!='$ff' && pendmnt>='8'");
$row21=mysqli_fetch_array($qry21);
$amt2 = $row21[0];
$tot8 = $n + $n1;
$tott8 = $amt1 + $amt2;
?>					
				<tr>
				<td><b><b>8>Above</b></td>
				<td><b><b><?php echo $n;?></b></td>
<td><b><b><?php echo $amt1;?></b></td>
<td><b><b><?php echo $n1;?></b></td>
<td><b><b><?php echo $amt2;?></b></td>
<td><b><b><?php echo $tot8;?></b></td>
<td><b><b><?php echo $tott8;?></b></td>				
					</tr>
					 </tbody>
					</table>
					
					
</div>

<?php

	$dataPoints = array( 
	array("label"=>"1 Due Pending", "y"=>$tot),
	array("label"=>"2 Due Pending", "y"=>$tot2),
	array("label"=>"3 Due Pending", "y"=>$tot3),
	array("label"=>"4 Due Pending", "y"=>$tot4),
	array("label"=>"5 Due Pending", "y"=>$tot5),
	array("label"=>"6 Due Pending", "y"=>$tot6),
	array("label"=>"7 Due Pending", "y"=>$tot7),
	array("label"=>"Above 8 Due", "y"=>$tot8),
	
);

$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" => "Net Income",  "isCumulativeSum" => true )
);

 ?>
<script>
window.onload = function() {
 
var chart = new CanvasJS.Chart("chartContainer", {
	animationEnabled: true,
	title: {
		text: "PENDING DUE ANATCS"
	},
	data: [{
		type: "pyramid",
		indexLabel: "{label} - {y}",
		yValueFormatString: "#,##0",
		dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
	}]
});
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></div></div>     <!-- /page content -->

        <!-- footer content -->
        <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>

