<?php 

function generated_pins_cb() {
	global $post_meta;
	$resultPin = new resultPin;	
	$post = new post;
	$sorting = new sorting;
	$output = $post->get_post_by_meta_data(['type' => 'result_pins']);
	$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">Generated Pins</strong>
                    <button class="btn btn-primary pull-right" id="generate-pins" data-url='?action=<?php echo base64_encode("generate_pins") ?>&token=<?php echo $token; ?>' style="top: 4px;position: absolute;right: 4px;">Generate New Pins</button>
                </div>
                <div class="card-body">
          <table id="bootstrap-data-table" class="table table-striped table-bordered">
            <thead>
              <tr>
                <th>SN</th>
				<th>Batch Number</th>
				<th>Pins Generated</th>
				<th>Date Generated</th>
				<th></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 $value['batch']; ?></td>
	 				<td><?php echo $value['count']; ?></td>
	 				<td><?php echo date(_DATE_FORMAT_, $value['posted_on']) ?></td>
	 				<td>
	 					<a href="pins-by-batch?id=<?php echo $value['id']; ?>&media=print" class="btn btn-success btn-block popmeup" data-width="1280" data-height="700">Print</a>
	 				</td>
	 			</tr>

	<?php $i++; } 
endif;
			?>
            </tbody>
          </table>
                </div>
            </div>
        </div>
    </div>
	<?php
	add_page_javascript('contents/plugins/eedu_portal/js/generated-pins.js');
	add_page_javascript('app/assets/js/page-scripts/js-functions.js');
}