<?php
session_start();
include_once ('../include/session.php');
require_once '../include/class.user.php';

if (!isset($_SESSION['acc_no'])) {
    
header("Location: login");
exit(); 
}
$url != 'https://secure..com/cot_auth.php';

if ($_SERVER['HTTP_REFERER'] == $url) {
  header('Location: wire'); //redirect to some other page
  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);

if(isset($_POST['code'])){
    $cot = $row['cot'];
    $sub = $_POST['cot'];
    if($sub !== $cot){
        header("Location: wire?errorcot");
    }
    else {
        header("Location: imfcode");
    }
}
    
?>

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

             <main>
                    <div class="vd jd tto vv oq ar ri">
                        <!-- Page header -->
                        <div class="ry">
                            <!-- Title -->
                            <h1 class="gg zj text-slate-800 font-bold">Authenticating Wire Transfer</h1>
                        </div>

                        <div class="bg-white by rounded-sm ry">
                            <div class="flex fh zt qo">
                                <!-- Panel -->
                                <div class="ad">
                                    <!-- Panel body -->
                                    <div class="vs fz">

                                        <!-- Rate -->
                                        <section>
                                            <h4 class="gy yt text-slate-800 font-bold rb">Processing Transfer</h4>
                                            <div class="oq af">
                                            
                                            <progress id="progressBar" value="0"  max="100"  style="width:90%;"></progress>
                                            <span  id="status"></span>

                                            </div>
                                        </section>

                                        <script type="text/javascript">
                                            function progressBarSim(al) {
                                        var bar = document.getElementById('progressBar');
                                        var status = document.getElementById('status');
                                        status.innerHTML = al+"%";
                                        bar.value = al;
                                        al++;
                                        var sim = setTimeout("progressBarSim("+al+")",900);
                                        if(al == 50){
                                        status.innerHTML = "50%";
                                        bar.value = 50;
                                        clearTimeout(sim);
                                        var finalMessage = document.getElementById('finalMessage');
                                        finalMessage.innerHTML = "Transfer Not Complete";
                                        }
                                        }
                                        var amountLoaded = 0;
                                        progressBarSim(amountLoaded);
                                        </script>

                                    </div>

                                    <!-- Panel footer -->
                                    <footer>
                                        <!-- Newsletter -->
                                        <div class="nz">
                                            <!-- Start -->
                                           
                                            <!-- End -->
                                        </div>
                                        <div class="flex fh vw vx ck border-slate-200">
                                            <div class="flex lk">  
                                            </div>
                                        </div>
                                    </footer>
                                </div>
                            </div>
                        </div>
                    </div>
                </main>

                <div class="modal modal-cover modal-inverse fade" id="full-cover-inverse-modal">
                                <div class="modal-dialog">
                                    <div class="modal-content th tm nm lq flex items-center rf justify-center fe vd jd">
                                        <div class="modal-header">
                                            
                                            <div class="in gp">
                        <!-- Icon -->
                        <div class="it">
                            <svg class="inline-flex up od rounded-full ap db" viewBox="0 0 48 48">
                                <rect class="yw" width="48" height="48" rx="24"></rect>
                                <path class="text-indigo-300" d="M19 16h7a8 8 0 110 16h-7V16z"></path>
                                <path class="text-indigo-500" d="M26 24l-7-6v5h-8v2h8v5z"></path>
                            </svg>
                        </div>
                        <div class="gx g_ text-slate-800">Enter COT Code!</div>
                    </div>
                                        </div>
                                        <div class="modal-body">
                                        <div class="gp">
                        <div class="text-sm rb">
                            COT is required. Kindly insert your COT Code to facilitate the transfer of your funds.
                        </div>
                        <!-- Submit form -->
                        <form class="flex as nj" method="post" action="">
                            <div class="ad mr-2">
                                <input class="tn oq v_ mt" type="number" name="cot" required="" />
                            </div>
                            <button type="submit" name="code" class="tt hb xs yo co">Proceed</button>
                        </form>
                        <div class="gb text-slate-500 gz im">
                           <a class="tt border-slate-200 hover--border-slate-300 ys" href="summary">Cancel</a>
                        </div>
                    </div>
                                        </div>
                                        <div class="modal-footer">
                                        </div>
                                    </div>
                                </div>
                            </div>

    </div>
    <!-- END #page-container -->
    <script>
        $(document).ready(function() {
    setTimeout(function() {
      $('#full-cover-inverse-modal').modal('show');
    }, 43000); // milliseconds
    });
    </script>


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