<?php

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

<head>
  <meta charset="utf-8" />
  <link rel="apple-touch-icon" sizes="76x76" href="../assets/images/logo/jofaye.ico">
  <link rel="icon" type="image/png" href="../assets/images/logo/jofaye.ico">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name=”robots” content=”noindex,nofollow”>
  <title>
    JOFAYE
  </title>
  <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
  <!--     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"><a href="#" class="simple-text logo-normal">
          <img src="../assets/images/logo/logo_85x85.png" />
        </a></div>
      <div class="sidebar-wrapper">
        <ul class="nav">
          <?php
          $query = "SELECT * FROM `contact` order by 'date' DESC";
          if (count(fetchAll($query)) > 0) {
          ?>
            <li class="nav-item active  ">
              <a class="nav-link" href="./dashboard.php">
                <i class="material-icons">dashboard</i>
                <p>Dashboard</p>
              </a>
            </li>
            <li class="nav-item ">
              <a class="nav-link" href="./message.php">
                <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
          }
          ?>
          <?php
          $query = "SELECT * FROM `volunteer` order by 'date' DESC";
          if (count(fetchAll($query)) > 0) {
          ?>
            <li class="nav-item ">
              <a class="nav-link" href="./volunteers.php">
                <i class="material-icons">content_paste</i>
                <p>Volunteers<span class="badge badge-danger badge-pill"><?php echo count(fetchAll($query)); ?></span></p>
              </a>
            </li>
          <?php
          }
          ?>
          <li class="nav-item ">
            <?php
            $query = "SELECT * FROM `newsletter` order by 'date' DESC";
            if (count(fetchAll($query)) > 0) {
            ?>
              <a class="nav-link" href="./newsletter.php">
                <i class="material-icons">library_books</i>
                <p>Newsletter<span class="badge badge-danger badge-pill"><?php echo count(fetchAll($query)); ?></span></p>
              </a>
            <?php
            }
            ?>
          </li>
          <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.php">Blog Manager</a>
              <a class="dropdown-item" href="./Blog/post-blog.php">Make a Blog Post</a>
            </div>
          </li>
          <!-- <li class="nav-item ">
            <a class="nav-link" href="#" onclick="new_features()">
              <i class="material-icons">content_paste</i>
              <p>Make a Post<span class="badge badge-warning badge-pill">new</span></p>
            </a>
          </li>
          <li class="nav-item ">
            <a class="nav-link" href="#" onclick="new_features()">
              <i class="material-icons">email</i>
              <p>Send a Mail<span class="badge badge-success 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>Dashboard</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 } ?>
                  <?php
                  $query = "SELECT * FROM `newsletter` order by 'date' DESC";
                  if (count(fetchAll($query)) > 0) {
                  ?>
                    <a class="dropdown-item" href="javascript:void(0)">You have <?php echo count(fetchAll($query)); ?> Subscribers</a>
                  <?php } ?>
                  <?php
                  $query = "SELECT * FROM `volunteer` order by 'date' DESC";
                  if (count(fetchAll($query)) > 0) {
                  ?>
                    <a class="dropdown-item" href="javascript:void(0)">You have a total of <?php echo count(fetchAll($query)); ?> volunteers</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="row">
            <?php
            $query = "SELECT * FROM `contact` order by 'date' DESC";
            if (count(fetchAll($query)) > 0) {
            ?>
              <div class="col-xl-4 col-lg-12">
                <div class="card card-chart">
                  <div class="card-header card-header-success">
                    <div class="ct-chart" id="dailySalesChart"></div>
                  </div>
                  <div class="card-body">
                    <h4 class="card-title">Messages<span class="badge badge-danger badge-pill badge-xl"><?php echo count(fetchAll($query)); ?></span></h4>
                    <p class="card-category">
                      <span class="text-success"><i class="fa fa-long-arrow-up"></i> 55% </span> increase in today sales.
                    </p>
                  </div>
                <?php
              }
                ?>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">access_time</i> updated 4 minutes ago
                  </div>
                </div>
                </div>
              </div>
              <div class="col-xl-4 col-lg-12">
                <div class="card card-chart">
                  <div class="card-header card-header-warning">
                    <div class="ct-chart" id="websiteViewsChart"></div>
                  </div>
                  <?php
                  $query = "SELECT * FROM `newsletter` order by 'date' DESC";
                  if (count(fetchAll($query)) > 0) {
                  ?>
                    <div class="card-body">
                      <h4 class="card-title">Email Subscriptions<span class="badge badge-danger badge-pill badge-xl"><?php echo count(fetchAll($query)); ?></span></h4>
                      <p class="card-category">Last Campaign Performance</p>
                    </div>
                  <?php
                  }
                  ?>
                  <div class="card-footer">
                    <div class="stats">
                      <i class="material-icons">access_time</i> campaign sent 2 days ago
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-xl-4 col-lg-12">
                <div class="card card-chart">
                  <div class="card-header card-header-danger">
                    <div class="ct-chart" id="completedTasksChart"></div>
                  </div>
                  <?php
                  $query = "SELECT * FROM `volunteer` order by 'date' DESC";
                  if (count(fetchAll($query)) > 0) {
                  ?>
                    <div class="card-body">
                      <h4 class="card-title">Volunteers<span class="badge badge-danger badge-pill"><?php echo count(fetchAll($query)); ?></span></h4>
                      <p class="card-category">Last Campaign Performance</p>
                    </div>
                  <?php
                  }
                  ?>
                  <div class="card-footer">
                    <div class="stats">
                      <i class="material-icons">access_time</i> campaign sent 2 days ago
                    </div>
                  </div>
                </div>
              </div>
          </div>
          <!-- <div class="row">
            <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-warning card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">content_copy</i>
                  </div>
                  <p class="card-category">Used Space</p>
                  <h3 class="card-title">49/50
                    <small>GB</small>
                  </h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons text-warning">warning</i>
                    <a href="#pablo" class="warning-link">Get More Space...</a>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-success card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">store</i>
                  </div>
                  <p class="card-category">Revenue</p>
                  <h3 class="card-title">$34,245</h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">date_range</i> Last 24 Hours
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-danger card-header-icon">
                  <div class="card-icon">
                    <i class="material-icons">info_outline</i>
                  </div>
                  <p class="card-category">Fixed Issues</p>
                  <h3 class="card-title">75</h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">local_offer</i> Tracked from Github
                  </div>
                </div>
              </div>
            </div>
            <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6">
              <div class="card card-stats">
                <div class="card-header card-header-info card-header-icon">
                  <div class="card-icon">
                    <i class="fa fa-twitter"></i>
                  </div>
                  <p class="card-category">Followers</p>
                  <h3 class="card-title">+245</h3>
                </div>
                <div class="card-footer">
                  <div class="stats">
                    <i class="material-icons">update</i> Just Updated
                  </div>
                </div>
              </div>
            </div>
          </div> -->
        </div>
      </div>
      <footer class="footer">
        <div class="container-fluid">
          <div class="copyright text-center" id="date">
            JOFAYE @ 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>