<?php include("session_controller.php"); ?>
<?php
//format date function
function dateformatReverse($datetime){
$received_timestamp = "";
 if($datetime != ""){
 $full_date = explode(" ", $datetime);
 $date = explode("-", $full_date[0]);
 $d = $date[2];
 $mo = $date[1];
 $y = $date[0];
 $time = explode(":",$full_date[1]);
 $h = $time[0];
 $min = $time[1];
 $s = $time[2];
 
 $received_timestamp = $d."/".$mo."/".$y." ".$h.":".$min.":".$s;
 }
 return $received_timestamp;
 }
 
function dateformat($datetime){
$received_timestamp = "";
 if($datetime != ""){
 $full_date = explode(" ", $datetime);
 $date = explode("/", $datetime);
 $d = $date[0];
 $mo = $date[1];
 $y = $date[2];
 //$time = explode(":",$full_date[1]);
 /*
 $h = $time[0];
 $min = $time[1];
 $s = $time[2];
 */
 $h = "00";
 $min = "00";
 $s = "00";
 
 $received_timestamp = $y."-".$mo."-".$d." ".$h.":".$min.":".$s;
 }
 return $received_timestamp;
 }
 
 
mysqli_select_db($conn,$database_conn);
$missing= "";

if(isset($_POST['date']) && ($_POST['date'] !="")){
$_SESSION['date'] = dateformat(trim($_POST['date']));
$_SESSION['date1'] = "";
$_SESSION['date2'] = "";
}
else{
	$_SESSION['date'] = "";
$_SESSION['date1'] = "";
$_SESSION['date2'] = "";
}

 
if(isset($_SESSION['date']) && $_SESSION['date'] != ""){

$missing .= " WHERE (date_entered = '".$_SESSION['date']."' OR DATE(date_entered) = DATE('".$_SESSION['date']."'))";

}


if((isset($_POST['date1']) && $_POST['date1']!="") && (isset($_POST['date2']) && $_POST['date2']!="" )){
$_SESSION['date1'] = dateformat(trim($_POST['date1']));
$_SESSION['date2'] = dateformat(trim($_POST['date2']));
}
else{
	$_SESSION['date1'] = "";
$_SESSION['date2'] = "";
}

if((isset($_SESSION['date1']) && $_SESSION['date1'] != "") && (isset($_SESSION['date2']) && $_SESSION['date2'] != "")){
	
$missing .= " WHERE (((DATE(date_entered) > '".$_SESSION['date1']."') OR (DATE(date_entered) = '".$_SESSION['date1']."')) AND (( DATE(date_entered) < '".$_SESSION['date2']."') OR (DATE(date_entered) = '".$_SESSION['date2']."')))";

}
$table = "";
$acct = "";
$query_accounts = NULL;
$query_Recordset1 = "";
if(isset($_GET['account']) && ($_GET['account'] != "")){
	$table = $_GET['account'];
	if($table == "bank"){
	$query_accounts = "SELECT s_no, name, account_no, credit, debit, tranx_id, tranx_details, name, date_entered FROM $table $missing ORDER BY s_no DESC";
	$query_Recordset1 = "SELECT sum(credit) as `total_credit`, sum(debit) as `total_debit` FROM $table $missing";
}
else if($table == "cash"){
	$query_accounts = "SELECT s_no, name, account_no, credit, debit, tranx_id, tranx_details, name, date_entered FROM $table $missing ORDER BY s_no DESC";
	$query_Recordset1 = "SELECT sum(credit) as `total_credit`, sum(debit) as `total_debit` FROM $table $missing";
}
else if($table == "balance"){
	$query_accounts = "SELECT s_no, credit, debit, date_entered FROM $table $missing ORDER BY s_no DESC";
	$query_Recordset1 = "SELECT sum(credit) as `total_credit`, sum(debit) as `total_debit` FROM $table $missing";
}
else{
	$query_accounts = "SELECT s_no, name, account_no, amount, tranx_id, tranx_details, name, date_entered FROM $table $missing ORDER BY s_no DESC";
	$query_Recordset1 = "SELECT sum(amount) as `total_amount` FROM $table $missing";
}
}

$_SESSION['query'] = $query_accounts; //add to session variable query for exporting to excel in download php file

$accounts = mysqli_query($conn, $query_accounts) or die(mysqli_error($conn));
$row_accounts = mysqli_fetch_assoc($accounts);
$totalRows_accounts = mysqli_num_rows($accounts);


mysqli_select_db($conn, $database_conn);
$Recordset1 = mysqli_query($conn, $query_Recordset1) or die(mysqli_error($conn));
$row_Recordset1 = mysqli_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysqli_num_rows($Recordset1);
?>
<html>
<head>
<title>Hylook Accounts - Tranx</title>

 
<script type="text/javascript">

function clearSingle(){
	document.getElementById("datetimepicker1").value= "";
}

function clearRange(){
	document.getElementById("datetimepicker2").value= "";
	document.getElementById("datetimepicker3").value= "";
}


function check_confirmation(){
var signal = prompt("Type DELETE");
if(signal == "DELETE"){
	return true;		
}
else{
	return false;
}
}


function getResult(){
//alert("hello");
document.sm.submit();
document.getElementById('sm').submit();
}

function ajax3(target) {

  // native XMLHttpRequest object
 // document.getElementById(target).innerHTML = '<img src="images/ajax-loader.gif" />';
   document.getElementById(target).innerHTML = 'loading...';
  var search4 = document.sm3.search3.value;
  var url = 'getLocations.php?search='+search4;
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = function() {ajaxDone(target);};
    req.open("GET", url, true);
    req.send(null);
    // IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLDOM");
    if (req) {
      req.onreadystatechange = function() {ajaxDone(target);};
      req.open("GET", url, true);
      req.send(null);
    }
  }
}


function ajax(target) {

  // native XMLHttpRequest object
 // document.getElementById(target).innerHTML = '<img src="images/ajax-loader.gif" />';
   document.getElementById(target).innerHTML = 'loading...';
  var search4 = document.sm.search2.value;
  var url = 'getAccounts.php?search='+search4;
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = function() {ajaxDone(target);};
    req.open("GET", url, true);
    req.send(null);
    // IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLDOM");
    if (req) {
      req.onreadystatechange = function() {ajaxDone(target);};
      req.open("GET", url, true);
      req.send(null);
    }
  }
}



function ajaxDone(target) {
  // only if req is "loaded"
  if (req.readyState == 4) {
    // only if "OK"
    if (req.status == 200 || req.status == 304) {
      results = req.responseText;
	//  document.getElementById(target).style.display='none';
      document.getElementById(target).innerHTML = results;
    } else {
      document.getElementById(target).innerHTML="ajax error:\n" +
      req.statusText;
    }
  }
}

//$(document).ready(function() { 
//setupRefresh();
 // $.ajaxSetup({ cache: false }); 
//}); 


</script>

<style>
/*STYLES FOR CSS POPUP*/
th{
	font-size:15px;
}
#blanket {
   background-color:#111;
   opacity: 0.65;
   *background:none;
   position:absolute;
   z-index: 9001;
   top:0px;
   left:0px;
   width:100%;
}

#popUpDiv {
	position:absolute;
	/*background:url(pop-back.jpg) no-repeat;*/
	background-color:#FFFFFF;
	/*background-image:url(../../../images/stories/new/resultbg2.png) ; */ 
	width:900px;
	height:500px;
	border:3px solid #0000FF;
	z-index: 9002;
	border-radius:10px 10px 10px 10px;
	font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
	overflow-y:auto
}

#popUpDiv a {position:relative; top:20px; left:20px}
</style>


<script>
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/350;
	//popUpDiv_height=blanket_height/20;
	//200 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
	
	
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-450;
	//200 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);	
	return false;	
}

</script>

<style type="text/css" >
@media print {
  * {
    display: none;
  }
  #printableTable {
    display: block;
  }
}
</style>


<script>
 function printDiv() {
         window.frames["print_frame"].document.body.innerHTML = document.getElementById("printableTable").innerHTML;
         window.frames["print_frame"].window.focus();
         window.frames["print_frame"].window.print();
       }
 </script>

</head>
<body>

<?php include("links.php");?>

<div class="container">
   <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>?account=<?php if(isset($_GET['account']) &&  ($_GET['account'] != "")){ echo $_GET['account']; }; ?>" name="dateF" class="form-group">
<div class="row">
<div class="col-sm-4">
                          
                          <font color="#003399">Search By Single Date</font>
    <input type='text' class="form-control boxes" id='datetimepicker1' onClick="clearRange();" name="date" value="<?php if(isset($_SESSION['date']) && $_SESSION['date'] != ""){ echo dateformatReverse($_SESSION['date']); } ?>" />
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker({
					format: 'DD/MM/YYYY'
				});
            });
        </script>
					</div>
                    
                
<div class="col-sm-3">	
  				
			      <font color="#003399">Date From  </font>
    <input type='text' class="form-control boxes" id='datetimepicker2'  onClick="clearSingle();" name="date1" value="<?php if(isset($_SESSION['date1']) && $_SESSION['date1'] != ""){ echo dateformatReverse($_SESSION['date1']); } ?>"/>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker2').datetimepicker({
					format: 'DD/MM/YYYY'
				});
            });
        </script>
 

  </div>                       
                     
<div class="col-sm-3">
   
                              <font color="#003399">Date To </font>
    <input type='text' class="form-control boxes" id='datetimepicker3'  onClick="clearSingle();" name="date2" value="<?php if(isset($_SESSION['date2']) && $_SESSION['date2'] != ""){ echo dateformatReverse($_SESSION['date2']); } ?>"/>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker3').datetimepicker({
					format: 'DD/MM/YYYY'
				});
            });
        </script> 
						  </div>
                          
                    <div class="col-sm-2" >
                     <font color="#003399">&nbsp;&nbsp; </font><br/>
                          <button name="search3" style="width:100%; height:auto;padding-left:10px;padding-left:10px; background-color:#f2f1f3; display:block; border-radius:5px; color:#333" type="submit"  class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> Search </button>
                           </div>
</div> <!-- close row -->
</form>



<div class="row">
<div class="col-sm-4">

                   
                          <a href="accounts.php"><button name="back" type="submit"  class="btn btn-primary" style="width:auto; height:auto;padding-left:15px;padding-left:15px; display:block; border-radius:5px; font-size:16px; font-family:Century Gothic"> Back to Personal Accounts </button></a>
                         
</div>
<div class="col-sm-3">
                          <a href="download.php"><button name="back" type="submit"  class="btn btn-primary" style="width:80%; height:auto;padding-left:15px;padding-left:15px; display:block; border-radius:5px; font-size:16px; font-family:Century Gothic"> Export to Excel </button></a>
                              
</div>
<div class="col-sm-3">
                         <button onClick="printDiv();" class="btn btn-primary" style="width:80%; height:auto;padding-left:15px;padding-left:15px; display:block; border-radius:5px; font-size:16px; font-family:Century Gothic"> Print Page </button>
                              
</div>
</div>
<br/>

<div id="printableTable">
<style type="text/css">
        body {
            font-family: verdana, arial, sans-serif ;
            font-size: 12px ;
            }
        thead,
        td {
            padding: 4px 4px 4px 4px ;
            /*text-align: center ; */
            }
        th {
            border-bottom: 2px solid #333333 ;
            }
        td {
            border-bottom: 1px dotted #999999 ;
            }
        tfoot td {
            border-bottom-width: 0px ;
            border-top: 2px solid #333333 ;
            padding-top: 20px ;
            }
  
h3{
	font-size:28px; font-family:Century Gothic; color:#036;
}
h5{
	font-size:16px; font-family:Century Gothic; color:#036; font-weight:700;
}
</style>
<!--<div class="col-sm-1">
<form class="form-group">
<button onclick="int=window.clearInterval(int)" class="btn btn-primary">Stop!!</button>
</form>
</div>
<div class="col-sm-1">
<form class="form-group">
<button onclick="int = self.setInterval('showAlertAfter5Seconds()', 5000);" class="btn btn-primary">Resume!!</button>
</form>
</div>
-->
<!-- close secondrow -->
<br/>
<div style="font-family:Century Gothic; font-size:24px; font-weight:600"><?php if(isset($_GET['account']) && ($_GET['account'] != "")){ echo strtoupper($_GET['account']);} ?> Account </div>
<?php if($table == "bank"){ ?>

<?php echo "<div style='font-size:20px;'><strong>Total Credit: NGN" .number_format($row_Recordset1['total_credit']). ", Total Debit: NGN". number_format($row_Recordset1['total_debit']) ."</strong></div>"; ?>

<?php }else if($table == "cash"){ ?>

<?php echo "<div style='font-size:20px;'><strong>Total Credit: NGN" .number_format($row_Recordset1['total_credit']). ", Total Debit: NGN". number_format($row_Recordset1['total_debit']) ."</strong></div>"; ?>

<?php } else if($table == "balance"){ ?>

<?php echo "<div style='font-size:20px;'><strong>Total Credit: NGN" .number_format($row_Recordset1['total_credit']). ", Total Debit: NGN". number_format($row_Recordset1['total_debit']) ."</strong></div>"; ?>

<?php  } else{ ?>

<?php echo "<div style='font-size:20px;'><strong>Total Amount: NGN" .number_format($row_Recordset1['total_amount']). "</strong></div>"; ?>

<?php }?>

<br/>
<?php if($totalRows_accounts > 0){ ?>

<div id="xy"> 
<div class="table-responsive">

<?php if($table == "bank"){ ?>

<table width="100%" class="table table-striped table-bordered"> 
<thead>
    <tr>
      <th width="44">S/N </th><th width="205"> Customer Name </th><th width="150">Credit (NGN) </th><th width="150">Debit (NGN) </th><th width="200">Details </th><th width="100">Tranx ID </th><th width="150">Tranx Date </th>
       <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
     <!-- <th width="107"><i class="glyphicon glyphicon-pencil"></i> Edit</th>--><th width="107"><i class="glyphicon glyphicon-remove"></i> Delete</th>
      <?php } ?>
    </tr>
    </thead>
    <tbody>

<?php 
$counter = 0;
$d="active";
do { ?>
    <tr>
      <td><?php echo ++$counter; ?></td> <td><a href="tranx_customer.php?account_no=<?php echo $row_accounts['account_no']; ?>" title="View Account History"><?php echo $row_accounts['name']; ?></a></td> <td><?php echo number_format($row_accounts['credit']); ?> </td> <td><?php echo number_format($row_accounts['debit']); ?> </td><td><?php echo $row_accounts['tranx_details']; ?> </td> <td><?php echo $row_accounts['tranx_id']; ?> </td><td><?php echo date('d/m/Y', strtotime($row_accounts['date_entered'])); ?>   </td>
 <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
 
	<!-- <td width="107"><form action="edit_tranx.php" method="get"><input name="s_no" value="<?php // echo $row_accounts['s_no']; ?>" type="hidden" /> <input name="account_no" value="<?php  //echo $row_accounts['account_no']; ?>"  type="hidden" /><button type="submit" name="up" class="btn btn-primary">Update</button></form> </td> -->
      <td width="107"><form action="delete_acct.php" method="get"><input name="s_no" value="<?php echo $row_accounts['s_no']; ?>" type="hidden" /><input name="table" value="<?php if(isset($_GET['account']) && ($_GET['account'] != "")){ echo $_GET['account'];} ?>" type="hidden" /><button type="submit" name="up" class="btn btn-primary" onClick="return check_confirmation();">Delete</button></form> </td>
     <?php } ?>
    </tr>
    <?php 
	if($d == "active"){
    $d = "success";
    }
    else{
    $d ="active";
    }
	?>
  <?php } while ($row_accounts = mysqli_fetch_assoc($accounts)); ?>
  <!-- close query div -->
 
  </tbody>
 </table>
 <?php } else if($table == "cash"){ ?>

<table width="100%" class="table table-striped table-bordered"> 
<thead>
    <tr>
      <th width="44">S/N </th><th width="205"> Customer Name </th><th width="150">Credit (NGN) </th><th width="150">Debit (NGN) </th><th width="200">Details </th><th width="100">Tranx ID </th><th width="150">Tranx Date </th>
       <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
     <!-- <th width="107"><i class="glyphicon glyphicon-pencil"></i> Edit</th>--><th width="107"><i class="glyphicon glyphicon-remove"></i> Delete</th>
      <?php } ?>
    </tr>
    </thead>
    <tbody>

<?php 
$counter = 0;
$d="active";
do { ?>
    <tr>
      <td><?php echo ++$counter; ?></td> <td><a href="tranx_customer.php?account_no=<?php echo $row_accounts['account_no']; ?>" title="View Account History"><?php echo $row_accounts['name']; ?></a></td> <td><?php echo number_format($row_accounts['credit']); ?> </td> <td><?php echo number_format($row_accounts['debit']); ?> </td><td><?php echo $row_accounts['tranx_details']; ?> </td> <td><?php echo $row_accounts['tranx_id']; ?> </td><td><?php echo date('d/m/Y', strtotime($row_accounts['date_entered'])); ?>   </td>
 <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
 
	<!-- <td width="107"><form action="edit_tranx.php" method="get"><input name="s_no" value="<?php // echo $row_accounts['s_no']; ?>" type="hidden" /> <input name="account_no" value="<?php  //echo $row_accounts['account_no']; ?>"  type="hidden" /><button type="submit" name="up" class="btn btn-primary">Update</button></form> </td> -->
      <td width="107"><form action="delete_acct.php" method="get"><input name="s_no" value="<?php echo $row_accounts['s_no']; ?>" type="hidden" /><input name="table" value="<?php if(isset($_GET['account']) && ($_GET['account'] != "")){ echo $_GET['account'];} ?>" type="hidden" /><button type="submit" name="up" class="btn btn-primary" onClick="return check_confirmation();">Delete</button></form> </td>
     <?php } ?>
    </tr>
    <?php 
	if($d == "active"){
    $d = "success";
    }
    else{
    $d ="active";
    }
	?>
  <?php } while ($row_accounts = mysqli_fetch_assoc($accounts)); ?>
  <!-- close query div -->
 
  </tbody>
 </table>
 <?php } else if($table == "balance"){ ?>

<table width="100%" class="table table-striped table-bordered"> 
<thead>
    <tr>
      <th width="44">S/N </th><th width="150">Credit (NGN) </th><th width="150">Debit (NGN) </th><th width="150">Tranx Date </th>
       <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
     <!-- <th width="107"><i class="glyphicon glyphicon-pencil"></i> Edit</th>--><th width="107"><i class="glyphicon glyphicon-remove"></i> Delete</th>
      <?php } ?>
    </tr>
    </thead>
    <tbody>

<?php 
$counter = 0;
$d="active";
do { ?>
    <tr>
      <td><?php echo ++$counter; ?></td> <td><?php echo number_format($row_accounts['credit']); ?> </td> <td><?php echo number_format($row_accounts['debit']); ?> </td><td><?php echo date('d/m/Y', strtotime($row_accounts['date_entered'])); ?>   </td>
 <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
 
	<!-- <td width="107"><form action="edit_tranx.php" method="get"><input name="s_no" value="<?php // echo $row_accounts['s_no']; ?>" type="hidden" /> <input name="account_no" value="<?php  //echo $row_accounts['account_no']; ?>"  type="hidden" /><button type="submit" name="up" class="btn btn-primary">Update</button></form> </td> -->
      <td width="107"><form action="delete_acct.php" method="get"><input name="s_no" value="<?php echo $row_accounts['s_no']; ?>" type="hidden" /><input name="table" value="<?php if(isset($_GET['account']) && ($_GET['account'] != "")){ echo $_GET['account'];} ?>" type="hidden" /><button type="submit" name="up" class="btn btn-primary" onClick="return check_confirmation();">Delete</button></form> </td>
     <?php } ?>
    </tr>
    <?php 
	if($d == "active"){
    $d = "success";
    }
    else{
    $d ="active";
    }
	?>
  <?php } while ($row_accounts = mysqli_fetch_assoc($accounts)); ?>
  <!-- close query div -->
 
  </tbody>
 </table>
  <?php } else { ?>
  
      <table width="100%" class="table table-striped table-bordered"> 
<thead>
    <tr>
      <th width="44">S/N </th><th width="205"> Customer Name </th><th width="150">Amount (NGN) </th><th width="200">Details </th><th width="100">Tranx ID </th><th width="150">Tranx Date </th>
       <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
     <!-- <th width="107"><i class="glyphicon glyphicon-pencil"></i> Edit</th>--><th width="107"><i class="glyphicon glyphicon-remove"></i> Delete</th>
      <?php } ?>
    </tr>
    </thead>
    <tbody>

<?php 
$counter = 0;
$d="active";
do { ?>
    <tr>
      <td><?php echo ++$counter; ?></td> <td><a href="tranx_customer.php?account_no=<?php echo $row_accounts['account_no']; ?>" title="View Account History"><?php echo $row_accounts['name']; ?></a></td> <td><?php echo number_format($row_accounts['amount']); ?> </td><td><?php echo $row_accounts['tranx_details']; ?> </td> <td><?php echo $row_accounts['tranx_id']; ?> </td><td><?php echo date('d/m/Y', strtotime($row_accounts['date_entered'])); ?>   </td>
 <?php if(isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup'] == "admin")){?>
 
	<!-- <td width="107"><form action="edit_tranx.php" method="get"><input name="s_no" value="<?php // echo $row_accounts['s_no']; ?>" type="hidden" /> <input name="account_no" value="<?php  //echo $row_accounts['account_no']; ?>"  type="hidden" /><button type="submit" name="up" class="btn btn-primary">Update</button></form> </td> -->
      <td width="107"><form action="delete_acct.php" method="get"><input name="s_no" value="<?php echo $row_accounts['s_no']; ?>" type="hidden" /><input name="table" value="<?php if(isset($_GET['account']) && ($_GET['account'] != "")){ echo $_GET['account'];} ?>" type="hidden" /><button type="submit" name="up" class="btn btn-primary" onClick="return check_confirmation();">Delete</button></form> </td>
     <?php } ?>
    </tr>
    <?php 
	if($d == "active"){
    $d = "success";
    }
    else{
    $d ="active";
    }
	?>
  <?php } while ($row_accounts = mysqli_fetch_assoc($accounts)); ?>
  <!-- close query div -->
 
  </tbody>
 </table>
   
  <?php } ?>
</div>
  </div>
  <?php } else{
	  echo "<h3> [ No transactions yet! ] </h3>";} ?>
  
</div><!-- close 3rd row -->
</div><!-- printable div -->

  <iframe name="print_frame" width="0" height="0" frameborder="0" src="about:blank"></iframe>


<br />
<script>
   //setTimeout(popup('popUpDiv'), 5000);
 // setInterval(popup('popUpDiv'), 5000);
    

//function setupRefresh() {         
 //setInterval(
    // $('#refresh').load('refreshDate.php');} , 1000); 
//	popup('popUpDiv'), 1000);
//}

//var int = self.setInterval("showAlertAfter5Seconds()", 5000);


function showAlertAfter5Seconds()
{
	popup('popUpDiv');
  //alert('5 seconds elapsed after the previous alert!!');
}

</script>
 </body>
 
 </html>


<?php  
 mysqli_free_result($accounts);
?>