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

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

$email = $row['email'];

$temp = $reg_user->runQuery("SELECT * FROM transfer WHERE email = '$email' ORDER BY id DESC LIMIT 1");
$temp->execute(array(":uname" => $_SESSION['uname']));
$rows = $temp->fetch(PDO::FETCH_ASSOC);

include_once('counter.php');
?>




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






<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
        background-color: #f9f9f9;
    }

    .receipt-container {
        width: 600px;
        margin: 20px auto;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        padding-top: 20px;
    }

    .header .top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-inline: 12px;
    }

    .header .top h2 {
        font-size: 24px;
        font-weight: bold;
        color: #a8a6a6;
        text-transform: uppercase;
    }

    .header .top img {
        max-width: 100px;
    }

    .header .date {
        background: #172541;
        color: white;
        text-align: center;
        padding: 10px 0;
        font-size: 18px;
        font-weight: bold;
    }

    .logo {
        text-align: right;
        margin: 10px 0;
    }

    .logo img {
        max-height: 50px;
    }

    /* .content {
            padding: 10px 20px;
        } */
    .content h4 {
        color: #000;
        font-size: 14px;
        margin: 10px 0;
    }

    .content p {
        font-size: 14px;
        margin: 5px 0;
    }

    .content .bold {
        font-weight: bold;
    }

    table {
        width: 100%;
        border-collapse: collapse;
    }

    table th,
    table td {
        text-align: left;
        padding: 12px;
        border-bottom: 1px solid #ccc;
    }

    .disclaimer {
        font-size: 12px;
        color: #555;
        margin-top: 20px;
        border-top: 1px solid #ccc;
        padding: 10px;
    }

    .disclaimer p {
        margin: 5px 0;
        text-align: justify;
    }

    .footer {
        margin-top: 20px;
        font-size: 12px;
        text-align: center;
        color: #fff;
        background-color: #172541;
    }

    .footer p {
        padding: 10px;
    }

    .print-btn {
        text-align: center;
        margin-bottom: 30px;
    }

    button {
        background-color: #172541;
        color: white;
        border: none;
        padding: 10px 20px;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    @media print {
        body * {
            visibility: hidden;
        }

        #printableReceipt,
        #printableReceipt * {
            visibility: visible;
        }

        #printableReceipt {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
        }
    }
</style>





<!---begin of Mobile View Here   only from Team-->

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

<!---End of Mobile View Here   only from Team-->

<!---begin of Main Menu View View Here   only from Team-->
<?php include 'mainmenu.php'; ?>

<!---End of Main Menu View Here   only from Team-->




<div class="container-fluid mt--7">






    <div class="row">

        <div class="col-xl-8 order-xl-1"><br><br>
            <div class="card-header border-0" style="background-color:<?php echo $tab; ?>; color:<?php echo $tab_font; ?>;">
                <div class="row align-items-center">
                    <div class="col-8">
                        <h3 class="mb-0">TRANSACTION CONFIRMATION</h3>
                    </div>
                    <div class="col-4 text-right">
                        <a href="ticket.php" class="btn btn-warning">Need Help?</a>
                    </div>
                </div>
            </div>
            <div class="card-body">



                <form autocomplete="off" method="post">


                    <center> <img src="icon/check-circle.gif" style="height:80px; width:80px;  " />
                        <br>
                        <h4 style="color:green;"> You have successfully Transfered <?php echo $row['currency'] ?><?php echo $rows['amount'] ?> to Account Number <?php echo $rows['uname'] ?> Belonging to <?php echo $rows['acc_name'] ?>
                            of <?php echo $rows['bank_name'] ?></h4>

                        <a href="summary.php" class="btn btn-warning">OKAY</a>
                    </center>

                    <hr>
                    <center>
                        <p style="color:red">Check your registered email or mobile number for transaction receipt</p>
                    </center>
                </form>

                <br><br><br><br><br><br>




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



<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<script>
    $(document).ready(function() {
        $("#myModal").modal('show');
    });
</script>

<div id="myModal" class="modal fade">
    <div class="modal-dialog style=" width: 640px;">
        <div class="modal-content">
            <div class="modal-body">
                <!-- Start of Invoice -->
                <div id="printableReceipt">
                    <div class="header">
                        <div class="top">
                            <h2>Transaction Receipt</h2>
                            <img src="https://alphaedgecb.com/account/assets/img/brand/blue.png" alt="Zenith Bank Logo">
                        </div>
                        <div class="date"><?php echo date("l, F j, Y"); ?></div>
                    </div>
                    <div class="content">
                        <table>
                            <tr>
                                <th>Transaction Type</th>
                                <td><?php echo $rows['transtype'] ?></td>
                            </tr>
                            <tr>
                                <th>Transaction Date</th>
                                <td><?php
                                    $formattedDatetime = date("d-M-Y h:i:s A", strtotime($rows['cout']));
                                    echo $formattedDatetime;
                                    ?></td>
                            </tr>
                            <tr>
                                <th>Debit Account</th>
                                <td>
                                    <?php
                                    $formattedName = "{$row['fname']} {$row['mname']} {$row['lname']}";
                                    $maskedAccount = substr($row['uname'], 0, 4) . "****";
                                    echo "$formattedName ($maskedAccount)";
                                    ?></td>
                            </tr>
                            <tr>
                                <th>Credit Account</th>
                                <td><?php echo $rows['uname'] ?></td>
                            </tr>
                            <tr>
                                <th>Beneficiary</th>
                                <td class="text-uppercase"><?php echo $rows['acc_name'] ?></td>
                            </tr>
                            <tr>
                                <th>Bank</th>
                                <td class="text-uppercase"><?php echo $rows['bank_name'] ?></td>
                            </tr>
                            <tr>
                                <th>Narration</th>
                                <td><?php echo $rows['remarks'] ?></td>
                            </tr>
                            <tr>
                                <th>Status</th>
                                <td><?php echo $rows['status'] ?></td>
                            </tr>
                            <tr>
                                <th>Amount</th>
                                <td>$<?php echo number_format($rows['amount'], 2) ?></td>
                            </tr>
                        </table>
                    </div>
                    <div class="disclaimer">
                        <p><strong>DISCLAIMER:</strong> Transaction initiated successfully. It might take 2-3 working days to credit funds in the receiver's account.
                            A detail of this transaction has been recorded in your e-statement and email. We recommend you contact the receiver of the fund to await 2-3 working days.</p>
                    </div>
                    <div class="footer p-0">
                        <p>For any other assistance, kindly contact us on info@alphaedgecb.com</p>
                    </div>
                </div>
                <!-- End of Invoice -->
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" onclick="printReceipt()">Print Receipt</button>
                <a href="summary" class="btn btn-success" data-dismiss="modal">Okay</a>
            </div>
        </div>
    </div>
</div>


<script>
    function printReceipt() {
        window.print();
    }
</script>



<!-- Footer -->
<?php include 'footercopyright.php'; ?>