92 lines
4.1 KiB
PHP
92 lines
4.1 KiB
PHP
<?php
|
|
$search_name = $_GET['name'] ?? '';
|
|
$search_phone = $_GET['phone'] ?? '';
|
|
|
|
$query = "SELECT * FROM insurance_companies WHERE 1=1";
|
|
$params = [];
|
|
|
|
if ($search_name) {
|
|
$query .= " AND (name_en LIKE ? OR name_ar LIKE ?)";
|
|
$params[] = "%$search_name%";
|
|
$params[] = "%$search_name%";
|
|
}
|
|
if ($search_phone) {
|
|
$query .= " AND phone LIKE ?";
|
|
$params[] = "%$search_phone%";
|
|
}
|
|
|
|
$query .= " ORDER BY id DESC";
|
|
$stmt = $db->prepare($query);
|
|
$stmt->execute($params);
|
|
$insurance_companies = $stmt->fetchAll();
|
|
?>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h3 class="fw-bold text-secondary"><?php echo __('insurance_companies'); ?></h3>
|
|
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addInsuranceModal">
|
|
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_insurance'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Search Bar -->
|
|
<div class="card shadow-sm border-0 mb-4">
|
|
<div class="card-body">
|
|
<form method="GET" action="" class="row g-3">
|
|
<div class="col-md-5">
|
|
<div class="input-group">
|
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
|
|
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-5">
|
|
<div class="input-group">
|
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-telephone"></i></span>
|
|
<input type="text" name="phone" class="form-control bg-light border-start-0" placeholder="<?php echo __('phone'); ?>" value="<?php echo htmlspecialchars($search_phone); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<button type="submit" class="btn btn-secondary w-100"><?php echo __('search'); ?></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card shadow-sm border-0">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0">
|
|
<thead class="table-light text-secondary">
|
|
<tr>
|
|
<th class="px-4 py-3">ID</th>
|
|
<th class="py-3"><?php echo __('name_en'); ?></th>
|
|
<th class="py-3"><?php echo __('name_ar'); ?></th>
|
|
<th class="py-3"><?php echo __('email'); ?></th>
|
|
<th class="py-3"><?php echo __('phone'); ?></th>
|
|
<th class="py-3 text-end px-4"><?php echo __('date'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($insurance_companies)): ?>
|
|
<tr>
|
|
<td colspan="6" class="text-center py-5 text-muted">
|
|
<i class="bi bi-shield-check display-4 d-block mb-3"></i>
|
|
No insurance companies found.
|
|
</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($insurance_companies as $ic): ?>
|
|
<tr>
|
|
<td class="px-4 text-secondary">#<?php echo $ic['id']; ?></td>
|
|
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($ic['name_en']); ?></td>
|
|
<td class="text-secondary"><?php echo htmlspecialchars($ic['name_ar']); ?></td>
|
|
<td class="text-secondary"><?php echo htmlspecialchars($ic['email'] ?: '-'); ?></td>
|
|
<td class="text-secondary"><?php echo htmlspecialchars($ic['phone'] ?: '-'); ?></td>
|
|
<td class="text-end px-4 text-muted"><?php echo date('Y-m-d', strtotime($ic['created_at'])); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|