Auto commit: 2025-10-26T16:49:58.252Z
This commit is contained in:
parent
6236799760
commit
b8ab420fdd
@ -132,7 +132,7 @@ $overdue_invoices = $invoice_statuses['Overdue'] ?? 0;
|
|||||||
<td><span class="badge bg-secondary"><?php echo htmlspecialchars($report['type']); ?></span></td>
|
<td><span class="badge bg-secondary"><?php echo htmlspecialchars($report['type']); ?></span></td>
|
||||||
<td><?php echo date('M d, Y H:i A', strtotime($report['created_at'])); ?></td>
|
<td><?php echo date('M d, Y H:i A', strtotime($report['created_at'])); ?></td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-sm btn-outline-primary"><i class="bi bi-eye"></i> View</button>
|
<a href="view_report.php?id=<?php echo $report['id']; ?>" class="btn btn-sm btn-outline-primary"><i class="bi bi-eye"></i> View</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
111
view_report.php
Normal file
111
view_report.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
require_once 'templates/header.php';
|
||||||
|
|
||||||
|
$report = null;
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if (isset($_GET['id']) && !empty(trim($_GET['id']))) {
|
||||||
|
$report_id = trim($_GET['id']);
|
||||||
|
|
||||||
|
if (filter_var($report_id, FILTER_VALIDATE_INT) === false) {
|
||||||
|
$errors[] = "Invalid report ID.";
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$sql = "SELECT * FROM reports WHERE id = ?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([$report_id]);
|
||||||
|
$report = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($report === false) {
|
||||||
|
$errors[] = "Report not found.";
|
||||||
|
$report = null;
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$errors[] = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$errors[] = "Report ID is missing.";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container-fluid px-4">
|
||||||
|
<?php if ($report): ?>
|
||||||
|
<h1 class="mt-4">Report: <?php echo htmlspecialchars($report['name']); ?></h1>
|
||||||
|
<ol class="breadcrumb mb-4">
|
||||||
|
<li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="reports.php">Reports</a></li>
|
||||||
|
<li class="breadcrumb-item active">View</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-header">
|
||||||
|
<i class="fas fa-chart-area me-1"></i>
|
||||||
|
Report Details
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p><strong>Report Type:</strong> <?php echo htmlspecialchars($report['type']); ?></p>
|
||||||
|
<p><strong>Date Generated:</strong> <?php echo htmlspecialchars(date("F j, Y, g:i a", strtotime($report['created_at']))); ?></p>
|
||||||
|
|
||||||
|
<h5 class="mt-4">Report Data</h5>
|
||||||
|
<?php
|
||||||
|
$report_data = json_decode($report['data'], true);
|
||||||
|
if (json_last_error() === JSON_ERROR_NONE && is_array($report_data)):
|
||||||
|
?>
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Key</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($report_data as $key => $value): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($key); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if (is_array($value) || is_object($value)) {
|
||||||
|
echo '<pre>' . htmlspecialchars(json_encode($value, JSON_PRETTY_PRINT)) . '</pre>';
|
||||||
|
} else {
|
||||||
|
echo htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="alert alert-warning">Could not decode report data or data is empty.</div>
|
||||||
|
<pre><?php echo htmlspecialchars($report['data']); ?></pre>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
<h1 class="mt-4">Error</h1>
|
||||||
|
<ol class="breadcrumb mb-4">
|
||||||
|
<li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="reports.php">Reports</a></li>
|
||||||
|
<li class="breadcrumb-item active">Error</li>
|
||||||
|
</ol>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($errors as $error): ?>
|
||||||
|
<li><?php echo htmlspecialchars($error); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<a href="reports.php" class="btn btn-secondary">
|
||||||
|
<i class="fas fa-arrow-left me-1"></i>
|
||||||
|
Back to Reports
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require_once 'templates/footer.php'; ?>
|
||||||
Loading…
x
Reference in New Issue
Block a user