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


$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' ORDER BY id DESC LIMIT 3");
$temp->execute(array(":acc_no" => $_SESSION['acc_no']));
$rows = $temp->fetch(PDO::FETCH_ASSOC);


?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Customer Dashboard - Skyutah Capitals</title>
            
            <?php include 'header.php';?>

                <main>
                    <div class="vd jd tto vv oq ar ri">
                        <!-- Page header -->
                        <div class="_y js jn id">
                            
                            <!-- Left: Title -->
                            <div class="rw _a">
                                <h1 class="gg zj text-slate-800 font-bold"><?php echo $row['type']; ?> Account ✨</h1>
                            </div>
                            <?php
                                if (isset($_GET['dormant'])) {
                                    ?>
                                     <!-- Start -->
                                        <div x-show="open" x-data="{ open: true }">
                                            <div class="vd vg rounded-sm text-sm pr yo">
                                                <div class="flex oq fg fd">
                                                    <div class="flex">
                                                        <svg class="ue on ap db bp if rk" viewBox="0 0 16 16">
                                                            <path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm3.5 10.1l-1.4 1.4L8 9.4l-2.1 2.1-1.4-1.4L6.6 8 4.5 5.9l1.4-1.4L8 6.6l2.1-2.1 1.4 1.4L9.4 8l2.1 2.1z"></path>
                                                        </svg>
                                                        <div class="gk">Sorry, your account is DORMANT/INACTIVE, please contact customer care</div>
                                                    </div>
                                                    <button class="bd ke ml-3 if" @click="open = false">
                                                        <div class="tc">Close</div>
                                                        <svg class="ue on db">
                                                            <path
                                                                d="M7.95 6.536l4.242-4.243a1 1 0 111.415 1.414L9.364 7.95l4.243 4.242a1 1 0 11-1.415 1.415L7.95 9.364l-4.243 4.243a1 1 0 01-1.414-1.415L6.536 7.95 2.293 3.707a1 1 0 011.414-1.414L7.95 6.536z"
                                                            ></path>
                                                        </svg>
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End -->
                                    <?php
                                }
                                ?>
                                
                                <?php
                                if (isset($_GET['hold'])) {
                                    ?>
                                     <!-- Start -->
                                        <div x-show="open" x-data="{ open: true }">
                                            <div class="vd vg rounded-sm text-sm pr yo">
                                                <div class="flex oq fg fd">
                                                    <div class="flex">
                                                        <svg class="ue on ap db bp if rk" viewBox="0 0 16 16">
                                                            <path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm3.5 10.1l-1.4 1.4L8 9.4l-2.1 2.1-1.4-1.4L6.6 8 4.5 5.9l1.4-1.4L8 6.6l2.1-2.1 1.4 1.4L9.4 8l2.1 2.1z"></path>
                                                        </svg>
                                                        <div class="gk">Sorry, your account is ON HOLD Please Contact Customer care</div>
                                                    </div>
                                                    <button class="bd ke ml-3 if" @click="open = false">
                                                        <div class="tc">Close</div>
                                                        <svg class="ue on db">
                                                            <path
                                                                d="M7.95 6.536l4.242-4.243a1 1 0 111.415 1.414L9.364 7.95l4.243 4.242a1 1 0 11-1.415 1.415L7.95 9.364l-4.243 4.243a1 1 0 01-1.414-1.415L6.536 7.95 2.293 3.707a1 1 0 011.414-1.414L7.95 6.536z"
                                                            ></path>
                                                        </svg>
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- End -->
                                    <?php
                                }
                                ?>
                        </div>

                        <!-- Cards -->
                        <div class="sq ff fb">
                            <!-- Page Intro -->
                            <div class="flex fh nk bg-white by rounded-sm border border-slate-200">
                            
                            <div class="td py va jp rounded-sm lq ry">
                            <div class="tp tw tk sk s_ pointer-events-none hidden tnn" aria-hidden="true">
                                <svg width="319" height="198" xmlns:xlink="http://www.w3.org/1999/xlink">
                                    <defs>
                                        <path id="welcome-a" d="M64 0l64 128-64-20-64 20z"></path>
                                        <path id="welcome-e" d="M40 0l40 80-40-12.5L0 80z"></path>
                                        <path id="welcome-g" d="M40 0l40 80-40-12.5L0 80z"></path>
                                        <linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="welcome-b">
                                            <stop stop-color="#A5B4FC" offset="0%"></stop>
                                            <stop stop-color="#818CF8" offset="100%"></stop>
                                        </linearGradient>
                                        <linearGradient x1="50%" y1="24.537%" x2="50%" y2="100%" id="welcome-c">
                                            <stop stop-color="#4338CA" offset="0%"></stop>
                                            <stop stop-color="#6366F1" stop-opacity="0" offset="100%"></stop>
                                        </linearGradient>
                                    </defs>
                                    <g fill="none" fill-rule="evenodd">
                                        <g transform="rotate(64 36.592 105.604)">
                                            <mask id="welcome-d" fill="#fff"><use xlink:href="#welcome-a"></use></mask>
                                            <use fill="url(#welcome-b)" xlink:href="#welcome-a"></use>
                                            <path fill="url(#welcome-c)" mask="url(#welcome-d)" d="M64-24h80v152H64z"></path>
                                        </g>
                                        <g transform="rotate(-51 91.324 -105.372)">
                                            <mask id="welcome-f" fill="#fff"><use xlink:href="#welcome-e"></use></mask>
                                            <use fill="url(#welcome-b)" xlink:href="#welcome-e"></use>
                                            <path fill="url(#welcome-c)" mask="url(#welcome-f)" d="M40.333-15.147h50v95h-50z"></path>
                                        </g>
                                        <g transform="rotate(44 61.546 392.623)">
                                            <mask id="welcome-h" fill="#fff"><use xlink:href="#welcome-g"></use></mask>
                                            <use fill="url(#welcome-b)" xlink:href="#welcome-g"></use>
                                            <path fill="url(#welcome-c)" mask="url(#welcome-h)" d="M40.333-15.147h50v95h-50z"></path>
                                        </g>
                                    </g>
                                </svg>
                            </div>
                            <div class="td">
                                <h1 class="gg zj text-slate-800 font-bold rx">Welcome, <?php echo $row['fname']; ?> <?php echo $row['lname']; ?>. 👋</h1>
                                <p>Tips: Change your Internet banking Password Frequently to keep your Account Safe</p>
                            </div>
                        </div>

                                <div class="mn mu">
                                    <div class="qd zo zr">
                                        <div class="flex items-center rw qf">
                                            <div class="mr-4"><img class="inline-flex rounded-full" src="admin/pic/<?php echo $row['uname']; ?>.jpg" width="64" height="64" alt="User" /></div>
                                            <div>
                                                <div class="in">Hey <strong class="gk text-slate-800"><?php echo $row['fname']; ?> </strong> 👋, your account is</div>
                                                <div class="text-3xl font-bold yg"><?php echo $row['status']; ?></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="flex fh nk bg-white by rounded-sm border border-slate-200">
                            <div x-show="open" x-data="{ open: true }">
                                            <div class="vd vg rounded-sm text-sm pi border hs text-indigo-500">
                                                <div class="flex oq fg fd">
                                                    <div class="flex">
                                                        <svg class="ue on ap db bp if rk" viewBox="0 0 16 16">
                                                            <path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm1 12H7V7h2v5zM8 6c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z"></path>
                                                        </svg>
                                                        <div><marquee>Notice: We are committed to providing a secured and convenient banking experience to all our customers through excellent services powered by state of the art technologies, however, if you notice anything <span style="color:orange;">SUSPICIOUS</span> with your online banking portal, kindly contact your account manager for immediate action <span style="color:WHITE" ;="">|</span> Thank you for banking with us! </marquee></div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                            <!-- Line chart (Acme Plus) -->
                            <div class="flex fh nk _s ttk bg-white by rounded-sm border border-slate-200">
                                <div class="mn gn">
                                    <header class="flex fg fd in">
                                        <img src="images/icon-01.svg" width="32" height="32" alt="Icon 01" />
                                        
                                    </header>
                                    <h2 class="gx g_ text-slate-800 in">Available Balance</h2>
                                    <div class="gb g_ yu gq rx">Account Number: <?php echo $row['acc_no']; ?></div>
                                    <div class="flex fd">
                                        <div class="text-3xl font-bold text-slate-800 mr-2"><?php echo $row['currency']; ?> <?php echo $english_format_number = number_format( $row['a_bal'] , 2, '.', ','); ?></div>
                                    </div>
                                </div>
                                <div class="ad"><canvas id="dashboard-card-01" width="389" height="100"></canvas></div>
                            </div>
                            <!-- Line chart (Acme Advanced) -->
                            <div class="flex fh nk _s ttk bg-white by rounded-sm border border-slate-200">
                                <div class="mn gn">
                                    <header class="flex fg fd in">
                                        <img src="images/icon-02.svg" width="32" height="32" alt="Icon 02" />
                                    </header>
                                    <h2 class="gx g_ text-slate-800 in">Total Book Balance</h2>
                                    <div class="gb g_ yu gq rx">As At <?php echo " " .$today = date("F j, Y"); ; ?></div>
                                    <div class="flex fd">
                                        <div class="text-3xl font-bold text-slate-800 mr-2"><?php echo $row['currency']; ?> <?php echo  $english_format_number = number_format( $row['t_bal'] , 2, '.', ','); ?></div>
                                    </div>
                                </div>
                                <div class="ad"><canvas id="dashboard-card-03" width="389" height="100"></canvas></div>
                            </div>
                            <!-- Credit Card -->
                            <div class="flex fh nk ttk pj du dm by rounded-sm border hd">
                                <header class="mn mr cx hv flex items-center"><h2 class="g_ ya">Cards</h2></header>
                                <div class="or flex fh mn mu">
                                    <div class="td oq as ri pa vf cf">
                                        <div class="td sz p_ pz dy vl ca lq">
                                            <div class="tp tb nf uw oe" aria-hidden="true">
                                                <svg class="oq or" width="398" height="392" viewBox="0 0 398 392" xmlns="http://www.w3.org/2000/svg">
                                                    <defs>
                                                        <filter x="-88.2%" y="-88.2%" width="276.5%" height="276.5%" filterUnits="objectBoundingBox" id="glow-a"><feGaussianBlur stdDeviation="50" in="SourceGraphic"></feGaussianBlur></filter>
                                                    </defs>
                                                    <circle class="ve bg" filter="url(#glow-a)" cx="85" cy="85" r="85" transform="translate(0 216)"></circle>
                                                </svg>
                                            </div>
                                            <div class="tp tw nl uw oe" aria-hidden="true">
                                                <svg class="oq or" width="398" height="392" viewBox="0 0 398 392" xmlns="http://www.w3.org/2000/svg">
                                                    <defs>
                                                        <filter x="-88.2%" y="-88.2%" width="276.5%" height="276.5%" filterUnits="objectBoundingBox" id="glow-b"><feGaussianBlur stdDeviation="50" in="SourceGraphic"></feGaussianBlur></filter>
                                                    </defs>
                                                    <circle class="vt bg" filter="url(#glow-b)" cx="85" cy="85" r="85" transform="translate(228 0)"></circle>
                                                </svg>
                                            </div>
                                            <div class="td or flex fh fg">
                                                <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                                                    <defs>
                                                        <linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="icon1-b">
                                                            <stop stop-color="#A5B4FC" offset="0%"></stop>
                                                            <stop stop-color="#E0E7FF" offset="100%"></stop>
                                                        </linearGradient>
                                                        <linearGradient x1="50%" y1="24.537%" x2="50%" y2="100%" id="icon1-c">
                                                            <stop stop-color="#4338CA" offset="0%"></stop>
                                                            <stop stop-color="#6366F1" stop-opacity="0" offset="100%"></stop>
                                                        </linearGradient>
                                                        <path id="icon1-a" d="M16 0l16 32-16-5-16 5z"></path>
                                                    </defs>
                                                    <g transform="rotate(90 16 16)" fill="none" fill-rule="evenodd">
                                                        <mask id="icon1-d" fill="#fff"><use xlink:href="#icon1-a"></use></mask>
                                                        <use fill="url(#icon1-b)" xlink:href="#icon1-a"></use>
                                                        <path fill="url(#icon1-c)" mask="url(#icon1-d)" d="M16-6h20v38H16z"></path>
                                                    </g>
                                                </svg>
                                                <div class="flex fg gx font-bold ya yi bz"><span>****</span> <span>****</span> <span>****</span> <span>7328</span></div>
                                                <div class="td flex fg items-center nv ib">
                                                    <div class="text-sm font-bold ya yi bz lu"><span>EXP **/**</span> <span>CVC ***</span></div>
                                                </div>
                                                <svg class="tp ty tw" width="48" height="28" viewBox="0 0 48 28">
                                                    <circle fill="#F59E0B" cx="34" cy="14" r="14" fill-opacity=".8"></circle>
                                                    <circle fill="#F43F5E" cx="14" cy="14" r="14" fill-opacity=".8"></circle>
                                                </svg>
                                            </div>
                                        </div>
                                        
                                    </div>
                                    <div class="ad flex fh justify-center im">
                                        <div class="gb text-slate-500 g_ gq it">Details</div>
                                        <div class="li">
                                            <div>
                                                <div class="flex fg text-sm in">
                                                    <div class="yv">Payment Limits</div>
                                                    <div class="yu gz"><span class="text-slate-500"></span> <?php echo $row['currency']; ?>1,500.00</div>
                                                </div>
                                                <div class="td oq h-2 pd"><div class="tp tm hk" aria-hidden="true" style="width: 100%;"></div></div>
                                            </div>
                                            <div>
                                                <div class="flex fg text-sm in">
                                                    <div class="yv">ATM Limits</div>
                                                    <div class="yu gz"><span class="text-slate-500"></span> <?php echo $row['currency']; ?>1,000.00</div>
                                                </div>
                                                <div class="td oq h-2 pd"><div class="tp tm hk" aria-hidden="true" style="width: 100%;"></div></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--  Line chart (Active Users Right Now) -->
                            <div class="nk ttx bg-white by rounded-sm border border-slate-200">
                                <header class="mn mr cx hp"><h2 class="g_ text-slate-800">Logged In From</h2></header>
                                <div class="flex fh or">
                                    <div class="mn vm">
                                        <div class="flex items-center">
                                            <div class="td flex items-center justify-center ue on rounded-full pt rk" aria-hidden="true"><div class="tp ub ob rounded-full pr"></div></div>
                                            <div>
                                                <div class="text-3xl font-bold text-slate-800 mr-2"><?PHP

function getUserIP()
{
    // Get real visitor IP behind CloudFlare network
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
              $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
              $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }

    return $ip;
}


$user_ip = getUserIP();

echo $user_ip; // Output IP address [Ex: 177.87.193.134]


?></div>
                                                <div class="text-sm text-slate-500">IP Address</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div><canvas id="analytics-card-02" width="389" height="70"></canvas></div>
                                    <div class="ad mn gi mx">
                                        <div class="lz">
                                            <table class="av oq">
                                                <thead class="gb gq yu">
                                                    <tr>
                                                        <th class="vg"><div class="g_ gh">Country</div></th>
                                                    </tr>
                                                </thead>
                                                <tbody class="text-sm lg lw">
                                                    <tr>
                                                        <td class="vg"><div class="gh">
<?php

$ip = $_SERVER['REMOTE_ADDR'];

// Use JSON encoded string and converts
// it into a PHP variable
$ipdat = @json_decode(file_get_contents(
    "http://www.geoplugin.net/json.gp?ip=".$ip));

echo '' . $ipdat->geoplugin_countryName . "\n";
?>
</div></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="gd mn mj"><a class="text-sm gk text-indigo-500 xd" href="#0">Real-Time Report -&gt;</a></div>
                                </div>
                            </div>
                            <!-- Table (Recent Earnings) -->
                            <div class="nk ttx bg-white by rounded-sm border border-slate-200">
                                <header class="mn mr cx hp"><h2 class="g_ text-slate-800">Recent Transfers</h2></header>
                                <div class="vf">
                                    <div class="lz">
                                        <table class="av oq">
                                            <thead class="gb gq yu hq rounded-sm">
                                                <tr>
                                                    <th class="vc co"><div class="g_ gh">Beneficiary Bank/Account</div></th>
                                                    <th class="vc co"><div class="g_ gh">Amount</div></th>
                                                    <th class="vc co"><div class="g_ gh">Status</div></th>
                                                    <th class="vc co"><div class="g_ gd">Date/Time</div></th>
                                                </tr>
                                            </thead>
                                            <tbody class="text-sm lg lw">
                                                <tr>
                                                    <td class="vc co">
                                                        <div class="flex items-center">
                                                            <div class="ap rounded-full mr-2 _f hx">
                                                                <svg class="uo oa db y_" viewBox="0 0 36 36"><path d="M18 26a8 8 0 1 1 8-8 8.009 8.009 0 0 1-8 8Zm0-14a6 6 0 1 0 0 12 6 6 0 0 0 0-12Z"></path></svg>
                                                            </div>
                                                            <div class="gk text-slate-800"><?php echo $rows['bank_name']; ?><br> <?php echo $rows['acc_no']; ?></div>
                                                        </div>
                                                    </td>
                                                    <td class="vc co"><div class="gk yg gd"><?php echo $row['currency']; ?> <?php echo $rows['amount']; ?></div></td>
                                                    <td class="vc co"><div><?php echo $rows['status']; ?></div></td>
                                                    <td class="vc co"><div><?php echo $rows['date']; ?></div></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="gp ck hp v_"><a class="block text-sm gk text-indigo-500 xd mw mx" href="statement.php">View More -&gt;</a></div>
                                </div>
                            </div>



                            <!-- Table (Top Products) -->
                            <div class="nk bg-white by rounded-sm border border-slate-200">
                                <header class="mn mr cx hp"><h2 class="g_ text-slate-800">Your Financial Statement</h2></header>
                                <div class="vf">
                                    <div class="lz">
                                        <table class="av oq">
                                            <thead class="gb gq yu hq rounded-sm">
                                                <tr>
                                                    <th class="vc co"><div class="g_ gh">Transaction Type</div></th>
                                                    <th class="vc co"><div class="g_ gh">Amount</div></th>
                                                    <th class="vc co"><div class="g_ gh">Beneficiary/Sender</div></th>
                                                    <th class="vc co"><div class="g_ gp">Description</div></th>
                                                    <th class="vc co"><div class="g_ gp">Date/Time</div></th>
                                                    <th class="vc co"><div class="g_ gp">Status</div></th>
                                                </tr>
                                            </thead>
                                            <?php 
                $acc_no = $_SESSION['acc_no'];
                $debcre = $reg_user->runQuery("SELECT * FROM alerts WHERE uname = '$acc_no' ORDER BY id DESC LIMIT 3 ");
                $debcre->execute();
                while($rows = $debcre->fetch(PDO::FETCH_ASSOC)){?>
                                            <tbody class="text-sm lg lw">
                                                <tr>
                                                    <td class="vc co">
                                                        <div class="flex items-center">
                                                            <div class="ap rounded-full mr-2 _f hk">
                                                                <svg class="uo oa db yc" viewBox="0 0 36 36">
                                                                    <path
                                                                        d="M11 22.012a1 1 0 01-.707-1.707l4.5-4.5a1 1 0 011.414 0l3.293 3.293 4.793-4.793a1 1 0 111.414 1.414l-5.5 5.5a1 1 0 01-1.414 0L15.5 17.926l-3.793 3.793a1 1 0 01-.707.293z"
                                                                    ></path>
                                                                </svg>
                                                            </div>
                                                            <div class="gk text-slate-800"><?php echo $rows['type']; ?></div>
                                                        </div>
                                                    </td>
                                                    <td class="vc co"><div class="gh gk yg"><?php echo $row['currency']; ?> <?php echo $rows['amount']; ?></div></td>
                                                    <td class="vc co">
                                                        <div class="flex items-center">
                                                            <svg class="ue on ap db yu mr-2 text-indigo-400" :class="settingsPanel === 'account' &amp;&amp; 'text-indigo-400'" viewBox="0 0 16 16"> <path d="M12.311 9.527c-1.161-.393-1.85-.825-2.143-1.175A3.991 3.991 0 0012 5V4c0-2.206-1.794-4-4-4S4 1.794 4 4v1c0 1.406.732 2.639 1.832 3.352-.292.35-.981.782-2.142 1.175A3.942 3.942 0 001 13.26V16h14v-2.74c0-1.69-1.081-3.19-2.689-3.733zM6 4c0-1.103.897-2 2-2s2 .897 2 2v1c0 1.103-.897 2-2 2s-2-.897-2-2V4zm7 10H3v-.74c0-.831.534-1.569 1.33-1.838 1.845-.624 3-1.436 3.452-2.422h.436c.452.986 1.607 1.798 3.453 2.422A1.943 1.943 0 0113 13.26V14z"></path> </svg>
                                                            <div><?php echo $rows['sender_name']; ?></div>
                                                        </div>
                                                    </td>
                                                    <td class="vc co"><div class="gp"><?php echo $rows['remarks']; ?></div></td>
                                                    <td class="vc co"><div class="gx gp"><?php echo $rows['date']; ?> &nbsp;<?php echo $rows['time']; ?></div></td>
                                                    <td class="vc co"><div class="gp"><?php echo $rows['statz']; ?></div></td>
                                                </tr>
                                            </tbody>
                                            <?php } ?>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </main>
            </div>
        </div>

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