diff --git a/.env.example b/.env.example index 15236da..439767f 100644 --- a/.env.example +++ b/.env.example @@ -32,6 +32,7 @@ MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" +MAIL_DIGITAL_SERVICE="" # Sentry SENTRY_LARAVEL_DSN= diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 9f6cd18..6ae34af 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -3,6 +3,7 @@ namespace App\Console; use App\Console\Commands\DeleteUnconfirmedCustomers; +use App\Jobs\SendTransferredToDigitalCountMail; use App\Jobs\StartStatJobs; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -26,6 +27,7 @@ class Kernel extends ConsoleKernel { // @codeCoverageIgnoreStart $schedule->job(StartStatJobs::class)->dailyAt('03:30'); + $schedule->job(SendTransferredToDigitalCountMail::class)->dailyAt('07:00'); $schedule->command(DeleteUnconfirmedCustomers::class)->dailyAt('05:30'); // @codeCoverageIgnoreEnd } diff --git a/app/Jobs/SendTransferredToDigitalCountMail.php b/app/Jobs/SendTransferredToDigitalCountMail.php new file mode 100644 index 0000000..9eebfe2 --- /dev/null +++ b/app/Jobs/SendTransferredToDigitalCountMail.php @@ -0,0 +1,47 @@ +where('status', ClaimStatus::sentDigital)->count(); + + if ($count <= 0) { + return; + } + + Mail::to(config('mail.digital_service')) + ->send(new TransferredToDigitalCountMail($count)); + } +} diff --git a/app/Mail/TransferredToDigitalCountMail.php b/app/Mail/TransferredToDigitalCountMail.php new file mode 100644 index 0000000..b2a12ec --- /dev/null +++ b/app/Mail/TransferredToDigitalCountMail.php @@ -0,0 +1,33 @@ +subject(sprintf('%s réclamations vous attendent', $this->count)) + ->view('mail.transferred-claim-count') + ->text('mail.transferred-claim-count-plain') + ->with('count', $this->count); + } +} + diff --git a/config/mail.php b/config/mail.php index e22ad1f..65be5b4 100644 --- a/config/mail.php +++ b/config/mail.php @@ -115,4 +115,10 @@ return [ ], ], + /** + * Contact list + */ + + 'digital_service' => env('MAIL_DIGITAL_SERVICE', 'digital@ldc.fr'), + ]; diff --git a/manifest.yaml b/manifest.yaml index 8fea819..b8eaab3 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -23,6 +23,7 @@ data: MAIL_ENCRYPTION: "${APP_MAIL_ENCRYPTION}" MAIL_FROM_ADDRESS: "${APP_MAIL_FROM_ADDRESS}" MAIL_FROM_NAME: "${APP_APP_NAME}" + MAIL_DIGITAL_SERVICE: "${APP_MAIL_DIGITAL_SERVICE}" SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}" LDC_WEB_API_KEY: "${APP_LDC_WEB_API_KEY}" SAML2_DEFAULT_TENANT_UUID: "${APP_SAML2_DEFAULT_TENANT_UUID}" diff --git a/resources/views/mail/transferred-claim-count-plain.blade.php b/resources/views/mail/transferred-claim-count-plain.blade.php new file mode 100644 index 0000000..e4f6dc5 --- /dev/null +++ b/resources/views/mail/transferred-claim-count-plain.blade.php @@ -0,0 +1,5 @@ +Bonjour, + +{{ $count }} réclamations vous sont actuellement attribuées. + +Accédez à ces réclamations via ce lien : https://crm.uwil.fr/bo/claims?sort_col=created_at&sort_way=desc&status[]=2 diff --git a/resources/views/mail/transferred-claim-count.blade.php b/resources/views/mail/transferred-claim-count.blade.php new file mode 100644 index 0000000..238e779 --- /dev/null +++ b/resources/views/mail/transferred-claim-count.blade.php @@ -0,0 +1,12 @@ + + +
+Bonjour,
+{{ $count }} réclamations vous sont actuellement attribuées.
+Cliquez ici pour y accéder.
+ +