<?php 

function admin_log_cb() {
	global $post_meta;
	add_page_javascript('app/assets/js/page-scripts/init-datatable.js');
	  do_action("display_qf_search_box", [
	  	'default' => ['type' => 'admin_log'],
	    'id' => "admin_log",
	    'query_function' => 'get_admin_log',
	    'settings' => ['autoload' => true, 'limit' => 20],
	  ]);

	return;
	global $post_meta;
	global $app;
	$user_meta = $app->user_meta;
	$user = new user;
	$post = new post;

	$logs = $post->get_post_by_meta_data(['type' => 'admin_log']);

	$sorting = new sorting;
	$output = $sorting->sort_by_meta_value($logs, 'posted_on', 'desc');

	?>

	<div class="row">
		<div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <strong class="card-title">Admin Action Log</strong>
                </div>
                <div class="card-body">
          <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
            <thead>
              <tr>
              	<th>SN</th>
                <th>Date</th>
				<th>Action</th>
				<th>Admin</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 date('d/m/Y h:i:sA', $value['posted_on']) ?></td>
	 				<td><?php echo $value['narration']; ?></td>
	 				<td><?php echo get_fullname($value['posted_by'], true); ?></td>
	 			</tr>

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