<?php 

function withdrawn_student_cb() {
	$user = new user;
	$post = new post;
	$class = '';
	if(isset($_GET['c'])) {
		$class = base64_decode($_GET['c']);
		$students = $user->get_user_by_meta_data(['role' => 'student', 'status' => 'inactive', 'class' => $class]);
		$classname = get_class_name($class);
	} else {
		$students = $user->get_user_by_meta_data(['role' => 'student', 'status' => 'inactive']);
		$classname = 'All';
	}
	
	$classes = $post->get_post_by_meta_data(['type' => 'class']);
	$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 <?php echo $classname ?> Withdrawn Students</strong>
                </div>
                <div class="card-body">
                <div class="filter">
                	<div class="row">
	                	<div class="col-md-12">
	                		<?php if (_count($classes) > 0): ?>
	                			<?php foreach ($classes as $class_meta): ?>
	                				<div class="btn-container">
	                					<a href="?c=<?php echo base64_encode($class_meta['id']) ?>" class="btn btn-secondary btn-sm btn-round <?php echo ($class == $class_meta['id']) ? 'active' : ''; ?>" ><i class="fas fa-bullseye"></i>&nbsp;<?php echo $class_meta['class_name']; ?></a>
	                				</div>
	                			<?php endforeach ?>
	                		<?php endif ?>
	                		<div class="btn-container">
            					<a href="our-students" class="btn btn-secondary btn-sm btn-round" >All Classes</a>
            				</div>
	                	</div>
	                </div>
                </div>
          <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;<?=$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
}