Initial commit
This commit is contained in:
49
templates/form-ticket.php
Normal file
49
templates/form-ticket.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
if (isset($_GET['ticket_submitted'])) {
|
||||
if ($_GET['ticket_submitted'] === 'success') {
|
||||
echo '<div class="sts-alert sts-alert-success">' . __('Ticket enviado com sucesso!', 'simple-ticket-system') . '</div>';
|
||||
} else {
|
||||
echo '<div class="sts-alert sts-alert-error">' . __('Ocorreu um erro ao enviar o ticket.', 'simple-ticket-system') . '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="" method="post" class="sts-ticket-form" enctype="multipart/form-data">
|
||||
<?php wp_nonce_field('sts_ticket_form', 'sts_ticket_form_nonce'); ?>
|
||||
|
||||
<div class="form-grupo">
|
||||
<label for="sts_ticket_title"><?php _e('Descreva resumidamente seu problema', 'simple-ticket-system'); ?></label>
|
||||
<input type="text" id="sts_ticket_title" name="sts_ticket_title" required>
|
||||
</div>
|
||||
|
||||
<div class="form-grupo">
|
||||
<label for="sts_ticket_content"><?php _e('Forneça detalhes', 'simple-ticket-system'); ?></label>
|
||||
<textarea id="sts_ticket_content" name="sts_ticket_content" rows="8" required></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-grupo">
|
||||
<label for="sts_ticket_type"><?php _e('Tipo de solicitação', 'simple-ticket-system'); ?></label>
|
||||
<select id="sts_ticket_type" name="sts_ticket_type" required>
|
||||
<?php
|
||||
$types = get_terms(array('taxonomy' => 'ticket_type', 'hide_empty' => false));
|
||||
foreach ($types as $type) {
|
||||
echo '<option value="' . esc_attr($type->term_id) . '">' . esc_html($type->name) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-grupo">
|
||||
<label for="sts_ticket_attachment"><?php _e('Anexo', 'simple-ticket-system'); ?></label>
|
||||
<div class="sts-file-input-wrapper">
|
||||
<span class="sts-file-input-button"><?php _e('Escolher arquivo', 'simple-ticket-system'); ?></span>
|
||||
<input type="file" id="sts_ticket_attachment" name="sts_ticket_attachment">
|
||||
</div>
|
||||
<span id="sts-file-name" class="sts-file-name"></span>
|
||||
<small><?php _e('(captura de tela, documento ou qualquer outro arquivo)', 'simple-ticket-system'); ?></small>
|
||||
</div>
|
||||
|
||||
<div class="form-grupo">
|
||||
<input type="submit" name="sts_submit_ticket" value="<?php _e('Enviar Ticket', 'simple-ticket-system'); ?>">
|
||||
</div>
|
||||
</form>
|
66
templates/single-ticket.php
Normal file
66
templates/single-ticket.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
get_header(); ?>
|
||||
|
||||
<div id="primary" class="sts-content-area">
|
||||
<main id="main" class="sts-site-main">
|
||||
|
||||
<?php
|
||||
while (have_posts()) : the_post();
|
||||
$status = wp_get_object_terms(get_the_ID(), 'ticket_status', array('fields' => 'names'));
|
||||
$types = wp_get_object_terms(get_the_ID(), 'ticket_type', array('fields' => 'names'));
|
||||
$attachments = get_attached_media('', get_the_ID());
|
||||
$ticket_id = get_post_meta(get_the_ID(), '_sts_ticket_id', true);
|
||||
|
||||
$current_status = !empty($status) ? esc_html($status[0]) : __('Sem status', 'simple-ticket-system');
|
||||
$status_class = !empty($status) ? sanitize_title($status[0]) : 'no-status';
|
||||
$current_type = !empty($types) ? esc_html($types[0]) : __('Não definido', 'simple-ticket-system');
|
||||
?>
|
||||
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class('sts-single-ticket'); ?>>
|
||||
<header class="sts-ticket-header">
|
||||
<div class="sts-title-wrapper">
|
||||
<h1 class="sts-ticket-title"><?php the_title(); ?></h1>
|
||||
<span class="sts-single-ticket-id"><?php echo esc_html($ticket_id); ?></span>
|
||||
</div>
|
||||
<div class="sts-ticket-meta">
|
||||
<span class="sts-ticket-status <?php echo $status_class; ?>"><?php echo $current_status; ?></span>
|
||||
<span class="sts-ticket-info"><strong><?php _e('Tipo:', 'simple-ticket-system'); ?></strong> <?php echo $current_type; ?></span>
|
||||
<span class="sts-ticket-info"><strong><?php _e('Criado em:', 'simple-ticket-system'); ?></strong> <?php echo get_the_date('d/m/Y H:i'); ?></span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="sts-ticket-content">
|
||||
<h3><?php _e('Descrição do Problema', 'simple-ticket-system'); ?></h3>
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($attachments)) : ?>
|
||||
<div class="sts-ticket-attachments">
|
||||
<h3><?php _e('Anexos', 'simple-ticket-system'); ?></h3>
|
||||
<ul>
|
||||
<?php foreach ($attachments as $attachment) : ?>
|
||||
<li><a href="<?php echo wp_get_attachment_url($attachment->ID); ?>" target="_blank"><?php echo esc_html($attachment->post_title); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="sts-ticket-responses">
|
||||
<?php
|
||||
// Se os comentários estiverem abertos ou se houver pelo menos um comentário, carregue o template de comentários.
|
||||
if (comments_open() || get_comments_number()) :
|
||||
comments_template();
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
?>
|
47
templates/view-ticket.php
Normal file
47
templates/view-ticket.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$current_user = wp_get_current_user();
|
||||
$args = array(
|
||||
'post_type' => 'ticket',
|
||||
'author' => $current_user->ID,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC'
|
||||
);
|
||||
|
||||
$tickets = get_posts($args);
|
||||
|
||||
if ($tickets) {
|
||||
echo '<h3 class="sts-section-title">' . __('Meus Tickets', 'simple-ticket-system') . '</h3>';
|
||||
echo '<div class="sts-ticket-grid">';
|
||||
|
||||
foreach ($tickets as $ticket) {
|
||||
$status = wp_get_object_terms($ticket->ID, 'ticket_status', array('fields' => 'names'));
|
||||
$types = wp_get_object_terms($ticket->ID, 'ticket_type', array('fields' => 'names'));
|
||||
$ticket_id = get_post_meta($ticket->ID, '_sts_ticket_id', true);
|
||||
|
||||
$status_class = !empty($status) ? sanitize_title($status[0]) : 'no-status';
|
||||
$current_status = !empty($status) ? esc_html($status[0]) : __('Sem status', 'simple-ticket-system');
|
||||
$current_type = !empty($types) ? esc_html($types[0]) : __('Não definido', 'simple-ticket-system');
|
||||
|
||||
echo '<a href="' . get_permalink($ticket->ID) . '" class="sts-ticket-card ' . $status_class . '">';
|
||||
echo '<span class="sts-card-ticket-id">' . esc_html($ticket_id) . '</span>';
|
||||
echo '<div class="sts-card-header">';
|
||||
echo '<h4 class="sts-card-title">' . esc_html($ticket->post_title) . '</h4>';
|
||||
echo '<span class="sts-ticket-status ' . $status_class . '">' . $current_status . '</span>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="sts-card-body">';
|
||||
echo '<p><strong>' . __('Tipo:', 'simple-ticket-system') . '</strong> ' . $current_type . '</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="sts-card-footer">';
|
||||
echo '<span class="sts-ticket-date">' . sprintf(__('Aberto em: %s', 'simple-ticket-system'), date_i18n('d/m/Y', strtotime($ticket->post_date))) . '</span>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<p>' . __('Você não possui tickets.', 'simple-ticket-system') . '</p>';
|
||||
}
|
Reference in New Issue
Block a user