<?php
define('INCLUDE_CHECK',true);
session_start();
require ('classes/config2.php');
require('includes/initialize.php');

global $database;

if($_SESSION['txn_ref']=="") {
		//header("location: index.php?action=payment_processing");	
	}
	
	 $sql = ("SELECT * FROM tranzact_t WHERE txn_ref='$_SESSION[txn_ref]' AND responsecode='00' LIMIT 1");			
	  $result = $database->query($sql);
	 	//	while($srows = mysql_fetch_array($sql)){
			while($row = $result->fetch_assoc()) {
				$fullname = $row['surname']. " " . $row['othername'] ; 
				$courses = $row['department'];
				$phone = $row['phone'];
				$level = $row['level'];
				$fno = $row['fno'];
				$total_amt = preg_replace("/\.?0*$/",'',$row['amount']);
				$txn_ref = $row['txn_ref'];
				$txn_date = $row['date_time'];
				$session = $row['session'];
				
			}
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Osun State College of Technology, Esa-Oke | College Web Payment Notification Receipt</title>
    <link rel="stylesheet" href="css/style.css" />
</head>

<body>
    <div class="ncontainer">
        <div class="nheader">
        	<div class="lefth">
        		<img src="images/logo.png" width="300px" alt="Logo" /><br>
          	</div>
            <div class="righth">
            	<img src="images/PoweredByInterswitchLogoAndVerve.jpg" width="250px" alt="Interswitch"/>
                <br>
            	<h4><center>Txn No: <?php echo $txn_ref; ?></center></h4> 
            </div>
        </div><!-- header -->
        <br><br><br><br>
        <h1 class="main_title"><center>Payment Notification Receipt</center></h1>
        <div class="content">
        	 <div class="row">
                <div class="col-sm-12">
                	<table class="table table-bordered">
                	<thead align="center" class="table-bordered text-center bg-success">
                    <tr>
                    	<th>Student Info</th>
                    	<th>Payment Mode</th>
                        <th>Session</th>
                        <th>Paid On</th>
                   	</thead>
                    	<tr>
                        	<td align="left" width="290px">
                            	<?php echo $fno . " - " . $fullname; ?><br>
                                <?php echo $level . " - " . $courses; ?><br>
                            </td>
                            <td width="110px">Online WebPay</td>
                            <td><?php echo $session; ?><br></td>
                            <td><?php echo $txn_date; ?></td>
                        </tr>
                    </table>
                </div>
                
                <div class=" col-sm-12">
                <table class="table table-bordered">
                	<thead align="center" class="table-bordered bg-success text-uppercase">
                    <tr>
                    	<th width="10">S/N</th>
                        <th align="center">Payment Item Description</th>
                        <th align="center">Amount (<strike>N</strike>)</th>
                   	</thead>
                    <?php
			  		$sql=("SELECT * FROM tranzact_t_items WHERE txn_ref='{$_SESSION['txn_ref']}'");
					$res = $conn->query($sql);
					$i=0;
				//	while($rowt=mysql_fetch_array($sql)){
					     while($row = $res->fetch_assoc()) {
					    
						$fees_description =$row['fees_description'];
						$amountt = preg_replace("/\.?0*$/",'',$row['amount']);
					$i++;
				?>
                    	<tr>
                            <td><?php echo $i; ?></td>
                            <td align="left"><?php echo $fees_description; ?></td>
                            <td align="right"><?php echo number_format($amountt,2); ?></td>
                        </tr>
                        <?php	
							}														
							?>
                        <tr>
                            <td colspan="2" align="right"><strong>TOTAL</strong></td>
                            <td align="right"><strong><?php echo number_format($total_amt,2); ?></strong></td>
                        </tr>
                    </table>
                    <p><em>* Please print for your records</em></p>
            	</div>
        	</div>
        </div><!-- content -->    
		<div class="footer">
            Powered by: <a href="#">OSCOTECH ICT Directorate</a>
        </div><!-- footer -->
    </div><!-- container -->
<script src="css/jquery-1.10.2.js"></script>
<script src="css/bootstrap.min.js"></script>
</body>
</html>
        	