Skip to content

Commit

Permalink
Merge pull request #172 from dbarzin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dbarzin authored Oct 11, 2024
2 parents 7b6846d + a4ddc51 commit aa06cc3
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
3 changes: 2 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ Finally, restart the Apache service to activate the changes:

## PHP

You need to set the value of upload_max_filesize and post_max_size in your php.ini :
You need to set the value of upload_max_filesize and post_max_size in your php.ini
(/etc/php/8.1/fpm/php.ini) :

; Maximum allowed size for uploaded files.
upload_max_filesize = 10M
Expand Down
8 changes: 5 additions & 3 deletions app/Console/Commands/SendNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function handle()
->get();
if ($controls->count() > 0) {
App::setlocale($user->language);
$txt = htmlentities(trans('cruds.notification.subject')) . '<br><br>';
$txt = '';
foreach ($controls as $control) {
// Date
$txt .= '<a href="' . url('/bob/show/'. $control->id) . '">';
Expand All @@ -92,7 +92,7 @@ public function handle()
$txt .= "<br>\n";
}

// send notification
// Create message
$mail_from = config('deming.notification.mail-from');
$headers = [
'MIME-Version: 1.0',
Expand All @@ -101,7 +101,9 @@ public function handle()
];
$to_email = $user->email;
$subject = config('deming.notification.mail-subject');
$message = $txt;

// Apply message model
$message = str_replace("%table%",$txt,config('deming.notification.mail-content'));

// Send mail
if (mail(
Expand Down
9 changes: 7 additions & 2 deletions app/Http/Controllers/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ public function index()
// Get configuration
$mail_from = config('deming.notification.mail-from');
$mail_subject = config('deming.notification.mail-subject');
$mail_content = config('deming.notification.mail-content');
$frequency = config('deming.notification.frequency');
$expire_delay = config('deming.notification.expire-delay');
$reminder = config('deming.notification.reminder');

// Return
return view(
'config',
compact('mail_from', 'mail_subject', 'frequency', 'expire_delay', 'reminder')
compact(
'mail_from', 'mail_subject', 'mail_content',
'frequency', 'expire_delay', 'reminder')
);
}

Expand All @@ -39,6 +42,7 @@ public function save(Request $request)
// read request
$mail_from = request('mail_from');
$mail_subject = request('mail_subject');
$mail_content = request('mail_content');
$frequency = request('frequency');
$expire_delay = request('expire_delay');
$reminder = request('reminder');
Expand All @@ -48,6 +52,7 @@ public function save(Request $request)
// put in config file
config(['deming.notification.mail-from' => $mail_from]);
config(['deming.notification.mail-subject' => $mail_subject]);
config(['deming.notification.mail-content' => $mail_content]);
config(['deming.notification.frequency' => $frequency]);

config(['deming.notification.expire-delay' => $expire_delay]);
Expand Down Expand Up @@ -89,7 +94,7 @@ public function save(Request $request)

return view(
'config',
compact('mail_from', 'mail_subject', 'frequency', 'expire_delay', 'reminder')
compact('mail_from', 'mail_subject', 'mail_content', 'frequency', 'expire_delay', 'reminder')
)
->withErrors($msg);
}
Expand Down
15 changes: 15 additions & 0 deletions resources/lang/en/cruds.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@
'title_short' => 'Notifications',
'help' => 'This screen allows you to configure the notifications sent by email to users.',
'message_subject' => 'Message subject',
'message_content' => 'Message content',
'message_default_content' => '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Here is the list of measurement that will be due soon:</p>
%table%
<p>This is an automatically generated email</p>
<p>Best regards,</p>
<p>Deming</p>
</body>
</html>',
'sent_from' => 'Sent from',
'to' => 'to',
'delay' => 'for controls that expire within',
Expand Down
15 changes: 15 additions & 0 deletions resources/lang/fr/cruds.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@
'title_short' => 'Notifications',
'help' => 'Cet écran permet de configurer les notifications envoyées par mail aux utilisateurs.',
'message_subject' => 'Sujet du message',
'message_content' => 'Contenu du message',
'message_default_content' => '<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Voici la liste des contrôles dû prochainement :</p>
%table%
<p>Ceci est un mail généré automatiquement.</p>
<p>Cordialement,</p>
<p>Deming</p>
</body>
</html>',
'sent_from' => 'Envoyé depuis',
'to' => 'à',
'delay' => 'Pour les contrôles qui arrivent à échéance dans',
Expand Down
20 changes: 13 additions & 7 deletions resources/views/config.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,30 @@

<div class="row">
<div class="cell-1">
<strong>{{ trans("cruds.config.notifications.message_subject") }}</strong>
<strong>{{ trans("cruds.config.notifications.sent_from") }}</strong>
</div>
<div class="cell-8">
<input type="text" name="mail_subject" id="mail_subject" value="{{ $mail_subject }}" required size=64/>
<input type="text" name="mail_from" id="mail_from" value="{{ $mail_from }}" required size=64/>
</div>
</div>

<div class="row">
<div class="cell-1">
<strong>{{ trans("cruds.config.notifications.sent_from") }}</strong>
<strong>{{ trans("cruds.config.notifications.message_subject") }}</strong>
</div>
<div class="cell-8">
<input type="text" name="mail_from" id="mail_from" value="{{ $mail_from }}" required size=64/>
<input type="text" name="mail_subject" id="mail_subject" value="{{ $mail_subject }}" required size=64/>
</div>
</div>

<div class="row">
<div class="cell-1">
<strong>{{ trans("cruds.config.notifications.message_content") }}</strong>
</div>
<div class="cell-6">
<textarea name="mail_content" rows="10" data-role="textarea" data-clear-button="false">{{ strlen($mail_content)==0 ? trans('cruds.config.notifications.message_default_content') : $mail_content }}</textarea>
</div>
</div>

<div class="row">
<div class="cell-1">
Expand Down Expand Up @@ -78,7 +86,7 @@
</select>
</div>
</div>

<div class="row">
<div class="cell-6">
</div>
Expand Down Expand Up @@ -110,5 +118,3 @@
</div>
</div>
@endsection


0 comments on commit aa06cc3

Please sign in to comment.