82 lines
3.2 KiB
PHP
82 lines
3.2 KiB
PHP
<?php
|
|
$title = 'Invoices - Billing';
|
|
$page = 'invoices';
|
|
require_once 'templates/header.php';
|
|
?>
|
|
|
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
|
<h1 class="h2">Invoices</h1>
|
|
<div class="btn-toolbar mb-2 mb-md-0">
|
|
<a href="create_invoice.php" class="btn btn-sm btn-primary">
|
|
<i class="bi bi-plus-circle"></i>
|
|
Create New Invoice
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->query('SELECT invoices.*, customers.name AS customer_name FROM invoices LEFT JOIN customers ON invoices.customer_id = customers.id ORDER BY invoices.created_at DESC');
|
|
$invoices = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$status_colors = [
|
|
'Paid' => 'success',
|
|
'Pending' => 'warning',
|
|
'Overdue' => 'danger',
|
|
];
|
|
|
|
?>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Invoice #</th>
|
|
<th>Customer</th>
|
|
<th>Amount</th>
|
|
<th>Status</th>
|
|
<th>Due Date</th>
|
|
<th>Created</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($invoices)): ?>
|
|
<tr>
|
|
<td colspan="7" class="text-center py-5">
|
|
<i class="bi bi-journal-text" style="font-size: 3rem; color: #ccc;"></i>
|
|
<h2 class="mt-3">No Invoices Found</h2>
|
|
<p class="text-muted">There are no invoices to display yet.</p>
|
|
</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($invoices as $invoice): ?>
|
|
<tr>
|
|
<td>#<?php echo htmlspecialchars($invoice['id']); ?></td>
|
|
<td><?php echo htmlspecialchars($invoice['customer_name']); ?></td>
|
|
<td>$<?php echo number_format($invoice['amount'], 2); ?></td>
|
|
<td>
|
|
<span class="badge bg-<?php echo $status_colors[$invoice['status']] ?? 'secondary'; ?>">
|
|
<?php echo htmlspecialchars($invoice['status']); ?>
|
|
</span>
|
|
</td>
|
|
<td><?php echo date('M d, Y', strtotime($invoice['due_date'])); ?></td>
|
|
<td><?php echo date('M d, Y', strtotime($invoice['created_at'])); ?></td>
|
|
<td>
|
|
<a href="view_invoice.php?id=<?php echo $invoice['id']; ?>" class="btn btn-sm btn-outline-secondary"><i class="bi bi-eye"></i></a>
|
|
<a href="edit_invoice.php?id=<?php echo $invoice['id']; ?>" class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil"></i></a>
|
|
<a href="delete_invoice.php?id=<?php echo $invoice['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this invoice?');"><i class="bi bi-trash"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
require_once 'templates/footer.php';
|
|
?>
|