 <?php
session_start();
include_once ('conn/session.php');
require_once 'conn/controller.php';
if(!isset($_SESSION['acc_no'])){
header("Location: auth_login.php");
exit(); 
}

if(isset($_GET['id'])){
	
$id=$_GET['id'];
}

$reg_user = new USER();

$stmt = $reg_user->runQuery("SELECT * FROM account WHERE acc_no=:acc_no");
$stmt->execute(array(":acc_no" => $_SESSION['acc_no']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);



$email = $row['email'];

$temp = $reg_user->runQuery("SELECT * FROM transfer WHERE email = '$email' ");
$temp->execute(array(":acc_no" => $_SESSION['acc_no']));
$rows = $temp->fetch(PDO::FETCH_ASSOC);




 ?>

 
 
  <?php include 'auth_header.php'; ?>	
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.6/jspdf.plugin.autotable.min.js"></script> 
  
				
                                    
           
  
 
 
 <br><br>
 
 
 <div class="container-fluid py-4">
 
  <div class="row">
        <div class="col-12">
          <div class="card my-4">
            <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
              <div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
                <h4 class="text-white text-capitalize ps-3">Account Statement</h4>
               &nbsp; &nbsp;&nbsp;<input type="button" onclick="generate()" class="btn bg-gradient-dark mb-0"  value="Export To PDF" />
              </div>
            </div>
            <div class="card-body px-0 pb-2">
              <div class="table-responsive p-0">
                <table class="table align-items-center mb-0" id="dataexample">
                    
                 
                    
                  <thead>
                                <tr>
                                   <td colspan="7" style="text-align:center;"><h6> BANK ADDRESS: &nbsp;&nbsp; <?php echo $site_address; ?>  </h6></td>  
                               </tr>
                     
                     
                     
                     
                      <tr>
                           <td colspan="7" style="text-align:center;"><h6>ACCOUNT NAME:&nbsp;&nbsp; <?php echo $row['fname']; ?> <?php echo $row['lname']; ?> &nbsp;&nbsp;&nbsp;&nbsp; ACCOUNT NUMBER: &nbsp;&nbsp; <?php echo $row['acc_no']; ?>  </h6></td> 
                         </tr>
                      
                   
                   
                   
                   
                    <tr>	
                      <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Amount</th>
                      <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">Reciever</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Type</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Bank</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Description</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Date/Time</th>
                      <th class="text-secondary opacity-7">Status</th>
                    </tr>
                  </thead>
                  <tbody>
                   
                   
                   <?php 
				$acc_no = $_SESSION['acc_no'];
				$email = $row['email'];
				$his = $reg_user->runQuery("SELECT * FROM transfer WHERE email = '$email'");
				$his->execute(array(":acc_no"=>$_SESSION['acc_no']));
				while($rows = $his->fetch(PDO::FETCH_ASSOC)){?>
                      <tr>
                       
						<td scope="row"><?php echo $row['currency']; ?> <?php echo $rows['amount']; ?></td>
						<td><?php echo $rows['acc_no']; ?> - <?php echo $rows['acc_name']; ?></td>
						<td><?php echo $rows['transtype']; ?></td>
						<td><?php echo $rows['bank_name']; ?></td>
						<td><?php echo $rows['remarks']; ?></td>
						<td><?php echo $rows['routing']; ?></td>
						<td style="color:green;font-size:700;"><?php echo $rows['status']; ?></td>
                      </tr>
               <?php } ?>
                  
                    
                    
          
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
 
 
 
 </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
	
	 <script type="text/javascript"> 
 
 
function generate() {  
    var doc = new jsPDF('p', 'pt', 'letter');  
    var htmlstring = '';  
    var tempVarToCheckPageHeight = 0;  
    var pageHeight = 0;  
    pageHeight = doc.internal.pageSize.height;  
    specialElementHandlers = {  
        // element with id of "bypass" - jQuery style selector  
        '#bypassme': function(element, renderer) {  
            // true = "handled elsewhere, bypass text extraction"  
            return true  
        }  
    };  
    margins = {  
        top: 150,  
        bottom: 60,  
        left: 40,  
        right: 40,  
        width: 600  
    };  
    var y = 20;  
    doc.setLineWidth(2);  
   
    
     doc.text(200, y = y + 30," <?php echo $site_title; ?> Account Statement"); 
 
    doc.autoTable({  
        html: '#dataexample',  
        startY: 70,  
        theme: 'striped',  
        columnStyles: {  
            0: {  
                cellWidth: 30,  
            },  
            1: {  
                cellWidth: 120,  
            },  
            2: {  
                cellWidth: 70,  
            },
            3: {  
                cellWidth: 80,  
            },
            4: {  
                cellWidth: 80,  
            },
            5: {  
                cellWidth: 80,  
            },
            6: {  
                cellWidth: 80,  
            }
       
        },  
        styles: {  
            minCellHeight: 20  
        }  
    })  
    doc.save('account_statement.pdf');  
}  
</script> 
 
 
	
       

 <?php include 'auth_footer.php'; ?>		
	