PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.5.5
Fluent Support – Helpdesk & Customer Support Ticket System v1.5.5
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Services / Tickets / TicketService.php

TicketService.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.5.5, at app/Services/Tickets/TicketService.php

85 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Services\Tickets;
4
5 use FluentSupport\App\Models\Conversation;
6
7 class TicketService
8 {
9 /**
10 * this function will set the ticket status as closed
11 * @param $ticket
12 * @param $person
13 * @param string $internalNote
14 * @return mixed
15 */
16 public function close($ticket, $person, $internalNote = '')
17 {
18 if ($ticket->status != 'closed') {
19 $ticket->status = 'closed';
20 $ticket->resolved_at = current_time('mysql');
21 $ticket->closed_by = $person->id;
22 $ticket->total_close_time = current_time('timestamp') - strtotime($ticket->created_at);
23 $ticket->save();
24 do_action('fluent_support/ticket_closed', $ticket, $person);
25 do_action('fluent_support/ticket_closed_by_' . $person->person_type, $ticket, $person);
26
27 if(!$internalNote) {
28 $internalNote = __('Ticket has been closed', 'fluent-support');
29 }
30
31 //Keep track in conversation
32 Conversation::create([
33 'ticket_id' => $ticket->id,
34 'person_id' => $person->id,
35 'conversation_type' => 'internal_info',
36 'content' => $internalNote
37 ]);
38
39 }
40
41 return $ticket;
42 }
43
44 public function reopen($ticket, $person)
45 {
46 if ($ticket->status == 'closed') {
47 $ticket->status = 'active';
48 $ticket->waiting_since = current_time('mysql');
49 $ticket->save();
50
51 /*
52 * Action on ticket reopen
53 *
54 * @since v1.0.0
55 * @param object $ticket
56 * @param object $person
57 */
58 do_action('fluent_support/ticket_reopen', $ticket, $person);
59 do_action('fluent_support/ticket_reopen_by_' . $person->person_type, $ticket, $person);
60 Conversation::create([
61 'ticket_id' => $ticket->id,
62 'person_id' => $person->id,
63 'conversation_type' => 'internal_info',
64 'content' => __('Ticket has been reopened', 'fluent-support')
65 ]);
66 }
67
68 return $person;
69 }
70
71 public function onAgentChange($ticket, $person){
72 do_action('fluent_support/ticket_agent_change', $ticket, $person);
73 Conversation::create([
74 'ticket_id' => $ticket->id,
75 'person_id' => $person->id,
76 'conversation_type' => 'internal_info',
77 'content' => $ticket->agent->user_id !== $person->user_id ?
78 __($person->full_name .' assign '. $ticket->agent->full_name .' in this ticket' , 'fluent-support') :
79 __($person->full_name. ' assign this ticket to self', 'fluent-support')
80 ]);
81
82 return $person;
83 }
84 }
85