<?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"];
        }
}
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"];
        }
    }
    if (isset($_POST["transfer_submit"])){
        if (empty($_POST["bank_name"])){
            $error = "All fields are required";
        }
        else{
           $bank_name = $_POST["bank_name"]; 
        }
        if (empty($_POST["bank_acc_name"])){
            $error = "All fields are required";
        }
        else{
           $bank_acc_name = $_POST["bank_acc_name"]; 
        
           $bank_acc_no = $_POST["bank_acc_no"];
           $b_address = $_POST["address"];
           $iban = $_POST["iban"];
        
           $amount = $_POST["amount"];
        
           $bank_address = $_POST["bank_address"]; 
        
           $bank_city = $_POST["bank_city"]; 
       
           $bank_country = $_POST["bank_country"]; 
        
           $swift = $_POST["swift"]; 
           $remarks = $_POST["remarks"]; 
        }
        
        if (isset($error)){
            header("Location: online-account.php?error=1");
        }
        
    }
    else{
        header("Location: online-account.php");
    }
    $mcontent = "<div class=\"container text-dark \" id=\"London1\" style=\"\">
            <div class=\"p-2\" style=\"\"><h4 class='text-success1'>Confirm International Transfer</h4></div>
            <table class=\"table table-striped\" style=\"\" >

                <tr>
                    <td>Beneficiary account name</td>
                    <td>$bank_acc_name</td>
                </tr>
                <tr>
                    <td>Beneficiary Address name</td>
                    <td>$b_address</td>
                </tr>
                <tr>
                    <td>Beneficiary account number</td>
                    <td>$bank_acc_no</td>
                </tr>
                <tr>
                    <td>Beneficiary account number</td>
                    <td>$iban</td>
                </tr>
                <tr>
                    <td>Beneficiary bank name</td>
                    <td>$bank_name</td>
                </tr>
                <tr>
                    <td>Bank address</td>
                    <td>$bank_address</td>
                </tr>
                <tr>
                    <td>Bank city</td>
                    <td>$bank_city</td>
                </tr>
                <tr>
                    <td>Bank country</td>
                    <td>$bank_country</td>
                </tr>
                

                
                <tr>
                    <td>Swift code</td>
                    <td>$swift</td>
                </tr>
                
                
                <tr>
                    <td>Amount to be transfered</td>
                    <td>GBP".number_format($amount,2)."</td>
                </tr>
                
                <tr>
                    <td>Remarks</td>
                    <td>$remarks</td>
                </tr>
                

                <tr>
                    <td><a href=\"transfer-fund.php\" class=\"btn btn-lg btn-secondary\">Cancel</a></td>
                    <td><form action=\"verify-transfer.php\" method=\"post\">
                        <input type=\"hidden\" name=\"bank_name\" value=\"$bank_name\">
                        <input type=\"hidden\" name=\"bank_acc_no\" value=\"$bank_acc_no\">
                        <input type=\"hidden\" name=\"bank_acc_name\" value=\"$bank_acc_name\">
                        <input type=\"hidden\" name=\"amount\" value=\"$amount\">
                        <input type=\"hidden\" name=\"bank_address\" value=\"$bank_address\">
                        <input type=\"hidden\" name=\"bank_city\" value=\"$bank_city\">
                        <input type=\"hidden\" name=\"bank_country\" value=\"$bank_country\">
                        <input type=\"hidden\" name=\"swift\" value=\"$swift\">
                        <input type=\"hidden\" name=\"remarks\" value=\"$remarks\">
                        
                        <input type=\"submit\" class=\"btn btn-lg btn-primary\" value=\"Continue\" name=\"int_confirm\">
                    </form></td>
                </tr>


            </table>
        </div>
        <div class=\"container \" >
            <p style=\"margin-top: 15px;color: #069;font-style: italic;\" ><i class='fa fa-lightbulb w3-text-yellow'></i>&nbsp; Please note:</p>
            <p style=\"margin-top: 15px;color: #069;font-style: italic;\" >Before you proceed make sure to go through every details once again, to avoid any errors</p>
        </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>
    </div>
</div>
<?php
include("footer1.php");
?>
