Skip to content

Commit 64f5dfc

Browse files
committed
Visual only: Add multiple recipients in new comment modal
1 parent 63a761e commit 64f5dfc

5 files changed

Lines changed: 56 additions & 4 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ public function viewAttachment($attachment_id)
11921192
*/
11931193
public function show($id)
11941194
{
1195-
$user = $this->member->find(auth()->user()->id);
1195+
$member = $this->member->find(auth()->user()->id);
11961196
$members_table = $this->member->getTable();
11971197

11981198
$ticket = $this->tickets
@@ -1226,7 +1226,7 @@ public function show($id)
12261226
// Select Ticket and properties
12271227
$ticket = $ticket->select($a_select)->findOrFail($id);
12281228

1229-
if ($ticket->hidden and $user->currentLevel() == 1){
1229+
if ($ticket->hidden and $member->currentLevel() == 1){
12301230
return redirect()->route(Setting::grab('main_route').'.index')->with('warning', trans('panichd::lang.you-are-not-permitted-to-access'));
12311231
}
12321232

@@ -1255,10 +1255,16 @@ public function show($id)
12551255

12561256
$agent_lists = $this->agentList($ticket->category_id);
12571257

1258-
$comments = $ticket->comments()->forLevel($user->levelInCategory($ticket->category_id))->orderBy('id','desc')->paginate(Setting::grab('paginate_items'));
1258+
$comments = $ticket->comments()->forLevel($member->levelInCategory($ticket->category_id))->orderBy('id','desc')->paginate(Setting::grab('paginate_items'));
1259+
1260+
if ($member->currentLevel() > 1){
1261+
$c_members = \PanicHDMember::with('userDepartment')->orderBy('name')->get();
1262+
}else{
1263+
$c_members = \PanicHDMember::whereNull('ticketit_department')->orWhere('id','=',$member->id)->with('userDepartment')->orderBy('name')->get();
1264+
}
12591265

12601266
$data = compact('ticket', 'a_reasons', 'a_tags_selected', 'status_lists', 'complete_status_list', 'agent_lists', 'tag_lists',
1261-
'comments', 'close_perm', 'reopen_perm');
1267+
'comments', 'c_members', 'close_perm', 'reopen_perm');
12621268
$data['menu'] = 'show';
12631269
return view('panichd::tickets.show', $data);
12641270
}

src/Translations/ca/lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
'show-ticket-add-comment-type' => 'Tipus',
316316
'show-ticket-add-comment-note' => 'Nota interna',
317317
'show-ticket-add-comment-reply' => 'Resposta a usuari',
318+
'show-ticket-add-comment-notificate' => 'Notificar',
318319
'show-ticket-add-com-check-email-text' => 'Afegir text a la notificació per a l\'usuari',
319320
'show-ticket-add-com-check-intervention' => 'Afegir aquesta resposta al camp actuació (visible per l\'usuari)',
320321
'show-ticket-add-com-check-resolve' => 'Tancar el tiquet amb estat',

src/Translations/en/lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
'show-ticket-add-comment-type' => 'Type',
316316
'show-ticket-add-comment-note' => 'Internal note',
317317
'show-ticket-add-comment-reply' => 'Reply to user',
318+
'show-ticket-add-comment-notificate' => 'Notificate',
318319
'show-ticket-add-com-check-email-text' => 'Add text in the user notification',
319320
'show-ticket-add-com-check-intervention' => 'Append this text in intervention field (visible by user)',
320321
'show-ticket-add-com-check-resolve' => 'Complete this ticket and apply the status',

src/Views/tickets/partials/comments/modal_new.blade.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,39 @@
2828
{!! CollectiveForm::hidden('response_type', 'note',['id'=>'response_type'] ) !!}
2929
</div>
3030
</div>
31+
32+
<div class="form-group row">
33+
<label class="col-lg-2 col-form-label">{{ trans('panichd::lang.show-ticket-add-comment-notificate') . trans('panichd::lang.colon') }}</label>
34+
<div class="col-lg-10">
35+
<select name="note_recipients[]" id="note_recipients" class="form-control" multiple="multiple" style="display: none; width: 100%">
36+
@foreach ($c_members as $member)
37+
<option value="{{ $member->id }}" {{ $member->id == $ticket->agent->id ? 'selected="selected"' : '' }}>{{ $member->name . ($member->email == "" ? ' ' . trans('panichd::lang.ticket-owner-no-email') : ' - ' . $member->email) }}
38+
@if ($setting->grab('departments_notices_feature'))
39+
@if ($member->ticketit_department == '0')
40+
{{ ' - ' . trans('panichd::lang.create-ticket-notices') . ' ' . trans('panichd::lang.all-depts')}}
41+
@elseif ($member->ticketit_department != "")
42+
{{ ' - ' . trans('panichd::lang.create-ticket-notices') . ' ' . $member->userDepartment->getFullName() }}
43+
@endif
44+
@endif
45+
</option>
46+
@endforeach
47+
</select>
48+
49+
<select name="reply_recipients[]" id="reply_recipients" class="form-control" multiple="multiple" style="display: none; width: 100%">
50+
@foreach ($c_members as $member)
51+
<option value="{{ $member->id }}" {{ !is_null($ticket->owner) && $member->id == $ticket->owner->id ? 'selected="selected"' : '' }}>{{ $member->name . ($member->email == "" ? ' ' . trans('panichd::lang.ticket-owner-no-email') : ' - ' . $member->email) }}
52+
@if ($setting->grab('departments_notices_feature'))
53+
@if ($member->ticketit_department == '0')
54+
{{ ' - ' . trans('panichd::lang.create-ticket-notices') . ' ' . trans('panichd::lang.all-depts')}}
55+
@elseif ($member->ticketit_department != "")
56+
{{ ' - ' . trans('panichd::lang.create-ticket-notices') . ' ' . $member->userDepartment->getFullName() }}
57+
@endif
58+
@endif
59+
</option>
60+
@endforeach
61+
</select>
62+
</div>
63+
</div>
3164
@endif
3265
<div class="form-group row">
3366
<div class="col-lg-12 summernote-text-wrapper">

src/Views/tickets/partials/comments/scripts.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,27 @@
1818
$(this).find("textarea.modal-summernote-editor").summernote('destroy');
1919
});
2020
21+
// Opening new comment modal
22+
$('#modal-comment-new').on('show.bs.modal', function (e) {
23+
$(this).find('#note_recipients').select2();
24+
});
25+
2126
// Comment form: Click on response type buttons (reply or note)
2227
$('.response_type').click(function(){
2328
var type = $(this).attr('data-type');
2429
$('#modal-comment-new #response_type').val(type);
2530
$(this).addClass($(this).attr('data-active-class'));
2631
2732
if (type == 'reply'){
33+
$(this).closest('.comment-modal').find('#note_recipients').select2('destroy');
34+
$(this).closest('.comment-modal').find('#reply_recipients').select2();
35+
2836
$('#add_in_user_notification_text, #add_to_intervention').prop('disabled', false);
2937
$('#add_in_user_notification_text, #add_to_intervention').closest('div').show();
3038
}else{
39+
$(this).closest('.comment-modal').find('#reply_recipients').select2('destroy');
40+
$(this).closest('.comment-modal').find('#note_recipients').select2();
41+
3142
$('#add_in_user_notification_text, #add_to_intervention').prop('disabled', true);
3243
$('#add_in_user_notification_text, #add_to_intervention').closest('div').hide();
3344
}

0 commit comments

Comments
 (0)