Fix Pint formatting
This commit is contained in:
@@ -9,8 +9,7 @@ class AdminNotificationSubjectService
|
||||
{
|
||||
public function __construct(
|
||||
protected AdminNotificationUserService $userService
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function subjectOptions(): array
|
||||
{
|
||||
@@ -31,7 +30,7 @@ class AdminNotificationSubjectService
|
||||
$assignedSubjects = [];
|
||||
$tableReady = DB::getSchemaBuilder()->hasTable('admin_notification_subjects');
|
||||
|
||||
if ($tableReady && !empty($admins)) {
|
||||
if ($tableReady && ! empty($admins)) {
|
||||
$adminIds = array_map('intval', array_column($admins, 'id'));
|
||||
|
||||
$rows = AdminNotificationSubject::query()
|
||||
@@ -59,7 +58,7 @@ class AdminNotificationSubjectService
|
||||
|
||||
public function save(array $posted): array
|
||||
{
|
||||
if (!DB::getSchemaBuilder()->hasTable('admin_notification_subjects')) {
|
||||
if (! DB::getSchemaBuilder()->hasTable('admin_notification_subjects')) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Notification subject storage is missing. Run migrations first.',
|
||||
@@ -102,7 +101,7 @@ class AdminNotificationSubjectService
|
||||
if (is_array($subjectRaw)) {
|
||||
foreach ($subjectRaw as $key => $value) {
|
||||
$candidate = is_string($key) ? $key : $value;
|
||||
if (!is_string($candidate)) {
|
||||
if (! is_string($candidate)) {
|
||||
continue;
|
||||
}
|
||||
$candidate = trim($candidate);
|
||||
@@ -118,7 +117,7 @@ class AdminNotificationSubjectService
|
||||
$toDelete = array_values(array_diff($current, $selected));
|
||||
$toInsert = array_values(array_diff($selected, $current));
|
||||
|
||||
if (!empty($toDelete)) {
|
||||
if (! empty($toDelete)) {
|
||||
AdminNotificationSubject::query()
|
||||
->where('admin_id', $adminId)
|
||||
->whereIn('subject', $toDelete)
|
||||
@@ -126,7 +125,7 @@ class AdminNotificationSubjectService
|
||||
$updates += count($toDelete);
|
||||
}
|
||||
|
||||
if (!empty($toInsert)) {
|
||||
if (! empty($toInsert)) {
|
||||
$batch = [];
|
||||
foreach ($toInsert as $subject) {
|
||||
$batch[] = [
|
||||
@@ -147,4 +146,4 @@ class AdminNotificationSubjectService
|
||||
'status' => 200,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class AdminNotificationUserService
|
||||
->orderBy('u.lastname')
|
||||
->orderBy('u.firstname')
|
||||
->get()
|
||||
->map(fn($r) => (array) $r)
|
||||
->map(fn ($r) => (array) $r)
|
||||
->all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ class AdminPrintRecipientService
|
||||
{
|
||||
public function __construct(
|
||||
protected AdminNotificationUserService $userService
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function data(): array
|
||||
{
|
||||
@@ -18,7 +17,7 @@ class AdminPrintRecipientService
|
||||
$tableReady = DB::getSchemaBuilder()->hasTable('admin_notification_subjects');
|
||||
$assigned = [];
|
||||
|
||||
if ($tableReady && !empty($admins)) {
|
||||
if ($tableReady && ! empty($admins)) {
|
||||
$adminIds = array_map('intval', array_column($admins, 'id'));
|
||||
|
||||
$rows = AdminNotificationSubject::query()
|
||||
@@ -44,7 +43,7 @@ class AdminPrintRecipientService
|
||||
|
||||
public function save(array $posted): array
|
||||
{
|
||||
if (!DB::getSchemaBuilder()->hasTable('admin_notification_subjects')) {
|
||||
if (! DB::getSchemaBuilder()->hasTable('admin_notification_subjects')) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Notification subject storage is missing. Run migrations first.',
|
||||
@@ -77,7 +76,7 @@ class AdminPrintRecipientService
|
||||
->where('subject', 'print_requests')
|
||||
->whereIn('admin_id', $adminIds)
|
||||
->pluck('admin_id')
|
||||
->map(fn($id) => (int) $id)
|
||||
->map(fn ($id) => (int) $id)
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
@@ -85,14 +84,14 @@ class AdminPrintRecipientService
|
||||
$toDelete = array_values(array_diff($current, $selected));
|
||||
$toInsert = array_values(array_diff($selected, $current));
|
||||
|
||||
if (!empty($toDelete)) {
|
||||
if (! empty($toDelete)) {
|
||||
AdminNotificationSubject::query()
|
||||
->where('subject', 'print_requests')
|
||||
->whereIn('admin_id', $toDelete)
|
||||
->delete();
|
||||
}
|
||||
|
||||
if (!empty($toInsert)) {
|
||||
if (! empty($toInsert)) {
|
||||
$batch = [];
|
||||
foreach ($toInsert as $adminId) {
|
||||
$batch[] = [
|
||||
@@ -113,4 +112,4 @@ class AdminPrintRecipientService
|
||||
'status' => 200,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace App\Services\Administrator;
|
||||
|
||||
use App\Services\ApplicationUrlService;
|
||||
use App\Services\Staff\StaffTimeOffLinkService;
|
||||
use App\Models\StaffAttendance;
|
||||
use App\Models\User;
|
||||
use App\Services\ApplicationUrlService;
|
||||
use App\Services\SemesterRangeService;
|
||||
use App\Services\Staff\StaffTimeOffLinkService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -20,14 +21,13 @@ class AdministratorAbsenceService
|
||||
protected SemesterRangeService $semesterRangeService,
|
||||
protected StaffTimeOffLinkService $staffTimeOffLinkService,
|
||||
protected ApplicationUrlService $urls,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getAbsenceFormData(int $userId): array
|
||||
{
|
||||
$admin = $this->userModel->find($userId);
|
||||
$displayName = $admin
|
||||
? trim(($admin->firstname ?? '') . ' ' . ($admin->lastname ?? ''))
|
||||
? trim(($admin->firstname ?? '').' '.($admin->lastname ?? ''))
|
||||
: 'Administrator';
|
||||
|
||||
$semester = $this->shared->getSemester();
|
||||
@@ -76,7 +76,7 @@ class AdministratorAbsenceService
|
||||
}
|
||||
|
||||
$reasonBase = $reasonType !== '' ? strtolower($reasonType) : '';
|
||||
$reason = $reasonBase !== '' ? ($reasonBase . ': ' . $reasonText) : $reasonText;
|
||||
$reason = $reasonBase !== '' ? ($reasonBase.': '.$reasonText) : $reasonText;
|
||||
|
||||
$allowedSet = array_fill_keys($this->shared->allowedAbsenceDates(), true);
|
||||
|
||||
@@ -97,13 +97,15 @@ class AdministratorAbsenceService
|
||||
}
|
||||
|
||||
try {
|
||||
$parsed = \Carbon\Carbon::createFromFormat('Y-m-d', $d);
|
||||
$parsed = Carbon::createFromFormat('Y-m-d', $d);
|
||||
if ($parsed->format('Y-m-d') !== $d || empty($allowedSet[$d])) {
|
||||
$invalid[] = $d;
|
||||
|
||||
continue;
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
$invalid[] = $d;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,10 +131,10 @@ class AdministratorAbsenceService
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalid)) {
|
||||
if (! empty($invalid)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Invalid dates: ' . implode(', ', $invalid),
|
||||
'message' => 'Invalid dates: '.implode(', ', $invalid),
|
||||
'status' => 422,
|
||||
];
|
||||
}
|
||||
@@ -150,7 +152,7 @@ class AdministratorAbsenceService
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => $saved . ' day(s) saved as absent.',
|
||||
'message' => $saved.' day(s) saved as absent.',
|
||||
'saved' => $saved,
|
||||
'dates' => $savedDates,
|
||||
'status' => 200,
|
||||
@@ -169,10 +171,10 @@ class AdministratorAbsenceService
|
||||
): void {
|
||||
try {
|
||||
$user = $this->userModel->find($userId);
|
||||
$fullName = trim(($user->firstname ?? '') . ' ' . ($user->lastname ?? '')) ?: 'Administrator';
|
||||
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? '')) ?: 'Administrator';
|
||||
$userEmail = $user->email ?? '';
|
||||
$role = $roleName ?: 'admin';
|
||||
$dateList = !empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
|
||||
$dateList = ! empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
|
||||
|
||||
$subject = sprintf(
|
||||
'TimeOff Request: %s (%s) — %s',
|
||||
@@ -184,20 +186,20 @@ class AdministratorAbsenceService
|
||||
$submittedAt = now()->toDateTimeString();
|
||||
|
||||
$body = '<div style="font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.5;">'
|
||||
. '<h3 style="margin:0 0 8px;">New TimeOff Request</h3>'
|
||||
. '<p style="margin:0 0 12px;">A staff time-off request was submitted from the administrator portal.</p>'
|
||||
. '<table cellpadding="6" cellspacing="0" style="border-collapse:collapse;">'
|
||||
. '<tr><td><strong>Name</strong></td><td>' . e($fullName) . '</td></tr>'
|
||||
. '<tr><td><strong>Email</strong></td><td>' . e($userEmail) . '</td></tr>'
|
||||
. '<tr><td><strong>Role</strong></td><td>' . e((string) $role) . '</td></tr>'
|
||||
. '<tr><td><strong>Semester</strong></td><td>' . e($semester) . '</td></tr>'
|
||||
. '<tr><td><strong>School Year</strong></td><td>' . e($schoolYear) . '</td></tr>'
|
||||
. '<tr><td><strong>Reason Type</strong></td><td>' . e($reasonType ?: '-') . '</td></tr>'
|
||||
. '<tr><td><strong>Reason</strong></td><td>' . e($reasonText) . '</td></tr>'
|
||||
. '<tr><td><strong>Dates</strong></td><td>' . e($dateList ?: '-') . '</td></tr>'
|
||||
. '<tr><td><strong>Submitted At</strong></td><td>' . e($submittedAt) . '</td></tr>'
|
||||
. '</table>'
|
||||
. '</div>';
|
||||
.'<h3 style="margin:0 0 8px;">New TimeOff Request</h3>'
|
||||
.'<p style="margin:0 0 12px;">A staff time-off request was submitted from the administrator portal.</p>'
|
||||
.'<table cellpadding="6" cellspacing="0" style="border-collapse:collapse;">'
|
||||
.'<tr><td><strong>Name</strong></td><td>'.e($fullName).'</td></tr>'
|
||||
.'<tr><td><strong>Email</strong></td><td>'.e($userEmail).'</td></tr>'
|
||||
.'<tr><td><strong>Role</strong></td><td>'.e((string) $role).'</td></tr>'
|
||||
.'<tr><td><strong>Semester</strong></td><td>'.e($semester).'</td></tr>'
|
||||
.'<tr><td><strong>School Year</strong></td><td>'.e($schoolYear).'</td></tr>'
|
||||
.'<tr><td><strong>Reason Type</strong></td><td>'.e($reasonType ?: '-').'</td></tr>'
|
||||
.'<tr><td><strong>Reason</strong></td><td>'.e($reasonText).'</td></tr>'
|
||||
.'<tr><td><strong>Dates</strong></td><td>'.e($dateList ?: '-').'</td></tr>'
|
||||
.'<tr><td><strong>Submitted At</strong></td><td>'.e($submittedAt).'</td></tr>'
|
||||
.'</table>'
|
||||
.'</div>';
|
||||
|
||||
$token = $this->staffTimeOffLinkService->createToken([
|
||||
'uid' => $userId,
|
||||
@@ -213,9 +215,9 @@ class AdministratorAbsenceService
|
||||
|
||||
$notifyUrl = $this->urls->timeoffNotifyUrl($token);
|
||||
|
||||
$body .= '<p style="margin-top:16px;">Click <a href="' . e($notifyUrl) . '">Send confirmation email to '
|
||||
. e($fullName)
|
||||
. '</a> so the staff member is notified automatically. This link expires in 14 days.</p>';
|
||||
$body .= '<p style="margin-top:16px;">Click <a href="'.e($notifyUrl).'">Send confirmation email to '
|
||||
.e($fullName)
|
||||
.'</a> so the staff member is notified automatically. This link expires in 14 days.</p>';
|
||||
|
||||
$principalEmail = env('PRINCIPAL_EMAIL', 'principal@alrahmaisgl.org');
|
||||
|
||||
@@ -223,7 +225,7 @@ class AdministratorAbsenceService
|
||||
$message->to($principalEmail)->subject($subject);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Failed to send TimeOff email (admin): ' . $e->getMessage());
|
||||
Log::error('Failed to send TimeOff email (admin): '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ class AdministratorDashboardService
|
||||
public function __construct(
|
||||
protected AdministratorMetricsService $metricsService,
|
||||
protected AdministratorUserSearchService $userSearchService,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function metrics(): array
|
||||
{
|
||||
@@ -19,4 +18,4 @@ class AdministratorDashboardService
|
||||
{
|
||||
return $this->userSearchService->search($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ class AdministratorEnrollmentEventService
|
||||
{
|
||||
public function __construct(
|
||||
private ApplicationUrlService $urls,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function dispatchGroupedEvents(
|
||||
array $groupsByParentStatus,
|
||||
@@ -45,7 +44,7 @@ class AdministratorEnrollmentEventService
|
||||
->first();
|
||||
|
||||
foreach ($byStatus as $status => $studentsArr) {
|
||||
if (!isset($eventMap[$status])) {
|
||||
if (! isset($eventMap[$status])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -77,4 +76,4 @@ class AdministratorEnrollmentEventService
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ class AdministratorEnrollmentQueryService
|
||||
protected StudentClass $studentClassModel,
|
||||
protected Enrollment $enrollmentModel,
|
||||
protected ClassSection $classSectionModel,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function enrollmentWithdrawalData(?string $selectedYear = null): array
|
||||
{
|
||||
@@ -59,7 +58,7 @@ class AdministratorEnrollmentQueryService
|
||||
$s['student_id'] = $studentId;
|
||||
$s['removed_previous_year'] = isset($removedPriorIds[$studentId]) ? 'Yes' : 'No';
|
||||
|
||||
if (empty($s['parent_id']) && !empty($s['secondparent_user_id'])) {
|
||||
if (empty($s['parent_id']) && ! empty($s['secondparent_user_id'])) {
|
||||
$s['parent_id'] = (int) $s['secondparent_user_id'];
|
||||
} else {
|
||||
$s['parent_id'] = (int) ($s['parent_id'] ?? 0);
|
||||
@@ -68,14 +67,14 @@ class AdministratorEnrollmentQueryService
|
||||
$pf = trim((string) ($s['parent_firstname'] ?? ''));
|
||||
$pl = trim((string) ($s['parent_lastname'] ?? ''));
|
||||
|
||||
if ($pf === '' && $pl === '' && !empty($s['parent_fullname'])) {
|
||||
if ($pf === '' && $pl === '' && ! empty($s['parent_fullname'])) {
|
||||
$parts = preg_split('/\s+/', trim((string) $s['parent_fullname']), 2);
|
||||
$pf = $parts[0] ?? '';
|
||||
$pl = $parts[1] ?? '';
|
||||
}
|
||||
|
||||
$s['parent_label'] = trim($pf . ' ' . $pl) ?: 'Unknown Parent';
|
||||
$s['parent_sort'] = trim(($pl !== '' ? $pl : $pf) . ' ' . $pf) ?: 'ZZZ Unknown Parent';
|
||||
$s['parent_label'] = trim($pf.' '.$pl) ?: 'Unknown Parent';
|
||||
$s['parent_sort'] = trim(($pl !== '' ? $pl : $pf).' '.$pf) ?: 'ZZZ Unknown Parent';
|
||||
|
||||
$s['is_new'] = (int) ($s['is_new'] ?? 0);
|
||||
$s['new_student'] = $s['is_new'] === 1 ? 'Yes' : 'No';
|
||||
@@ -84,7 +83,7 @@ class AdministratorEnrollmentQueryService
|
||||
? $this->enrollmentModel->getEnrollmentStatus($studentId, $selectedYear)
|
||||
: null;
|
||||
|
||||
if (!empty($statusForYear)) {
|
||||
if (! empty($statusForYear)) {
|
||||
$s['enrollment_status'] = $statusForYear;
|
||||
} elseif (($s['admission_status'] ?? null) === 'denied') {
|
||||
$s['enrollment_status'] = 'denied';
|
||||
@@ -96,7 +95,7 @@ class AdministratorEnrollmentQueryService
|
||||
|
||||
$s['class_section'] = $className ?: 'Class not Assigned';
|
||||
|
||||
$s['registration_date_order'] = !empty($s['registration_date'])
|
||||
$s['registration_date_order'] = ! empty($s['registration_date'])
|
||||
? Carbon::parse($s['registration_date'])->format('Y-m-d')
|
||||
: '';
|
||||
}
|
||||
@@ -172,10 +171,10 @@ class AdministratorEnrollmentQueryService
|
||||
|
||||
$r['is_new'] = (int) ($r['is_new'] ?? 0);
|
||||
$r['new_student'] = $r['is_new'] === 1 ? 'Yes' : 'No';
|
||||
$r['modalIdContact'] = 'contact_' . $studentId;
|
||||
$r['modalIdContact'] = 'contact_'.$studentId;
|
||||
$r['enrollment_status'] = $enrollmentStatus;
|
||||
|
||||
if (!empty($r['registration_date'])) {
|
||||
if (! empty($r['registration_date'])) {
|
||||
try {
|
||||
$r['registration_date'] = Carbon::parse($r['registration_date'])->format('Y-m-d');
|
||||
} catch (\Throwable) {
|
||||
@@ -191,4 +190,4 @@ class AdministratorEnrollmentQueryService
|
||||
'total_new' => count($newStudents),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ class AdministratorEnrollmentRefundService
|
||||
{
|
||||
public function __construct(
|
||||
protected FeeCalculationService $feeCalculationService
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function processRefunds(array $parentIds, string $schoolYear, int $editorUserId): array
|
||||
{
|
||||
@@ -36,8 +35,9 @@ class AdministratorEnrollmentRefundService
|
||||
->latest('created_at')
|
||||
->first();
|
||||
|
||||
if (!$invoice) {
|
||||
if (! $invoice) {
|
||||
$errors[] = "No invoice found for parent ID {$pid} (for refund calc).";
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ class AdministratorEnrollmentService
|
||||
public function __construct(
|
||||
protected AdministratorEnrollmentQueryService $queryService,
|
||||
protected AdministratorEnrollmentStatusService $statusService,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function enrollmentWithdrawalData(?string $selectedYear = null): array
|
||||
{
|
||||
|
||||
@@ -15,8 +15,7 @@ class AdministratorEnrollmentStatusService
|
||||
protected User $userModel,
|
||||
protected AdministratorEnrollmentRefundService $refundService,
|
||||
protected AdministratorEnrollmentEventService $eventService,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function updateStatuses(array $enrollmentStatuses, int $editorUserId): array
|
||||
{
|
||||
@@ -53,8 +52,9 @@ class AdministratorEnrollmentStatusService
|
||||
foreach ($enrollmentStatuses as $studentId => $newEnrollmentStatus) {
|
||||
$studentId = (int) $studentId;
|
||||
|
||||
if (!in_array($newEnrollmentStatus, $validStatuses, true)) {
|
||||
if (! in_array($newEnrollmentStatus, $validStatuses, true)) {
|
||||
$errors[] = "Invalid enrollment status '{$newEnrollmentStatus}' for student ID {$studentId}.";
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class AdministratorEnrollmentStatusService
|
||||
$refundParents
|
||||
);
|
||||
|
||||
if (!$result['success']) {
|
||||
if (! $result['success']) {
|
||||
$errors[] = $result['message'];
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class AdministratorEnrollmentStatusService
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
DB::rollBack();
|
||||
Log::error('Enrollment withdrawal error: ' . $e->getMessage());
|
||||
Log::error('Enrollment withdrawal error: '.$e->getMessage());
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
@@ -129,7 +129,7 @@ class AdministratorEnrollmentStatusService
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
if (!$enrollmentRow) {
|
||||
if (! $enrollmentRow) {
|
||||
return $this->createEnrollmentRow(
|
||||
$studentId,
|
||||
$newEnrollmentStatus,
|
||||
@@ -145,7 +145,7 @@ class AdministratorEnrollmentStatusService
|
||||
$oldStatus = $enrollmentRow->enrollment_status ?? null;
|
||||
$parentId = (int) ($enrollmentRow->parent_id ?? 0);
|
||||
|
||||
if (!$parentId) {
|
||||
if (! $parentId) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => "No parent ID found for student ID {$studentId}.",
|
||||
@@ -165,7 +165,7 @@ class AdministratorEnrollmentStatusService
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if (!$updated) {
|
||||
if (! $updated) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => "Failed to update enrollment for student ID {$studentId}.",
|
||||
@@ -201,7 +201,7 @@ class AdministratorEnrollmentStatusService
|
||||
$stu = is_array($stu) ? $stu : ($stu?->toArray() ?? []);
|
||||
|
||||
$parentId = (int) ($stu['parent_id'] ?? ($stu['secondparent_user_id'] ?? 0));
|
||||
if (!$parentId) {
|
||||
if (! $parentId) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => "No parent ID found for student ID {$studentId}.",
|
||||
@@ -223,7 +223,7 @@ class AdministratorEnrollmentStatusService
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if (!$ok) {
|
||||
if (! $ok) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => "Failed to create enrollment for student ID {$studentId}.",
|
||||
@@ -250,7 +250,7 @@ class AdministratorEnrollmentStatusService
|
||||
$studentRow = $this->studentModel->find($studentId);
|
||||
$studentData = is_array($studentRow) ? $studentRow : ($studentRow?->toArray() ?? []);
|
||||
|
||||
return trim(($studentData['firstname'] ?? '') . ' ' . ($studentData['lastname'] ?? ''))
|
||||
return trim(($studentData['firstname'] ?? '').' '.($studentData['lastname'] ?? ''))
|
||||
?: "Student #{$studentId}";
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ class AdministratorMetricsService
|
||||
protected AdministratorSharedService $shared,
|
||||
protected User $userModel,
|
||||
protected LoginActivity $loginActivityModel,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function metrics(): array
|
||||
{
|
||||
@@ -70,4 +69,4 @@ class AdministratorMetricsService
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ class AdministratorNotificationService
|
||||
public function __construct(
|
||||
protected AdminNotificationSubjectService $subjectService,
|
||||
protected AdminPrintRecipientService $printRecipientService,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function notificationsAlertsData(): array
|
||||
{
|
||||
@@ -29,4 +28,4 @@ class AdministratorNotificationService
|
||||
{
|
||||
return $this->printRecipientService->save($posted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ class AdministratorSharedService
|
||||
{
|
||||
public function __construct(
|
||||
protected Configuration $configuration
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getSemester(?string $override = null): string
|
||||
{
|
||||
@@ -35,7 +34,7 @@ class AdministratorSharedService
|
||||
}
|
||||
|
||||
if (preg_match('/^(\d{4})\s*-\s*(\d{4})$/', $schoolYear, $m)) {
|
||||
return ((int) $m[1] - 1) . '-' . ((int) $m[2] - 1);
|
||||
return ((int) $m[1] - 1).'-'.((int) $m[2] - 1);
|
||||
}
|
||||
|
||||
if (preg_match('/^(\d{4})\s*-\s*(\d{2})$/', $schoolYear, $m)) {
|
||||
@@ -44,6 +43,7 @@ class AdministratorSharedService
|
||||
if ($end < 0) {
|
||||
$end += 100;
|
||||
}
|
||||
|
||||
return sprintf('%04d-%02d', $start, $end);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class AdministratorSharedService
|
||||
|
||||
public function countUniqueEntities($rows): int
|
||||
{
|
||||
if (!is_iterable($rows)) {
|
||||
if (! is_iterable($rows)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ class AdministratorTeacherSubmissionService
|
||||
public function __construct(
|
||||
protected TeacherSubmissionReportService $reportService,
|
||||
protected TeacherSubmissionNotificationService $notificationService,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function report(array $filters = []): array
|
||||
{
|
||||
|
||||
@@ -38,23 +38,23 @@ class AdministratorUserSearchService
|
||||
$v[] = sprintf('(%s)-%s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = sprintf('%s-%s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = sprintf('%s %s %s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = '1' . $digits;
|
||||
$v[] = '+1' . $digits;
|
||||
$v[] = '+1 ' . sprintf('(%s) %s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = '+1-' . sprintf('%s-%s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = '1'.$digits;
|
||||
$v[] = '+1'.$digits;
|
||||
$v[] = '+1 '.sprintf('(%s) %s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
$v[] = '+1-'.sprintf('%s-%s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
|
||||
} elseif (strlen($digits) === 11 && str_starts_with($digits, '1')) {
|
||||
$ten = substr($digits, 1);
|
||||
$v[] = $ten;
|
||||
$v[] = sprintf('(%s)-%s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = sprintf('%s-%s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = sprintf('%s %s %s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = '+1' . $ten;
|
||||
$v[] = '+1 ' . sprintf('(%s) %s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = '+1-' . sprintf('%s-%s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = '+1'.$ten;
|
||||
$v[] = '+1 '.sprintf('(%s) %s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
$v[] = '+1-'.sprintf('%s-%s-%s', substr($ten, 0, 3), substr($ten, 3, 3), substr($ten, 6));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($v)) {
|
||||
if (! empty($v)) {
|
||||
$phoneMap[$t] = array_values(array_unique($v));
|
||||
}
|
||||
}
|
||||
@@ -63,13 +63,13 @@ class AdministratorUserSearchService
|
||||
foreach ($tokens as $t) {
|
||||
$qb->where(function ($sub) use ($columns, $phoneCols, $phoneMap, $t) {
|
||||
foreach ($columns as $col) {
|
||||
$sub->orWhere($col, 'like', '%' . $t . '%');
|
||||
$sub->orWhere($col, 'like', '%'.$t.'%');
|
||||
}
|
||||
|
||||
if (!empty($phoneMap[$t]) && !empty($phoneCols)) {
|
||||
if (! empty($phoneMap[$t]) && ! empty($phoneCols)) {
|
||||
foreach ($phoneMap[$t] as $pv) {
|
||||
foreach ($phoneCols as $pcol) {
|
||||
$sub->orWhere($pcol, 'like', '%' . $pv . '%');
|
||||
$sub->orWhere($pcol, 'like', '%'.$pv.'%');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,12 +82,12 @@ class AdministratorUserSearchService
|
||||
$uQB = DB::table('users')
|
||||
->select('id', 'firstname', 'lastname', 'email', 'cellphone', 'school_id', 'city', 'state', 'school_year', 'semester');
|
||||
$applyMultiTokenLike($uQB, ['firstname', 'lastname', 'email', 'cellphone', 'school_id', 'city', 'state'], $tokens, ['cellphone']);
|
||||
$users = $uQB->limit(150)->get()->map(fn($r) => (array) $r)->all();
|
||||
$users = $uQB->limit(150)->get()->map(fn ($r) => (array) $r)->all();
|
||||
|
||||
$sQB = DB::table('students')
|
||||
->select('id', 'parent_id', 'school_id', 'firstname', 'lastname', 'dob', 'gender', 'school_year', 'semester', 'rfid_tag');
|
||||
$applyMultiTokenLike($sQB, ['firstname', 'lastname', 'school_id', 'rfid_tag', 'dob', 'gender'], $tokens);
|
||||
$students = $sQB->limit(150)->get()->map(fn($r) => (array) $r)->all();
|
||||
$students = $sQB->limit(150)->get()->map(fn ($r) => (array) $r)->all();
|
||||
|
||||
$pQB = DB::table('parents')
|
||||
->select('id', 'firstparent_id', 'secondparent_firstname', 'secondparent_lastname', 'secondparent_email', 'secondparent_phone', 'school_year', 'semester');
|
||||
@@ -99,17 +99,17 @@ class AdministratorUserSearchService
|
||||
}
|
||||
}
|
||||
|
||||
$parents = $pQB->limit(150)->get()->map(fn($r) => (array) $r)->all();
|
||||
$parents = $pQB->limit(150)->get()->map(fn ($r) => (array) $r)->all();
|
||||
|
||||
$stQB = DB::table('staff')
|
||||
->select('id', 'user_id', 'firstname', 'lastname', 'email', 'phone', 'role_name', 'school_year', 'active_role');
|
||||
$applyMultiTokenLike($stQB, ['firstname', 'lastname', 'email', 'role_name', 'phone'], $tokens, ['phone']);
|
||||
$staff = $stQB->limit(150)->get()->map(fn($r) => (array) $r)->all();
|
||||
$staff = $stQB->limit(150)->get()->map(fn ($r) => (array) $r)->all();
|
||||
|
||||
$ecQB = DB::table('emergency_contacts')
|
||||
->select('id', 'parent_id', 'emergency_contact_name', 'relation', 'cellphone', 'email', 'school_year', 'semester');
|
||||
$applyMultiTokenLike($ecQB, ['emergency_contact_name', 'relation', 'email', 'cellphone'], $tokens, ['cellphone']);
|
||||
$emergency = $ecQB->limit(150)->get()->map(fn($r) => (array) $r)->all();
|
||||
$emergency = $ecQB->limit(150)->get()->map(fn ($r) => (array) $r)->all();
|
||||
|
||||
return [
|
||||
'query' => $q,
|
||||
@@ -125,4 +125,4 @@ class AdministratorUserSearchService
|
||||
'total_found' => count($users) + count($students) + count($parents) + count($staff) + count($emergency),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace App\Services\Administrator;
|
||||
|
||||
use App\Mail\TeacherSubmissionReminderMail;
|
||||
use App\Services\ApplicationUrlService;
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\TeacherSubmissionNotificationHistory;
|
||||
use App\Models\User;
|
||||
use App\Services\ApplicationUrlService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -17,13 +17,12 @@ class TeacherSubmissionNotificationService
|
||||
protected AdministratorSharedService $shared,
|
||||
protected TeacherSubmissionSupportService $support,
|
||||
protected ApplicationUrlService $urls,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function send(Request $request, int $adminId): array
|
||||
{
|
||||
$notify = $request->input('notify');
|
||||
if (!is_array($notify)) {
|
||||
if (! is_array($notify)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Select at least one teacher to notify.',
|
||||
@@ -60,7 +59,7 @@ class TeacherSubmissionNotificationService
|
||||
->keyBy('id');
|
||||
|
||||
$adminUser = User::find($adminId);
|
||||
$adminName = trim(($adminUser->firstname ?? '') . ' ' . ($adminUser->lastname ?? '')) ?: 'Administrator';
|
||||
$adminName = trim(($adminUser->firstname ?? '').' '.($adminUser->lastname ?? '')) ?: 'Administrator';
|
||||
|
||||
$scoreUrl = $this->urls->docsHomeUrl();
|
||||
$sentCount = 0;
|
||||
@@ -72,30 +71,30 @@ class TeacherSubmissionNotificationService
|
||||
|
||||
$teacher = $teachers->get($teacherId);
|
||||
$sectionName = $classSections->get($classSectionId)?->class_section_name ?? "Section {$classSectionId}";
|
||||
$teacherName = trim(($teacher->firstname ?? '') . ' ' . ($teacher->lastname ?? '')) ?: 'Teacher';
|
||||
$teacherName = trim(($teacher->firstname ?? '').' '.($teacher->lastname ?? '')) ?: 'Teacher';
|
||||
|
||||
$missingItems = $this->resolveMissingItems($missingItemsPayload, $classSectionId, $teacherId);
|
||||
|
||||
$missingNote = !empty($missingItems)
|
||||
? '<p>Outstanding items: ' . e($this->support->formatMissingItemsText($missingItems)) . '.</p>'
|
||||
$missingNote = ! empty($missingItems)
|
||||
? '<p>Outstanding items: '.e($this->support->formatMissingItemsText($missingItems)).'.</p>'
|
||||
: '<p>Our records show no outstanding submissions for this section, but please verify if anything still needs attention.</p>';
|
||||
|
||||
$subject = "Reminder: Complete submissions for {$sectionName}";
|
||||
$body = "<p>Dear {$teacherName},</p>"
|
||||
. "<p>Administration is gently reminding you to wrap up any remaining score submissions and/or comments for {$sectionName}.</p>"
|
||||
. $missingNote
|
||||
. "<p>Visit <a href=\"{$scoreUrl}\">Teacher Score Submission</a> to address any remaining items.</p>"
|
||||
. "<p>Thank you,<br>{$adminName}</p>";
|
||||
."<p>Administration is gently reminding you to wrap up any remaining score submissions and/or comments for {$sectionName}.</p>"
|
||||
.$missingNote
|
||||
."<p>Visit <a href=\"{$scoreUrl}\">Teacher Score Submission</a> to address any remaining items.</p>"
|
||||
."<p>Thank you,<br>{$adminName}</p>";
|
||||
|
||||
$email = $teacher->email ?? '';
|
||||
$status = 'failed';
|
||||
|
||||
if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
if (! empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
try {
|
||||
Mail::to($email)->send(new TeacherSubmissionReminderMail($subject, $body));
|
||||
$status = 'sent';
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Teacher submission notification failed: ' . $e->getMessage());
|
||||
Log::error('Teacher submission notification failed: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,15 +119,15 @@ class TeacherSubmissionNotificationService
|
||||
|
||||
$parts = [];
|
||||
if ($sentCount > 0) {
|
||||
$parts[] = $sentCount . ' reminder' . ($sentCount === 1 ? '' : 's') . ' sent';
|
||||
$parts[] = $sentCount.' reminder'.($sentCount === 1 ? '' : 's').' sent';
|
||||
}
|
||||
if ($failCount > 0) {
|
||||
$parts[] = $failCount . ' reminder' . ($failCount === 1 ? '' : 's') . ' failed';
|
||||
$parts[] = $failCount.' reminder'.($failCount === 1 ? '' : 's').' failed';
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => $failCount === 0,
|
||||
'message' => !empty($parts) ? implode(' and ', $parts) : 'No notifications were sent.',
|
||||
'message' => ! empty($parts) ? implode(' and ', $parts) : 'No notifications were sent.',
|
||||
'sent' => $sentCount,
|
||||
'failed' => $failCount,
|
||||
'status' => $failCount === 0 ? 200 : 207,
|
||||
@@ -164,7 +163,7 @@ class TeacherSubmissionNotificationService
|
||||
|
||||
foreach ($notify as $sectionIdRaw => $teachers) {
|
||||
$sectionId = (int) $sectionIdRaw;
|
||||
if ($sectionId <= 0 || !is_array($teachers)) {
|
||||
if ($sectionId <= 0 || ! is_array($teachers)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -197,7 +196,7 @@ class TeacherSubmissionNotificationService
|
||||
|
||||
protected function resolveMissingItems($payload, int $classSectionId, int $teacherId): array
|
||||
{
|
||||
if (!is_array($payload)) {
|
||||
if (! is_array($payload)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ class TeacherSubmissionReportService
|
||||
public function __construct(
|
||||
protected AdministratorSharedService $shared,
|
||||
protected TeacherSubmissionSupportService $support
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function report(array $filters = []): array
|
||||
{
|
||||
@@ -56,14 +55,14 @@ class TeacherSubmissionReportService
|
||||
default => $roleKey !== '' ? ucfirst($roleKey) : 'Teacher',
|
||||
};
|
||||
|
||||
$teacherFullName = trim(($assignment['firstname'] ?? '') . ' ' . ($assignment['lastname'] ?? ''));
|
||||
$teacherFullName = trim(($assignment['firstname'] ?? '').' '.($assignment['lastname'] ?? ''));
|
||||
$teacherId = (int) ($assignment['teacher_id'] ?? 0);
|
||||
|
||||
if ($teacherFullName === '' || $teacherId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($teachersBySection[$sectionId])) {
|
||||
if (! isset($teachersBySection[$sectionId])) {
|
||||
$teachersBySection[$sectionId] = [
|
||||
'class_section' => $assignment['class_section_name'] ?? "Section {$sectionId}",
|
||||
'teachers' => [],
|
||||
@@ -113,7 +112,7 @@ class TeacherSubmissionReportService
|
||||
|
||||
foreach ($scoreRecords as $score) {
|
||||
$sid = (int) ($score->student_id ?? 0);
|
||||
if ($sid <= 0 || ($expected > 0 && !in_array($sid, $studentIds, true))) {
|
||||
if ($sid <= 0 || ($expected > 0 && ! in_array($sid, $studentIds, true))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,7 +128,7 @@ class TeacherSubmissionReportService
|
||||
$midtermCommentStudents = [];
|
||||
$ptapCommentStudents = [];
|
||||
|
||||
if (!empty($studentIds)) {
|
||||
if (! empty($studentIds)) {
|
||||
$comments = ScoreComment::query()
|
||||
->select('student_id', 'score_type', 'comment')
|
||||
->whereIn('student_id', $studentIds)
|
||||
@@ -177,7 +176,7 @@ class TeacherSubmissionReportService
|
||||
);
|
||||
|
||||
foreach ($teacherList as $teacherEntry) {
|
||||
if (!empty($teacherEntry['id'])) {
|
||||
if (! empty($teacherEntry['id'])) {
|
||||
$allTeacherIds[] = $teacherEntry['id'];
|
||||
}
|
||||
}
|
||||
@@ -264,7 +263,7 @@ class TeacherSubmissionReportService
|
||||
continue;
|
||||
}
|
||||
|
||||
$adminName = trim(($record->firstname ?? '') . ' ' . ($record->lastname ?? ''));
|
||||
$adminName = trim(($record->firstname ?? '').' '.($record->lastname ?? ''));
|
||||
if ($adminName === '') {
|
||||
$adminName = 'Administrator';
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class TeacherSubmissionSupportService
|
||||
|
||||
$items = [];
|
||||
foreach ($statusMap as $key => $status) {
|
||||
if (!(bool) ($status['completed'] ?? true) && isset($labels[$key])) {
|
||||
if (! (bool) ($status['completed'] ?? true) && isset($labels[$key])) {
|
||||
$items[] = $labels[$key];
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class TeacherSubmissionSupportService
|
||||
|
||||
return mb_strlen($text) <= $limit
|
||||
? $text
|
||||
: mb_substr($text, 0, $limit) . '…';
|
||||
: mb_substr($text, 0, $limit).'…';
|
||||
}
|
||||
|
||||
public function parseMissingItemsPayload($payload): array
|
||||
@@ -103,7 +103,7 @@ class TeacherSubmissionSupportService
|
||||
}
|
||||
|
||||
$decoded = json_decode(base64_decode($payload, true) ?: '', true);
|
||||
if (!is_array($decoded)) {
|
||||
if (! is_array($decoded)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -130,10 +130,11 @@ class TeacherSubmissionSupportService
|
||||
return $items[0];
|
||||
}
|
||||
if ($count === 2) {
|
||||
return $items[0] . ' and ' . $items[1];
|
||||
return $items[0].' and '.$items[1];
|
||||
}
|
||||
|
||||
$last = array_pop($items);
|
||||
return implode(', ', $items) . ' and ' . $last;
|
||||
|
||||
return implode(', ', $items).' and '.$last;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ class TrophyReportService
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection<int, array<string, mixed>>
|
||||
* @return Collection<int, array<string, mixed>>
|
||||
*/
|
||||
private function studentRows(string $schoolYear): Collection
|
||||
{
|
||||
@@ -393,7 +393,7 @@ class TrophyReportService
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Support\Collection<int, array<string, mixed>> $rows
|
||||
* @param Collection<int, array<string, mixed>> $rows
|
||||
* @return array<int, array{name: string, students: list<array<string, mixed>>}>
|
||||
*/
|
||||
private function sectionMap(Collection $rows): array
|
||||
|
||||
Reference in New Issue
Block a user