<?php include "layouts/menu.php"; ?> 
    <?php $hpl=$_REQUEST['hpl'];?>
  <!--  page-wrapper -->
<script type="text/javascript">
/* 
   Willmaster Table Sort
   Version 1.0
   July 3, 2011

   Will Bontrager
   http://www.willmaster.com/
   Copyright 2011 Will Bontrager Software, LLC

   This software is provided "AS IS," without 
   any warranty of any kind, without even any 
   implied warranty such as merchantability 
   or fitness for a particular purpose.
   Will Bontrager Software, LLC grants 
   you a royalty free license to use or 
   modify this software provided this 
   notice appears on all copies. 
*/
//
// One placed to customize - The id value of the table tag.

var TableIDvalue = "indextable";

//
//////////////////////////////////////
var TableLastSortedColumn = -1;
function SortTable() {
var sortColumn = parseInt(arguments[0]);
var type = arguments.length > 1 ? arguments[1] : 'T';
var dateformat = arguments.length > 2 ? arguments[2] : '';
var table = document.getElementById(TableIDvalue);
var tbody = table.getElementsByTagName("tbody")[0];
var rows = tbody.getElementsByTagName("tr");
var arrayOfRows = new Array();
type = type.toUpperCase();
dateformat = dateformat.toLowerCase();
for(var i=0, len=rows.length; i<len; i++) {
	arrayOfRows[i] = new Object;
	arrayOfRows[i].oldIndex = i;
	var celltext = rows[i].getElementsByTagName("td")[sortColumn].innerHTML.replace(/<[^>]*>/g,"");
	if( type=='D' ) { arrayOfRows[i].value = GetDateSortingKey(dateformat,celltext); }
	else {
		var re = type=="N" ? /[^\.\-\+\d]/g : /[^a-zA-Z0-9]/g;
		arrayOfRows[i].value = celltext.replace(re,"").substr(0,25).toLowerCase();
		}
	}
if (sortColumn == TableLastSortedColumn) { arrayOfRows.reverse(); }
else {
	TableLastSortedColumn = sortColumn;
	switch(type) {
		case "N" : arrayOfRows.sort(CompareRowOfNumbers); break;
		case "D" : arrayOfRows.sort(CompareRowOfNumbers); break;
		default  : arrayOfRows.sort(CompareRowOfText);
		}
	}
var newTableBody = document.createElement("tbody");
for(var i=0, len=arrayOfRows.length; i<len; i++) {
	newTableBody.appendChild(rows[arrayOfRows[i].oldIndex].cloneNode(true));
	}
table.replaceChild(newTableBody,tbody);
} // function SortTable()

function CompareRowOfText(a,b) {
var aval = a.value;
var bval = b.value;
return( aval == bval ? 0 : (aval > bval ? 1 : -1) );
} // function CompareRowOfText()

function CompareRowOfNumbers(a,b) {
var aval = /\d/.test(a.value) ? parseFloat(a.value) : 0;
var bval = /\d/.test(b.value) ? parseFloat(b.value) : 0;
return( aval == bval ? 0 : (aval > bval ? 1 : -1) );
} // function CompareRowOfNumbers()

function GetDateSortingKey(format,text) {
if( format.length < 1 ) { return ""; }
format = format.toLowerCase();
text = text.toLowerCase();
text = text.replace(/^[^a-z0-9]*/,"",text);
text = text.replace(/[^a-z0-9]*$/,"",text);
if( text.length < 1 ) { return ""; }
text = text.replace(/[^a-z0-9]+/g,",",text);
var date = text.split(",");
if( date.length < 3 ) { return ""; }
var d=0, m=0, y=0;
for( var i=0; i<3; i++ ) {
	var ts = format.substr(i,1);
	if( ts == "d" ) { d = date[i]; }
	else if( ts == "m" ) { m = date[i]; }
	else if( ts == "y" ) { y = date[i]; }
	}
if( d < 10 ) { d = "0" + d; }
if( /[a-z]/.test(m) ) {
	m = m.substr(0,3);
	switch(m) {
		case "jan" : m = 1; break;
		case "feb" : m = 2; break;
		case "mar" : m = 3; break;
		case "apr" : m = 4; break;
		case "may" : m = 5; break;
		case "jun" : m = 6; break;
		case "jul" : m = 7; break;
		case "aug" : m = 8; break;
		case "sep" : m = 9; break;
		case "oct" : m = 10; break;
		case "nov" : m = 11; break;
		case "dec" : m = 12; break;
		default    : m = 0;
		}
	}
if( m < 10 ) { m = "0" + m; }
y = parseInt(y);
if( y < 100 ) { y = parseInt(y) + 2000; }
return "" + String(y) + "" + String(m) + "" + String(d) + "";
} // function GetDateSortingKey()
</script>






         <div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h1 class="page-header  alert alert-info">Due Details</h1>
                </div>
                <!--end page header -->
            </div>
            <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">
   <div id="mydiv">
  <input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;">
   <div class="alert alert-info">Monthly Due</div>
  
                    <?php
					
						$qry=mysqli_query($conn, "select * from user where mfin='$mfin' &&  hpl='$hpl'");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
					{ 
						?></p>
					<div class="table-responsive">
					
  <table class="table table-bordered table-hover" id="indextable"><thead>
  <tr class="info">
						<th><a href="javascript:SortTable(0,'T');">Name</a></th>
						
						<th><a href="javascript:SortTable(2,'N');">Hpl</a></th>
						<th><a href="javascript:SortTable(2,'N');">Duemonth</a></th>
						<th><a href="javascript:SortTable(3,'D','mdy');">Duedate</a></th>
						<th><a href="javascript:SortTable(2,'N');">Dueamount</a></th>
						<th><a href="javascript:SortTable(2,'N');">Interest</a></th>
						<th><a href="javascript:SortTable(2,'N');">Amt W/o</a></th>
						<th><a href="javascript:SortTable(2,'N');">Pay Months</a></th>
						<th><a href="javascript:SortTable(2,'N');">Total Paid Months</a></th>
						<th><a href="javascript:SortTable(2,'N');">Paydate</a></th>
						<th><a href="javascript:SortTable(2,'N');">Fine</a></th>
						<th><a href="javascript:SortTable(2,'N');">Bal</a></th>
						<th><a href="javascript:SortTable(2,'N');">Amount</a></th>
						<th><a href="javascript:SortTable(2,'N');">Delete</a></th>
					</tr></thead>
					<?php 
					while($row=mysqli_fetch_array($qry))
						{
					?>
					<tbody><tr class="warning">
					<col width="100px">
						<td><?php echo $row['name'];?></td>
						
						<td><?php echo $row['hpl'];?></td>
						<td><?php echo $row['no'];?></td>
						<td><?php echo $row['duedate'];?></td>
						<td><?php echo $row['dueamount'];?></td>
						<td><?php echo $row['rno'];?></td>
						<td><?php echo $row['pass'];?></td>
						<td><?php echo $row['paymnt'];?></td>
						<td><?php echo $row['payyr'];?></td>
						<td><?php echo $row['paydate'];?></td>
						
						
						<td><?php echo $row['fine'];?></td>
						<td><?php echo $row['bal'];?></td>
						<td><?php echo $row['urname'];?></td>
						<td><a href="ddelete.php?hpl=<?php echo $row['hpl'];?>&name=<?php echo $row['name'];?>&fid=<?php echo $row['fid'];?>">More Info</a></td>
					</tr></tbody>
					<?php
						}
					}
				
					?>
					</table>
</div></div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?></body></html>