<?php 

function download_external_exam_cb () {
	$session = Session::getInstance();
	global $app;
	$user_meta = $app->user_meta;
	$post = new post;
	$existing = $post->get_post_by_meta_data(['student_id' => $session->id, 'type' => 'external_exam']);
	?>

	<div class="row">
		<div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <strong class="card-title">External Examinations</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>Examination</th>
				<th>Class</th>
				<th>Published On</th>
				<th></th>
              </tr>
            </thead>
            <tbody>
<?php
$i = 1;
if(_count($existing) > 0) : 
	foreach ($existing as $key => $value) {
	 ?>
	 			<tr>
	 				<td><?=$i ?></td>
	 				<td><?=$user_meta['surname'].' '.$user_meta['other_names']; ?></td>
	 				<td><i class="fa fa-user"></i>&nbsp;<?=strtoupper($user_meta['username']);?></td>
	 				<td><?=ucwords($value['exam']);?></td>
	 				<td><?=get_class_name($value['class'], $value['category']); ?></td>
	 				<td><?= date(_DATE_FORMAT_, $value['posted_on']) ?></td>
	 				<td><a href="<?= $value['file']; ?>" download>Download</a></td>
	 			</tr>

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