| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Services; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use FluentSupport\App\Models\Conversation; |
| 7 |
|
| 8 |
class FluentBoardsService |
| 9 |
{ |
| 10 |
|
| 11 |
public function addInternalNote($task) |
| 12 |
{ |
| 13 |
$urlBase = admin_url('admin.php?page=fluent-boards#/'); |
| 14 |
$boardsProfileUrl = $urlBase . 'boards/' . $task->board_id . '/tasks/' . $task->id; |
| 15 |
|
| 16 |
$internalNote = 'A new task has been created for this ticket in Fluent Boards. You can view and manage it at the following link:<br><a href="' . $boardsProfileUrl . '">here</a>'; |
| 17 |
|
| 18 |
$agent = Helper::getAgentByUserId(get_current_user_id()); |
| 19 |
|
| 20 |
Conversation::create([ |
| 21 |
'ticket_id' => $task->source_id, |
| 22 |
'person_id' => $agent->id, |
| 23 |
'conversation_type' => 'internal_info', |
| 24 |
'content' => $internalNote |
| 25 |
]); |
| 26 |
} |
| 27 |
|
| 28 |
public function addComment($task) |
| 29 |
{ |
| 30 |
$baseUrl = admin_url('admin.php?page=fluent-support#/tickets/'); |
| 31 |
$ticketUrl = $baseUrl . $task->source_id . '/view'; |
| 32 |
|
| 33 |
$description = 'This task was created from Fluent Support. Here you can find this ticket: <a href="' . $ticketUrl . '" target="_blank">View Ticket</a>'; |
| 34 |
|
| 35 |
$commentData = [ |
| 36 |
'description' => $description, |
| 37 |
'created_by' => $task->created_by, |
| 38 |
'task_id' => $task->id, |
| 39 |
'board_id' => $task->board_id, |
| 40 |
'type' => 'comment' |
| 41 |
]; |
| 42 |
|
| 43 |
\FluentBoards\App\Models\Comment::create( $commentData); |
| 44 |
} |
| 45 |
} |
| 46 |
|