<?php

if( !defined( 'ABSPATH' ) ) exit;  // Exit if accessed directly

global $wpdb;
$template_table = $wpdb->prefix . 'giftvouchers_template';
$template_count = $wpdb->get_var( "SELECT COUNT(*) FROM $template_table" );
?>
<div class="wrap">
	<h1><?php echo __('Voucher Templates', 'gift-voucher' ); ?> <?php if($template_count <= 3) { ?><a class="page-title-action" id="add_new_template" href="<?php echo admin_url( 'edit.php' ); ?>?post_type=wpgv_voucher_product&page=new-voucher-template"><?php echo __('Add New Template', 'gift-voucher' ) ?></a><?php } ?></h1>
	<div class="content">
		<div id="post-body" class="metabox-holder">
			<div id="post-body-content">
				<div class="meta-box-sortables ui-sortable">
					<form method="post">
						<?php
						$this->vouchers_obj->prepare_items();
						$this->vouchers_obj->display(); ?>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>