<?php 

events::addListener('admin::index', function() { 

	$array = array(
		"exams" => 1,
		"questions" => 1,
		"subjects" => 1,
		"departments" => 1,
		"portals" => 1,
	);
	
	$prefix = DB_TABLE_PREFIX;

?>
	
	<div class='container-fluid'>
	
		<div class='row'>
			
			<?php 
				function dropbox( $table, $total ) {
			?>
			
			<div class='col-lg-4 col-md-3 col-sm-6 mb-3'>
				<div class='card'>
					<div class='card-body text-capitalize'>
						<h4 class='fw-normal'><?php echo $table; ?></h4>
						<p class='display-6 text-end'><?php echo $total; ?></p>
					</div>
				</div>
			</div>
			<?php }; ?>
				
			<?php 
			
				$students = roles::get_assigned_users('student');
				
				dropbox( 'Students', count($students) );
				
				foreach( $array as $table => $condition ):
		
					$tablename = "{$prefix}_{$table}";
					
					$SQL = "
						SELECT COUNT( $tablename.id ) as total
						FROM {$tablename}
						WHERE {$condition}
					";
					
					$result = uss::$global['mysqli']->query( $SQL );
					$total = $result->fetch_assoc()['total'];
					
					dropbox( $table, $total );
					
				endforeach; 
			 
			?>
			
		</div>
	
	</div>
	
<?php });