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

__construct
__construct($db, $events, string $storagePath)

Creates a new PTC module instance with database access, event system, and file storage.

Parameters

$dbDatabaseYesDatabase connection instance
$eventsEventsYesEvent system for notifications
$storagePathstringYesPath 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

createSlots()
createSlots(int $teacherId, string $date, string $startTime, string $endTime, int $slotMinutes, int $capacity = 1, ?string $location = null): int

Creates time slots for teacher conference availability

book()
book(int $slotId, int $studentId, string $guardianName, string $guardianEmail, ?string $notes = null): int

Books a conference slot for a student and guardian

listSlots()
listSlots(array $filters = [], array $opts = []): array

Lists conference slots with filtering options

teacherDailySchedule()
teacherDailySchedule(int $teacherId, string $date): array

Gets comprehensive teacher schedule for a day

Slot & Schedule Management

createSlots
createSlots(int $teacherId, string $date, string $startTime, string $endTime, int $slotMinutes, int $capacity = 1, ?string $location = null): int

Creates a block of available conference slots for a specific teacher on a given day.

Parameters

$teacherIdintYesThe ID of the staff member (teacher).
$datestringYesThe date for the slots (YYYY-MM-DD).
$startTimestringYesThe start time for the block (HH:MM:SS).
$endTimestringYesThe end time for the block (HH:MM:SS).
$slotMinutesintYesThe duration of each conference slot in minutes.
$capacityintNoHow many parents can book a single slot (default: 1).
$location?stringNoThe 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.";
?>
listSlots
listSlots(array $filters = [], array $opts = []): array

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

deleteSlot
deleteSlot(int $slotId): bool

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

blockSlot
blockSlot(int $slotId): bool

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

unblockSlot
unblockSlot(int $slotId): bool

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

createBreak
createBreak(int $teacherId, string $date, string $startsAt, string $endsAt): int

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 teacher
  • string $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

teacherDailySchedule
teacherDailySchedule(int $teacherId, string $date): array

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 teacher
  • string $date - Date to get schedule for (YYYY-MM-DD)

Returns

array - Comprehensive schedule data with slots, booking status, and summary statistics

Booking & Appointments

book
book(int $slotId, int $studentId, string $guardianName, string $guardianEmail, ?string $notes = null): int

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 book
  • int $studentId - ID of the student
  • string $guardianName - Name of the parent/guardian
  • string $guardianEmail - Email address of the parent/guardian
  • ?string $notes - Optional notes about the conference (default: null)

Returns

int - ID of the new booking record

cancel
cancel(int $bookingId): bool

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

getBooking
getBooking(int $bookingId): ?array

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

bookingsForTeacherDay
bookingsForTeacherDay(int $teacherId, string $date): array

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 teacher
  • string $date - Date to get bookings for (YYYY-MM-DD)

Returns

array - Array of confirmed booking records for the day

bookingsForGuardian
bookingsForGuardian(string $email): array

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

availableSlotsForGuardian
availableSlotsForGuardian(int $guardianId): array

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

icsForTeacherDay
icsForTeacherDay(int $teacherId, string $date): string

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 teacher
  • string $date - Date to generate calendar for (YYYY-MM-DD)

Returns

string - ICS calendar file content

All Available Methods

Constructor

Slot & Schedule Management (7 methods)

Booking & Appointments (6 methods)

Export & Utilities (1 method)

Total: 15 methods documented (14 public methods + constructor)