diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a8aff551..8e4a4f97 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -8,6 +8,7 @@ use App\Jobs\ProcessSoloCertExpiryWarnings; use App\Jobs\ProcessShanwickController; use App\Jobs\DiscordTrainingWeeklyUpdates; +use App\Jobs\ProcessMonthlyBreakdown; use App\Jobs\UpdateDiscordUserRoles; use App\Jobs\DiscordAccountCheck; use App\Models\Roster\RosterMember; @@ -42,7 +43,25 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSessionLogging())->everyMinute(); //Inactivity checks - $schedule->job(new ProcessRosterInactivity())->dailyAt('14:05'); + $schedule->job(new ProcessRosterInactivity())->daily(); + + // Monthly Statistics Breakdown + $schedule->job(new ProcessMonthlyBreakdown())->monthlyOn(1, '00:40'); + + //Solo cert expiry warning + // $schedule->job(new ProcessSoloCertExpiryWarnings())->daily(); + + // Shanwick Controller Roster Update + $schedule->job(new ProcessShanwickController())->daily(); + + //Training/OTS session reminders + $schedule->job(new ProcessSessionReminders())->daily(); + + // Check Training Threads Status (Once per week) + $schedule->job(new DiscordTrainingWeeklyUpdates())->weeklyOn(6, '6:00'); + + // Check If Account is Linked + $schedule->job(new DiscordAccountCheck)->weeklyOn(5, '0:30'); //CRONS FOR INACTIVITY EMAILS 2 weeks // $schedule->call(function () { @@ -77,24 +96,6 @@ protected function schedule(Schedule $schedule) // $discord = new DiscordClient(); // $discord->sendMessage(753086414811562014, 'Sent '.$count.' one-week warning inactivity emails'); // })->cron('00 00 23 MAR,JUN,SEP,DEC *'); // 1 week before end of quarter*/ - - // Monthly Statistics Breakdown - $schedule->job(new ProcessShanwickController())->monthlyOn(1, '00:00'); - - //Solo cert expiry warning - // $schedule->job(new ProcessSoloCertExpiryWarnings())->daily(); - - // Shanwick Controller Roster Update - $schedule->job(new ProcessShanwickController())->daily(); - - //Training/OTS session reminders - $schedule->job(new ProcessSessionReminders())->daily(); - - // Check Training Threads Status (Once per week) - $schedule->job(new DiscordTrainingWeeklyUpdates())->weeklyOn(6, '6:00'); - - // Check If Account is Linked - $schedule->job(new DiscordAccountCheck)->weeklyOn(5, '0:30'); } /** diff --git a/app/Http/Controllers/Training/ApplicationsController.php b/app/Http/Controllers/Training/ApplicationsController.php index 165a9513..623ad815 100644 --- a/app/Http/Controllers/Training/ApplicationsController.php +++ b/app/Http/Controllers/Training/ApplicationsController.php @@ -442,7 +442,7 @@ public function adminAcceptApplication($reference_id, Request $request) $discord->assignRole($student->user->discord_user_id, 482824058141016075); //Create Instructor Thread - $discord->createTrainingThread($student->user->id, '<@'.$student->user->discord_user_id.'>'); + $discord->createTrainingThread($student->user->fullName('FLC'), '<@'.$student->user->discord_user_id.'>'); // Notify Senior Team that the application was accepted. $discord->sendMessageWithEmbed(config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.applications')), 'Accepted Applicant', $student->user->fullName('FLC').' has just been accepted.', 'error'); diff --git a/app/Jobs/ProcessMonthlyBreakdown.php b/app/Jobs/ProcessMonthlyBreakdown.php index 2c44087f..bd35af11 100644 --- a/app/Jobs/ProcessMonthlyBreakdown.php +++ b/app/Jobs/ProcessMonthlyBreakdown.php @@ -43,13 +43,13 @@ public function handle() $total_hours += $roster->monthly_hours; } + // Compose the message $message = 'It is the beginning of a new month, so here are some wonderful stats for ' . Carbon::now()->subMonth()->format('F, Y') . "\n\n"; $message .= "**__Total Controller Hours__**\n"; $message .= "- " . $total_hours . " hours\n"; $message .= "\n**__Top 3 Controllers__**\n"; - foreach($top_3 as $t) { if($t->user->discord_user_id === null){ $message .= "- " . $t->user->fullName('FLC') . " - ".$t->monthly_hours."\n"; @@ -59,7 +59,6 @@ public function handle() } $message .= "\n**__New Certified Controllers__**\n"; - foreach($new_controllers as $nc) { if($nc->controller->discord_user_id === null){ $message .= "- " . $nc->controller->fullName('FLC') . "\n"; @@ -70,8 +69,9 @@ public function handle() $message .= "\nWell done to everyone for your contributions to Gander Oceanic over the last Month! Enjoy ".Carbon::now()->format('F, Y'); + // Send the Announcement $discord = new DiscordClient(); - $discord->sendMessageWithEmbed('488265136696459292', 'Gander Oceanic Operations Breakdown - '.Carbon::now()->subMonth()->format('F, Y'), $message); + $discord->sendMessageWithEmbed(env('DISCORD_ANNOUNCEMENTS'), 'Gander Oceanic Operations Breakdown - '.Carbon::now()->subMonth()->format('F, Y'), $message); foreach($roster_member as $roster){ $roster->monthly_hours = 0.0; diff --git a/app/Jobs/ProcessRosterInactivity.php b/app/Jobs/ProcessRosterInactivity.php index 5eab0a5f..77401d40 100644 --- a/app/Jobs/ProcessRosterInactivity.php +++ b/app/Jobs/ProcessRosterInactivity.php @@ -11,8 +11,10 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Notification; -use App\Notifications\Roster\RosterStatusChanged; -use App\Notifications\Roster\RemovedFromRoster; +use App\Notifications\Network\TwoMonthInactivityReminder; +use App\Notifications\Network\OneMonthInactivityReminder; +use App\Notifications\Network\OneWeekInactivityReminder; +use App\Notifications\Network\ControllerTerminated; use App\Services\DiscordClient; class ProcessRosterInactivity implements ShouldQueue diff --git a/app/Notifications/Network/ControllerTerminated.php b/app/Notifications/Network/ControllerTerminated.php new file mode 100644 index 00000000..a86bb1ce --- /dev/null +++ b/app/Notifications/Network/ControllerTerminated.php @@ -0,0 +1,71 @@ +rosterMember = $rosterMember; + $this->cycle = $cycle; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * + * @return array + */ + public function via($notifiable) + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + return (new MailMessage()) + ->greeting("Hi {$this->rosterMember->user->fullName('FLC')}") + ->line('**Controller Certification Expired**') + ->line('According to our records, you have not controlled **1 hour** online controlling on EGGX, CZQO or NAT within the last 12 months.') + ->line('This email is notification that your Gander Oceanic Certification has now expired.') + ->line('In order to reattain this certification, please apply via the Gander Oceanic Website.') + ->line("Please don’t hesitate to contact us should you have any concerns.") + ->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*') + ->salutation('Sent automatically through ActivityBot.') + ->subject('[NOTICE] Controller Certification Expired'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/Network/OneMonthInactivityReminder.php b/app/Notifications/Network/OneMonthInactivityReminder.php new file mode 100644 index 00000000..aeb72c28 --- /dev/null +++ b/app/Notifications/Network/OneMonthInactivityReminder.php @@ -0,0 +1,70 @@ +rosterMember = $rosterMember; + $this->cycle = $cycle; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * + * @return array + */ + public function via($notifiable) + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + return (new MailMessage()) + ->greeting("Hi {$this->rosterMember->user->fullName('FLC')}") + ->line('**One Month - Activity Reminder**') + ->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.') + ->line('This email serves only as a reminder in case you may have forgotten.') + ->line("Please don’t hesitate to contact us should you have any concerns.") + ->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*') + ->salutation('Sent automatically through ActivityBot.') + ->subject('[NOTICE] One Month To Fulfil Activity Requirement'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/Network/OneWeekInactivityReminder.php b/app/Notifications/Network/OneWeekInactivityReminder.php index 065e22e6..881bb394 100644 --- a/app/Notifications/Network/OneWeekInactivityReminder.php +++ b/app/Notifications/Network/OneWeekInactivityReminder.php @@ -45,10 +45,10 @@ public function toMail($notifiable) { return (new MailMessage()) ->greeting("Hi {$this->rosterMember->user->fullName('FLC')}") - ->line('**One Week Left - Activity Reminder**') - ->line('According to our records, you have not yet fulfilled our currency requirement. You require **6 hours** online controlling on Gander or Shanwick or Bandbox by the end of the quarter, otherwise you will be marked inactive.') - ->line('There is one week remaining in the current quarter, so this email serves only as a reminder in case you may have forgotten.') - ->line("Please don’t hesitate to contact us should you have any concerns, or if you need us to make an accommodation. We're here to help!") + ->line('**Activity Reminder - One Week till Uncertified**') + ->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.') + ->line('There is one week remaining in this requirement, so this email serves only as a reminder in case you may have forgotten.') + ->line("Please don’t hesitate to contact us should you have any concerns.") ->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*') ->salutation('Sent automatically through ActivityBot.') ->subject('[NOTICE] One Week To Fulfil Activity Requirement'); diff --git a/app/Notifications/Network/TwoWeekInactivityReminder.php b/app/Notifications/Network/TwoMonthInactivityReminder.php similarity index 74% rename from app/Notifications/Network/TwoWeekInactivityReminder.php rename to app/Notifications/Network/TwoMonthInactivityReminder.php index e5daf62c..1d27185f 100644 --- a/app/Notifications/Network/TwoWeekInactivityReminder.php +++ b/app/Notifications/Network/TwoMonthInactivityReminder.php @@ -7,7 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; -class TwoWeekInactivityReminder extends Notification implements ShouldQueue +class TwoMonthInactivityReminder extends Notification implements ShouldQueue { use Queueable; protected $rosterMember, $cycle; @@ -46,12 +46,12 @@ public function toMail($notifiable) return (new MailMessage()) ->greeting("Hi {$this->rosterMember->user->fullName('FLC')}") ->line('**Two Weeks Left - Activity Reminder**') - ->line('According to our records, you have not yet fulfilled our currency requirement. You require **6 hours** online controlling on Gander or Shanwick or Bandbox by the end of the quarter, otherwise you will be marked inactive.') - ->line('There are two weeks remaining in the current quarter, so this email serves only as a reminder in case you may have forgotten.') - ->line("Please don’t hesitate to contact us should you have any concerns, or if you need us to make an accommodation. We're here to help!") + ->line('According to our records, you have not yet fulfilled our currency requirement. You require **1 hour** online controlling on EGGX, CZQO or NAT in a 12 Month Period.') + ->line('This email serves only as a reminder in case you may have forgotten.') + ->line("Please don’t hesitate to contact us should you have any concerns.") ->line('*You received this email as there is important information in regard to your status with Gander Oceanic.*') ->salutation('Sent automatically through ActivityBot.') - ->subject('[NOTICE] Two Weeks To Fulfil Activity Requirement'); + ->subject('[NOTICE] Two Months To Fulfil Activity Requirement'); } /**