105 lines
4.5 KiB
PHP
105 lines
4.5 KiB
PHP
|
<?php
|
||
|
if (!defined('ABSPATH')) {
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
// Verifica se é a seção principal ou apenas resultados
|
||
|
$is_results_section = isset($is_results_section) ? $is_results_section : false;
|
||
|
|
||
|
// Obtém valores únicos para os filtros (só se for a chamada principal)
|
||
|
if (!$is_results_section) {
|
||
|
$secretarias = $this->database->get_unique_values('secretaria');
|
||
|
$setores = $this->database->get_unique_values('setor');
|
||
|
}
|
||
|
|
||
|
// Filtros atuais
|
||
|
$current_search = isset($filters['search']) ? esc_attr($filters['search']) : '';
|
||
|
$current_secretaria = isset($filters['secretaria']) ? esc_attr($filters['secretaria']) : '';
|
||
|
$current_setor = isset($filters['setor']) ? esc_attr($filters['setor']) : '';
|
||
|
?>
|
||
|
|
||
|
<div class="ramais-container">
|
||
|
<?php if (!$is_results_section): ?>
|
||
|
<!-- Seção de Filtros (só aparece na chamada principal) -->
|
||
|
<div class="ramais-filtros">
|
||
|
<input type="text" id="ramais-search"
|
||
|
placeholder="<?php esc_attr_e('Buscar por ramal, nome ou setor...', 'ramais-telefonicos'); ?>"
|
||
|
value="<?php echo $current_search; ?>">
|
||
|
|
||
|
<select id="ramais-secretaria">
|
||
|
<option value=""><?php _e('Todas as Secretarias', 'ramais-telefonicos'); ?></option>
|
||
|
<?php foreach ($secretarias as $secretaria): ?>
|
||
|
<?php if (!empty($secretaria)): ?>
|
||
|
<option value="<?php echo esc_attr($secretaria); ?>"
|
||
|
<?php selected($current_secretaria, $secretaria); ?>>
|
||
|
<?php echo esc_html($secretaria); ?>
|
||
|
</option>
|
||
|
<?php endif; ?>
|
||
|
<?php endforeach; ?>
|
||
|
</select>
|
||
|
|
||
|
<select id="ramais-setor">
|
||
|
<option value=""><?php _e('Todos os Setores', 'ramais-telefonicos'); ?></option>
|
||
|
<?php foreach ($setores as $setor): ?>
|
||
|
<?php if (!empty($setor)): ?>
|
||
|
<option value="<?php echo esc_attr($setor); ?>"
|
||
|
<?php selected($current_setor, $setor); ?>>
|
||
|
<?php echo esc_html($setor); ?>
|
||
|
</option>
|
||
|
<?php endif; ?>
|
||
|
<?php endforeach; ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<!-- Seção de Resultados (sempre visível) -->
|
||
|
<div class="ramais-results">
|
||
|
<?php if (empty($ramais)): ?>
|
||
|
<p class="ramais-no-results">
|
||
|
<?php _e('Nenhum ramal encontrado com os filtros atuais.', 'ramais-telefonicos'); ?>
|
||
|
</p>
|
||
|
<?php else: ?>
|
||
|
<table class="ramais-table">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th><?php _e('Ramal', 'ramais-telefonicos'); ?></th>
|
||
|
<th><?php _e('Responsável', 'ramais-telefonicos'); ?></th>
|
||
|
<th><?php _e('Secretaria', 'ramais-telefonicos'); ?></th>
|
||
|
<th><?php _e('Setor', 'ramais-telefonicos'); ?></th>
|
||
|
<th><?php _e('Email', 'ramais-telefonicos'); ?></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php foreach ($ramais as $ramal): ?>
|
||
|
<tr>
|
||
|
<td><?php echo esc_html($ramal['ramal']); ?></td>
|
||
|
<td><?php echo esc_html($ramal['responsavel']); ?></td>
|
||
|
<td><?php echo esc_html($ramal['secretaria']); ?></td>
|
||
|
<td><?php echo esc_html($ramal['setor']); ?></td>
|
||
|
<td>
|
||
|
<?php if (!empty($ramal['email'])): ?>
|
||
|
<a href="mailto:<?php echo esc_attr($ramal['email']); ?>">
|
||
|
<?php echo esc_html($ramal['email']); ?>
|
||
|
</a>
|
||
|
<?php else: ?>
|
||
|
-
|
||
|
<?php endif; ?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php endforeach; ?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
|
||
|
<?php if ($total_pages > 1): ?>
|
||
|
<div class="ramais-pagination">
|
||
|
<?php for ($i = 1; $i <= $total_pages; $i++): ?>
|
||
|
<a href="#" class="ramais-page-link <?php echo $i === $current_page ? 'active' : ''; ?>"
|
||
|
data-page="<?php echo $i; ?>">
|
||
|
<?php echo $i; ?>
|
||
|
</a>
|
||
|
<?php endfor; ?>
|
||
|
</div>
|
||
|
<?php endif; ?>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
</div>
|