<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** TESTIMONIALS LIST — Expects: $testimonials. */
?>
<div class="page-head">
	<div><h2>Testimonials</h2><p>Manage client and talent testimonials.</p></div>
	<a href="<?= base_url('admin/testimonials/create') ?>" class="btn btn-primary"><?= bloom_icon('plus', 16) ?> Add Testimonial</a>
</div>

<div class="card"><div class="card-body flush">
	<?php if ($testimonials): ?>
		<div class="table-wrap">
			<table class="data">
				<thead><tr><th>Author</th><th>Quote</th><th>Source</th><th>Rating</th><th>Status</th><th class="text-right">Actions</th></tr></thead>
				<tbody>
				<?php foreach ($testimonials as $t): ?>
					<tr>
						<td><div class="row-title"><?= html_escape($t['author_name']) ?></div><div class="row-sub"><?= html_escape($t['author_role']) ?></div></td>
						<td class="muted"><?= html_escape(excerpt($t['quote'], 14)) ?></td>
						<td><span class="pill pill-grey"><?= html_escape(ucfirst($t['source_type'])) ?></span></td>
						<td><?= str_repeat('★', (int) $t['rating']) ?></td>
						<td><a href="<?= base_url('admin/testimonials/toggle/'.$t['id']) ?>"><?= status_pill($t['is_active'] ? 'published' : 'draft') ?></a></td>
						<td><div class="row-actions" style="justify-content:flex-end;">
							<a href="<?= base_url('admin/testimonials/edit/'.$t['id']) ?>" class="icon-btn"><?= bloom_icon('edit', 16) ?></a>
							<a href="<?= base_url('admin/testimonials/delete/'.$t['id']) ?>" class="icon-btn danger" data-confirm="Delete this testimonial?"><?= bloom_icon('trash', 16) ?></a>
						</div></td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
		</div>
	<?php else: ?>
		<div class="empty"><?= bloom_icon('quote', 44) ?><p>No testimonials yet.</p></div>
	<?php endif; ?>
</div></div>
