Ticket Templates - tickets ready to raise: a subject, details and * tasks, and how the ticket is set up (category, priority, billing, agent, due * time and tags). Each row shows what it sets up, its tasks and their time, * and how often it has been used. A template can be changed, copied as the * start of another, archived - kept for the recurring tickets and project * templates that use it, not offered for new tickets - or deleted. The work is * in functions/ticket_template.php; the handlers are admin/post/ticket_template.php. */ require_once "includes/inc_all_admin.php"; $show_archived = isset($_GET['archived']); $search = trim((string) ($_GET['q'] ?? '')); $search_sql = escapeSql($search); $templates = []; $sql = mysqli_query($mysqli, "SELECT ticket_templates.*, category_name, category_color, category_icon, user_name AS assignee_name, (SELECT COUNT(*) FROM task_templates WHERE task_template_ticket_template_id = ticket_templates.ticket_template_id) AS task_count, (SELECT COALESCE(SUM(task_template_completion_estimate), 0) FROM task_templates WHERE task_template_ticket_template_id = ticket_templates.ticket_template_id) AS task_minutes, (SELECT COUNT(*) FROM recurring_tickets WHERE recurring_ticket_ticket_template_id = ticket_templates.ticket_template_id) AS recurring_count, (SELECT COUNT(*) FROM project_template_ticket_templates WHERE project_template_ticket_templates.ticket_template_id = ticket_templates.ticket_template_id) AS project_count FROM ticket_templates LEFT JOIN categories ON category_id = ticket_template_category_id AND ticket_template_category_id > 0 LEFT JOIN users ON user_id = ticket_template_assigned_to AND ticket_template_assigned_to > 0 WHERE ticket_template_archived_at IS " . ($show_archived ? 'NOT NULL' : 'NULL') . " " . ($search !== '' ? "AND (ticket_template_name LIKE '%$search_sql%' OR ticket_template_description LIKE '%$search_sql%' OR ticket_template_subject LIKE '%$search_sql%')" : '') . " ORDER BY ticket_template_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $templates[intval($row['ticket_template_id'])] = $row; } $usage = ticketTemplateUsage(array_keys($templates)); $archived_count = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM ticket_templates WHERE ticket_template_archived_at IS NOT NULL"))[0]); $tag_rows = []; $sql_tags = mysqli_query($mysqli, "SELECT ticket_template_id, tags.* FROM ticket_template_tags JOIN tags ON tags.tag_id = ticket_template_tags.tag_id ORDER BY tag_name"); while ($row = mysqli_fetch_assoc($sql_tags)) { $tag_rows[intval($row['ticket_template_id'])][] = $row; } // This page with some of its query changed - null drops a key $page_url = function (array $change = []) use ($show_archived, $search) { $query = array_merge(['q' => $search !== '' ? $search : null, 'archived' => $show_archived ? 1 : null], $change); return 'ticket_templates.php' . (($query = http_build_query(array_filter($query, function ($v) { return $v !== null; }))) ? "?$query" : ''); }; $csrf = $_SESSION['csrf_token']; ?>

Ticket Templates

A ticket ready to raise - its subject, details and tasks, and how it is set up. Pick one on New Ticket, when raising tickets for several assets or clients, and on recurring tickets; project templates raise theirs. [Client], [Contact], [Month] and the like are filled in when a ticket is raised.

$row) { $name = escapeHtml($row['ticket_template_name']); $task_count = intval($row['task_count']); $minutes = intval($row['task_minutes']); $used = $usage[$template_id] ?? ['count' => 0, 'open' => 0, 'last' => null]; $tags = $tag_rows[$template_id] ?? []; $defaults = ticketTemplateDefaultsHtml($row); $tags_html = $tags ? '' . implode('', array_map('tagPill', $tags)) . '' : ''; $set_up = trim($defaults . ($defaults !== '' && $tags_html !== '' ? ' ' : '') . $tags_html); $linked = []; if (intval($row['recurring_count'])) { $linked[] = intval($row['recurring_count']) . ' recurring ticket' . (intval($row['recurring_count']) === 1 ? '' : 's'); } if (intval($row['project_count'])) { $linked[] = intval($row['project_count']) . ' project template' . (intval($row['project_count']) === 1 ? '' : 's'); } ob_start(); ?>
ticketยท ' . $used['open'] . ' open' : '' ?>
Last
Not yet
Template Sets up Tasks Used Action
Archived
Just the subject and details' ?>
task
None
'ticket templates', 'title' => $show_archived ? 'No archived ticket templates' : 'No ticket templates yet', 'text' => $show_archived ? 'An archived template isn\'t offered for new tickets, but the recurring tickets and project templates that use it keep it.' : 'A ticket ready to raise - its subject, details and tasks, and how it is set up.', 'icon' => 'fa-life-ring', 'filtered' => $search !== '', 'clear_url' => $page_url(['q' => null]), 'actions' => $show_archived ? [] : [['label' => 'New Ticket Template', 'modal' => 'modals/ticket_template/ticket_template_add.php', 'size' => 'lg']], ]) ?>