Mini Kabibi Habibi
<?php
session_start();
@include 'include/config.php';
if (!isset($_SESSION['username_school'])) {
header('Location: login.php');
exit();
}
$username = $_SESSION['username_school'];
$month = date('m');
$year = date('Y');
// Default values to avoid undefined warnings
$fullname = 'N/A';
$designation = 'N/A';
// Fetch user details
$name_stmt = $conn->prepare("SELECT fullname, designation FROM information WHERE username = ?");
if (!$name_stmt) {
die("Query preparation failed: " . $conn->error);
}
$name_stmt->bind_param("s", $username);
$name_stmt->execute();
$name_result = $name_stmt->get_result();
if ($name_result->num_rows > 0) {
$row = $name_result->fetch_assoc();
$fullname = $row['fullname'];
$designation = $row['designation'];
}
// Fetch accomplishments
$stmt = $conn->prepare("SELECT date, activities, other_activity FROM schedule WHERE username = ? AND MONTH(date) = ? AND YEAR(date) = ? ORDER BY date ASC");
$stmt->bind_param("sii", $username, $month, $year);
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Monthly Accomplishment Report</title>
<link rel="stylesheet" href="../vendors/bootstrap/dist/css/bootstrap.min.css">
<style>
body, table, p, h2 {
font-family: "Bookman Old Style", serif;
font-size: 11pt;
}
table {
width: 100%;
border-collapse: collapse;
border: 1.2px solid black;
}
th, td {
border: 1.2px solid black;
padding: 2px 6px;
vertical-align: top;
line-height: 1.5;
text-align: left;
}
th {
background-color: #f8f9fa;
font-weight: bold;
}
.underline {
text-decoration: underline;
}
.single-space {
margin: 0;
padding: 0;
}
.space-between-year-table {
margin-bottom: 10px;
}
.report-wrapper {
padding-top: 0.2in; /* Push content slightly below the template header */
}
@media print {
@page {
size: landscape;
margin-top: 1.7in; /* Adjust this to match template header on all pages */
margin-bottom: 1.0in; /* Adjust this to match template footer */
margin-left: 1.0in;
margin-right: 1.0in;
}
body {
margin: 0;
}
/* Ensure consistent header size across pages */
h2 {
font-size: 11pt; /* Keep the same font size for headers */
margin-top: 0;
}
.no-print {
display: none !important;
}
.container {
margin-top: 0;
margin-bottom: 0;
}
.report-wrapper {
padding-top: 0.2in;
}
/* Ensure proper page breaks and header consistency */
.report-wrapper {
page-break-before: always; /* Ensure content starts cleanly */
}
}
</style>
</head>
<body>
<div class="report-wrapper">
<div class="container mt-5">
<!-- Back Button -->
<div class="mb-3 no-print">
<a href="javascript:history.back()" class="btn btn-secondary">Back</a>
</div>
<!-- Print Button -->
<div class="text-end mb-3 no-print">
<button class="btn btn-primary" onclick="window.print()">Save Report</button>
</div>
<h2 class="text-center mb-4">MONTHLY ACCOMPLISHMENT REPORT</h2>
<!-- Header Info -->
<p class="single-space"><strong>Division/Section/Unit:</strong> <?php echo htmlspecialchars($designation); ?></p>
<p class="single-space"><strong>Month:</strong> <?php echo date('F'); ?></p>
<p class="single-space space-between-year-table"><strong>Year:</strong> <?php echo date('Y'); ?></p>
<!-- Activity Table -->
<table>
<thead>
<tr>
<th>DATE</th>
<th>ACTIVITIES UNDERTAKEN</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$activity = $row['activities'] === 'Others' && !empty($row['other_activity'])
? 'Other Activity: ' . $row['other_activity']
: $row['activities'];
echo "<tr>
<td>" . htmlspecialchars($row['date']) . "</td>
<td>" . htmlspecialchars($activity) . "</td>
</tr>";
}
} else {
echo "<tr><td colspan='2'>No records found for this month.</td></tr>";
}
?>
</tbody>
</table>
<!-- Footer Section -->
<div class="row mt-4">
<div class="col-6">
<p><strong>Prepared by:</strong></p>
<p><span class="underline"><?php echo strtoupper(htmlspecialchars($fullname)); ?></span><br>Name of Employee</p>
<p><span class="underline"><?php echo date('F d, Y'); ?></span><br>Date</p>
</div>
<div class="col-6">
<p><strong>Noted by:</strong></p>
<p>______________________________<br>Immediate Supervisor</p>
<p><span class="underline"><?php echo date('F d, Y'); ?></span><br>Date</p>
</div>
</div>
</div>
</div>
</body>
</html>