 <?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">Bitcoin Statement 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">
                            <tr>
                              <th>AMOUNT</th>
        						<th>REF NO</th>
        						<th>COIN</th>
        						<th>SENDER ID</th>
        						<th>RECEIVER ID</th>
        						<th>DATE</th>
        						<th>STATUS</th>
                           
                            </tr>
                            <?php 
				$acc_no = $_SESSION['acc_no'];
				$email = $row['email'];
				$his = $reg_user->runQuery("SELECT * FROM crypto WHERE email = '$email'");
				$his->execute(array(":acc_no"=>$_SESSION['acc_no']));
				while($rows = $his->fetch(PDO::FETCH_ASSOC)){?>
                      <tr>
                       
						<td scope="row"><?php echo $rows['coin_type']; ?> <?php echo $rows['amt']; ?></td>
						<td><?php echo $rows['ref']; ?></td>
						<td>Bitcoin</td>
						<td><?php echo $rows['swallet']; ?></td>
						<td><?php echo $rows['rwallet']; ?></td>
						<td><?php echo $rows['date']; ?></td>
						<td style="color:green"><?php echo $rows['status']; ?></td>
                      </tr>
               <?php } ?>
                         
                          </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('bitcoin_statement.pdf');  
}  
</script> 
 
 
	
       

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