<?php require("header_sum.php"); ?>

<div class="container py-4">
    <br><br><br>

    <!-- HEADER -->
    <div class="text-center mb-4">
        <h4 class="fw-bold">Transfer Summary</h4>
        <p class="text-muted">Confirm your transaction details before proceeding</p>
    </div>

    <?php
    $trans_id = rand(1000000000000, 10000000000000);
    $trans_id2 = rand(1000000000000, 10000000000000);
    ?>

    <!-- ACCOUNT CARD -->
    <div class="row justify-content-center mb-4">
        <div class="col-md-8">
            <div class="card p-4 shadow-sm bg-gradient-primary text-white">

                <div class="d-flex justify-content-between">
                    <div>
                        <small class="opacity-75">Available Balance</small>
                        <h3 class="fw-bold mb-0">
                            <?= $curr ?> <?= number_format($balc,2) ?>
                        </h3>
                        <small>Acct: <strong><?= $acc_no ?></strong></small>
                    </div>

                    <div class="text-end">
                        <small class="opacity-75">Transaction ID</small>
                        <div class="fw-bold"><?= $trans_id ?></div>

                        <span class="badge bg-warning text-dark mt-2">
                            Pending
                        </span>
                    </div>
                </div>

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

    <!-- DETAILS CARD -->
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-sm">

                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0">Transaction Details</h5>
                </div>

                <div class="card-body">

                    <?php
                    if(isset($success_transfer)){
                        echo "<div class='alert alert-success'>$success_transfer</div>";
                    } elseif(isset($failed_summary)){
                        echo "<div class='alert alert-danger'>$failed_summary</div>";
                    }
                    ?>

                    <form method="post">
 <?php $trans_id = rand(1000000000000, 10000000000000); ?>
    <input type="hidden" name="trans_id" value="<?php echo $trans_id; ?>" readonly class="form-control border-primary">

    <?php $trans_id2 = rand(1000000000000, 10000000000000); ?>
    <input type="hidden" name="trans_id2" value="<?php echo $trans_id2; ?>" readonly class="form-control border-primary">

   

    <input type="hidden" name="rate2" value="<?php echo $rate; ?>" class="form-control border-primary">
    <input type="hidden" name="balc" value="<?php echo $balc; ?>" class="form-control border-primary">
    <input type="hidden" name="date" value="<?php echo(date("jS F Y g.iA")); ?>" readonly class="form-control border-primary">
    <input type="hidden" name="name" value="<?php echo $firstname; ?>" class="form-control border-primary">
    <input type="hidden" name="email" value="<?php echo $email; ?>" class="form-control border-primary">
    <input type="hidden" name="phone" value="<?php echo $phone; ?>" class="form-control border-primary">
    <input type="hidden" name="cell[]" value="<?php echo $phone; ?>" class="form-control border-primary">
    <input type="hidden" name="acc_no" value="<?php echo $acc_no; ?>" class="form-control border-primary">
    <input type="hidden" name="tran_type" value="1" class="form-control border-primary">
    <input type="hidden" name="tran_type2" value="2" class="form-control border-primary">
    <input type="hidden" name="status" value="pending" class="form-control border-primary">
     <input type="hidden" name="cur2" value="<?php echo $curr; ?>" class="form-control border-primary">





  <?php
    $stmt = $pdo->prepare("SELECT * FROM payee WHERE log_id = :id ORDER BY id DESC LIMIT 1");
    $stmt->execute(['id' => $id]);

    if ($stmt->rowCount() === 0) {
        echo "<strong>NO HISTORY</strong>";
    } else {
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        echo "
            <input type='hidden' name='ben_acct_no' value='" . htmlspecialchars($row['ben_acct_no']) . "'>


                    <input type='hidden' name='ben_name' value='" . htmlspecialchars($row['ben_name']) . "' class='form-control border-primary' readonly>


            <input type='hidden' name='ben_phone' value='" . htmlspecialchars($row['ben_phone']) . "'>
            <input type='hidden' name='ben_email' value='" . htmlspecialchars($row['ben_email']) . "'>
            <input type='hidden' name='ben_wallet' value='" . htmlspecialchars($row['ben_wallet']) . "'>
            <input type='hidden' name='btc_amt' value='" . htmlspecialchars($row['btc_amt']) . "'>
            <input type='hidden' name='bank_name' value='" . htmlspecialchars($row['bank_name']) . "'>
            <input type='hidden' name='bank_zip_code' value='" . htmlspecialchars($row['bank_zip_code']) . "'>
            <input type='hidden' name='bank_branch' value='" . htmlspecialchars($row['bank_branch']) . "'>
            <input type='hidden' name='bank_swift' value='" . htmlspecialchars($row['bank_swift']) . "'>
            <input type='hidden' name='method' value='" . htmlspecialchars($row['method']) . "'>
            <input type='hidden' name='routin' value='" . htmlspecialchars($row['routin']) . "'>
            <input type='hidden' name='mybtc' value='" . htmlspecialchars($row['mybtc']) . "'>

            <input type='hidden' name='trans_amount' value='" . htmlspecialchars($row['trans_amount']) . "' class='form-control' style='font-weight: bold;' readonly>


             <input type='hidden' name='note' value='" . htmlspecialchars($row['note']) . "'>
             
             <input type='hidden' name='cur3' value='" . htmlspecialchars($row['cur']) . "'>
             
             <input type='hidden' name='rate3' value='" . htmlspecialchars($row['rate']) . "'>
             
             
           
        ";
    }
    ?>
    
    
    
    
    
                        <!-- FROM -->
                        <div class="mb-3">
                            <label class="fw-semibold">From Account</label>
                            <div class="summary-box">
                                <?= $acc_no ?>  
                                <span class="float-end fw-bold">
                                    <?= $curr ?> <?= number_format($balc,2) ?>
                                </span>
                            </div>
                            <small class="text-muted">
                                Limit: <?= $curr ?> <?= number_format($tr_limit,2) ?>
                            </small>
                        </div>

                        <?php
                        $stmt = $pdo->prepare("SELECT * FROM payee WHERE log_id = :id ORDER BY id DESC LIMIT 1");
                        $stmt->execute(['id' => $id]);

                        if ($stmt->rowCount() > 0) {
                            $row = $stmt->fetch(PDO::FETCH_ASSOC);
                        ?>

                        <!-- BENEFICIARY -->
                        <div class="mb-3">
                            <label class="fw-semibold">Beneficiary</label>
                            <div class="summary-box">
                                <?= htmlspecialchars($row['ben_name']) ?>
                            </div>
                        </div>

                        <!-- AMOUNT -->
                        <div class="mb-3">
                            <label class="fw-semibold">Amount</label>
                            <div class="summary-box text-success fw-bold">
                                <?= number_format($row['trans_amount'],2) ?>
                                <?php echo $curr; ?>
                            </div>
                        </div>

                        <!-- NOTE -->
                        <div class="mb-3">
                            <label class="fw-semibold">Remark</label>
                            <div class="summary-box">
                                <?= htmlspecialchars($row['note']) ?>
                            </div>
                        </div>

                        <?php } else { ?>
                            <div class="alert alert-warning">No beneficiary found</div>
                        <?php } ?>

                        <!-- PROCESS INFO -->
                        <div class="alert alert-info mt-4">
                            ⏱ Processing Time: <strong>Within 24 - 48 Hours</strong><br>
                            🔒 Your transaction is secured and encrypted.
                        </div>

                        <!-- SETTINGS -->
                       
    <?php
    $stmt = $pdo->prepare("SELECT * FROM settings ORDER BY id DESC");
    $stmt->execute();
    $settings = $stmt->fetchAll(PDO::FETCH_ASSOC);

    foreach ($settings as $row) {
        echo "
            <input type='hidden' name='cname' value='" . htmlspecialchars($row['domain_name']) . "'>
            <input type='hidden' name='cemail' value='" . htmlspecialchars($row['email2']) . "'>
            <input type='hidden' name='cphone' value='" . htmlspecialchars($row['phone']) . "'>
            <input type='hidden' name='caddress' value='" . htmlspecialchars($row['address']) . "'>
            <input type='hidden' name='cIP' value='" . htmlspecialchars($row['IP']) . "'>
            <input type='hidden' name='cGBP' value='" . htmlspecialchars($row['GBP']) . "'>
            <input type='hidden' name='cEUR' value='" . htmlspecialchars($row['EUR']) . "'>
            <input type='hidden' name='cAUD' value='" . htmlspecialchars($row['AUD']) . "'>
            <input type='hidden' name='cCAD' value='" . htmlspecialchars($row['CAD']) . "'>
            <input type='hidden' name='cCNY' value='" . htmlspecialchars($row['CNY']) . "'>
            <input type='hidden' name='cZAR' value='" . htmlspecialchars($row['ZAR']) . "'>
            <input type='hidden' name='cNGN' value='" . htmlspecialchars($row['NGN']) . "'>
            <input type='hidden' name='cGHS' value='" . htmlspecialchars($row['GHS']) . "'>
        ";
    }
    ?>



                        <!-- BUTTON -->
                        <div class="text-center mt-4">
                            <button type="submit" name="action_summary" class="btn btn-primary w-50">
                                Confirm & Proceed
                            </button>
                        </div>

                    </form>

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

</div>

<style>
body {
    background: #f5f6fa;
}

/* Summary Box */
.summary-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    margin-top: 5px;
}

/* Card */
.card {
    border-radius: 15px;
}

/* Button */
.btn {
    border-radius: 12px;
    font-weight: bold;
}

/* Mobile */
@media (max-width: 768px) {
    .summary-box {
        font-size: 14px;
    }
}
</style>

<?php require("footer.php"); ?>