Skip to content

Commit 17dd215

Browse files
committed
allow text in notification body when sending a reply to user
1 parent b2529db commit 17dd215

9 files changed

Lines changed: 36 additions & 19 deletions

File tree

src/Controllers/CommentsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function store(Request $request)
171171
}
172172

173173
DB::commit();
174-
event(new CommentCreated($comment));
174+
event(new CommentCreated($comment, $request));
175175

176176
session()->flash('status', trans('panichd::lang.comment-has-been-added-ok'));
177177

src/Controllers/NotificationsController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function ticketAgentUpdated(Ticket $original_ticket, Ticket $ticket)
126126
$this->sendNotification($a_to, $data);
127127
}
128128

129-
public function newComment(Comment $comment)
129+
public function newComment(Comment $comment, $request)
130130
{
131131
if (in_array($comment->type, ['reply', 'note'])){
132132
$ticket = $comment->ticket;
@@ -147,6 +147,10 @@ public function newComment(Comment $comment)
147147

148148
// Notificate ticket owner
149149
if ($comment->type == 'reply' and !$ticket->hidden and !in_array($ticket->owner->email, [$notification_owner->email, $ticket->agent->email])){
150+
if ($request->has('add_in_user_notification_text')){
151+
$data['add_in_user_notification_text'] = true;
152+
}
153+
150154
$a_to[] = [
151155
'recipient' => $ticket->owner,
152156
'subject' => $subject,

src/Events/CommentCreated.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PanicHD\PanicHD\Events;
44

55
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Http\Request;
67
use Illuminate\Queue\SerializesModels;
78
use Illuminate\Broadcasting\PrivateChannel;
89
use Illuminate\Broadcasting\PresenceChannel;
@@ -20,9 +21,10 @@ class CommentCreated
2021
*
2122
* @return void
2223
*/
23-
public function __construct(Comment $comment)
24+
public function __construct(Comment $comment, Request $request)
2425
{
2526
$this->comment = $comment;
27+
$this->request = $request;
2628
}
2729

2830
/**
@@ -34,4 +36,4 @@ public function broadcastOn()
3436
{
3537
return new PrivateChannel('channel-name');
3638
}
37-
}
39+
}

src/PanicHDServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function boot()
230230
if (Setting::grab('comment_notification')) {
231231
$comment = $event->comment;
232232
$notification = new NotificationsController($comment->ticket->category);
233-
$notification->newComment($comment);
233+
$notification->newComment($comment, $event->request);
234234
}
235235
});
236236

src/Translations/ca/lang.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@
287287
'show-ticket-add-comment-type' => 'Tipus',
288288
'show-ticket-add-comment-note' => 'Nota interna',
289289
'show-ticket-add-comment-reply' => 'Resposta a usuari',
290-
'show-ticket-add-com-check-intervention' => 'Afegir aquesta resposta al camp actuació',
290+
'show-ticket-add-com-check-email-text' => 'Afegir text a la notificació per a l\'usuari',
291+
'show-ticket-add-com-check-intervention' => 'Afegir aquesta resposta al camp actuació (visible per l\'usuari)',
291292
'show-ticket-add-com-check-resolve' => 'Tancar el tiquet amb estat',
292293
'add-comment-confirm-blank-intervention' => 'El camp "actuació" està en blanc. Vols tancar el tiquet igualment?',
293294

src/Translations/en/lang.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@
289289
'show-ticket-add-comment-type' => 'Type',
290290
'show-ticket-add-comment-note' => 'Internal note',
291291
'show-ticket-add-comment-reply' => 'Reply to user',
292-
'show-ticket-add-com-check-intervention' => 'Append this text in intervention field',
292+
'show-ticket-add-com-check-email-text' => 'Add text in the user notification',
293+
'show-ticket-add-com-check-intervention' => 'Append this text in intervention field (visible by user)',
293294
'show-ticket-add-com-check-resolve' => 'Complete this ticket and apply the status',
294295
'add-comment-confirm-blank-intervention' => 'The "intervention" field is empty. Would you want to close ticket anyway?',
295296

src/Views/emails/new_comment.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
@if ($recipient->levelInCategory($ticket->category->id) > 1)
1818
@include('panichd::emails.partial.common_fields')
1919
<b>{{ trans('panichd::email/globals.new_' . $notification_type . '_title') }}</b>
20+
@endif
21+
22+
@if ($recipient->levelInCategory($ticket->category->id) > 1 || (isset($add_in_user_notification_text) and $add_in_user_notification_text))
2023
<table border="0" cellpadding="10" cellspacing="0" style="border: 1px solid #ddd; border-radius: 5px;"><tr>
2124
<td>@include('panichd::emails.partial.html_field', ['html_field' => $comment->html])</td>
2225
</tr></table><br /><br />

src/Views/tickets/show/modal_comment_new.blade.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,26 @@
5151
</div>
5252
</div>
5353
@endif
54-
55-
@if ($u->currentLevel() > 1 && $u->canManageTicket($ticket->id))
54+
@if ($u->currentLevel() > 1)
5655
<div class="form-group">
5756
<div class="col-lg-12" style="display: none;">
58-
<label><input type="checkbox" id="add_to_intervention" name="add_to_intervention" value="yes" disabled> {{ trans('panichd::lang.show-ticket-add-com-check-intervention') }}</label>
57+
<label><input type="checkbox" id="add_in_user_notification_text" name="add_in_user_notification_text" value="yes" disabled> {{ trans('panichd::lang.show-ticket-add-com-check-email-text') }}</label>
5958
</div>
60-
@if ($u->canCloseTicket($ticket->id))
61-
<div class="col-lg-12">
62-
<label><input type="checkbox" name="complete_ticket" value="yes"> {{ trans('panichd::lang.show-ticket-add-com-check-resolve') . trans('panichd::lang.colon')}}</label>
63-
&nbsp;{!! CollectiveForm::select('status_id', $status_lists, $setting->grab('default_close_status_id'), []) !!}
59+
60+
@if ($u->canManageTicket($ticket->id))
61+
<div class="col-lg-12" style="display: none;">
62+
<label><input type="checkbox" id="add_to_intervention" name="add_to_intervention" value="yes" disabled> {{ trans('panichd::lang.show-ticket-add-com-check-intervention') }}</label>
6463
</div>
65-
@endif
64+
@if ($u->canCloseTicket($ticket->id))
65+
<div class="col-lg-12">
66+
<label><input type="checkbox" name="complete_ticket" value="yes"> {{ trans('panichd::lang.show-ticket-add-com-check-resolve') . trans('panichd::lang.colon')}}</label>
67+
&nbsp;{!! CollectiveForm::select('status_id', $status_lists, $setting->grab('default_close_status_id'), []) !!}
68+
</div>
69+
@endif
70+
@endif
6671
</div>
6772
@endif
73+
6874
<div class="text-right col-md-12">
6975
{!! CollectiveForm::submit( trans('panichd::lang.btn-submit'), [
7076
'id' => 'new_comment_submit',

src/Views/tickets/show/script.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@
9898
$(this).addClass($(this).attr('data-active-class'));
9999
100100
if (type == 'reply'){
101-
$('#add_to_intervention').prop('disabled', false);
102-
$('#add_to_intervention').closest('div').show();
101+
$('#add_in_user_notification_text, #add_to_intervention').prop('disabled', false);
102+
$('#add_in_user_notification_text, #add_to_intervention').closest('div').show();
103103
}else{
104-
$('#add_to_intervention').prop('disabled', true);
105-
$('#add_to_intervention').closest('div').hide();
104+
$('#add_in_user_notification_text, #add_to_intervention').prop('disabled', true);
105+
$('#add_in_user_notification_text, #add_to_intervention').closest('div').hide();
106106
}
107107
108108
var alt = type == 'note' ? 'reply' : 'note';

0 commit comments

Comments
 (0)