<?php 
    // continue the session
    session_start();
    
    // Add includes to PHP files that I will need to access
    include 'php_only_scripts/database.php';
    include 'php_only_scripts/presentation.php';
    include 'php_only_scripts/users_presentation.php';
    include_once 'php_only_scripts/timecards_presentation.php';
    include_once 'php_only_scripts/user_agent.php';

    // Init some variables
    $userRow=null;

    // Assume NOT gtg
    $gtg = false;

    // Create and Setup the database
    $db = new Database();
    $db->setupTmsDB();

    // Attempt to log in with this user
    $currentUser = $db->getLoggedInSessionUser(session_id());
    
    // If there is only one result for a username/password combo, then they are good to go.
    if ($currentUser == null){
        exit;
    }
    elseif (mysqli_num_rows($currentUser)==1){
        // Attempt to get the user row
        $userRow = $currentUser->fetch_assoc();
        
        //create an instance of UserAgent class
        $ua = new UserAgent();

        // Determine if this user has access to this page
        if ($userRow["SUEmployee"]!=1 ||
            $userRow["AccountStatus"]!='ACTIVE'){
            // redirect to the invalid access page
            echo ('<script>window.location = "invalid_access.php";</script>');

            exit;
        }
        // If site is accessed from mobile, then redirect to the page stating 
        // mobile devices are not useable here
        //.
        else if($ua->is_mobile() && 
           $userRow["UserLevel"]!='SU' &&
           $userRow["UserLevel"]!='EXECUTIVE' ||
           $userRow["AccountStatus"]!='ACTIVE'){
                // Redirect to the site informing them
                echo ('<script>window.location = "invalid_device.php";</script>');

                // Exit out of any more code execution
                exit;
        }
    
        
        // Set the good to go until they log out
        $gtg = true;
    }

?>
        
﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="refresh" content="60"/>
    <title>Task Management System - Account - Clock Status</title>

    <meta name="keywords" content="GIS,data,testing,IT" />
    <meta name="description" content="EES Divisions." />

    <script src="./javascript/general.js" type="text/javascript"></script>
    <script src="./SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <script src="scripts/jquery-ui-1.10.4.custom/js/jquery-1.10.2.js" type="text/javascript"></script>
    <script src="scripts/jquery-ui-1.11.4.custom/jquery-ui.js" type="text/javascript"></script>

    <link rel="icon" href="images/ees_ico.ico"/> 
    <link href="scripts/jquery-ui-1.10.4.custom/development-bundle/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css"/>
    <link href="./SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <link href="./SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
    <link rel = "stylesheet" type="text/css" href="./css/contentpage.css" >
        
    <style type="text/css">
        .Table
        {
            display: table;
            width: 100%;
        }
        .Title
        {
            display: table-caption;
            text-align: center;
            font-weight: bold;
            font-size: larger;
        }
        .Heading
        {
            display: table-row;
            font-weight: bold;
            text-align: center;
            width: 100%;
        }
        .Row
        {
            display: table-row;
            width: 100%;
        }
        .cell
        {
            display: table-cell;
            border: solid;
            border-width: thin;
            padding-left: 2px;
            padding-right: 2px;
            font-weight: bold;
            vertical-align: middle;
        }
        .standardFontSize
        {
            font-size: 16px;
        }
        .trialCell
        {
            width: 5%;
            text-align: center;
        }
        .nameCell
        {
            width: 10%;
            text-align: center;
        }
        .levelCell
        {
            width: 15%;
            text-align: center;
        }
        .dateTimeCell
        {
            text-align: left;
        }
        .clockInStatusCell
        {
            width: 19%;
            text-align: center;
        }
        .durationCell
        {
            width: 11%;
            text-align: center;
        }
        .weekHoursCell
        {
            width: 12%;
            text-align: center;
        }
        .subWeekHoursCell
        {
            width: 6%;
            text-align: center;
        }
        span {
          display: inline-block;
          vertical-align: middle;
          line-height: normal;      
        }
        
        /*----------------------------------------------
        CSS settings for HTML div Exact Center
        ------------------------------------------------*/
        #showExpandedClockStatus {
            align-items: center;
            width:100%;
            height:100%;
            top:0;
            left:0;
            position:fixed;
            background-color: rgba(49, 49, 49, .95);
            overflow:hidden;
        }
        
        #showExpandedClockStatusBackground {
            background-color: rgba(255, 255, 255, 1); 
            overflow-y: scroll; 
            top: 0%;
            left: 0%;
            right: 0%;
            width: 100%; 
            height: 97%; 
            padding: 2px; 
            margin: 0 auto;
            position:absolute;
        }
        
        #closeExpandedBtn:hover {
            float:right;
            display:inline-block;
            padding:2px 5px;
            background-color: rgba(60, 108, 155, 1);
        }    
        
        #closeExpandedDiv {
            position: fixed;
            left: 95%;
            top: 95%;
            float:right;
            display:inline-block;
            padding:2px 5px;
            background-color: rgba(49, 49, 49, 0);
        }   
        
        /*----------------------------------------------
        CSS settings for blinker
        ------------------------------------------------*/
        .waitingForConnection {
          -webkit-animation-name: blinker;
          -webkit-animation-iteration-count: infinite;
          -webkit-animation-timing-function: cubic-bezier(.5, 0, 1, 1);
          -webkit-animation-duration: 1.5s;
        }        
        @keyframes blinker {
          50% {
            opacity: 0;
          }
        }
    </style>
    <script>
        $(function() {
            $( "#tabs" ).tabs();
        });
    </script>
</head>

<body class="thrColElsHdr">

<div id="container">
  
<!-- start of banner wrap --->

<div id="topContent">
</div>
<!-- end of banner wrap --->

  <!-- end #header -->
  <br class="clearfloat" />
  <div id="sidebar1">
      <?php 
        // Determine if we are GTG
        if ($gtg){
            // Render the appropriate presentation for the tasks sidebar
            getSidebar($userRow, 'timecard');
        }
      ?>       
      <br class="clearfloat" />
  <!-- end #sidebar1 -->
  </div>
  
  <!-- start #mainContent -->
  <div id="mainContent">
    <div class="maintitle">Task Management System - Accounts - Clock Status</div>
    <div class="breadcrumb"> <a href="index.html"> Home </a> > <a href="tasks.php"> Task Management System </a> > <a href="users.php"> Accounts </a> > <a href="clockedStatus.php"> Clock Status </a></div>
    <br>
        
    <div id="showExpandedClockStatus">
        <div id="showExpandedClockStatusBackground" style="text-align:center; vertical-align: middle; font-size: 33; background-color: Gainsboro;">
            <div id="closeExpandedDiv">
                <button id="closeExpandedBtn" onclick="window.location.href = 'clockedStatus.php';"">MIN</button>
            </div>        
            <?php
                // Determine if they are GTG
                if ($gtg){
                    // Time to query for their tasks
                    echo(retrieveSUEmployeesTimeAsList($db, $userRow));
                }
                else {
                    // Set the login failed to true
                    $_SESSION['failedLogin']='TRUE';

                    // Add a session variable that is this page URL
                    $_SESSION['pageToGoTo']=$_SERVER['REQUEST_URI'];

                    // redirect to the login page
                    echo ('<script>window.location = ".";</script>');
                }
            ?>       
    
        </div>
    <!-- Popup Div Ends Here -->
    </div>
  <!-- end #mainContent -->
  
  <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
  <br class="clearfloat" />

  <!-- start #footer --></div>
   <div id="footer">
    <p>© 2018 Evolve Engineering and Software. EES, Evolve Engineering and Software, EES Logo are registered marks of Evolve Engineering and Software.</p>
  <!-- end #footer -->
   </div>
<!-- end #container -->
</div>

</body>

</html>