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
Creates a new ASA module instance with database access, event system, and file storage for activity-related documents.
Parameters
$db | Database | Yes | Database connection instance |
$events | Events | Yes | Event system for activity notifications |
$storagePath | string | Yes | Path 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
List activities with filtering options
Record student attendance
Activity Management
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 nameseason
- 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
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 IDarray $data
- Fields to update
Returns
bool
- True on success, false otherwise
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
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
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 IDint $staffId
- Staff member IDstring $role
- Staff role (coach, head_coach, assistant_coach, volunteer)
Returns
bool
- True on success, false otherwise
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
Removes a staff member from an activity.
Example
<?php
if ($asa->removeStaff($activityId, $staffId)) {
echo "Staff member removed from activity";
}
?>
Parameters
int $activityId
- Activity IDint $staffId
- Staff member ID to remove
Returns
bool
- True on success, false otherwise
Student Registration
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 IDint $studentId
- Student ID
Returns
array
- Array with registration details:
registrationId
- Registration record IDstatus
- 'confirmed' or 'waitlisted'waitlist_position
- Position if waitlisted (null if confirmed)
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
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 IDarray $opts
- Options (status, order, limit)
Returns
array
- Array of registration records with student details
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
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
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 IDstring $date
- Date in YYYY-MM-DD formatint $studentId
- Student IDbool $present
- True if present, false if absent
Returns
bool
- True on success, false otherwise
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 IDstring $date
- Date in YYYY-MM-DD format
Returns
array
- Array of attendance records with student details
Payment Management
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 IDfloat $amount
- Payment amount
Returns
bool
- True on success, false otherwise
Reporting & Export
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
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 IDstring $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
- __construct($db, $events, string $storagePath) - Initialize ASA module
Activity Management (4 methods)
- createActivity() - Creates a new after-school activity
- updateActivity() - Updates an existing activity's details
- archiveActivity() - Archives an activity to prevent new registrations
- listActivities() - Retrieves activities with optional filtering
Staff Management (3 methods)
- assignStaff() - Assigns a staff member to an activity
- listActivityStaff() - Lists all staff assigned to an activity
- removeStaff() - Removes a staff member from an activity
Student Registration (5 methods)
- register() - Registers a student for an activity
- cancelRegistration() - Cancels a student registration
- registrations() - Gets all registrations for an activity
- isFull() - Checks if an activity has reached capacity
- promoteFromWaitlist() - Promotes students from waitlist
Attendance Management (2 methods)
- markAttendance() - Records attendance for a student
- attendanceSheet() - Gets attendance sheet for a specific date
Payment Management (1 method)
- recordPayment() - Records a payment for registration
Reporting & Export (2 methods)
- exportRosterCSV() - Exports activity roster as CSV
- exportAttendanceCSV() - Exports attendance records as CSV
Total: 18 methods documented (including constructor)