<?php
session_start();
if (isset($_SESSION["username"])) {
    $username = $_SESSION["username"];
    session_write_close();
} else {
    // since the username is not set in session, the user is not-logged-in
    // he is trying to access this page unauthorized
    // so let's clear all session variables and redirect him to index
    session_unset();
    session_write_close();
    $url = "./index.php";
    header("Location: $url");
}

?>

<!doctype html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="theme-color" content="#000000">
    <title>Wells Fargo Bank - Mobile</title>
    <meta name="description" content="Wells Fargo Bank">
    <meta name="keywords" content="wallet, banking, mobile, bank" />
    <link rel="icon" type="image/png" href="assets/img/ally.png" sizes="32x32">
    <!-- <link rel="apple-touch-icon" sizes="180x180" href="assets/img/icon/192x192.png"> -->
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="manifest" href="__manifest.json">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="assets/query.js"></script>
</head>
<style>
#myProgress {
  width: 100%;
  /* background-color: #ddd; */
}

#myBar {
  width: 1%;
  height: 20px;
  background-color: #04aa6d;
}

#demoMessage {
  color: red;
}

#myBarr {
  color: green;
}

</style>

<body>

    <!-- loader -->
    <!-- <div id="loader">
        <img src="assets/img/logo-icon.png" alt="icon" class="loading-icon">
    </div> -->
    <!-- * loader -->

    <!-- App Header -->
    <div class="appHeader">
        <div class="left">
            <a href="#" class="headerButton goBack">
                <ion-icon name="chevron-back-outline"></ion-icon>
            </a>
        </div>
        <div class="pageTitle">
          <img src="assets/img/logo.png" alt="logo" class="logo">
        </div>
        <div class="right">
            <a href="app-notifications.php" class="headerButton">
                <ion-icon class="icon" name="notifications-outline"></ion-icon>
                <span class="badge badge-danger">3</span>
            </a>
            <a href="app-settings.php" class="headerButton">
                <!-- <img src="assets/img/sample/avatar/avatar1.jpg" alt="image" class="imaged w32"> -->
                <ion-icon class="icon" name="settings-outline"></ion-icon>
                <span class="badge badge-danger"></span>
            </a>
        </div>
    </div>
    <!-- * App Header -->

    <!-- App Capsule -->
    <div id="appCapsule">
      <!-- <div class="listview-title mt-1">App Pages</div> -->

      <!-- Wallet Card -->
      <div class="section wallet-card-section pt-1">
          <div class="wallet-card">
              <!-- Balance -->
              <div class="balance">
                  <div class="left">
                    <h6 class="value" id="welcomeBack"></h6>
                    <h3 class="value">REAL HUSTLERS ONLY</h3>
                      <span class="title">Total Balance</span>
                      <h1 class="value">$ 5,000,000.00</h1>
                  </div>

              </div>
              <!-- * Balance -->
              <!-- Wallet Footer -->
              <div class="wallet-footer">
                <h2 class="value">TRANSFER FUNDS</h2>

              </div>
              <!-- * Wallet Footer -->
          </div>
      </div>
      <!-- Wallet Card -->

      <!-- Stats -->
      <div class="section">
        <p id="demoMessage" style="display:none"> Transfer Failed, Try Again!</p>
        <div  id="myProgress" style="display:none">
            <div class="" style="margin-bottom: 5px;">
                <div id="myBarr">Transfer Processing....</div>
                <div id="myBar"></div>
            </div>
        </div>
      </div>
      <!-- * Stats -->
      <div class="section mb-5 p-2">

      <form name="sendForm" action="" method="post" onsubmit="return move()">
        <div class="card">
          <div class="card-body pb-1">
            <div class="form-group basic">
              <div class="input-wrapper">
                <div class="label">
                  Reciever's Name <span id="rname-info" style="display:none">(This Field Is Required)</span>
                </div>
                <input class="form-control" type="text" name="rname" id="rname" placeholder="Enter Reciever's Full Name" required>
              </div>
            </div>
            <!-- <div class="form-group basic">
              <div class="input-wrapper">
                <div class="label">
                  Bank Name
                </div>
                <input class="form-control" type="text" name="username" id="username" placeholder="Enter Bank Name" required>
              </div>
            </div>
            <div class="form-group basic">
              <div class="input-wrapper">
                <div class="label">
                  Account Number
                </div>
                <input class="form-control" type="number" name="username" id="username" placeholder="Enter Acc.No" required>
              </div>
            </div>
            <div class="form-group basic">
              <div class="input-wrapper">
                <div class="label">
                  Routine Number
                </div>
                <input class="form-control" type="number" name="username" id="username" placeholder="Enter Routine.No" required>
              </div>
            </div>
            <div class="form-group basic">
                <label class="label">Enter Amount</label>
                <div class="input-group mb-2">
                    <span class="input-group-text" id="basic-addona1">$</span>
                    <input type="number" class="form-control" placeholder="Enter an amount" required>
                </div>
            </div> -->
            <!-- <div class="form-group basic">
              <div class="input-wrapper">
                <div class="label">
                  Amount
                </div>
                <input class="form-control" type="number" name="username" id="username" placeholder="Enter an amount" required>
              </div>
            </div> -->
          </div>
        </div>


        <div class="form-group basic">
            <input type="submit" name="submit" value="Send" class="btn btn-primary btn-block btn-lg"
                data-bs-dismiss="modal" onsubmit="move()">
        </div>
        </form>
      </div>







    </div>
    <!-- * App Capsule -->


    <!-- App Bottom Menu -->
    <div class="appBottomMenu">
        <a href="home.php" class="item">
            <div class="col">
                <ion-icon name="pie-chart-outline"></ion-icon>
                <strong>Overview</strong>
            </div>
        </a>
        <a href="app-pages.php" class="item active">
            <div class="col">
                <ion-icon name="document-text-outline"></ion-icon>
                <strong>Pages</strong>
            </div>
        </a>
        <a href="home.php" class="item">
            <div class="col">
                <ion-icon name="apps-outline"></ion-icon>
                <strong>Components</strong>
            </div>
        </a>
        <a href="app-cards.php" class="item">
            <div class="col">
                <ion-icon name="card-outline"></ion-icon>
                <strong>My Cards</strong>
            </div>
        </a>
        <a href="app-settings.php" class="item">
            <div class="col">
                <ion-icon name="settings-outline"></ion-icon>
                <strong>Settings</strong>
            </div>
        </a>
    </div>
    <!-- * App Bottom Menu -->


    <!-- ========= JS Files =========  -->
    <!-- Bootstrap -->
    <script src="assets/js/lib/bootstrap.bundle.min.js"></script>
    <!-- Ionicons -->
    <script type="module" src="https://unpkg.com/ionicons@5.4.0/dist/ionicons/ionicons.js"></script>
    <!-- Splide -->
    <script src="assets/js/plugins/splide/splide.min.js"></script>
    <!-- Base Js File -->
    <script src="assets/js/base.js"></script>
    <!-- Site Js File -->
    <script src="assets/js/site.js"></script>

    <script>

    // var i = 1;
    //         function move() {
    //           if (i == 0) {
    //             i = 1;
    //             var elem = document.getElementById("myProgress").style.display='block';
    //             var elem = document.getElementById("myBar");
    //             var width = 1;
    //             var id = setInterval(frame, 180);
    //             function frame () {
    //               if (width >= 28) {
    //                 clearInterval(id);
    //                 document.getElementById("myProgress").style.display='none';
    //                 document.getElementById("demoMessage").style.display='block';
    //               } else {
    //                 width++;
    //                 elem.style.width = width + "%"
    //               }
    //             }
    //           }
    //         }


    // function move() {
    //
    //     var rname = document.sendForm.rname;
    //     var i = 0;
    //
    //     if (rname.value == "") {
    //       // alert("Your name wasn't filled.");
    //       document.getElementById("rname-info").style.display='block';
    //       rname.focus();
    //       return false;
    //   } else if (i == 0) {
    //     i = 1;
    //     var elem = document.getElementById("myProgress").style.display='block';
    //     var elem = document.getElementById("myBar");
    //     var width = 1;
    //     var id = setInterval(frame, 180);
    //     function frame () {
    //       if (width >= 88) {
    //         clearInterval(id);
    //         document.getElementById("myProgress").style.display='none';
    //         document.getElementById("demoMessage").style.display='block';
    //       } else {
    //         width++;
    //         elem.style.width = width + "%"
    //       }
    //     }
    //    }
    //  }

    var i = 0; //remove this
    function move() {

        var rname = document.sendForm.rname;
        //put the var code here

        if (rname.value == "") {
          // alert("Your name wasn't filled.");
          document.getElementById("rname-info").style.display='block';
          rname.focus();
          return false;
      } else if (i == 0){   // remove the IF (i == 0)
        i = 1;
        var elem = document.getElementById("myProgress").style.display='block';
        var elem = document.getElementById("myBar");
        var width = 1;
        var id = setInterval(frame, 180);
        function frame () {
          if (width >= 18) {
            clearInterval(id);
            document.getElementById("myProgress").style.display='none';
            document.getElementById("demoMessage").style.display='block';
          } else {
            width++;
            elem.style.width = width + "%"
          }
        }
       }
     }



    // Get the time for welcome
    const time = new Date().getHours();
    let greeting;
        if (time < 12) {
        greeting = "Good Morning!";
    } else if (time < 16) {
        greeting = "Good Afternoon!";
    } else if (time < 20) {
        greeting = "Welcome Back!";
    } else {
        greeting = "Good Evening!";
    }
     document.getElementById("welcomeBack").innerHTML = greeting;

    </script>

</body>

</html>
