PTC (Parent-Teacher Conferences)
The PTC
module provides a comprehensive system for scheduling and managing parent-teacher conferences. It allows administrators or teachers to create available time slots, which parents can then book online.
Constructor
Creates a new PTC module instance with database access, event system, and file storage.
Parameters
$db | Database | Yes | Database connection instance |
$events | Events | Yes | Event system for notifications |
$storagePath | string | Yes | Path for storing conference-related files |
Example
<?php
$config = [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=schoolkit;charset=utf8mb4',
'user' => 'your_username',
'pass' => 'your_password'
],
'storage_path' => __DIR__ . '/storage'
];
$schoolKit = SchoolKit::start($config);
$ptc = $schoolKit->ptc();
// PTC module is now ready for conference management
echo "PTC module initialized successfully";
?>
Quick Reference
Creates time slots for teacher conference availability
Books a conference slot for a student and guardian
Lists conference slots with filtering options
Gets comprehensive teacher schedule for a day
Slot & Schedule Management
Creates a block of available conference slots for a specific teacher on a given day.
Parameters
$teacherId | int | Yes | The ID of the staff member (teacher). |
$date | string | Yes | The date for the slots (YYYY-MM-DD). |
$startTime | string | Yes | The start time for the block (HH:MM:SS). |
$endTime | string | Yes | The end time for the block (HH:MM:SS). |
$slotMinutes | int | Yes | The duration of each conference slot in minutes. |
$capacity | int | No | How many parents can book a single slot (default: 1). |
$location | ?string | No | The location of the conference (e.g., 'Room 201'). |
Returns
The number of new slots that were created.
Example
<?php
// Create 15-minute slots for teacher #5 from 4 PM to 7 PM on Oct 20, 2025
$count = $schoolKit->ptc()->createSlots(
5,
'2025-10-20',
'16:00:00',
'19:00:00',
15,
1,
'Main Hall'
);
echo "Created {$count} new appointment slots.";
?>
Lists conference slots based on various filter criteria and options.
Example
<?php
// Find all of teacher #5's available slots for a specific date
$slots = $schoolKit->ptc()->listSlots([
'teacher_id' => 5,
'date' => '2025-10-20',
'blocked' => 0
]);
// List all slots with booking information
$allSlots = $schoolKit->ptc()->listSlots([], [
'order' => ['starts_at' => 'ASC'],
'limit' => 50
]);
print_r($slots);
?>
Parameters
array $filters
- Filter criteria (teacher_id, date, blocked, available, etc.)array $opts
- Options for ordering, limiting, and column selection
Returns
array
- Array of slot records matching the criteria
Permanently deletes a conference slot. Operation fails if there are confirmed bookings.
Example
<?php
$deleted = $schoolKit->ptc()->deleteSlot(345);
if ($deleted) {
echo "Slot deleted successfully";
} else {
echo "Cannot delete slot - may have confirmed bookings";
}
?>
Parameters
int $slotId
- ID of the slot to delete
Returns
bool
- True if deleted successfully, false if bookings exist or deletion failed
Manually blocks a time slot, making it unavailable for new bookings.
Example
<?php
$blocked = $schoolKit->ptc()->blockSlot(345);
if ($blocked) {
echo "Slot blocked successfully";
} else {
echo "Failed to block slot";
}
?>
Parameters
int $slotId
- ID of the slot to block
Returns
bool
- True if blocked successfully, false otherwise
Unblocks a previously blocked slot, making it available for booking again.
Example
<?php
$unblocked = $schoolKit->ptc()->unblockSlot(345);
if ($unblocked) {
echo "Slot is now available for booking";
} else {
echo "Failed to unblock slot";
}
?>
Parameters
int $slotId
- ID of the slot to unblock
Returns
bool
- True if unblocked successfully, false otherwise
Creates a scheduled break for a teacher, automatically blocking all overlapping time slots.
Example
<?php
// Create a lunch break from 12:00 to 13:00
$affectedSlots = $schoolKit->ptc()->createBreak(
5,
'2025-10-20',
'2025-10-20 12:00:00',
'2025-10-20 13:00:00'
);
echo "Break created, {$affectedSlots} slots were blocked";
?>
Parameters
int $teacherId
- ID of the teacherstring $date
- Date of the break (YYYY-MM-DD)string $startsAt
- Break start datetime (YYYY-MM-DD HH:MM:SS)string $endsAt
- Break end datetime (YYYY-MM-DD HH:MM:SS)
Returns
int
- Number of slots that were blocked by this break
Gets a comprehensive view of a teacher's conference schedule for a specific day, including all slots, bookings, and breaks.
Example
<?php
$schedule = $schoolKit->ptc()->teacherDailySchedule(5, '2025-10-20');
echo "Teacher Schedule for {$schedule['date']}:\n";
foreach ($schedule['slots'] as $slot) {
$status = $slot['is_booked'] ? 'BOOKED' : ($slot['is_blocked'] ? 'BLOCKED' : 'AVAILABLE');
echo "{$slot['start_time']} - {$slot['end_time']}: {$status}\n";
if ($slot['is_booked']) {
echo " (Parent: {$slot['guardian_name']})\n";
}
}
?>
Parameters
int $teacherId
- ID of the teacherstring $date
- Date to get schedule for (YYYY-MM-DD)
Returns
array
- Comprehensive schedule data with slots, booking status, and summary statistics
Booking & Appointments
Books an available conference time slot for a student and their guardian.
Example
<?php
$slotId = 345;
$studentId = 123;
try {
$bookingId = $schoolKit->ptc()->book(
$slotId,
$studentId,
'John Glenn',
'john.glenn@example.com',
'Would like to discuss math progress.'
);
echo "Conference booked with ID: {$bookingId}";
} catch (Exception $e) {
echo "Booking failed: " . $e->getMessage();
}
?>
Parameters
int $slotId
- ID of the slot to bookint $studentId
- ID of the studentstring $guardianName
- Name of the parent/guardianstring $guardianEmail
- Email address of the parent/guardian?string $notes
- Optional notes about the conference (default: null)
Returns
int
- ID of the new booking record
Cancels an existing conference booking, making the slot available again.
Example
<?php
$cancelled = $schoolKit->ptc()->cancel(678);
if ($cancelled) {
echo "Booking cancelled successfully";
} else {
echo "Failed to cancel booking";
}
?>
Parameters
int $bookingId
- ID of the booking to cancel
Returns
bool
- True if cancelled successfully, false otherwise
Retrieves a single conference booking record by its ID.
Example
<?php
$booking = $schoolKit->ptc()->getBooking(678);
if ($booking) {
echo "Booking for: {$booking['guardian_name']}\n";
echo "Student: {$booking['student_name']}\n";
echo "Date/Time: {$booking['slot_date']} {$booking['slot_time']}\n";
echo "Notes: {$booking['notes']}\n";
} else {
echo "Booking not found";
}
?>
Parameters
int $bookingId
- ID of the booking to retrieve
Returns
?array
- Booking record with details, or null if not found
Retrieves all confirmed conference bookings for a specific teacher on a given day.
Example
<?php
$bookings = $schoolKit->ptc()->bookingsForTeacherDay(5, '2025-10-20');
echo "Teacher has " . count($bookings) . " conferences today:\n";
foreach ($bookings as $booking) {
echo "{$booking['slot_time']}: {$booking['guardian_name']} (Student: {$booking['student_name']})\n";
}
?>
Parameters
int $teacherId
- ID of the teacherstring $date
- Date to get bookings for (YYYY-MM-DD)
Returns
array
- Array of confirmed booking records for the day
Retrieves all confirmed conference bookings made with a specific guardian email address.
Example
<?php
$myBookings = $schoolKit->ptc()->bookingsForGuardian('john.glenn@example.com');
echo "Your upcoming conferences:\n";
foreach ($myBookings as $booking) {
echo "• {$booking['slot_date']} at {$booking['slot_time']}\n";
echo " Teacher: {$booking['teacher_name']}\n";
echo " Student: {$booking['student_name']}\n";
echo " Location: {$booking['location']}\n";
}
?>
Parameters
string $email
- Guardian's email address
Returns
array
- Array of booking records for the guardian
Retrieves all available conference slots for a guardian, filtered by the teachers of their children's classes.
Example
<?php
$availableSlots = $schoolKit->ptc()->availableSlotsForGuardian(456);
echo "Available conference slots for your children's teachers:\n";
foreach ($availableSlots as $slot) {
echo "• {$slot['date']} {$slot['start_time']} - {$slot['end_time']}\n";
echo " Teacher: {$slot['teacher_name']}\n";
echo " Location: {$slot['location']}\n";
}
?>
Parameters
int $guardianId
- ID of the guardian
Returns
array
- Array of available slot records for relevant teachers
Export & Utilities
Generates an ICS calendar file containing a teacher's conference schedule for a specific day.
Example
<?php
$icsContent = $schoolKit->ptc()->icsForTeacherDay(5, '2025-10-20');
// Send as download
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="teacher-schedule-2025-10-20.ics"');
echo $icsContent;
// Or save to file
file_put_contents('schedule.ics', $icsContent);
?>
Parameters
int $teacherId
- ID of the teacherstring $date
- Date to generate calendar for (YYYY-MM-DD)
Returns
string
- ICS calendar file content
All Available Methods
Constructor
- __construct($db, $events, string $storagePath) - Initialize PTC module
Slot & Schedule Management (7 methods)
- createSlots() - Creates time slots for teacher availability
- listSlots() - Lists conference slots with filtering
- deleteSlot() - Permanently deletes a conference slot
- blockSlot() - Blocks a slot from being booked
- unblockSlot() - Unblocks a previously blocked slot
- createBreak() - Creates a scheduled break period
- teacherDailySchedule() - Gets comprehensive daily schedule
Booking & Appointments (6 methods)
- book() - Books a conference slot for a guardian
- cancel() - Cancels an existing booking
- getBooking() - Retrieves a single booking by ID
- bookingsForTeacherDay() - Gets all bookings for a teacher on a day
- bookingsForGuardian() - Gets all bookings for a guardian
- availableSlotsForGuardian() - Gets available slots for a guardian
Export & Utilities (1 method)
- icsForTeacherDay() - Generates ICS calendar file for a teacher's day
Total: 15 methods documented (14 public methods + constructor)