<?php

require 'functions.php';
// require 'php/init.php'
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name=”robots” content=”noindex,nofollow”>
  <link rel="apple-touch-icon" sizes="76x76" href="../../assets/images/logo-res.ico">
  <link rel="icon" type="image/png" href="../../assets/images/logo-res.ico">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title>
    St Jude Wellness
  </title>
  <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
  <meta name=”robots” content=”noindex,nofollow”>

  <!--     Fonts and icons     -->
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
  <!-- CSS Files -->
  <link href="./assets/css/style.css" rel="stylesheet" />
</head>

<body>
  <div class="wrapper ">
    <div class="sidebar" data-color="purple">
      <div class="logo" style="background: #31436b;">
        <a class="navbar-brand p-3" href="../">
          <img class="w-100" src="../assets/images/logo-3.png" alt="logo">
        </a>
      </div>
			<div class="sidebar-wrapper">
				<ul class="nav">
					<?php
					$query = "SELECT * FROM `contact` WHERE c_status='unread'";
					if (count(fetchAll($query)) > 0) {
					?>
					<li class="nav-item active">
						<a class="nav-link" href="./message">
							<i class="material-icons">message</i>
							<p>Messages<span class="badge badge-danger badge-pill"><?php echo count(fetchAll($query)); ?></span></p>
						</a>
					</li>
					<?php
					}
					?>
					<li class="nav-item">
						<a class="nav-link dropdown-toggle" href="#" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
							<i class="material-icons">flag</i>
							<p>Blog</p>
						</a>
						<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
							<a class="dropdown-item" href="./Blog/blog-manager">Blog Manager</a>
							<a class="dropdown-item" href="./Blog/post-blog">Make a Blog Post</a>
						</div>
					</li>
					<?php
					$query = "SELECT * FROM `tbl_consultation` WHERE a_status='opened'";
					if (count(fetchAll($query)) > 0) {
					?>
                    <li class="nav-item">
						<a class="nav-link dropdown-toggle" href="#" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="material-icons">content_paste</i>
                        <p>Consultation<span class="badge badge-danger badge-pill"><?php echo count(fetchAll($query)); ?></span></p>
						</a>
						<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
							<a class="dropdown-item" href="./consultation/consultation-manager.php">Consultation Manager</a>
						</div>
					</li>
					<?php
					}
					?>
					<li class="nav-item ">
						<a class="nav-link" href="#" onclick="new_features()">
							<i class="material-icons">notifications</i>
							<p>Notifications<span class="badge badge-secondary badge-pill">new</span></p>
						</a>
					</li> 
				</ul>
			</div>
    </div>
    <div class="main-panel">
      <!-- Navbar -->
      <nav class="navbar navbar-expand-lg navbar-transparent navbar-absolute fixed-top " id="navigation-example">
        <div class="container-fluid">
          <div class="navbar-wrapper">
            <a class="navbar-brand" href="javascript:void(0)">
              <h3>Messages</h3>
            </a>
          </div>
          <button class="navbar-toggler" type="button" data-toggle="collapse" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation" data-target="#navigation-example">
            <span class="sr-only">Toggle navigation</span>
            <span class="navbar-toggler-icon icon-bar"></span>
            <span class="navbar-toggler-icon icon-bar"></span>
            <span class="navbar-toggler-icon icon-bar"></span>
          </button>
          <div class="collapse navbar-collapse justify-content-end">
            <form class="navbar-form">
              <div class="input-group no-border">
                <input type="text" value="" class="form-control" placeholder="Search...">
                <button type="submit" class="btn btn-default btn-round btn-just-icon">
                  <i class="material-icons">search</i>
                  <div class="ripple-container"></div>
                </button>
              </div>
            </form>
            <ul class="navbar-nav">
              <li class="nav-item">
                <a class="nav-link" href="javascript:void(0)">
                  <i class="material-icons">dashboard</i>
                  <p class="d-lg-none d-md-block">
                    Stats
                  </p>
                </a>
              </li>
              <li class="nav-item dropdown">
                <a class="nav-link" href="javscript:void(0)" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  <i class="material-icons">notifications</i>
                  <span class="notification">5</span>
                  <p class="d-lg-none d-md-block">
                    Notifications
                  </p>
                </a>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
                  <?php
                  $query = "SELECT * FROM `contact` WHERE c_status = 'unread' order by 'date' DESC";
                  if (count(fetchAll($query)) > 0) {
                  ?>
                    <a class="dropdown-item" href="javascript:void(0)">You have <?php echo count(fetchAll($query)); ?> new Messages</a>
                  <?php } ?>
                </div>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="javascript:void(0)">
                  <i class="material-icons">person</i>
                  <p class="d-lg-none d-md-block">
                    Account
                  </p>
                </a>
              </li>
            </ul>
          </div>
        </div>
      </nav>
      <!-- End Navbar -->
      <div class="content">
        <div class="container-fluid">
          <div class="card display-bar">
            <div class="card-body" style="color: black !important">
              <div class="panel-body">
                <?php
                $query = "SELECT * FROM `contact`  ORDER BY created_at DESC";
                if (count(FetchAll($query)) > 0) {
                  foreach (FetchAll($query) as $i) {
                ?>
                    <a class="dropdown-item text-black" href="./display_msg.php?id=<?php echo $i['id'] ?>" style="
                        <?php
                        if ($i['c_status'] == 'unread') {
                          echo "font-weight:bold;";
                        }
                        ?>
                    ">
                      <small class="text-black"><em><?php echo date('F j,Y, g:i a', strtotime($i['created_at'])) ?></em></small><br />
                      <?php
                      if ($i['c_message']) {
                        // echo "New message from ".$i['c_fullname']; 
                        echo $i['c_fullname'];
                      }
                      ?>
                    </a>
                    <div class="dropdown-divider"></div>
                <?php
                  }
                } else {
                  echo "No New Message yet";
                }
                ?>
              </div>
            </div>
          </div>
        </div>
      </div>
      <footer class="footer">
        <div class="container-fluid">
          <div class="copyright text-center">
            St Jude-wellness @ copyrights <script>
              document.write(new Date().getFullYear());
            </script> -Powered by <a href="mailto:anonymous.inview@gmail.com" target="_blank">Alaid</a>
          </div>
        </div>
      </footer>
      <script>
        const x = new Date().getFullYear();
        let date = document.getElementById('date');
        date.innerHTML = '&copy; ' + x + date.innerHTML;
      </script>
    </div>
  </div>

  <script src="./assets/js/jquery.min.js"></script>
  <script src="./assets/js/popper.min.js"></script>
  <script src="./assets/js/bootstrap-material-design.min.js"></script>
  <script src="./assets/js/perfect-scrollbar.jquery.min.js"></script>
  <script src="./assets/js/chartist.min.js"></script>
  <script src="./assets/js/bootstrap-notify.js"></script>
  <script src="./assets/js/material-dashboard.js"></script>
  <script type="text/javascript">
    function new_features() {
      alert("This feature is not available, contact Developer (+2347052245543) for an upgrade...");
    }
  </script>
  <script>
    $(document).ready(function() {
      $().ready(function() {
        $sidebar = $('.sidebar');

        $sidebar_img_container = $sidebar.find('.sidebar-background');

        $full_page = $('.full-page');

        $sidebar_responsive = $('body > .navbar-collapse');

        window_width = $(window).width();

        $('.switch-sidebar-image input').change(function() {
          $full_page_background = $('.full-page-background');

          $input = $(this);

          if ($input.is(':checked')) {
            if ($sidebar_img_container.length != 0) {
              $sidebar_img_container.fadeIn('fast');
              $sidebar.attr('data-image', '#');
            }

            if ($full_page_background.length != 0) {
              $full_page_background.fadeIn('fast');
              $full_page.attr('data-image', '#');
            }

            background_image = true;
          } else {
            if ($sidebar_img_container.length != 0) {
              $sidebar.removeAttr('data-image');
              $sidebar_img_container.fadeOut('fast');
            }

            if ($full_page_background.length != 0) {
              $full_page.removeAttr('data-image', '#');
              $full_page_background.fadeOut('fast');
            }

            background_image = false;
          }
        });

        $('.switch-sidebar-mini input').change(function() {
          $body = $('body');

          $input = $(this);

          if (md.misc.sidebar_mini_active == true) {
            $('body').removeClass('sidebar-mini');
            md.misc.sidebar_mini_active = false;

            $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar();

          } else {

            $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar('destroy');

            setTimeout(function() {
              $('body').addClass('sidebar-mini');

              md.misc.sidebar_mini_active = true;
            }, 300);
          }

          // we simulate the window Resize so the charts will get updated in realtime.
          var simulateWindowResize = setInterval(function() {
            window.dispatchEvent(new Event('resize'));
          }, 180);

          // we stop the simulation of Window Resize after the animations are completed
          setTimeout(function() {
            clearInterval(simulateWindowResize);
          }, 1000);

        });
      });
    });
  </script>
  <script>
    $(document).ready(function() {
      // Javascript method's body can be found in assets/js/demos.js
      md.initDashboardPageCharts();

    });
  </script>
</body>

</html>