<?php
session_start();
$user = "educateb_bof-engla";
$pass = "bof-engla.com";
$dbname = "educateb_bof-engla";
$conn = mysqli_connect("localhost", $user, $pass, $dbname);
$sql = "SELECT * FROM site_details";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $email = $row["email"];
            $sitename = $row["site_name"];
            $location = $row["location"];
            $phone = $row["phone"];
            $routing = $row['routing'];
            $swift = $row['swift'];
        }
}


if (!isset($_SESSION["online_id"])){
    header("Location: login.php");
}
else{
    $online_id = $_SESSION["online_id"];
    $sql = "SELECT online_id, status FROM accounts WHERE online_id='$online_id'";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $chk_id = $row["online_id"];
            $status = $row["status"];
        }
        
    }
    
    $online_id = $_SESSION["online_id"];
    $conn = mysqli_connect("localhost", $user, $pass, $dbname);
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    $sql = "SELECT * FROM accounts WHERE online_id='$online_id'";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $online_id = $row["online_id"];
            $balance = $row["balance"];
            $reg_firstname = $row["reg_firstname"];
            $reg_middlename = $row["reg_middlename"];
            $reg_lastname = $row["reg_lastname"];
            $reg_acc_type = $row["reg_acc_type"];
            $account_no = $row["account_no"];
            $reg_phone1 = $row["reg_phone1"];
            $passport = $row["passport"];
            $reg_nos_firstname = $row["reg_nos_firstname"];
            $reg_nos_middlename = $row["reg_nos_middlename"];
            $reg_nos_lastname = $row["reg_nos_lastname"];
            $reg_suffix = $row["reg_suffix"];
            $reg_dob = $row["reg_dob"];
            $reg_src_income = $row["reg_src_income"];
            $reg_address1 = $row["reg_address1"];
            $reg_city = $row["reg_city"];
            $reg_state = $row["reg_state"];
            $reg_zip = $row["reg_zip"];
            $reg_country = $row["reg_country"];
            $reg_email = $row["reg_email"];
            $reg_nos_address = $row["reg_nos_address"];
            $reg_nos_rel = $row["reg_nos_rel"];
            $reg_nos_phone = $row["reg_nos_phone"];
        }
    }
    
    $content .= "<h4>Recent Activities</h4><table  class='table table-striped text-success1' style=''>
    				
    					<tr class='w3-text-theme'>
    						<!-- <th>S/no</th> -->
    						<th>Transaction Type</th>
    						<th>Description</th>
    						<th>Amount</th>
    						<th>Date</th>
    						<th>Time</th>
    					</tr>";
    $sql = "SELECT * FROM transactions WHERE online_id='$online_id' ORDER BY tid DESC LIMIT 5";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        
        while($row = mysqli_fetch_assoc($result)) {
            $tranfer_type = $row['transfer_type'];
            $description = $row['description'];
            $amount = $row['amount'];
            $mamount = number_format($amount,2);
            $date = $row['date'];
            $time = $row['time'];
	        $content .= "<tr class=''>
	        
            <td> $tranfer_type </td>
			<td> $description </td>
			<td> GBP".$mamount." </td>
			<td> $date </td>
			<td> $time </td>

    		</tr>";
	    }
	    $content .= "</table>";
   }
   else{
       $content = "<h4 style=';' class='text-success1'>No Transactoions Available</h4>";
   }
   $mcontent ="<div class=\"container text-dark \" id=\"London1\" style=\"\">
            <div class=\"p-2\" style=\"\"><h4 class='text-success1'>Account Summary</h4></div>
            <table class=\"table table-striped\" style=\"\" >

                
                <tr>
                    <td>Name</td>
                    <td>$reg_firstname $reg_middlename $reg_lastname</td>
                </tr>

                <tr>
                    <td>Account Type</td>
                    <td>$reg_acc_type</td>
                </tr>                       

                <tr>
                    <td>Account Number</td>
                    <td>$account_no</td>
                </tr>

                <tr>
                    <td>Account Balance</td>
                    <td>GBP".number_format($balance,2)."</td>
                </tr>

                <tr>
                    <td>Phone Number</td>
                    <td>$reg_phone1</td>
                </tr>

                <tr>
                    <td>Online ID</td>
                    <td>$online_id</td>
                </tr>

                <tr>
                    <td>Routing Number</td>
                    <td>$routing</td>
                </tr>
                
                <tr>
                    <td>Swift Code</td>
                    <td>$swift</td>
                </tr>
            </table>
        </div>";
}
?>
<?php
include("accountheader.php");
?>
<div class="header-bg" style="width:100%;overflow:hidden">
    <div class="row">
        <div class="col-sm-3 mob2 shadow bg-light" style="">
            <?php
            include("accountsidebar.php");
            ?>
        </div>
        <div class="col-sm-9 pb-5" style="padding:0px;margin:0px">
            <?php
            include("dashhome.php");
            ?>
            
            <div class="container mt-5">
                <div class="">
                    <? echo $mcontent; ?>
                </div>
            </div>
            <div class="container mt-5">
                <div class="" style="overflow:scroll">
                    <? echo $content; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $(".nav-tabs a").click(function(){
            $(this).tab('show');
            });
    });
</script>
<?php
include("footer1.php");
?>