<?php
session_start();

require('../../includes/database.php');
include("../../log.php");

if (isset($_SESSION['accUsername']) && $_SESSION['accPassword'] != "") {
} else {
   header("Location:../../login/");
}
$accUsername = $_SESSION['accUsername'];

$accUsername = $_SESSION['accUsername'];
$accPassword = $_SESSION['accPassword'];

$query = "SELECT * FROM accounts	
			WHERE username = '$accUsername'
			&&   password = '$accPassword'";

$result = mysqli_query($con, $query) or die(mysqli_connect_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
   while ($data = mysqli_fetch_assoc($result)) {

      extract($data);
      include('../components/head.php');

      if (isset($_SESSION['transfer_error']) != "") {
         $message = $_SESSION['transfer_error'];
      } else {
         $message = "";
      }
?>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

      <body x-data class="is-header-blur is-sidebar-open" x-bind="$store.global.documentBody">
         <!-- App preloader-->
         <?php
         include("../components/preloader.php");
         include("../components/sidebar.php");
         include("../components/sidebar-body.php");
         include("../components/nav.php");
         include("../components/mobile-search.php");
         include("../components/right-sidebar.php");
         ?>

         <!-- Main Content Wrapper -->
         <main class="main-content w-full px-[var(--margin-x)] pb-8">
            <h2 class="mt-3 text-xl font-medium text-slate-800 dark:text-navy-50 lg:text-2xl">
               Make Transfer
            </h2>
            <?php
            if ($message != "") {
            ?>
               <div class="space-y-4 mt-3">
                  <div x-data="{isShow:true}" :class="!isShow && 'opacity-0 transition-opacity duration-300'" class="alert flex items-center justify-between overflow-hidden rounded-lg border border-error text-error">
                     <div class="flex">
                        <div class="px-4 py-3 sm:px-5 text-center"><?php echo $message ?></div>
                     </div>
                     <div class="px-2">
                        <button @click="isShow = false; setTimeout(()=>$root.remove(),300)" class="btn h-7 w-7 rounded-full p-0 font-medium text-error border-error">
                           <i class="fa fa-close"></i>
                        </button>
                     </div>
                  </div>
               <?php } ?>
               <div class="mt-4 grid grid-cols-12 gap-4 sm:mt-5 sm:gap-5 lg:mt-6 lg:gap-1">
                  <div class="card col-span-12 lg:col-span-12">
                     <div class="flex items-center justify-between py-3 px-4">
                        <h1 class="font-medium tracking-wide dark:text-navy-100">
                           Transfer Money
                        </h1>
                     </div>
                     <div class="grid grid-cols-1 gap-y-4 pb-3 sm:grid-cols-3">
                        <div class="flex flex-col justify-between border-transparent border-l-info px-4">
                           <div>
                              <p class="text-base font-medium text-slate-600 dark:text-navy-100">
                                 To <?php echo $siteName ?> Account
                              </p>
                              <p class="pb-3 text-xs text-slate-400 dark:text-navy-300">
                                 Send money to a <?php echo $siteName ?> account receipient
                              </p>
                              <?php include("./mb-transfer.php") ?>
                           </div>
                        </div>
                        <!-- <hr style="border:1px solid lightgray;" class="d-none sm-block"> -->
                        <div class="flex flex-col justify-between border-4 border-transparent border-l-info px-4">
                           <div>
                              <p class="text-base font-medium text-slate-600 dark:text-navy-100">
                                 To Other Local Banks
                              </p>
                              <p class="pb-3 text-xs text-slate-400 dark:text-navy-300">
                                 Send money to other account holders in <?php echo $siteCountry ?>
                              </p>
                              <?php include("./ol-transfer.php") ?>
                           </div>
                        </div>
                        <div class="flex flex-col justify-between border-4 border-transparent border-l-warning px-4">
                           <div>
                              <p class="text-base font-medium text-slate-600 dark:text-navy-100">
                                 International Wire Transfer
                              </p>
                              <p class="pb-3 text-xs text-slate-400 dark:text-navy-300">
                                 Using IBAN you can make international bank transfers
                              </p>
                              <?php include("./iw-transfer.php")
                              ?>
                           </div>
                        </div>
                     </div>
                  </div>
                  <?php
                  include("../components/user-pan.php");
                  ?>
               </div>
         </main>
         </div>

         <div id="mybank-transfer"></div>
         <div id="otherbank-transfer"></div>
         <div id="wire-transfer"></div>
         <script>
            window.addEventListener("DOMContentLoaded", () => Alpine.start());
         </script>
      </body>

      </html>


<?php
   }
}
?>