<?php include('header.php');?>
<?php include('sidebar.php');
include 'includes/db_config.php';?>

<?php 
include('includes/class.usertype.php');
$usertype = new Usertype();
 
if(!isset($user_id)){
	header('Location: dashboard.php');
}
?>
<?php
$maintitle=AL_ADMINISTRATOR;
$page="administrator.php";
$table="tbl_login";
$field_id="userid";
$mode=$_REQUEST['mode'];
$content_id=$_REQUEST['content_id'];

?>


<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1><?php echo $maintitle;?></h1>
      <ol class="breadcrumb">
        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>
        <li class="active"><?php echo $maintitle;?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
   
        
         
        <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
                <a href="<?php echo $page;?>?mode=add"><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i>&nbsp;<?php echo AL_ADDNEW;?> <?php echo $maintitle;?></button></a>                   
                </div>
              </div>
            </div>
            <?php
			$listtypes=$helper->selectlimit($table,"*",array(),$start,$limit);			 
			?>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            
              <table class="table table-hover">
                <tr>
                  <th>Serial No.</th>
                  <th>Name</th>
                  <th>Date</th>
                  <th>Duration</th>
                  
 
                </tr>
                <?php
				$i=($start*$limit)+1;
				  $listtypes=mysqli_query($con,"select * from tbl_login where user='23'");			  
				foreach($listtypes as $type){
					$uu=$type['user'];
					 $listuser=mysqli_query($con,"select * from tbl_users where int_user_id='$uu'");
					$resuser=mysqli_fetch_array($listuser);
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <td><?php echo $resuser['firstname']." ".$resuser['middlename']." ".$resuser['laststname'];?></td>
                  <td><?php echo $type['enterdate'];?> </td>
                  <td><?php 
					 $date1 = strtotime($type['login']);
 $date2=strtotime($type['logout']); 
					
					$diff = abs($date2 - $date1);  
					$years = floor($diff / (365*60*60*24));  
					  $months = floor(($diff - $years * 365*60*60*24)/ (30*60*60*24));
					$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); 
					$hours = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); 
					$minutes = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24  - $hours*60*60)/ 60); 
					$seconds = floor(($diff - $years * 365*60*60*24- $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); 
	//printf("%d years, %d months, %d days, %d hours, " . "%d minutes, %d seconds", $years, $months,$days, $hours, $minutes, $seconds); 
		printf(" %d hours, " . "%d minutes, %d seconds",  $hours, $minutes, $seconds); 
					  ?> </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
              <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
     

    </section>
    <!-- /.content -->
  </div>
<?php include('footer.php');  ?>