<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** NEWSLETTER SUBSCRIBERS — Expects: $subscribers. */
?>
<div class="page-head">
	<div><h2>Newsletter Subscribers</h2><p><?= count($subscribers) ?> total subscriber<?= count($subscribers) === 1 ? '' : 's' ?>.</p></div>
	<div style="display:flex;gap:8px;">
		<a href="<?= base_url('admin/inquiries') ?>" class="btn btn-ghost">← Inquiries</a>
		<?php if ($subscribers): ?>
			<a href="<?= base_url('admin/inquiries/subscribers?export=csv') ?>" class="btn btn-primary"><?= bloom_icon('inbox', 16) ?> Export CSV</a>
		<?php endif; ?>
	</div>
</div>

<div class="card"><div class="card-body flush">
	<?php if ($subscribers): ?>
		<div class="table-wrap">
			<table class="data">
				<thead><tr><th>Email Address</th><th>Subscribed On</th></tr></thead>
				<tbody>
				<?php foreach ($subscribers as $s): ?>
					<tr>
						<td class="row-title"><?= html_escape($s['email']) ?></td>
						<td class="muted"><?= nice_date($s['created_at'], 'd M Y') ?></td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
		</div>
	<?php else: ?>
		<div class="empty"><?= bloom_icon('mail', 44) ?><p>No newsletter subscribers yet.</p></div>
	<?php endif; ?>
</div></div>
