<?php 

function pins_by_batch_cb() {
	$post = new post;
	$resultPin = new resultPin;
	$batch_meta = $post->get_post_meta($_GET['id']);
	$pins = $resultPin->get_pins_by_meta_data(['batch' => $batch_meta['batch']]);
	$i = 1;
	?>
	<style type="text/css">
		.result-pin {
			font-size: 22px;
			text-align: center;
		}
		.card-text {
			display: inline flow-root list-item;
			font-size: 15px;
			text-align: justify;
			line-height: 1.2;
		}
		.page-break {
			page-break-after: always;
		}

		@media all {
			.page-break-before{ display: none; }
		}

		@media print {
			.page-break-before{ display: block; page-break-before: always !important; }

			.page-break-avoid{ page-break-inside: avoid !important; }
			.row {
				display: block !important; 
			}
		}
	</style>
	<div class="bg-white">
		<!-- <div class="row"> -->
			<div class="page-break-avoid row">
			<?php foreach ($pins as $pin_meta): ?>
				<div class="card pt-2 pb-2 result-pin-card col-xs-4">
					<?php if ($pin_meta['result'] != '-1' && $pin_meta['valid'] == 0): 
						$result_meta = $post->get_post_meta($pin_meta['result']);
						?>
						<span class="badge badge-danger"><i class="fas fa-info-circle"></i>&nbsp;Used by <?php echo get_fullname($result_meta['student_id']) ?></span>
					<?php endif ?> 

					<?php if ($pin_meta['result'] == '-1' && $pin_meta['valid'] == 0): ?>
						<span class="badge badge-danger"><i class="fas fa-info-circle"></i>&nbsp;Invalidated</span>
					<?php endif ?>
					<img src="contents/plugins/eedu_portal/images/crypt.png" alt="Card image cap" width="318" height="180" class="card-img-top">
				  <div class="card-body">
				    <h5 class="result-pin"><?php echo $resultPin->format_pin($pin_meta['pin']); ?></h5>
				    <p class="card-text text-center mt-2">Visit: <?php echo get_option("home_url"); ?></p>
				    <p class="card-text">Click on check termly result. On the next page enter your surname and allow some time for system to search your record. Select your name from the list. Enter your 15 digits pin. Then click on "Get Result". This PIN will be tied to that result once you use it and ensure you keep it safe for reprinting.<br/>If the result is for mock exam, especially JS3 and SS3 second term, ensure that you check the column for mock exam before sending.</p>
			      </div>
				</div>
				<?php if ($i%9 == 0): ?>
				  	</div>
				  	<div class="page-break-before"></div>
				  	<div class="page-break-avoid row">
				<?php endif ?>
			<?php $i++; endforeach; ?>
			</div>
		</div>
	<!-- </div> -->
	<?php
}