Mini Kabibi Habibi
<?php
session_start();
@include 'include/config.php';
// Check if session variable 'username_school' is set
if (isset($_SESSION['username_school'])) {
$username = $_SESSION['username_school']; // Get the username from session
} else {
die("Error: User not logged in.");
}
// Check if the 'plan_id' is passed in the URL
if (isset($_GET['plan_id'])) {
$plan_id = $_GET['plan_id']; // Get the plan_id from URL parameter
} else {
die("Error: Plan ID not provided.");
}
// Query to fetch the selected MISTA plan details by plan_id
$sql_plan = "SELECT * FROM mista_plans WHERE id = ? AND username = ?";
$stmt_plan = $conn->prepare($sql_plan);
$stmt_plan->bind_param("is", $plan_id, $username); // Bind plan_id and username parameters
$stmt_plan->execute();
$plan_result = $stmt_plan->get_result();
// Check if the MISTA plan is found
if ($plan_result->num_rows > 0) {
$plan_row = $plan_result->fetch_assoc(); // Fetch the plan details
// Display MISTA plan details
echo "<h2>View MISTA Plan Details</h2>";
echo "<table class='table table-bordered'>";
echo "<tr><th>Division</th><td>" . htmlspecialchars($plan_row['division']) . "</td></tr>";
echo "<tr><th>Section</th><td>" . htmlspecialchars($plan_row['section']) . "</td></tr>";
echo "<tr><th>District</th><td>" . htmlspecialchars($plan_row['district']) . "</td></tr>";
echo "<tr><th>Month</th><td>" . htmlspecialchars($plan_row['month']) . "</td></tr>";
echo "<tr><th>Year</th><td>" . htmlspecialchars($plan_row['year']) . "</td></tr>";
echo "</table>";
// Fetch activities for the selected MISTA plan
$sql_activities = "SELECT * FROM mista_plan_activities WHERE plan_id = ?";
$stmt_activities = $conn->prepare($sql_activities);
$stmt_activities->bind_param("i", $plan_id); // Bind the plan_id parameter
$stmt_activities->execute();
$activities_result = $stmt_activities->get_result();
if ($activities_result->num_rows > 0) {
// Display the activities in a nested table under this plan
echo "<h3>Activities for this Plan:</h3>";
echo "<table class='table table-bordered'>";
echo "<thead><tr>
<th>Date</th>
<th>Instructional Supervisory and Monitoring Activity</th>
<th>School</th>
<th>School Head</th>
<th>Remarks</th>
</tr></thead><tbody>";
// Loop through the activities and display them
while ($activity_row = $activities_result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . htmlspecialchars($activity_row['date']) . "</td>";
echo "<td>" . htmlspecialchars($activity_row['instructional_supervisory_and_monitoring_activity']) . "</td>";
echo "<td>" . htmlspecialchars($activity_row['school']) . "</td>";
echo "<td>" . htmlspecialchars($activity_row['school_head']) . "</td>";
echo "<td>" . htmlspecialchars($activity_row['remarks']) . "</td>";
echo "</tr>";
}
echo "</tbody></table>";
} else {
echo "<p>No activities found for this plan.</p>";
}
$stmt_activities->close();
} else {
echo "<p>Error: Plan not found or you do not have permission to view this plan.</p>";
}
$stmt_plan->close();
$conn->close();
?>