ASA (After-School Activities)

The ASA module provides comprehensive management for after-school programs including activity creation, student registration with waitlist support, staff assignments, attendance tracking, and payment processing.

Constructor

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

Creates a new ASA module instance with database access, event system, and file storage for activity-related documents.

Parameters

$dbDatabaseYesDatabase connection instance
$eventsEventsYesEvent system for activity notifications
$storagePathstringYesPath for storing activity-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);
$asa = $schoolKit->asa();

// ASA module is now ready for activity management
echo "ASA module initialized successfully";
?>

Quick Reference

createActivity()
createActivity(array $data): int

Create a new after-school activity

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

List activities with filtering options

register()
register(int $activityId, int $studentId): array

Register student for activity

markAttendance()
markAttendance(int $activityId, string $date, int $studentId, bool $present): bool

Record student attendance

Activity Management

createActivity
createActivity(array $data): int

Creates a new after-school activity with scheduling and capacity information.

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);
$asa = $schoolKit->asa();

$activityId = $asa->createActivity([
    'title' => 'Basketball Club',
    'season' => 'winter',
    'day_of_week' => 1, // Monday (0=Sunday, 1=Monday, etc.)
    'start_time' => '15:30:00',
    'end_time' => '17:00:00',
    'capacity' => 20,
    'fee' => 50.00,
    'location' => 'Gymnasium'
]);

echo "Activity created with ID: $activityId";
?>

Parameters

  • array $data - Activity details

Required Fields

  • title - Activity name
  • season - Season (fall, winter, spring, summer)
  • day_of_week - Day of week (integer: 0=Sunday, 1=Monday, etc.)
  • start_time - Start time (HH:MM:SS format)
  • end_time - End time (HH:MM:SS format)
  • capacity - Maximum number of students

Returns

int - Activity ID

updateActivity
updateActivity(int $activityId, array $data): bool

Updates an existing activity's details.

Example

<?php
$updated = $asa->updateActivity($activityId, [
    'title' => 'Advanced Basketball Club',
    'capacity' => 25,
    'fee' => 60.00
]);

if ($updated) {
    echo "Activity updated successfully";
}
?>

Parameters

  • int $activityId - Activity ID
  • array $data - Fields to update

Returns

bool - True on success, false otherwise

archiveActivity
archiveActivity(int $activityId): bool

Archives an activity, preventing new registrations while preserving historical data.

Example

<?php
if ($asa->archiveActivity($activityId)) {
    echo "Activity archived successfully";
}
?>

Parameters

  • int $activityId - Activity ID to archive

Returns

bool - True on success, false otherwise

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

Retrieves activities with optional filtering and sorting.

Example

<?php
// Get all winter activities
$winterActivities = $asa->listActivities(['season' => 'winter']);

// Get non-archived activities
$activeActivities = $asa->listActivities(['archived' => 0]);

// Get all activities sorted by title
$allActivities = $asa->listActivities([], ['order' => ['title' => 'ASC']]);

foreach ($winterActivities as $activity) {
    echo $activity['title'] . " - " . $activity['day_of_week'] . "\n";
}
?>

Parameters

  • array $filters - Filter criteria (season, archived)
  • array $opts - Query options (order, limit, offset)

Returns

array - Array of activity records

Staff Management

assignStaff
assignStaff(int $activityId, int $staffId, string $role = 'coach'): bool

Assigns a staff member to an activity with a specific role.

Example

<?php
// Assign a head coach
$asa->assignStaff($activityId, $staffId, 'head_coach');

// Assign an assistant coach
$asa->assignStaff($activityId, $assistantStaffId, 'assistant_coach');

// Default role is 'coach'
$asa->assignStaff($activityId, $coachStaffId);
?>

Parameters

  • int $activityId - Activity ID
  • int $staffId - Staff member ID
  • string $role - Staff role (coach, head_coach, assistant_coach, volunteer)

Returns

bool - True on success, false otherwise

listActivityStaff
listActivityStaff(int $activityId): array

Lists all staff assigned to an activity.

Example

<?php
$staff = $asa->listActivityStaff($activityId);

foreach ($staff as $member) {
    echo $member['first_name'] . " " . $member['last_name'];
    echo " (" . $member['activity_role'] . ")\n";
}
?>

Parameters

  • int $activityId - Activity ID

Returns

array - Array of staff records with role information

removeStaff
removeStaff(int $activityId, int $staffId): bool

Removes a staff member from an activity.

Example

<?php
if ($asa->removeStaff($activityId, $staffId)) {
    echo "Staff member removed from activity";
}
?>

Parameters

  • int $activityId - Activity ID
  • int $staffId - Staff member ID to remove

Returns

bool - True on success, false otherwise

Student Registration

register
register(int $activityId, int $studentId): array

Registers a student for an activity. If the activity is full, adds to waitlist.

Example

<?php
$result = $asa->register($activityId, $studentId);

if ($result['status'] === 'confirmed') {
    echo "Successfully registered for activity!";
} elseif ($result['status'] === 'waitlisted') {
    echo "Added to waitlist (position: " . $result['waitlist_position'] . ")";
}
?>

Parameters

  • int $activityId - Activity ID
  • int $studentId - Student ID

Returns

array - Array with registration details:

  • registrationId - Registration record ID
  • status - 'confirmed' or 'waitlisted'
  • waitlist_position - Position if waitlisted (null if confirmed)
cancelRegistration
cancelRegistration(int $registrationId): bool

Cancels a student's registration and promotes next waitlisted student.

Example

<?php
if ($asa->cancelRegistration($registrationId)) {
    echo "Registration cancelled successfully";
}
?>

Parameters

  • int $registrationId - Registration ID to cancel

Returns

bool - True on success, false otherwise

registrations
registrations(int $activityId, array $opts = []): array

Gets all registrations for an activity with status filtering.

Example

<?php
// Get all confirmed registrations
$confirmedRegistrations = $asa->registrations($activityId, ['status' => 'confirmed']);

// Get waitlisted students
$waitlist = $asa->registrations($activityId, ['status' => 'waitlisted']);

foreach ($confirmedRegistrations as $reg) {
    echo $reg['first_name'] . " " . $reg['last_name'] . "\n";
}
?>

Parameters

  • int $activityId - Activity ID
  • array $opts - Options (status, order, limit)

Returns

array - Array of registration records with student details

isFull
isFull(int $activityId): bool

Checks if an activity has reached its capacity.

Example

<?php
if ($asa->isFull($activityId)) {
    echo "Activity is full - new registrations will be waitlisted";
} else {
    echo "Spots available for registration";
}
?>

Parameters

  • int $activityId - Activity ID to check

Returns

bool - True if activity is at capacity, false otherwise

promoteFromWaitlist
promoteFromWaitlist(int $activityId, ?int $studentId = null): ?int

Promotes the next student from waitlist to registered status.

Example

<?php
// Promote next student in waitlist order
$promotedRegistrationId = $asa->promoteFromWaitlist($activityId);

if ($promotedRegistrationId) {
    echo "Registration ID $promotedRegistrationId promoted from waitlist";
} else {
    echo "No students on waitlist or activity is full";
}

// Promote specific student
$specificRegistrationId = $asa->promoteFromWaitlist($activityId, $studentId);
?>

Parameters

  • int $activityId - Activity ID
  • ?int $studentId - Specific student to promote (optional, default: null)

Returns

?int - Registration ID that was promoted, or null if no promotion occurred

Attendance Management

markAttendance
markAttendance(int $activityId, string $date, int $studentId, bool $present): bool

Records attendance for a student on a specific date.

Example

<?php
// Mark student present
$asa->markAttendance($activityId, '2024-03-15', $studentId, true);

// Mark student absent
$asa->markAttendance($activityId, '2024-03-15', $absentStudentId, false);
?>

Parameters

  • int $activityId - Activity ID
  • string $date - Date in YYYY-MM-DD format
  • int $studentId - Student ID
  • bool $present - True if present, false if absent

Returns

bool - True on success, false otherwise

attendanceSheet
attendanceSheet(int $activityId, string $date): array

Gets attendance sheet for an activity on a specific date.

Example

<?php
$attendance = $asa->attendanceSheet($activityId, '2024-03-15');

foreach ($attendance as $record) {
    $status = $record['present'] ? 'Present' : 'Absent';
    echo $record['first_name'] . " " . $record['last_name'] . ": " . $status . "\n";
}
?>

Parameters

  • int $activityId - Activity ID
  • string $date - Date in YYYY-MM-DD format

Returns

array - Array of attendance records with student details

Payment Management

recordPayment
recordPayment(int $registrationId, float $amount): bool

Records a payment for an activity registration.

Example

<?php
// Record full payment
$paymentRecorded = $asa->recordPayment($registrationId, 50.00);

if ($paymentRecorded) {
    echo "Payment recorded successfully";
}
?>

Parameters

  • int $registrationId - Registration ID
  • float $amount - Payment amount

Returns

bool - True on success, false otherwise

Reporting & Export

exportRosterCSV
exportRosterCSV(int $activityId): string

Exports activity roster as CSV data.

Example

<?php
$csvFilePath = $asa->exportRosterCSV($activityId);

// Output the CSV file
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="activity-roster.csv"');
readfile($csvFilePath);

// Optional: Clean up file after download
unlink($csvFilePath);
?>

Parameters

  • int $activityId - Activity ID

Returns

string - File path to generated CSV file

exportAttendanceCSV
exportAttendanceCSV(int $activityId, string $from, string $to): string

Exports attendance records for a date range as CSV data.

Example

<?php
$csvFilePath = $asa->exportAttendanceCSV(
    $activityId, 
    '2024-03-01', 
    '2024-03-31'
);

// Output the CSV file
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="attendance-report.csv"');
readfile($csvFilePath);

// Optional: Clean up file after download
unlink($csvFilePath);
?>

Parameters

  • int $activityId - Activity ID
  • string $from - Start date (YYYY-MM-DD)
  • string $to - End date (YYYY-MM-DD)

Returns

string - File path to generated CSV file

All Available Methods

Constructor

Activity Management (4 methods)

Staff Management (3 methods)

Student Registration (5 methods)

Attendance Management (2 methods)

Payment Management (1 method)

Reporting & Export (2 methods)

Total: 18 methods documented (including constructor)