} else {
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['page_num'])) {
    $page_num = (int) $_GET['page_num'];
} else {
    $page_num = 1;
}
if (isset($_GET['s'])) {
    $templatessearch = $_GET['s'];
} else {
    $templatessearch = '';
}
$wp_templates_search = new TC_Templates_Search($templatessearch, $page_num);
$fields = $templates->get_template_col_fields();
$columns = $templates->get_columns();
?>
<div class="wrap tc_wrap">
	<h2><?php 
_e('Ticket Templates', 'tc');
if (isset($_GET['action']) && ($_GET['action'] == 'edit' || $_GET['action'] == 'add_new')) {
    ?>
<a href="edit.php?post_type=tc_events&page=<?php 
    echo $_GET['page'];
    ?>
" class="add-new-h2"><?php 
    _e('Back', 'tc');
    ?>
</a><?php 
function tc_get_ticket_templates($field_name = '', $post_id = '')
{
    $wp_templates_search = new TC_Templates_Search('', '', -1);
    if ($post_id !== '') {
        $currently_selected = get_post_meta($post_id, $field_name, true);
    } else {
        $currently_selected = '';
    }
    ?>
	<select name="<?php 
    echo $field_name;
    ?>
_post_meta">
		<?php 
    foreach ($wp_templates_search->get_results() as $template) {
        $template_obj = new TC_Event($template->ID);
        $template_object = $template_obj->details;
        ?>
			<option value="<?php 
        echo $template_object->ID;
        ?>
" <?php 
        selected($currently_selected, $template_object->ID, true);
        ?>
><?php 
        echo $template_object->post_title;
        ?>
</option>
			<?php 
    }
    ?>
	</select>
	<?php 
    if (isset($_GET['ID'])) {
        $ticket = new TC_Ticket((int) $_GET['ID']);
        $template_id = $ticket->details->ticket_template;
        ?>
		<a class="ticket_preview_link" target="_blank" href="<?php 
        echo apply_filters('tc_ticket_preview_link', admin_url('edit.php?post_type=tc_events&page=tc_ticket_templates&action=preview&ticket_type_id=' . (int) $_GET['ID']) . '&template_id=' . $template_id);
        ?>
"><?php 
        _e('Preview', 'tc');
        ?>
</a>
		<?php 
    }
}