<?php 

function my_students_cb() {
	$user = new user;
	$post = new post;
	
	if(isset($_GET['id'])) {
		if(!verify_token($_GET['token'])) {
           token_error();
           return_method();
           return;
        }
		$teacher_id = $_GET['id'];
	} else $teacher_id = $session->id;

	$students = get_form_teacher_students($teacher_id);
	
	$sorting = new sorting;
	$output = $sorting->sort_by_meta_value($students, 'surname', 'asc');
	?>

	<div class="row">
		<div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <strong class="card-title">Showing students under <?php echo get_fullname($teacher_id) ?>'s class </strong>
                </div>
                <div class="card-body">
          <table id="bootstrap-data-table" class="table table-striped table-bordered">
            <thead>
              <tr>
                <th>SN</th>
				<th>Name</th>
				<th>Student ID</th>
				<th>Image</th>
				<th>Gender</th>
				<th>Class</th>
              </tr>
            </thead>
            <tbody>
<?php
$i = 1;
if(_count($output) > 0) : 
	foreach ($output as $key => $value) {
		$cmeta = $post->get_post_meta($value['class']);
	 ?>
	 			<tr>
	 				<td><?=$i ?></td>
	 				<td><?=$value['surname'].' '.$value['other_names']; 
	 					action(['profile' => '?id='.$value['id']], ['view_student'], ['edit_student']);
	 					?>
	 				</td>
	 				<td><i class="fas fa-user"></i>&nbsp;<?=strtoupper($value['username']);?></td>
	 				<td><img class="img img-72" src="<?php echo get_user_image($value['id']); ?>"></td>
	 				<td><?=$value['gender'];?></td>
	 				<td><?=$cmeta['class_name']?></td>
	 			</tr>

	<?php $i++; } 
endif;
			?>
            </tbody>
          </table>
                </div>
            </div>
        </div>
    </div>
	<?php
}