/home/techb158/workloadmatch.com/Manager
Edit: /home/techb158/workloadmatch.com/Manager/teacher_notes.php (18936B)
false, 'message' => 'Select a teacher and enter note text.']);
exit;
}
$stmt = $mysqli->prepare("INSERT INTO teacher_notes (teacher_id, manager_id, note_type, note_text) VALUES (?, ?, ?, ?)");
$stmt->bind_param("iiss", $teacher_id, $manager_id, $note_type, $note_text);
if ($stmt->execute()) {
echo json_encode(['success' => true, 'message' => 'Note added successfully.']);
} else {
echo json_encode(['success' => false, 'message' => 'Database error.']);
}
exit;
}
if ($_POST['action'] === 'edit_note') {
$note_id = (int)($_POST['note_id'] ?? 0);
$note_text = trim($_POST['note_text'] ?? '');
$note_type = trim($_POST['note_type'] ?? 'General');
if ($note_text === '') {
echo json_encode(['success' => false, 'message' => 'Note text cannot be empty.']);
exit;
}
$stmt = $mysqli->prepare("UPDATE teacher_notes SET note_text = ?, note_type = ? WHERE note_id = ?");
$stmt->bind_param("ssi", $note_text, $note_type, $note_id);
if ($stmt->execute()) {
echo json_encode(['success' => true, 'message' => 'Note updated successfully.']);
} else {
echo json_encode(['success' => false, 'message' => 'Database error.']);
}
exit;
}
if ($_POST['action'] === 'delete_note') {
$note_id = (int)($_POST['note_id'] ?? 0);
$stmt = $mysqli->prepare("DELETE FROM teacher_notes WHERE note_id = ?");
$stmt->bind_param("i", $note_id);
if ($stmt->execute()) {
echo json_encode(['success' => true, 'message' => 'Note deleted successfully.']);
} else {
echo json_encode(['success' => false, 'message' => 'Database error.']);
}
exit;
}
echo json_encode(['success' => false, 'message' => 'Invalid action.']);
exit;
}
// Page data
$allNotes = [];
$stmt = $mysqli->prepare("
SELECT tn.note_id, tn.note_text, tn.note_type, tn.created_at, tn.updated_at,
tp.Teacher_ID, CONCAT(tp.First_Name, ' ', tp.Last_Name) AS teacher_name,
tp.User_Img, tp.Note AS profile_note,
CONCAT(mp.First_Name, ' ', mp.Last_Name) AS manager_name
FROM teacher_notes tn
JOIN teacher_profile tp ON tn.teacher_id = tp.Teacher_ID
LEFT JOIN manager_profile mp ON tn.manager_id = mp.Manager_ID
WHERE tp.Manager_ID = ?
ORDER BY tn.created_at DESC
");
$stmt->bind_param("s", $manager_id);
$stmt->execute();
$res = $stmt->get_result();
while ($row = $res->fetch_assoc()) {
$allNotes[] = $row;
}
$stmt->close();
// Teacher list for dropdown
$teachers = [];
$stmt = $mysqli->prepare("SELECT Teacher_ID, CONCAT(First_Name, ' ', Last_Name) AS name, Note FROM teacher_profile WHERE Manager_ID = ? ORDER BY First_Name ASC");
$stmt->bind_param("s", $manager_id);
$stmt->execute();
$res = $stmt->get_result();
while ($row = $res->fetch_assoc()) {
$teachers[] = $row;
}
$stmt->close();
$totalNotes = count($allNotes);
$teachersWithNotes = [];
foreach ($allNotes as $n) { $teachersWithNotes[$n['Teacher_ID']] = true; }
$uniqueTeachers = count($teachersWithNotes);
$totalTeacherCount = count($teachers);
?>
CMS | Teacher Notes
0 ? round($totalNotes / $totalTeacherCount, 1) : 0; ?>
Profile Note:
|
Type |
Note |
Date |
Added By |
|
'bg-light-blue','Performance'=>'bg-green','Attendance'=>'bg-yellow','Schedule'=>'bg-purple','Other'=>'bg-gray'];
$badge = $types[$n['note_type']] ?? 'bg-light-blue';
$img = $n['User_Img'] ?: 'avatar.png';
?>
|
|
Profile: 60 ? '...' : ''); ?>
|
|
|
|
No notes yet. Use the form above to add one.