<?php
session_start();

require('../includes/database.php');

if (isset($_SESSION['username']) && $_SESSION['password'] != "") {
} else {
    header("Location:index.php");
}
$username = $_SESSION['username'];


$username = $_SESSION['username'];
$password = $_SESSION['password'];

$query = "SELECT *
			FROM admin	
			WHERE username = '$username'
			&&   password = '$password'";

$result = mysqli_query($con, $query) or die(mysqli_connect_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
    while ($data = mysqli_fetch_assoc($result)) {

        extract($data);
        include('head.php');

?>

        <body class="theme-blush">

            <!-- Page Loader -->
            <?php
            include('loader.php');
            ?>

            <!-- Overlay For Sidebars -->
            <div class="overlay"></div>

            <!-- Main Search -->
            <div id="search">
                <button id="close" type="button" class="close btn btn-primary btn-icon btn-icon-mini btn-round">x</button>
                <form>
                    <input type="search" value="" placeholder="Search..." />
                    <button type="submit" class="btn btn-primary">Search</button>
                </form>
            </div>

            <?php
            include('right-sidebar.php');
            include('left-side.php');
            ?>

            <!-- Right Sidebar -->
            <?php
            include('settings&pops.php');
            ?>

            <?php
            require('../includes/database.php');
            $user = $_GET['user'];
            $sql = "SELECT * FROM accounts where email = '$user'";
            $cons_list = mysqli_query($con, $sql) or die(mysqli_connect_error());
            if ($row = mysqli_fetch_assoc($cons_list)) {

            ?>
                <section class="content">
                    <div class="body_scroll">
                        <div class="block-header">
                            <div class="row">
                                <div class="col-lg-7 col-md-6 col-sm-12">
                                    <h2>Profile</h2>
                                    <ul class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="dashboard.php"><i class="zmdi zmdi-home"></i> Online Bank</a></li>
                                        <li class="breadcrumb-item">Pages</li>
                                        <li class="breadcrumb-item active">Profile</li>
                                    </ul>
                                    <button style="background:red;" class="btn btn-icon mobile_menu" type="button"><i class="zmdi zmdi-sort-amount-desc"></i></button>
                                </div>
                                <div class="col-lg-5 col-md-6 col-sm-12">
                                    <button style="background:red;" class="btn btn-icon float-right right_icon_toggle_btn" type="button"><i class="zmdi zmdi-arrow-right"></i></button>
                                </div>
                            </div>
                        </div>
                        <div class="container-fluid">
                            <div style="margin:auto;" class="row">
                                <div class="col-lg-4 col-sm-12 col-md-6">
                                    <div class="card mcard_3">
                                        <div class="body">
                                            <a href="#"><img class="rounded-circle shadow " width="100" height="100" alt="profile-image" <?php if ($row['passport'] != "") { ?> src="../my-account/uploads/profile-pic/<?php echo $row['passport'] ?>">
                                            <?php } else { ?> src='user.jpg'>
                                            <?php } ?>
                                            </a>
                                            <h4 class="m-t-10"><?php echo $row['fname'] . " " . $row['mname'] . " " . $row['lname']; ?></h4>
                                            <div class="col-12 m-t-10">
                                                <ul class="social-links list-unstyled">
                                                    <?php $user = ($row['email']); ?>
                                                    <a style="border-radius:10px; background-color:red;" href="profile-edit.php?user=<?php echo $user ?>" class="btn"><strong><i class="zmdi zmdi-edit"></i> Edit Profile</strong></a>
                                                </ul>
                                                <p class="text-muted"><?php echo $row['address']; ?></p>
                                            </div>

                                            <?php $account_activation = ($row['account_activation']);
                                            if ($account_activation == 0) {
                                            ?>
                                                <form action="../bank-manager.php?action=activity-on" method="post">
                                                    <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                    <input style="background:blue;" type="submit" value="Activate Account" class="btn-xs btn-danger form-control">
                                                </form>
                                            <?php } else {
                                            ?>
                                                <form action="../bank-manager.php?action=activity-off" method="post">
                                                    <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                    <input style="background:red;" type="submit" value="Deactivate Account" class="btn-xs btn-danger form-control">
                                                </form>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-8 col-sm-12 col-md-6">
                                    <div class="card">
                                        <div class="body">
                                            <div class="row">
                                                <div class="col-lg-6 col-sm-12">
                                                    <small class="text-muted">Email address: </small>
                                                    <p><strong><?php echo $row['email']; ?></strong></p>
                                                </div>
                                                <div class="col-lg-3 col-sm-12">
                                                    <small class="text-muted">Account Number: </small>
                                                    <p><strong><?php echo $row['account_number']; ?></strong></p>
                                                </div>
                                                <div class="col-lg-3 col-sm-12">
                                                    <small class="text-muted">Current Balance: </small>
                                                    <p><strong><?php echo $row['currency'] . " " . number_format($row['balance'], 2) ?></strong></p>
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="row">
                                                <div class="col-lg-4 col-sm-12">
                                                    <small class="text-muted">Phone: </small>
                                                    <p><strong><?php echo $row['phone'] ?></strong></p>
                                                </div>
                                                <div class="col-lg-4 col-sm-12">
                                                    <small class="text-muted">Account Type: </small>
                                                    <p><strong><?php echo $row['acc_type']; ?></strong></p>
                                                </div>
                                               
                                                <div class="col-lg-4 col-sm-12">
                                                    <small class="text-muted">Username: </small>
                                                    <p><strong><?php echo $row['username']; ?></strong></p>
                                                </div>

                                                <a style="border-radius:10px; background-color:green;" href="addpassport.php?user=<?php echo $user ?>" class="btn"><strong><i class="zmdi zmdi-upload"></i>Upload A Recent Passport</strong></a>

                                            </div>
                                            <hr>
                                            <ul class="list-unstyled">
                                                <div row>
                                                    <div class="col-lg-12 col-sm-12">
                                                        <table class="table table-bordered">
                                                            <thead>
                                                                <tr>
                                                                    <th scope="col" width="30%">Code Name</th>
                                                                    <th scope="col"> <a href="edit-tfcode.php?user=<?php echo $user ?>" style="float: right" class="btn btn-warning">Edit Transfer Codes</a>
                                                                    </th>
                                                                    <th scope="col" width="30%">Send Code</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <tr>
                                                                    <th scope="row">IMF CODE</th>
                                                                    <td><?php echo $row['imf_code']; ?></td>
                                                                    <td>
                                                                         <form action="../bank-manager.php?action=send-code" method="POST">
                                                                            <input type="hidden" name="fullname" value="<?php echo $row['fname'] . " " . $row['mname'] . " " . $row['lname']; ?>">
                                                                            <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                                            <input type="hidden" name="type" value="IMF">
                                                                            <input type="hidden" name="code" value="<?php echo $row['imf_code']; ?>">
                                                                            <input type="hidden" name="account_number" value="<?php echo $row['account_number']; ?>">
                                                                            <button class="btn btn-primary" type="submit"><i class="zmdi zmdi-email"></i> Send IMF</button>
                                                                        </form>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <th scope="row">IRS CODE</th>
                                                                    <td><?php echo $row['irs_code']; ?></td>
                                                                    <td>
                                                                        <form action="../bank-manager.php?action=send-code" method="POST">
                                                                            <input type="hidden" name="fullname" value="<?php echo $row['fname'] . " " . $row['mname'] . " " . $row['lname']; ?>">
                                                                            <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                                            <input type="hidden" name="type" value="IRS">
                                                                            <input type="hidden" name="code" value="<?php echo $row['irs_code']; ?>">
                                                                            <input type="hidden" name="account_number" value="<?php  echo $row['account_number']; ?>">
                                                                            <button class="btn btn-success" type="submit"><i class="zmdi zmdi-email"></i> Send IRS</button>
                                                                        </form>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <th scope="row">TAX CODE</th>
                                                                    <td><?php echo $row['tax_code']; ?></td>
                                                                     <td>
                                                                        <form action="../bank-manager.php?action=send-code" method="POST">
                                                                            <input type="hidden" name="fullname" value="<?php echo $row['fname'] . " " . $row['mname'] . " " . $row['lname']; ?>">
                                                                            <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                                            <input type="hidden" name="type" value="TAX">
                                                                            <input type="hidden" name="code" value="<?php echo $row['tax_code']; ?>">
                                                                            <input type="hidden" name="account_number" value="<?php echo $row['account_number']; ?>">
                                                                            <button class="btn btn-danger" type="submit"><i class="zmdi zmdi-email"></i> Send TAX</button>
                                                                        </form>
                                                                     </td>
                                                                </tr>
                                                                <tr>
                                                                    <th scope="row">AML CODE</th>
                                                                    <td><?php echo $row['aml_code']; ?></td>
                                                                    <td>
                                                                         <form action="../bank-manager.php?action=send-code" method="POST">
                                                                            <input type="hidden" name="fullname" value="<?php echo $row['fname'] . " " . $row['mname'] . " " . $row['lname']; ?>">
                                                                            <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                                                                            <input type="hidden" name="type" value="AML">
                                                                            <input type="hidden" name="code" value="<?php echo $row['aml_code']; ?>">
                                                                            <input type="hidden" name="account_number" value="<?php echo $row['account_number']; ?>">
                                                                            <button class="btn btn-secondary" type="submit"><i class="zmdi zmdi-email"></i> Send AML</button>
                                                                        </form>
                                                                    </td>
                                                                </tr>
                                                                
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </ul>
                                            <ul class="social-links list-unstyled">

                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </section>
    <?php include('footer.php');
            }
        }
    } ?>