SupportManagerStaff extends SupportManagerModel
SupportManagerStaff model
Table of Contents
Properties
| $serializable_settings | |
| $time_interval |
Methods
| __construct() | Constructor |
| add() | Adds a staff member to the support staff |
| delete() | Deletes the staff member from the support system |
| edit() | Updates a staff member of the support staff |
| get() | Retrieves a staff member from the support system |
| getAll() | Retrieve a list of all staff |
| getAllAvailable() | Fetches a list of all staff members from the given department that is available on the given day and time |
| getDays() | Retrieves the scheduled days |
| getList() | Retrieve a list of staff |
| getListCount() | Retrieves the total number of staff |
| getSchedules() | Fetches al of the staff schedules for the given staff member |
| getSettings() | Retrieves a staff member's settings |
| getTimes() | Retrieves available times in 24-hour format |
| setSetting() | Sets a support staff setting |
| setSettings() | Sets support staff settings |
| validateDepartmentExists() | Validates that every support department exists |
| validateDuplicateStaff() | Validates that the given staff member does NOT exist for the given company in the support system |
| validateScheduleDay() | Validates that the given day is valid |
| validateScheduleDays() | Validates that the gives scheduled days are unique |
| validateScheduleDaysGiven() | Validates that the given scheduled days are valid |
| validateScheduleTime() | Validates that the given time is in a valid format |
| validateStaffInCompany() | Validates that the given staff member belongs to the given company |
| addToDepartments() | Adds the staff member to the given departments, removing existing department assignments |
| formatSchedulesAllDay() | Sets the start_time and end_time of days to 00:00:00 the times encompass the entire day |
| getRules() | Retrieves a list of validation rules for adding/editing a staff member |
| getStaff() | Returns a Record object for fetching staff |
| updateSchedule() | Updates a staff member's schedule, removing existing schedule |
| updateStaff() | Updates a staff member's departments, schedules, and settings |
Methods
__construct()
Constructor
public
__construct() : mixed
add()
Adds a staff member to the support staff
public
add(array<string|int, mixed> $vars) : mixed
Parameters
- $vars : array<string|int, mixed>
-
A list of input vars including:
- staff_id The staff ID
- company_id The company ID to assign this schedule to
- departments An array of staff department IDs to assign this staff member to
- schedules An array containing the days/times the staff is available for support, including:
- day The day of the week (i.e. "sun", "mon", "tue", "wed", "thu", "fri", "sat")
- all_day The value of 1 to set start and end times to 00:00:00 (optional)
- start_time The time of day the staff member begins (required if all_day is not 1)
- end_time The time of day the staff member ends (required if all_day is not 1)
- settings A list of key=>value settings
Return values
mixed —An stdClass object representing the newly-created staff member, or void on error
delete()
Deletes the staff member from the support system
public
delete(int $staff_id, int $company_id) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member to delete
- $company_id : int
-
The company to which the staff member is assigned
edit()
Updates a staff member of the support staff
public
edit(int $staff_id, array<string|int, mixed> $vars) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member to update
- $vars : array<string|int, mixed>
-
A list of input vars including:
- company_id The company ID to assign this schedule to
- departments An array of staff department IDs to assign this staff member to
- schedules An array containing the days/times the staff is available for support, including:
- day The day of the week (i.e. "sun", "mon", "tue", "wed", "thu", "fri", "sat")
- start_time The time of day the staff member begins
- end_time The time of day the staff member ends
- settings A list of key=>value settings
Return values
mixed —An stdClass object representing the newly-created staff member, or void on error
get()
Retrieves a staff member from the support system
public
get(int $staff_id, int $company_id) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company to which this staff belongs
Return values
mixed —An stdClass object representing the staff member, or false if none found
getAll()
Retrieve a list of all staff
public
getAll(int $company_id[, int $department_id = null ][, mixed $get_settings = true ][, array<string|int, mixed> $order_by = ['first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch staff from
- $department_id : int = null
-
The ID of the department to fetch staff from
- $get_settings : mixed = true
- $order_by : array<string|int, mixed> = ['first_name' => 'asc']
-
A list of sort=>order options
Return values
array<string|int, mixed> —A list of stdClass objects representing staff
getAllAvailable()
Fetches a list of all staff members from the given department that is available on the given day and time
public
getAllAvailable(int $company_id, int $department_id[, array<string|int, mixed> $available_days = null ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch staff from
- $department_id : int
-
The ID of the department to fetch staff from
- $available_days : array<string|int, mixed> = null
-
A key=>value array of days=>times that the staff must be available e.g. array('sun' => '08:00:00', 'mon' => '10:00:00') fetches staff available Sunday at 8am UTC AND monday at 10am UTC
Return values
array<string|int, mixed> —A list of stdClass objects each representing a staff member
getDays()
Retrieves the scheduled days
public
getDays([bool $order = false ]) : array<string|int, mixed>
Parameters
- $order : bool = false
-
True to order the days by the calendar setting, false otherwise
Return values
array<string|int, mixed> —A list of days and their language
getList()
Retrieve a list of staff
public
getList(int $company_id[, int $department_id = null ][, mixed $get_settings = true ][, int $page = 1 ][, array<string|int, mixed> $order_by = ['first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch staff from
- $department_id : int = null
-
The ID of the department to fetch staff from
- $get_settings : mixed = true
- $page : int = 1
-
The page number of results to fetch
- $order_by : array<string|int, mixed> = ['first_name' => 'asc']
-
A list of sort=>order options
Return values
array<string|int, mixed> —A list of stdClass objects representing staff
getListCount()
Retrieves the total number of staff
public
getListCount(int $company_id[, int $department_id = null ]) : int
Parameters
- $company_id : int
-
The ID of the company to fetch staff from
- $department_id : int = null
-
The ID of the department to fetch staff from
Return values
int —The total number of staff
getSchedules()
Fetches al of the staff schedules for the given staff member
public
getSchedules(int $staff_id, int $company_id) : array<string|int, mixed>
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company to which this staff belongs
Return values
array<string|int, mixed> —A list of staff schedules
getSettings()
Retrieves a staff member's settings
public
getSettings(int $staff_id, int $company_id) : array<string|int, mixed>
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company to which this staff belongs
Return values
array<string|int, mixed> —A list of staff member settings
getTimes()
Retrieves available times in 24-hour format
public
getTimes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of times
setSetting()
Sets a support staff setting
public
setSetting(mixed $staff_id, int $company_id, array<string|int, mixed> $vars) : mixed
Parameters
- $staff_id : mixed
- $company_id : int
-
The ID of the company
- $vars : array<string|int, mixed>
-
An array containing:
- key The setting key
- value The setting value
setSettings()
Sets support staff settings
public
setSettings(mixed $staff_id, int $company_id, array<string|int, mixed> $settings) : mixed
Parameters
- $staff_id : mixed
- $company_id : int
-
The ID of the company
- $settings : array<string|int, mixed>
-
A key=>value list of staff settings
validateDepartmentExists()
Validates that every support department exists
public
validateDepartmentExists(array<string|int, mixed> $departments) : bool
Parameters
- $departments : array<string|int, mixed>
-
A list of department IDs
Return values
bool —False if a department given does not exist, true otherwise
validateDuplicateStaff()
Validates that the given staff member does NOT exist for the given company in the support system
public
validateDuplicateStaff(int $staff_id, int $company_id) : bool
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company
Return values
bool —True if the staff member does not already exist, false otherwise
validateScheduleDay()
Validates that the given day is valid
public
validateScheduleDay(string $day) : bool
Parameters
- $day : string
-
The day to validate
Return values
bool —True if the given day is valid, false otherwise
validateScheduleDays()
Validates that the gives scheduled days are unique
public
validateScheduleDays(array<string|int, mixed> $schedules) : bool
Parameters
- $schedules : array<string|int, mixed>
-
A list of staff schedules
Return values
bool —True if no duplicate scheduled days exist, false otherwise
validateScheduleDaysGiven()
Validates that the given scheduled days are valid
public
validateScheduleDaysGiven(array<string|int, mixed> $schedules) : bool
Parameters
- $schedules : array<string|int, mixed>
-
A list of staff schedules
Return values
bool —True if the given scheduled days contains at least one valid day, false otherwise
validateScheduleTime()
Validates that the given time is in a valid format
public
validateScheduleTime(string $time[, mixed $allow_empty = true ]) : bool
Parameters
- $time : string
-
The time to validate
- $allow_empty : mixed = true
Return values
bool —True if the time is in a valid format, false otherwise
validateStaffInCompany()
Validates that the given staff member belongs to the given company
public
validateStaffInCompany(int $staff_id, int $company_id) : bool
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company
Return values
bool —True if the staff member belongs to the company, false otherwise
addToDepartments()
Adds the staff member to the given departments, removing existing department assignments
private
addToDepartments(int $staff_id, int $company_id, array<string|int, mixed> $departments) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member to add
- $company_id : int
-
The ID of the company
- $departments : array<string|int, mixed>
-
A list of department IDs to add the staff member to
formatSchedulesAllDay()
Sets the start_time and end_time of days to 00:00:00 the times encompass the entire day
private
formatSchedulesAllDay(array<string|int, mixed> $schedules) : array<string|int, mixed>
Parameters
- $schedules : array<string|int, mixed>
-
A list of all the schedules
Return values
array<string|int, mixed> —An updated list of all the schedules
getRules()
Retrieves a list of validation rules for adding/editing a staff member
private
getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
A list of input vars
- $edit : bool = false
-
True to get the edit rules, false for the add rules
Return values
array<string|int, mixed> —A list of validation rules
getStaff()
Returns a Record object for fetching staff
private
getStaff(mixed $company_id[, int $department_id = null ]) : Record
Parameters
- $company_id : mixed
- $department_id : int = null
-
The ID of the department to fetch staff from
Return values
Record —A partially-built Record object to fetch staff
updateSchedule()
Updates a staff member's schedule, removing existing schedule
private
updateSchedule(int $staff_id, int $company_id, array<string|int, mixed> $schedules) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member
- $company_id : int
-
The ID of the company
- $schedules : array<string|int, mixed>
-
An array containing the days/times the staff is available for support, including:
- day The day of the week (i.e. "sun", "mon", "tue", "wed", "thu", "fri", "sat")
- start_time The time of day the staff member begins
- end_time The time of day the staff member ends
updateStaff()
Updates a staff member's departments, schedules, and settings
private
updateStaff(int $staff_id, int $company_id, array<string|int, mixed> $vars) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member to update
- $company_id : int
-
The company ID
- $vars : array<string|int, mixed>
-
A list of input vars including:
- departments An array of staff department IDs to assign this staff member to
- schedules An array containing the days/times the staff is available for support, including:
- day The day of the week (i.e. "sun", "mon", "tue", "wed", "thu", "fri", "sat")
- start_time The time of day the staff member begins
- end_time The time of day the staff member ends
- settings A list of key=>value settings