<?php 
error_reporting(E_ALL ^ E_DEPRECATED);
?>
<?php require_once '../Connections/ebanking.php'; ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = mysqli_real_escape_string($ebanking, $theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_customer = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_customer = $_SESSION['MM_Username'];
}
//mysql_select_db($database_ebanking, $ebanking);
$colname_customer = mysqli_real_escape_string($ebanking,$colname_customer);
$query_customer = "SELECT * FROM customer WHERE accountno = $colname_customer";
$customer = mysqli_query($ebanking,$query_customer);
$row_customer = mysqli_fetch_assoc($customer);
$totalRows_customer = mysqli_num_rows($customer);
?>
<!DOCTYPE html>
<html lang="en">
<?php 
error_reporting(E_ALL ^ E_DEPRECATED);
?>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wolfville Credit Union, Canada - Online Banking Platform</title>
    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/all.css">
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/roc-dachboard.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/sidebar.css">
    <link rel="stylesheet" href="css/floating-chatbox.css">
    <link href="../vendor/morrisjs/morris.css" rel="stylesheet">
    <script src="gen_validatorv4.js" type="text/javascript"></script>
    <style>
        .content-list li .accounts.active{
            background-image: linear-gradient(to bottom,#5864aaa1 0,#070b21 100%);
        }
    </style>
</head>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">

    <?php include "includes/header.php"; ?>

    <?php require_once('../Connections/ebanking.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_balance = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_balance = $_SESSION['MM_Username'];
}

$colname_welcome = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_welcome = $_SESSION['MM_Username'];
}
//mysql_select_db($database_ebanking, $ebanking);
$colname_welcome = mysqli_real_escape_string($ebanking, $colname_welcome);
$query_welcome = "SELECT * FROM customer WHERE accountno = '$colname_welcome'";
$welcome = mysqli_query($ebanking, $query_welcome);
$row_welcome = mysqli_fetch_assoc($welcome);
$totalRows_welcome = mysqli_num_rows($welcome);

$colname_balance = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_balance = $_SESSION['MM_Username'];
}
//mysql_select_db($database_ebanking, $ebanking);
$colname_balance = mysqli_real_escape_string($ebanking,$colname_balance);
$query_balance = "SELECT * FROM balance WHERE account = '$colname_balance'";
$balance = mysqli_query($ebanking, $query_balance);
$row_balance = mysqli_fetch_assoc($balance);
$totalRows_balance = mysqli_num_rows($balance);
?>

    <div id="content">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="row">
                        <div class="col-lg-3 col-sm-6 col-xs-12 bordered-radius mob-space orders">
                            <div class="row mobile-view">
                                <div style="padding-left: 0;" class="col-lg-10 col-lg-offset-1 col-xs-12">
                                    <div class="welcome">
                                        <div class="icon"><svg class="svg-inline--fa fa-home fa-w-18" aria-hidden="true" data-prefix="fas" data-icon="home" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg=""><path fill="currentColor" d="M488 312.7V456c0 13.3-10.7 24-24 24H348c-6.6 0-12-5.4-12-12V356c0-6.6-5.4-12-12-12h-72c-6.6 0-12 5.4-12 12v112c0 6.6-5.4 12-12 12H112c-13.3 0-24-10.7-24-24V312.7c0-3.6 1.6-7 4.4-9.3l188-154.8c4.4-3.6 10.8-3.6 15.3 0l188 154.8c2.7 2.3 4.3 5.7 4.3 9.3zm83.6-60.9L488 182.9V44.4c0-6.6-5.4-12-12-12h-56c-6.6 0-12 5.4-12 12V117l-89.5-73.7c-17.7-14.6-43.3-14.6-61 0L4.4 251.8c-5.1 4.2-5.8 11.8-1.6 16.9l25.5 31c4.2 5.1 11.8 5.8 16.9 1.6l235.2-193.7c4.4-3.6 10.8-3.6 15.3 0l235.2 193.7c5.1 4.2 12.7 3.5 16.9-1.6l25.5-31c4.2-5.2 3.4-12.7-1.7-16.9z"></path></svg></div>
                                        <h3>WELCOME <span><?php echo $row_customer['acctname']; ?></span></h3>
                                    </div>
                                </div>
                            </div>
                            <div class="side-quicklinks">
                                <h3>Navigate to</h3>
                                <div class="divider"></div>
                                <ul>
                                    <li><a class="bjb-link-arrow text-nowrap" href="loans.php">Loans</a></li>
                                    <hr>
                                    <li><a class="bjb-link-arrow text-nowrap" href="openaccount.php">Open an Account</a></li>
                                    <hr>
                                    <li style="border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;"><a class="bjb-link-arrow text-nowrap" href="profile.php">Change Password</a></li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-lg-6 col-sm-12 col-xs-12 mob-space orders">
                            <div class="row desk">
                                <div style="padding-left: 0;" class="col-lg-10 col-lg-offset-1">
                                    <div class="welcome">
                                        <div class="icon"><svg class="svg-inline--fa fa-home fa-w-18" aria-hidden="true" data-prefix="fas" data-icon="home" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg=""><path fill="currentColor" d="M488 312.7V456c0 13.3-10.7 24-24 24H348c-6.6 0-12-5.4-12-12V356c0-6.6-5.4-12-12-12h-72c-6.6 0-12 5.4-12 12v112c0 6.6-5.4 12-12 12H112c-13.3 0-24-10.7-24-24V312.7c0-3.6 1.6-7 4.4-9.3l188-154.8c4.4-3.6 10.8-3.6 15.3 0l188 154.8c2.7 2.3 4.3 5.7 4.3 9.3zm83.6-60.9L488 182.9V44.4c0-6.6-5.4-12-12-12h-56c-6.6 0-12 5.4-12 12V117l-89.5-73.7c-17.7-14.6-43.3-14.6-61 0L4.4 251.8c-5.1 4.2-5.8 11.8-1.6 16.9l25.5 31c4.2 5.1 11.8 5.8 16.9 1.6l235.2-193.7c4.4-3.6 10.8-3.6 15.3 0l235.2 193.7c5.1 4.2 12.7 3.5 16.9-1.6l25.5-31c4.2-5.2 3.4-12.7-1.7-16.9z"></path></svg><!-- <i class="fas fa-home"></i> --></div>
                                        <h3>WELCOME <span><?php echo $row_customer['acctname']; ?></span></h3>
                                    </div>
                                </div>
                            </div>
                            <div class="account-container">
                                <div class="row">
                                    <div class="col-lg-10 col-lg-offset-1 flx-d">
                                        <div class="account-card">
                                            <h3>ACCOUNT BALANCE</h3>
                                            <div class="inner-card">
                                                <ul class="nav acc nav-pills">
                                                    <li class="active"><a data-toggle="tab" href="#usd">Balance (USD)</a></li>
                                                    <li><a data-toggle="tab" href="#gbp">Balance (GBP)</a></li>
                                                    <li><a data-toggle="tab" href="#eur">Balance (EUR)</a></li>
                                                </ul>

                                                <div class="tab-content">
                                                    <div id="usd" class="tab-pane fade in active">
                                                        <table class="table">
                                                            <thead>
                                                                <tr>
                                                                    <th scope="col">Account Name</th>
                                                                    <th scope="col">Account Number</th>
                                                                    <th scope="col">Account Balance</th>
                                                                </tr>
                                                            </thead>

                                                            <tbody>
                                                                <tr>
                                                                    <td><?php echo $row_welcome['acctname']; ?></td>
                                                                    <td><?php echo $row_customer['accountno']; ?></td>
                                                                    <td>$<?php echo $row_balance['usd']; ?></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>

                                                    <div id="gbp" class="tab-pane fade in">
                                                        <table class="table">
                                                            <thead>
                                                                <tr>
                                                                    <th scope="col">Account Name</th>
                                                                    <th scope="col">Account Number</th>
                                                                    <th scope="col">Account Balance</th>
                                                                </tr>
                                                            </thead>

                                                            <tbody>
                                                                <tr>
                                                                    <td><?php echo $row_welcome['acctname']; ?></td>
                                                                    <td><?php echo $row_customer['accountno']; ?></td>
                                                                    <td>£<?php echo $row_balance['pounds']; ?></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>

                                                    <div id="eur" class="tab-pane fade in">
                                                        <table class="table">
                                                            <thead>
                                                                <tr>
                                                                    <th scope="col">Account Name</th>
                                                                    <th scope="col">Account Number</th>
                                                                    <th scope="col">Account Balance</th>
                                                                </tr>
                                                            </thead>

                                                            <tbody>
                                                                <tr>
                                                                    <td><?php echo $row_welcome['acctname']; ?></td>
                                                                    <td><?php echo $row_customer['accountno']; ?></td>
                                                                    <td>€<?php echo $row_balance['euros']; ?></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <div class="table-divider"></div>

                                                    <a class="btn btn-default btn-custom pull-right account-modal" data-target="#account-modal" data-toggle="modal" href="#">View Transaction History</a>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-sm-6 col-xs-12 orders">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="calendar-container">
                                        <div class="calendar">
                                            <div class="month">
                                            <i class="fas fa-angle-left prev"></i>
                                            <div class="date">
                                                <h1></h1>
                                                <p></p>
                                            </div>
                                            <i class="fas fa-angle-right next"></i>
                                            </div>
                                            <div class="weekdays">
                                            <div>Sun</div>
                                            <div>Mon</div>
                                            <div>Tue</div>
                                            <div>Wed</div>
                                            <div>Thu</div>
                                            <div>Fri</div>
                                            <div>Sat</div>
                                            </div>
                                            <div class="days"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php
mysqli_free_result($welcome);

mysqli_free_result($balance);
?>

    <div class="modal fade" id="account-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
		<div class="modal-dialog modal-con">
			<div class="modal-content">
				<div class="modal-header modal-reconfig" align="center">
                    <h5 class="update-header" style="font-weight: 600;">Transaction History</h5>
                </div>
                <div class="modal-body">
                	<div class="row">
                        <div class="col-md-12">
                    <?php require_once "../Connections/ebanking.php";
                        $sql = "SELECT * FROM accountstatement WHERE account = '".$_SESSION['MM_Username']."'";
                        if ($result = mysqli_query($ebanking, $sql)) {
                            if (mysqli_num_rows($result) > 0) {
                                echo'<table class="mobile table table-striped" id="dataTables-userlist-2">';
                                    while ($row = mysqli_fetch_array($result)) {
                                        echo '<thead>';
                                            echo'<tr>';
                                                echo'<th>Details</th>';
                                                echo'<th>Info</th>';
                                            echo'</tr>';
                                        echo'</thead>';
                                        echo'<tbody>';
                                        echo'<tr>';
                                            echo'<th>Date</th>';
                                            echo "<td>".$row['transactiondate']."</td>";
                                        echo'</tr>';
                                        echo'<tr>';
                                            echo'<th>Debit</th>';
                                            echo"<td>".$row['debit']."</td>";
                                        echo'</tr>';
                                        echo'<tr>';
                                            echo'<th>Credit</th>';
                                            echo"<td>".$row['credit']."</td>";
                                        echo'</tr>';
                                        echo'<tr>';
                                            echo'<th>Status</th>';
                                            echo"<td><span class='status active'>".$row['status']."</span></td>";
                                        echo'</tr>';
                                        echo'<tr>';
                                            echo'<th>Balance</th>';
                                            echo"<td>".$row['balance']."</td>";
                                        echo'</tr>';
                                        echo'<tr>';
                                            echo'<th>Description</th>';
                                            echo"<td>".$row['remarks']."</td>";
                                        echo'</tr>';
                                        echo'</tbody>';
                                    }
                                    echo'</table>';
                                    mysqli_free_result($result);
                            }
                        }
                    ?>
                    <table style="width:100%;" class="table table-striped no-wrap desk" id="dataTables-userlist">
                                    <thead>
                                        <tr>
                                        <th data-priority="1">Transaction Date</th>
                                        <th data-priority="2">Credit</th>
                                        <th>Debit</th>
                                        <th>balance</th>
                                        <th>status</th>
                                        <th>description</th>
                                        </tr>
                                    </thead>
                    <?php 
                    $sqli = "SELECT * FROM accountstatement WHERE account = '".$_SESSION['MM_Username']."'";
                    if ($results = mysqli_query($ebanking, $sqli)) {
                        if (mysqli_num_rows($results) > 0) {
                            while ($rows = mysqli_fetch_array($results)) {
                                    echo'<tbody>';
                                        echo'<tr class="odd">';
                                        echo"<td>".$rows['transactiondate']."</td>";
                                        echo"<td class='gray credit-green'>".$rows['credit']."</td>";
                                        echo"<td class='debit-red'>".$rows['debit']."</td>";
                                        echo"<td class='gray'>".$rows['balance']."</td>";
                                        echo"<td><span class='status active'>".$rows['status']."</span></td>";
                                        echo"<td class='gray'>".$rows['remarks']."</td>";
                                        echo'</tr>';
                                    echo'</tbody>';
                            }
                            
                            mysqli_free_result($results);
                        }
                    }

                    ?>
                    </table>
                        
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-success pull-right tools but close" data-dismiss="modal" aria-label="Close"><i style="margin-right: 4px;" class="pe-7s-close"></i>close</button>
                </div>
			</div>
		</div>
	</div>

    <div id="loader">
        <div class="spinner">
            <div class="double-bounce1"></div>
            <div class="double-bounce2"></div>
        </div>
    </div>

    <?php include "includes/footer.php"; ?>
    <script src="js/main.js"></script>
    
    
    
    <script src="../vendor/datatables/js/jquery.dataTables.min.js"></script> 
    <script src="../vendor/datatables-plugins/dataTables.bootstrap.min.js"></script> 
    <script src="../vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script src="../js/adminnine.js"></script>
<script src="js/script.js"></script>
    <script>
    $(document).ready(function(){
            $('#dataTables-userlist').DataTable({
                columnDefs: [
        { responsivePriority: 1, targets: 0 },
        { responsivePriority: 2, targets: -1 }
    ],
                responsive: true,
                pageLength:10,
                sPaginationType: "full_numbers",
                oLanguage: {
                    oPaginate: {
                        sFirst: "<<",
                        sPrevious: "<",
                        sNext: ">", 
                        sLast: ">>" 
                    }
                }
            });
            $('.mobile').DataTable({
                columnDefs: [
        { responsivePriority: 1, targets: 0 },
        { responsivePriority: 2, targets: -1 }
    ],
                responsive: true,
                pageLength:10,
                sPaginationType: "full_numbers",
                oLanguage: {
                    oPaginate: {
                        sFirst: "<<",
                        sPrevious: "<",
                        sNext: ">", 
                        sLast: ">>" 
                    }
                }
            });
             Morris.Bar({
            element: 'morris-bar-chart2',
              data: [
                { y: '2006', a: 100, b: 100},
                { y: '2007', a: 75,  b: 75 },
                { y: '2008', a: 60 , b: 60 },
                { y: '2009', a: 75 , b: 75 },
                { y: '2006', a: 100, b: 100},
                { y: '2007', a: 75,  b: 75 },
                { y: '2008', a: 40,  b: 40 },
                { y: '2009', a: 25,  b: 25 },
                { y: '2006', a: 110, b: 110},
                { y: '2007', a: 75,  b: 75 },
                { y: '2008', a: 60,  b: 60 },
                { y: '2009', a: 75,  b: 75 },
                { y: '2012', a: 100, b: 100}
              ],
               resize: true,
                 axes:'',
                 hideHover: 'auto',
              xkey: 'y',
              padding:1,
              ykeys: ['a', 'b'],
              labels: ['Series A'],
              barColors: ["#ffffff", "#cfdfed"]
            });
            
              $('#mapwrap').vectorMap({map: 'world_mill'});              
                  
    
        $(window).resize(function(){
            
            $('#dataTables-userlist').DataTable();
            
            
        });

        $(window).resize(function(){
            
            $('.mobile').DataTable();
            
            
        });
        
    });
    </script>
</body>
</html>