-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
314 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,12 @@ WP_SECURE_AUTH_SALT="ThisIsASecretKey!DoNotUseItInProduction!ChangeIt!" | |
WP_LOGGED_IN_SALT="ThisIsASecretKey!DoNotUseItInProduction!ChangeIt!" | ||
WP_NONCE_SALT="ThisIsASecretKey!DoNotUseItInProduction!ChangeIt!" | ||
|
||
EXPIRY_SEND_ESCALATION=false | ||
EXPIRY_SEND_ESCALATION_DAYS_BEFORE=7 | ||
EXPIRY_SEND_ESCALATION_COPY=[email protected] | ||
EXPIRY_PANEL_PATH=moox | ||
LOGO_URL="https://moox.org/img/logo.png" | ||
|
||
APP_LOCALE=en | ||
APP_FALLBACK_LOCALE=en | ||
APP_FAKER_LOCALE=en_US | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,21 @@ | |
'user_model' => \Moox\Press\Models\WpUser::class, | ||
'default_notified_to' => 1, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Escalation Settings | ||
|-------------------------------------------------------------------------- | ||
| Configure notifications for escalations. | ||
| Define timing and recipients. | ||
| Set the dashboard path. | ||
*/ | ||
|
||
'send-escalation' => env('EXPIRY_SEND_ESCALATION', true), | ||
'send-escalation-days-before' => env('EXPIRY_SEND_ESCALATION_DAYS_BEFORE', 7), | ||
'send-escalation-copy' => env('EXPIRY_SEND_ESCALATION_COPY', '[email protected]'), | ||
'panel_path' => env('EXPIRY_PANEL_PATH', 'press'), | ||
'logo_url' => env('LOGO_URL', 'https://moox.org/img/logo.png'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Disable actions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,21 @@ | |
'user_model' => \Moox\Press\Models\WpUser::class, | ||
'default_notified_to' => 1, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Escalation Settings | ||
|-------------------------------------------------------------------------- | ||
| Configure notifications for escalations. | ||
| Define timing and recipients. | ||
| Set the dashboard path. | ||
*/ | ||
|
||
'send-escalation' => env('EXPIRY_SEND_ESCALATION', false), | ||
'send-escalation-days-before' => env('EXPIRY_SEND_ESCALATION_DAYS_BEFORE', 7), | ||
'send-escalation-copy' => env('EXPIRY_SEND_ESCALATION_COPY', '[email protected]'), | ||
'panel_path' => env('EXPIRY_PANEL_PATH', 'moox'), | ||
'logo_url' => env('LOGO_URL', 'https://moox.org/img/logo.png'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Disable actions | ||
|
139 changes: 139 additions & 0 deletions
139
packages/expiry/resources/views/emails/escalated_expiries.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<!DOCTYPE html> | ||
<html lang="de"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Escalated Entries</title> | ||
<style> | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f9fafb; | ||
} | ||
.container { | ||
width: 100%; | ||
max-width: 800px; | ||
margin: 20px auto; | ||
padding: 20px; | ||
background-color: #ffffff; | ||
border-radius: 8px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
h1, | ||
h3 { | ||
font-size: 1.25rem; | ||
color: #333333; | ||
margin-bottom: 20px; | ||
} | ||
p { | ||
font-size: 1rem; | ||
color: #555555; | ||
} | ||
.table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
margin-top: 20px; | ||
} | ||
.table th, | ||
.table td { | ||
padding: 12px; | ||
text-align: left; | ||
border-bottom: 1px solid #e0e0e0; | ||
} | ||
.table th { | ||
background-color: #f4f4f4; | ||
font-weight: 600; | ||
color: #333333; | ||
} | ||
.table tr:nth-child(even) { | ||
background-color: #f9f9f9; | ||
} | ||
.table tr:hover { | ||
background-color: #f1f1f1; | ||
} | ||
.table .title { | ||
font-weight: bold; | ||
color: #1a202c; | ||
} | ||
.table .escalation { | ||
color: #e53e3e; | ||
font-weight: bold; | ||
} | ||
.footer { | ||
margin-top: 20px; | ||
font-size: 0.875rem; | ||
color: #777777; | ||
} | ||
.footer a { | ||
color: #3182ce; | ||
text-decoration: none; | ||
} | ||
.footer a:hover { | ||
text-decoration: underline; | ||
} | ||
.logo { | ||
display: block; | ||
margin-bottom: 20px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<!-- Header with Logo --> | ||
<div class="logo"> | ||
<img src="{{ config('expiry.logo_url') }}" alt="Company Logo" class="w-24 h-auto"> | ||
</div> | ||
<h1>{{ __('core::expiry.escalated_entries_in_expiry_dashboard') }}</h1> | ||
<h4>{{ __('core::expiry.following_escalated_entries') }}</h4> | ||
|
||
<!-- Escalated Entries --> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>{{ __('core::core.title') }}</th> | ||
<th>{{ __('core::expiry.notifyUser') }}</th> | ||
<th>{{ __('core::expiry.will_expire_at') }}</th> | ||
<th>{{ __('core::expiry.processing_deadline') }}</th> | ||
<th>{{ __('core::expiry.escalated_at') }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($escalatedEntries as $entry) | ||
<tr> | ||
<td class="title">{{ $entry['title'] }}</td> | ||
<td>{{ $entry['notified_to'] }}</td> | ||
<td>{{ $entry['expired_at'] }}</td> | ||
<td>{{ $entry['processing_deadline'] }}</td> | ||
<td class="escalation">{{ $entry['escalated_at'] }}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<!-- Footer --> | ||
<p class="footer">{{ __('core::expiry.review_entreis') }}<a | ||
href="{{ url($panelPath . '/expiries') }}">{{ __('core::expiry.expiry_dashboard') }}</a>.</p> | ||
</div> | ||
</body> | ||
|
||
</html> |
14 changes: 0 additions & 14 deletions
14
packages/expiry/resources/views/emails/expirySummary.blade.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Moox\Expiry\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Moox\Expiry\Jobs\SendEscalatedExpiriesJob; | ||
|
||
class EscalatedExpiriesCommand extends Command | ||
{ | ||
protected $signature = 'mooxexpiry:escalated'; | ||
|
||
protected $description = 'Dispatch the job to send notifications for escalated expiries'; | ||
|
||
public function handle() | ||
{ | ||
SendEscalatedExpiriesJob::dispatch(); | ||
$this->info('Escalated Expiries Notification Dispatched'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Moox\Expiry\Jobs; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Mail; | ||
use Moox\Expiry\Mail\EscalatedExpiriesMail; | ||
use Moox\Expiry\Models\Expiry; | ||
|
||
class SendEscalatedExpiriesJob implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public function handle() | ||
{ | ||
if (! config('expiry.send-escalation')) { | ||
return; | ||
} | ||
|
||
$adminEmail = config('expiry.send-escalation-copy'); | ||
$panelPath = config('expiry.panel_path'); | ||
|
||
$escalatedExpiries = Expiry::query() | ||
->where(function ($query) { | ||
$query->whereNull('escalated_to') | ||
->whereNotNull('escalated_at'); | ||
}) | ||
->get(); | ||
|
||
if ($escalatedExpiries->isEmpty()) { | ||
return; | ||
} | ||
|
||
$escalatedEntries = $escalatedExpiries->filter(fn ($entry) => $entry->escalated_at !== null); | ||
|
||
$escalatedEntries->each(function ($entry) { | ||
$responsibleId = $entry->notified_to; | ||
$entry->escalated_to = $responsibleId; | ||
$entry->save(); | ||
}); | ||
|
||
$data = [ | ||
'escalatedEntries' => $escalatedEntries->map(function ($entry) { | ||
return [ | ||
'title' => $entry->title, | ||
'expired_at' => Carbon::parse($entry->expired_at)->format('d.m.Y'), | ||
'processing_deadline' => Carbon::parse($entry->processing_deadline)->format('d.m.Y'), | ||
'escalated_at' => Carbon::parse($entry->escalated_at)->format('d.m.Y'), | ||
'notified_to' => config('expiry.user_model')::where('ID', $entry->notified_to)->first()?->display_name, | ||
'user_email' => config('expiry.user_model')::where('ID', $entry->notified_to)->first()?->email, | ||
]; | ||
}), | ||
]; | ||
|
||
$responsibleEmail = config('expiry.user_model')::where('ID', $escalatedExpiries->first()->notified_to)->first()?->email; | ||
|
||
Mail::to($responsibleEmail) | ||
->cc($adminEmail) | ||
->send(new EscalatedExpiriesMail($data, $panelPath)); | ||
} | ||
} |
Oops, something went wrong.