<?php
	include("../utilities/UtilitiesManagers.php");
	include("../utilities/UtilitiesReporting.php");
	include("../include/session.php");
	date_default_timezone_set('America/New_York');
?>
<!-- jQplot CSS -->
<link rel="stylesheet" media="screen" href="lib/jqplot/jquery.jqplot.min.css" />
<!-- jQplot CSS END -->

                <h1 class="page-title">Dashboard</h1>
                <div class="container_12 clearfix leading">
					<?php
						if(isset($_SESSION['clientAddedSuccess'])){
							if($_SESSION['clientAddedSuccess']){
							?>
							<div class="message success closeable">
								<span class="message-close"></span>
								<h3>Client Record Added Successfully</h3>
							</div>
							
							<?php
							}
							unset($_SESSION['clientAddedSuccess']);
						}
					?>
					<?php
						if(isset($_SESSION['clientUpdatedSuccess'])){
							if($_SESSION['clientUpdatedSuccess']){
							?>
							<div class="message success closeable">
								<span class="message-close"></span>
								<h3>Client Record Updated Successfully</h3>
							</div>
							
							<?php
							}
							unset($_SESSION['clientUpdatedSuccess']);
						}
					?>
					
					<?php
						if(isset($_SESSION['clientDeleted'])){
							if($_SESSION['clientDeleted']){
							?>
							
							
							<?php
							}
							unset($_SESSION['clientDeleted']);
						}
					?>
					
   
                    <section class="grid_12"> 
                        <?php $manager->getManagersMessage(); ?>
                    </section> 
                
                    <section class="portlet grid_6 leading"> 
 
                        <header>
                            <h2>Demographics - City</h2> 
                        </header>
                        
                        <section>
                            <?php $reporting->getClientCities();?>
                            
                        </section>
                        
                    </section> 
					
					<?php 
						if($session->isAdmin())
						{
					?>
					<section class="portlet grid_6 leading"> 
 
                        <header>
                            <h2>System Stats:</h2> 
                        </header>
                        
                        <section>
							<table class="full">
								<tbody>
									<tr>
										<td>
										Total Users Online:
										</td>
										<td>
										<?php echo $reporting->getTotalActiveUsers();?>
										</td>
									</tr>
									<tr>
										<td>
										Total Users:
										</td>
										<td>
										<?php echo $reporting->getTotalUsers();?>
										</td>
									</tr>
									<tr>
										<td>
										Total Clients:
										</td>
										<td>
										<?php echo $reporting->getTotalClients();?>
										</td>
									</tr>
								</tbody>
							
							</table>
                            
                            
                        </section>
                        
                    </section> 
				
 
                    <div class="clear"></div>
<?php } ?>
                    <section class="portlet grid_6 leading"> 
 
                        <header>
                            <h2>EMERAS Data Integrity: (All Stats Refer To Client Data)</h2>
                        </header>

                        <section>
                            <table class="full">
 
                                <tbody> 
 
                                    <tr> 
 
                                        <td>Empty Cities:</td> 
										<?php
										$totalClients = $reporting->getTotalClientCount();
										$emptyCityClients = $reporting->getNoCityClients();
										$percentage = round(($emptyCityClients/$totalClients) * 100);
										?>
                                        <td style="width:70%"><div id="progress1" class="progress"><span style="width: <?php echo $percentage;?>%;"><b><?php echo $percentage;?>%</b></span></div></td> 
                                    </tr> 
 
                            
 
                                </tbody> 
 
                            </table>
                        </section>
                    </section>
 
                
                    <div class="clear"></div>
                
                </div>

    <!-- jQplot SETUP -->
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/jqplot/excanvas.js"></script>
    <![endif]-->
    <script type="text/javascript" src="lib/jqplot/jquery.jqplot.min.js"></script>
    <script type="text/javascript" src="lib/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
    <script type="text/javascript" src="lib/jqplot/plugins/jqplot.barRenderer.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){

    });
    </script>
    <!-- jQplot SETUP END -->