<?php
/**
 * CSV / PDF / Word download buttons that preserve current filters.
 * TPIN is required (when assigned) before generating the file.
 *
 * @var string               $actionPath  Current report path (no leading slash)
 * @var array<string, mixed> $query       Filter query params (export key ignored)
 * @var bool                 $includeWord Whether to show the Word button (default true)
 */
$query = $query ?? [];
unset($query['export']);
$includeWord = $includeWord ?? true;
$csvQuery  = array_merge($query, ['export' => 'csv']);
$pdfQuery  = array_merge($query, ['export' => 'pdf']);
$wordQuery = array_merge($query, ['export' => 'word']);
?>
<a href="<?= esc(base_url($actionPath) . '?' . http_build_query($csvQuery)) ?>"
   class="btn btn-sm btn-outline-secondary" data-tpin-confirm>
    <i class="fa-solid fa-file-csv me-1"></i>CSV
</a>
<a href="<?= esc(base_url($actionPath) . '?' . http_build_query($pdfQuery)) ?>"
   class="btn btn-sm btn-outline-secondary" data-tpin-confirm>
    <i class="fa-solid fa-file-pdf me-1"></i>PDF
</a>
<?php if ($includeWord): ?>
<a href="<?= esc(base_url($actionPath) . '?' . http_build_query($wordQuery)) ?>"
   class="btn btn-sm btn-outline-secondary" data-tpin-confirm>
    <i class="fa-solid fa-file-word me-1"></i>Word
</a>
<?php endif; ?>
<?= view('Modules\Tpin\Views\partials\verify_modal') ?>
