-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_book.php
More file actions
55 lines (52 loc) · 2.05 KB
/
Copy pathreport_book.php
File metadata and controls
55 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require 'config/db.php';
require 'includes/functions.php';
$fromDate = $_GET['from_date'] ?? '';
$toDate = $_GET['to_date'] ?? '';
$rows = [];
if ($fromDate !== '' && $toDate !== '') {
$stmt = $pdo->prepare("SELECT s.student_name, s.roll_no, b.book_title, b.book_isbn, i.issue_date, i.due_date, i.return_date
FROM issues i
INNER JOIN students s ON s.id = i.student_id
INNER JOIN books b ON b.id = i.book_id
WHERE i.issue_date BETWEEN ? AND ?
ORDER BY i.issue_date DESC");
$stmt->execute([$fromDate, $toDate]);
$rows = $stmt->fetchAll();
}
include 'includes/header.php';
?>
<h2>Borrow Report</h2>
<form method="GET">
<div class="grid">
<div>
<label>From Date</label>
<input type="date" name="from_date" value="<?php echo h($fromDate); ?>" required>
</div>
<div>
<label>To Date</label>
<input type="date" name="to_date" value="<?php echo h($toDate); ?>" required>
</div>
<div style="align-self:end;"><button type="submit">Generate Report</button></div>
</div>
</form>
<table>
<tr>
<th>Student</th><th>Roll No</th><th>Book</th><th>ISBN</th><th>Issue Date</th><th>Due Date</th><th>Return Date</th>
</tr>
<?php if ($fromDate !== '' && $toDate !== '' && !$rows): ?>
<tr><td colspan="7">No records found for the selected date range.</td></tr>
<?php endif; ?>
<?php foreach ($rows as $row): ?>
<tr>
<td><?php echo h($row['student_name']); ?></td>
<td><?php echo h($row['roll_no']); ?></td>
<td><?php echo h($row['book_title']); ?></td>
<td><?php echo h($row['book_isbn']); ?></td>
<td><?php echo h($row['issue_date']); ?></td>
<td><?php echo h($row['due_date']); ?></td>
<td><?php echo h($row['return_date'] ?: 'Not Returned'); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php include 'includes/footer.php'; ?>