From 77fa3fe32673c49349e03e5e660956585f260f0a Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Mon, 5 Dec 2016 14:09:26 +0530 Subject: [PATCH] #update-patch # multiple assignment option in inbox --- .../Agent/helpdesk/TicketController.php | 105 +++++++++--------- .../Agent/helpdesk/UserController.php | 10 ++ app/Http/routes.php | 2 + resources/lang/en/lang.php | 2 +- .../agent/helpdesk/ticket/inbox.blade.php | 91 +++++++++++++++ 5 files changed, 158 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/Agent/helpdesk/TicketController.php b/app/Http/Controllers/Agent/helpdesk/TicketController.php index cbc8300be..8b5f6fe99 100644 --- a/app/Http/Controllers/Agent/helpdesk/TicketController.php +++ b/app/Http/Controllers/Agent/helpdesk/TicketController.php @@ -1464,62 +1464,65 @@ class TicketController extends Controller */ public function assign($id) { + $ticket_array = []; + if(strpos($id, ',') !== false) { + $ticket_array = explode(',', $id); + } else { + array_push($ticket_array, $id); + } $UserEmail = Input::get('assign_to'); $assign_to = explode('_', $UserEmail); - $ticket = Tickets::where('id', '=', $id)->first(); + $user_detail = null; + foreach ($ticket_array as $id) { + $ticket = Tickets::where('id', '=', $id)->first(); + if ($assign_to[0] == 'team') { + $ticket->team_id = $assign_to[1]; + $team_detail = Teams::where('id', '=', $assign_to[1])->first(); + $assignee = $team_detail->name; + $ticket_number = $ticket->ticket_number; + $ticket->save(); + $ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first(); + $ticket_subject = $ticket_thread->title; + $thread = new Ticket_Thread(); + $thread->ticket_id = $ticket->id; + $thread->user_id = Auth::user()->id; + $thread->is_internal = 1; + $thread->body = 'This Ticket has been assigned to '.$assignee; + $thread->save(); + } elseif ($assign_to[0] == 'user') { + $ticket->assigned_to = $assign_to[1]; + if( $user_detail === null) { + $user_detail = User::where('id', '=', $assign_to[1])->first(); + $assignee = $user_detail->first_name.' '.$user_detail->last_name; + } + $company = $this->company(); + $system = $this->system(); + $ticket_number = $ticket->ticket_number; + $ticket->save(); + $data = [ + 'id' => $id, + ]; + \Event::fire('ticket-assignment', [$data]); + $ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first(); + $ticket_subject = $ticket_thread->title; + $thread = new Ticket_Thread(); + $thread->ticket_id = $ticket->id; + $thread->user_id = Auth::user()->id; + $thread->is_internal = 1; + $thread->body = 'This Ticket has been assigned to '.$assignee; + $thread->save(); - if ($assign_to[0] == 'team') { - $ticket->team_id = $assign_to[1]; - $team_detail = Teams::where('id', '=', $assign_to[1])->first(); - $assignee = $team_detail->name; - - $ticket_number = $ticket->ticket_number; - $ticket->save(); - - $ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first(); - $ticket_subject = $ticket_thread->title; - - $thread = new Ticket_Thread(); - $thread->ticket_id = $ticket->id; - $thread->user_id = Auth::user()->id; - $thread->is_internal = 1; - $thread->body = 'This Ticket has been assigned to '.$assignee; - $thread->save(); - } elseif ($assign_to[0] == 'user') { - $ticket->assigned_to = $assign_to[1]; - $user_detail = User::where('id', '=', $assign_to[1])->first(); - $assignee = $user_detail->first_name.' '.$user_detail->last_name; - - $company = $this->company(); - $system = $this->system(); - - $ticket_number = $ticket->ticket_number; - $ticket->save(); - $data = [ - 'id' => $id, - ]; - \Event::fire('ticket-assignment', [$data]); - $ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first(); - $ticket_subject = $ticket_thread->title; - - $thread = new Ticket_Thread(); - $thread->ticket_id = $ticket->id; - $thread->user_id = Auth::user()->id; - $thread->is_internal = 1; - $thread->body = 'This Ticket has been assigned to '.$assignee; - $thread->save(); - - $agent = $user_detail->first_name; - $agent_email = $user_detail->email; - $ticket_link = route('ticket.thread', $id); - $master = Auth::user()->first_name.' '.Auth::user()->last_name; - try { - $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket->dept_id), $to = ['name' => $agent, 'email' => $agent_email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'assign-ticket'], $template_variables = ['ticket_agent_name' => $agent, 'ticket_number' => $ticket_number, 'ticket_assigner' => $master, 'ticket_link' => $ticket_link]); - } catch (\Exception $e) { - return 0; + $agent = $user_detail->first_name; + $agent_email = $user_detail->email; + $ticket_link = route('ticket.thread', $id); + $master = Auth::user()->first_name.' '.Auth::user()->last_name; + try { + $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket->dept_id), $to = ['name' => $agent, 'email' => $agent_email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'assign-ticket'], $template_variables = ['ticket_agent_name' => $agent, 'ticket_number' => $ticket_number, 'ticket_assigner' => $master, 'ticket_link' => $ticket_link]); + } catch (\Exception $e) { + return 0; + } } } - return 1; } diff --git a/app/Http/Controllers/Agent/helpdesk/UserController.php b/app/Http/Controllers/Agent/helpdesk/UserController.php index 538842d04..c86b5dd61 100644 --- a/app/Http/Controllers/Agent/helpdesk/UserController.php +++ b/app/Http/Controllers/Agent/helpdesk/UserController.php @@ -1003,4 +1003,14 @@ class UserController extends Controller return $message; } } + + /** + */ + public function getAgentDetails() + { + $users = User::where('role', '<>', 'user')->where('active', '=', 1)->get(); + foreach ($users as $user) { + echo "'; + } + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 3071be0b7..865b50155 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -724,6 +724,8 @@ Route::group(['middleware' => ['web']], function () { // route to get the data on change Route::post('help-topic-report/{date1}/{date2}/{id}', ['as' => 'report.helptopic', 'uses' => 'Agent\helpdesk\ReportController@chartdataHelptopic']); /* To show dashboard pages */ Route::post('help-topic-pdf', ['as' => 'help.topic.pdf', 'uses' => 'Agent\helpdesk\ReportController@helptopicPdf']); + // Route to get details of agents + Route::post('get-agents', ['as' => 'get-agents', 'uses' => 'Agent\helpdesk\UserController@getAgentDetails']); }); /* diff --git a/resources/lang/en/lang.php b/resources/lang/en/lang.php index fe2f19a0a..12b6dccfc 100644 --- a/resources/lang/en/lang.php +++ b/resources/lang/en/lang.php @@ -1549,5 +1549,5 @@ return [ /*********** Updated 3-12-2016 **********/ 'activate' => 'Activate', 'system-email-not-configured' => 'We are unable to process email request as the system has no configured email for sending mails. Please contact and report system admin.', - + 'assign-ticket' => 'Assign tickets', ]; diff --git a/resources/views/themes/default1/agent/helpdesk/ticket/inbox.blade.php b/resources/views/themes/default1/agent/helpdesk/ticket/inbox.blade.php index 3c61dfcbd..1d7da33ce 100644 --- a/resources/views/themes/default1/agent/helpdesk/ticket/inbox.blade.php +++ b/resources/views/themes/default1/agent/helpdesk/ticket/inbox.blade.php @@ -58,6 +58,7 @@ if (Auth::user()->role == 'agent') { {{--@endif--}} +

@@ -166,6 +167,42 @@ if (Auth::user()->role == 'agent') {
+ + + +