Skip to content

Commit a9404b7

Browse files
committed
Ticket list: Internal notes dedicated counters
1 parent 54ff081 commit a9404b7

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@ public function data($ticketList = 'active')
150150
->with('owner.department.ancestor')
151151
->withCount('allAttachments')
152152
->withCount(['comments' => function($query) use($currentLevel){
153-
$query->countable()->forLevel($currentLevel);
153+
$query->countable()->forLevel($currentLevel)->where('type', '!=', 'note');
154154
}])
155155
->withCount(['recentComments' => function($query) use($currentLevel){
156-
$query->countable()->forLevel($currentLevel);
157-
}]);
156+
$query->countable()->forLevel($currentLevel)->where('type', '!=', 'note');
157+
}])
158+
->withCount('internalNotes');
158159

159160
$collection = $datatables->of($collection);
160161

@@ -225,8 +226,11 @@ public function renderTicketTable($collection)
225226
$field.=$ticket->recent_comments_count.' ';
226227
}
227228
if ($ticket->comments_count>0){
228-
$field.='<span class="fa fa-comment tooltip-info comment" title="'.trans('panichd::lang.table-info-comments-total', ['num'=>$ticket->comments_count]).($ticket->recent_comments_count>0 ? ' '.trans('panichd::lang.table-info-comments-recent', ['num'=>$ticket->recent_comments_count]) : '').'"></span>';
229+
$field.=$ticket->comments_count . ' <span class="fa fa-comments tooltip-info comment" title="'.trans('panichd::lang.table-info-comments-total', ['num'=>$ticket->comments_count]).($ticket->recent_comments_count>0 ? ' '.trans('panichd::lang.table-info-comments-recent', ['num'=>$ticket->recent_comments_count]) : '').'"></span>';
229230
}
231+
if ($this->member->currentLevel() >= 2 and $ticket->internal_notes_count > 0){
232+
$field.= ' ' . $ticket->internal_notes_count . ' <span class="fa fa-pencil-alt tooltip-info comment" title="' . trans('panichd::lang.table-info-notes-total', ['num' => $ticket->internal_notes_count]) . '"></span>';
233+
}
230234

231235
return $field;
232236
});

src/Models/Ticket.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function comments()
227227
}
228228

229229
/**
230-
* Get Ticket comments.
230+
* Get Ticket comments updated recently
231231
*
232232
* @return \Illuminate\Database\Eloquent\Relations\HasMany
233233
*/
@@ -236,6 +236,17 @@ public function recentComments()
236236
return $this->hasMany('PanicHD\PanicHD\Models\Comment', 'ticket_id')->where('panichd_comments.updated_at','>', Carbon::yesterday());
237237
}
238238

239+
/*
240+
* Get Ticket internal notes only
241+
*
242+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
243+
*/
244+
public function internalNotes()
245+
{
246+
return $this->hasMany('PanicHD\PanicHD\Models\Comment', 'ticket_id')->where('panichd_comments.type','note');
247+
}
248+
249+
239250
/**
240251
* Ticket attachments (NOT including its comments attachments).
241252
*

src/Translations/ca/lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
'table-info-attachments-total' => ':num fitxers adjunts',
4242
'table-info-comments-total' => ':num comentaris totals.',
4343
'table-info-comments-recent' => ':num recents.',
44+
'table-info-notes-total' => ':num notes internes',
4445

4546
'calendar-active' => 'Va començar :description',
4647
'calendar-active-today' => 'Ha començat :description',

src/Translations/en/lang.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
'table-info-attachments-total' => ':num attached files',
4242
'table-info-comments-total' => ':num Total comments.',
4343
'table-info-comments-recent' => ':num recent ones.',
44+
'table-info-notes-total' => ':num internal notes',
4445

45-
'calendar-active' => 'Started :description',
46+
'calendar-active' => 'Started :description',
4647
'calendar-active-today' => 'Started :description',
4748
'calendar-active-future' => 'Starts :description',
4849
'calendar-expired' => 'Expired :description',

0 commit comments

Comments
 (0)