<?php 

function my_results_cb() {
	$session = Session::getInstance();
	do_action("display_qf_search_box", [
	  	'default' => ['student_id' => $session->id],
	    'id' => "eedu_portal_print_myresults",
	    'query_function' => 'eedu_portal_print_myresults',
	    'settings' => ['autoload' => true, 'limit' => 20, 'autostart' => false]
	]);
	return;
	$session = Session::getInstance();
	$post = new post;
	$sorting = new sorting;
	global $post_meta;
	$output = $post->get_post_by_meta_data(['type' => 'compiled_result', 'student_id' => $session->id]);
	$output = $sorting->sort_by_meta_value($output, 'id', 'desc');
	$token = new_token();
	?>
	<div class="row">
		<div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <strong class="card-title"><?php echo get_fullname($session->id); ?></strong>
                </div>
                <div class="card-body">
          <table id="bootstrap-data-table" class="table table-striped table-bordered">
            <thead>
              <tr>
                <th>SN</th>
                <th>Class</th>
				<th>Academic Session</th>
				<th>Academic Term</th>
				<th>Date Compiled</th>
				<th>Results</th>
              </tr>
            </thead>
            <tbody>
<?php
$i = 1;
if(_count($output) > 0) : 
	foreach ($output as $key => $value) {
		// var_dump($value);
	 ?>
	 			<tr>
	 				<td><?php echo $i; ?></td>
	 				<td><?php echo get_class_name($value['class']); ?></td>
	 				<td><?php echo get_session_name($value['session']); ?></td>
	 				<td><?php echo get_term_name($value['term']); ?></td>
	 				<td><?php echo date(_DATE_FORMAT_, $value['posted_on']) ?></td>
	 				<td>
	 					<?php if ($value['status'] == 'locked'): ?>
	 						<button class="unlock-pad btn btn-danger btn-block" data-url='?action=<?php echo base64_encode("unlock_result") ?>&id=<?php echo $value["id"] ?>&token=<?php echo $token; ?>'><i class="fas fa-unlock-alt"></i>&nbsp;Unlock</button>
	 					<?php else: ?>
		 					<a href="result-sheet?id=<?php echo $value['id']; ?>&token=<?php echo $token; ?>" class="btn btn-success btn-block">View Result</a>
		 				<?php endif ?>
	 				</td>
	 			</tr>

	<?php $i++; } 
endif;
			?>
            </tbody>
          </table>
                </div>
            </div>
        </div>
    </div>
	<?php
	add_page_javascript('contents/plugins/eedu_portal/js/my-results.js');
}