Update v1.0.6.10

This commit is contained in:
sujitprasad
2016-04-01 10:37:46 +05:30
parent d8400d6d79
commit ce796d2a89
10 changed files with 562 additions and 81 deletions

View File

@@ -181,7 +181,7 @@ class EmailsController extends Controller
try {
// getConnection($request->input('email_name'), $request->input('email_address'), $request->input('email_address'))
// saving all the fields to the database
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'sending_status'))->save() == true) {
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'sending_status', 'auto_response'))->save() == true) {
if ($request->fetching_status == 'on') {
$email->fetching_status = 1;
} else {
@@ -192,6 +192,11 @@ class EmailsController extends Controller
} else {
$email->sending_status = 0;
}
if ($request->auto_response == 'on') {
$email->auto_response = 1;
} else {
$email->auto_response = 0;
}
// fetching department value
$email->department = $this->departmentValue($request->input('department'));
// fetching priority value
@@ -356,6 +361,11 @@ class EmailsController extends Controller
} else {
$emails->sending_status = 0;
}
if ($request->auto_response == 'on') {
$emails->auto_response = 1;
} else {
$emails->auto_response = 0;
}
// fetching department value
$emails->department = $this->departmentValue($request->input('department'));
// fetching priority value

View File

@@ -55,6 +55,7 @@ class MailController extends Controller
$email = $emails->get();
foreach ($email as $e_mail) {
if ($e_mail->fetching_status == 1) {
$auto_response = $e_mail->auto_response;
$priority = $e_mail->priority;
$dept = $e_mail->department;
$helptopic = $e_mail->help_topic;
@@ -129,7 +130,7 @@ class MailController extends Controller
$assign = $get_helptopic->auto_assign;
$form_data = null;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data, $auto_response);
// dd($result);
if ($result[1] == true) {
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();

View File

@@ -2,15 +2,17 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
// controllers
use App\Http\Controllers\Common\PhpMailController;
// Model
use App\Http\Controllers\Controller;
// Model
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\settings\Email;
use App\Model\helpdesk\Utility\Log_notification;
use App\User;
use View;
// classes
@@ -22,8 +24,13 @@ use App\User;
*/
class NotificationController extends Controller
{
public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController;
}
/**
* This function is for sending daily report/notification about the system.
* This function is for sending daily report/notification about the system.
* */
public function send_notification()
{
@@ -52,11 +59,11 @@ class NotificationController extends Controller
}
/**
* Admin Notification/Report.
* Admin Notification/Report.
*
* @param company
* @param company
*
* @return mail
* @return mail
* */
public function send_notification_to_admin($company)
{
@@ -66,16 +73,20 @@ class NotificationController extends Controller
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name.' '.$user->last_name;
\Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message) use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company.' Daily Report ');
});
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Dily Report', 'scenario' => null, 'body' => $contents]);
// \Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message) use ($email, $user_name, $company) {
// $message->to($email, $user_name)->subject($company.' Daily Report ');
// });
}
}
/**
* Department Manager Notification/Report.
* Department Manager Notification/Report.
*
* @return mail
* @return mail
* */
public function send_notification_to_manager($company)
{
@@ -89,9 +100,13 @@ class NotificationController extends Controller
// Send notification details to manager of a department
$email = $user->email;
$user_name = $user->first_name.' '.$user->last_name;
\Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message) use ($email, $user_name, $company, $dept_name) {
$message->to($email, $user_name)->subject($company.' Daily Report for department manager of '.$dept_name.' department.');
});
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Dily Report', 'scenario' => null, 'body' => $contents]);
// \Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message) use ($email, $user_name, $company, $dept_name) {
// $message->to($email, $user_name)->subject($company.' Daily Report for department manager of '.$dept_name.' department.');
// });
}
}
}
@@ -100,7 +115,7 @@ class NotificationController extends Controller
/**
* Team Lead Notification/Report.
*
* @return mail
* @return mail
* */
public function send_notification_to_team_lead($company)
{
@@ -114,18 +129,22 @@ class NotificationController extends Controller
// Send notification details to team lead
$email = $user->email;
$user_name = $user->first_name.' '.$user->last_name;
\Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message) use ($email, $user_name, $company, $team_name) {
$message->to($email, $user_name)->subject($company.' Daily Report for Team Lead of team '.$team_name);
});
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Dily Report', 'scenario' => null, 'body' => $contents]);
// \Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message) use ($email, $user_name, $company, $team_name) {
// $message->to($email, $user_name)->subject($company.' Daily Report for Team Lead of team '.$team_name);
// });
}
}
}
}
/**
* Agent Notification/Report.
* Agent Notification/Report.
*
* @return mail
* @return mail
* */
public function send_notification_to_agent($company)
{
@@ -135,9 +154,13 @@ class NotificationController extends Controller
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name.' '.$user->last_name;
\Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message) use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company.' Daily Report for Agents');
});
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Dily Report', 'scenario' => null, 'body' => $contents]);
// \Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message) use ($email, $user_name, $company) {
// $message->to($email, $user_name)->subject($company.' Daily Report for Agents');
// });
}
}
@@ -162,10 +185,10 @@ class NotificationController extends Controller
// // testing
// public function test(){
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// }
}

View File

@@ -8,14 +8,23 @@ use App\Http\Controllers\Controller;
// requests
// models
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\User;
// classes
use Auth;
use DB;
// classes
use Illuminate\support\Collection;
use Input;
use UTC;
/**
* TicketController2.
*
* @author Ladybird <info@ladybirdweb.com>
* @author Ladybird <info@ladybirdweb.com>
*/
class Ticket2Controller extends Controller
{
@@ -49,6 +58,100 @@ class Ticket2Controller extends Controller
}
}
public function getOpenTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->get();
}
return \Datatable::collection(new Collection($tickets))
->addColumn('id', function ($ticket) {
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
})
->addColumn('subject', function ($ticket) {
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
if (isset($subject->title)) {
$string = $subject->title;
if (strlen($string) > 20) {
$stringCut = substr($string, 0, 30);
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
}
} else {
$string = '(no subject)';
}
//collabrations
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
$collab = count($collaborators);
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users"></i>';
} else {
$collabString = null;
}
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first(); //
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count(); //
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
$attachCount = count($attachment);
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip"></i>';
} else {
$attachString = '';
}
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string."&nbsp;<span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
})
->addColumn('ticket_number', function ($ticket) {
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
})
->addColumn('priority', function ($ticket) {
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
})
->addColumn('from', function ($ticket) {
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
return "<span style='color:#508983'>".$from->user_name.'</span>';
})
->addColumn('Last Replier', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '=', 0)->max('id');
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
if ($LastResponse->role == 'user') {
$rep = '#F39C12';
$username = $LastResponse->user_name;
} else {
$rep = '#000';
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
$username = $LastResponse->user_name;
}
}
return "<span style='color:".$rep."'>".$username.'</span>';
})
->addColumn('assigned_to', function ($ticket) {
if ($ticket->assigned_to == null) {
return "<span style='color:red'>Unassigned</span>";
} else {
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
}
})
->addColumn('Last', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
return UTC::usertimezone($TicketDatarow->updated_at);
})
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
->make();
}
/**
* Show the Inbox ticket list page.
*
@@ -68,6 +171,100 @@ class Ticket2Controller extends Controller
}
}
public function getCloseTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', '2')->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', '2')->where('dept_id', '=', $dept->id)->get();
}
return \Datatable::collection(new Collection($tickets))
->addColumn('id', function ($ticket) {
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
})
->addColumn('subject', function ($ticket) {
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
if (isset($subject->title)) {
$string = $subject->title;
if (strlen($string) > 20) {
$stringCut = substr($string, 0, 30);
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
}
} else {
$string = '(no subject)';
}
//collabrations
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
$collab = count($collaborators);
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users"></i>';
} else {
$collabString = null;
}
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count();
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
$attachCount = count($attachment);
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip"></i>';
} else {
$attachString = '';
}
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string."&nbsp;<span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
})
->addColumn('ticket_number', function ($ticket) {
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
})
->addColumn('priority', function ($ticket) {
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
})
->addColumn('from', function ($ticket) {
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
return "<span style='color:#508983'>".$from->user_name.'</span>';
})
->addColumn('Last Replier', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '!=', 1)->max('id');
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
if ($LastResponse->role == 'user') {
$rep = '#F39C12';
$username = $LastResponse->user_name;
} else {
$rep = '#000';
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
$username = $LastResponse->user_name;
}
}
return "<span style='color:".$rep."'>".$username.'</span>';
})
->addColumn('assigned_to', function ($ticket) {
if ($ticket->assigned_to == null) {
return "<span style='color:red'>Usernassigned</span>";
} else {
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
}
})
->addColumn('Last', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
return UTC::usertimezone($TicketDatarow->updated_at);
})
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
->make();
}
/**
* Show the Inbox ticket list page.
*
@@ -86,4 +283,103 @@ class Ticket2Controller extends Controller
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
}
}
/**
*Show the list of In process tickets.
*
*@param $id int
*/
public function getInProcessTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $dept->id)->get();
}
return \Datatable::collection(new Collection($tickets))
->addColumn('id', function ($ticket) {
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
})
->addColumn('subject', function ($ticket) {
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
if (isset($subject->title)) {
$string = $subject->title;
if (strlen($string) > 20) {
$stringCut = substr($string, 0, 30);
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
}
} else {
$string = '(no subject)';
}
//collabrations
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
$collab = count($collaborators);
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users"></i>';
} else {
$collabString = null;
}
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count();
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
$attachCount = count($attachment);
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip"></i>';
} else {
$attachString = '';
}
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string."&nbsp;<span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
})
->addColumn('ticket_number', function ($ticket) {
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
})
->addColumn('priority', function ($ticket) {
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
})
->addColumn('from', function ($ticket) {
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
return "<span style='color:#508983'>".$from->user_name.'</span>';
})
->addColumn('Last Replier', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '!=', 1)->max('id');
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
if ($LastResponse->role == 'user') {
$rep = '#F39C12';
$username = $LastResponse->user_name;
} else {
$rep = '#000';
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
$username = $LastResponse->user_name;
}
}
return "<span style='color:".$rep."'>".$username.'</span>';
})
->addColumn('assigned_to', function ($ticket) {
if ($ticket->assigned_to == null) {
return "<span style='color:red'>Usernassigned</span>";
} else {
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
}
})
->addColumn('Last', function ($ticket) {
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
return UTC::usertimezone($TicketDatarow->updated_at);
})
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
->make();
}
}

View File

@@ -734,14 +734,15 @@ class TicketController extends Controller
$headers = null;
$help = Help_topic::where('id', '=', $helptopic)->first();
$form_data = null;
$auto_response = 0;
//create user
if ($this->create_user($email, $fullname, $subject, $body, $phone, $helptopic, $sla, $priority, $source->id, $headers, $help->department, $assignto, $form_data)) {
if ($this->create_user($email, $fullname, $subject, $body, $phone, $helptopic, $sla, $priority, $source->id, $headers, $help->department, $assignto, $form_data, $auto_response)) {
return Redirect('newticket')->with('success', 'Ticket created successfully!');
} else {
return Redirect('newticket')->with('fails', 'fails');
}
} catch (Exception $e) {
return Redirect()->back()->with('fails', '<li>'.$e->errorInfo.'</li>');
return Redirect()->back()->with('fails', '<li>'.$e->getMessage().'</li>');
}
}
@@ -825,18 +826,20 @@ class TicketController extends Controller
}
$thread->save();
foreach ($attachments as $attachment) {
if ($attachment != null) {
$name = $attachment->getClientOriginalName();
$type = $attachment->getClientOriginalExtension();
$size = $attachment->getSize();
$data = file_get_contents($attachment->getRealPath());
$attachPath = $attachment->getRealPath();
$ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
if ($attachments != null) {
foreach ($attachments as $attachment) {
if ($attachment != null) {
$name = $attachment->getClientOriginalName();
$type = $attachment->getClientOriginalExtension();
$size = $attachment->getSize();
$data = file_get_contents($attachment->getRealPath());
$attachPath = $attachment->getRealPath();
$ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
$check_attachment = 1;
} else {
$check_attachment = null;
$check_attachment = 1;
} else {
$check_attachment = null;
}
}
}
@@ -872,7 +875,7 @@ class TicketController extends Controller
try {
$this->PhpMailController->sendmail(
$from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email, 'cc' => $collaborators], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'body' => $request->input('reply_content'), 'scenario' => 'ticket-reply-agent', 'attachments' => $attachment_files], $template_variables = ['ticket_number' => $ticket_number, 'user' => $username, 'agent_sign' => $agentsign]
$from = $this->PhpMailController->mailfrom('0', $tickets->dept_id), $to = ['name' => $user_name, 'email' => $email, 'cc' => $collaborators], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'body' => $request->input('reply_content'), 'scenario' => 'ticket-reply', 'attachments' => $attachment_files], $template_variables = ['ticket_number' => $ticket_number, 'user' => $username, 'agent_sign' => $agentsign]
);
} catch (\Exception $e) {
return 0;
@@ -907,6 +910,8 @@ class TicketController extends Controller
$ticket->help_topic_id = Input::get('help_topic');
$ticket->source = Input::get('ticket_source');
$ticket->priority_id = Input::get('ticket_priority');
$dept = Help_topic::select('department')->where('id', '=', $ticket->help_topic_id)->first();
$ticket->dept_id = $dept->department;
$ticket->save();
$threads = $thread->where('ticket_id', '=', $ticket_id)->first();
@@ -998,7 +1003,7 @@ class TicketController extends Controller
*
* @return type bool
*/
public function create_user($emailadd, $username, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $from_data)
public function create_user($emailadd, $username, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $from_data, $auto_response)
{
// define global variables
$email;
@@ -1029,12 +1034,14 @@ class TicketController extends Controller
// Event fire
\Event::fire(new \App\Events\ReadMailEvent($user_id, $password));
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => 'Welcome to '.$company.' helpdesk', 'scenario' => 'registration-notification'], $template_variables = ['user' => $username, 'email_address' => $emailadd, 'user_password' => $password]);
if ($auto_response == 0) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => 'Welcome to '.$company.' helpdesk', 'scenario' => 'registration-notification'], $template_variables = ['user' => $username, 'email_address' => $emailadd, 'user_password' => $password]);
}
} catch (\Exception $e) {
}
}
} else {
$username = $checkemail->username;
$username = $checkemail->user_name;
$user_id = $checkemail->id;
}
$ticket_number = $this->check_ticket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $from_data);
@@ -1042,6 +1049,7 @@ class TicketController extends Controller
$ticketdata = Tickets::where('ticket_number', '=', $ticket_number2)->first();
$threaddata = Ticket_Thread::where('ticket_id', '=', $ticketdata->id)->first();
$is_reply = $ticket_number[1];
// dd($is_reply);
$system = $this->system();
$updated_subject = $threaddata->title.'[#'.$ticket_number2.']';
if ($ticket_number2) {
@@ -1056,29 +1064,33 @@ class TicketController extends Controller
if ($source == 3) {
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], $template_variables = ['agent_sign' => Auth::user()->agent_sign, 'ticket_number' => $ticket_number2]);
if ($auto_response == 0) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], $template_variables = ['agent_sign' => Auth::user()->agent_sign, 'ticket_number' => $ticket_number2]);
}
} catch (\Exception $e) {
}
} else {
$body2 = null;
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'], $template_variables = ['user' => $username, 'ticket_number' => $ticket_number2, 'department_sign' => '']);
if ($auto_response == 0) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'], $template_variables = ['user' => $username, 'ticket_number' => $ticket_number2, 'department_sign' => '']);
}
} catch (\Exception $e) {
}
}
} else {
} elseif ($is_reply == 1) {
$mail = 'ticket-reply-agent';
}
if (Alert::first()->ticket_status == 1 || Alert::first()->ticket_admin_email == 1) {
// send email to admin
$admins = User::where('role', '=', 'admin')->get();
$set_mails = '';
foreach ($admins as $admin) {
$admin_email = $admin->email;
$admin_user = $admin->first_name;
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $admin_user, 'email' => $admin_email], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $admin_user, 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $admin_user, 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
} catch (\Exception $e) {
}
$to_email = $admin->email;
$to_user = $admin->first_name;
$to_user_name = $admin->first_name.' '.$admin->last_name;
$set_mails[] = ['to_email' => $to_email, 'to_user' => $to_user, 'to_user_name' => $to_user_name];
}
}
@@ -1090,12 +1102,10 @@ class TicketController extends Controller
$department_data = Department::where('id', '=', $ticketdata->dept_id)->first();
if ($department_data->name == $agent->primary_dpt) {
$agent_email = $agent->email;
$agent_user = $agent->first_name;
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $agent_user, 'email' => $agent_email], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $admin_user, 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $agent_user, 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
} catch (\Exception $e) {
}
$to_email = $agent->email;
$to_user = $agent->first_name;
$to_user_name = $agent->first_name.' '.$agent->last_name;
$set_mails[] = ['to_email' => $to_email, 'to_user' => $to_user, 'to_user_name' => $to_user_name];
}
}
}
@@ -1103,12 +1113,14 @@ class TicketController extends Controller
if ($ticketdata->assigned_to) {
$assigned_to = User::where('id', '=', $ticketdata->assigned_to)->first();
$agent_email = $assigned_to->email;
$agent_user = $assigned_to->first_name;
try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $agent_user, 'email' => $agent_email], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $admin_user, 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $assigned_to->user_name, 'ticket_number' => $ticket_number2, 'email_address' => $assigned_to->email, 'name' => $ticket_creator]);
} catch (\Exception $e) {
}
$to_email = $assigned_to->email;
$to_user = $assigned_to->first_name;
$to_user_name = $assigned_to->first_name.' '.$assigned_to->last_name;
$set_mails[] = ['to_email' => $to_email, 'to_user' => $to_user, 'to_user_name' => $to_user_name];
}
$emails_to_be_sent = array_unique($set_mails, SORT_REGULAR);
foreach ($emails_to_be_sent as $email_data) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $email_data['to_user'], 'email' => $email_data['to_email']], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $email_data['to_user_name'], 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $email_data['to_user_name'], 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
}
return ['0' => $ticket_number2, '1' => true];
@@ -1438,15 +1450,15 @@ class TicketController extends Controller
{
$ticket_delete = $ticket->where('id', '=', $id)->first();
if ($ticket_delete->status == 5) {
$ticket_delete->delete();
$ticket_threads = Ticket_Thread::where('ticket_id', '=', $id)->get();
foreach ($ticket_threads as $ticket_thread) {
$ticket_attachments = Ticket_attachments::where('thread_id', '=', $ticket_thread->id)->get();
foreach ($ticket_attachments as $ticket_attachment) {
$ticket_attachment->delete();
}
$ticket_thread->delete();
}
$ticket_delete->delete();
$ticket_attachments = Ticket_attachments::where('ticket_id', '=', $id)->get();
foreach ($ticket_attachments as $ticket_attachment) {
$ticket_attachment->delete();
}
return 'your ticket has been delete';
} else {
@@ -2355,7 +2367,8 @@ class TicketController extends Controller
['email' => $email,
'name' => $name, ],
['email' => 'required|email',
]);
]
);
$user = User::where('email', '=', $email)->first();
$count = count($user);
if ($count === 1) {

View File

@@ -16,6 +16,7 @@ use Hash;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Lang;
use Mail;
/**
@@ -177,7 +178,7 @@ class AuthController extends Controller
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
// If attempts > 3 and time < 10 minutes
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
return redirect()->back()->with('error', 'Maximum login attempts reached. Try again in a while');
return redirect()->back()->withErrors('email', 'incorrect email')->with('error', 'Maximum login attempts reached. Try again in a while');
}
// If time > 10 minutes, reset attempts counter and time in session
if (time() - $loginAttemptTime > 600) {
@@ -198,12 +199,12 @@ class AuthController extends Controller
}
}
return redirect($this->loginPath())
return redirect()->back()
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(),
]);
])->with('error', Lang::get('lang.invalid'));
// Increment login attempts
}

View File

@@ -151,8 +151,8 @@ class FormController extends Controller
$collaborator = null;
$assignto = null;
if ($this->TicketController->create_user($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source->id, $collaborator, $department, $assignto, $form_extras)) {
$auto_response = 0;
if ($this->TicketController->create_user($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source->id, $collaborator, $department, $assignto, $form_extras, $auto_response)) {
return Redirect::route('guest.getform')->with('success', 'Ticket Created Successfully');
}
}

View File

@@ -262,6 +262,133 @@ class PhpMailController extends Controller
}
}
/**
* Sending emails from the system.
*
* @return MailNotification
*/
public function sendEmail($from, $to, $message)
{
// dd($from);
$from_address = $this->fetch_smtp_details($from);
// dd($from_address);
$username = $from_address->email_address;
$fromname = $from_address->email_name;
$password = \Crypt::decrypt($from_address->password);
$smtpsecure = $from_address->sending_encryption;
$host = $from_address->sending_host;
$port = $from_address->sending_port;
if (isset($to['email'])) {
$recipants = $to['email'];
} else {
$recipants = null;
}
if (isset($to['name'])) {
$recipantname = $to['name'];
} else {
$recipantname = null;
}
if (isset($to['cc'])) {
$cc = $to['cc'];
} else {
$cc = null;
}
if (isset($to['bc'])) {
$bc = $to['bc'];
} else {
$bc = null;
}
if (isset($message['subject'])) {
$subject = $message['subject'];
} else {
$subject = null;
}
if (isset($message['body'])) {
$content = $message['body'];
} else {
$content = null;
}
if (isset($message['scenario'])) {
$template = $message['scenario'];
} else {
$template = null;
}
if (isset($message['attachments'])) {
$attachment = $message['attachments'];
} else {
$attachment = null;
}
// template variables
if (Auth::user()) {
$agent = Auth::user()->user_name;
} else {
$agent = null;
}
$system_link = url('/');
$system_from = $this->company();
$mail = new \PHPMailer();
$status = \DB::table('settings_email')->first();
// dd($messagebody);
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $host; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $username; // SMTP username
$mail->Password = $password; // SMTP password
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $port; // TCP port to connect to
$mail->setFrom($username, $fromname);
$mail->addAddress($recipants); // Add a recipient
// Name is optional
// $mail->addReplyTo('sada059@gmail.com', 'Information');
// Optional name
$mail->isHTML(true); // Set email format to HTML
if ($cc != null) {
foreach ($cc as $collaborator) {
//mail to collaborators
$collab_user_id = $collaborator->user_id;
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
$collab_email = $user_id_collab->email;
$mail->addCC($collab_email);
}
}
$mail->addBCC($bc);
if ($attachment != null) {
$size = count($message['attachments']);
$attach = $message['attachments'];
for ($i = 0; $i < $size; $i++) {
$file_path = $attach[$i]->getRealPath();
$file_name = $attach[$i]->getClientOriginalName();
$mail->addAttachment($file_path, $file_name);
}
}
$mail->Subject = $subject;
$mail->Body = $content;
// $mail->AltBody = $altbody;
if (!$mail->send()) {
// echo 'Message could not be sent.';
// echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
// echo 'Message has been sent';
}
}
/**
* Fetching comapny name to send mail.
*

View File

@@ -298,6 +298,7 @@ class InstallController extends Controller
// checking is the installation was done previously
try {
$check_for_pre_installation = System::all();
dd($check_for_pre_installation);
if ($check_for_pre_installation) {
return redirect()->back()->with('fails', 'The data in database already exist. Please provide fresh database');
}

View File

@@ -359,6 +359,15 @@ Route::group(['middleware' => 'role.agent', 'middleware' => 'auth'], function ()
Route::patch('/merge-tickets/{id}', ['as' => 'merge.tickets', 'uses' => 'Agent\helpdesk\TicketController@mergeTickets']);
//To get department tickets data
//open tickets of department
Route::get('/get-open-tickets/{id}', ['as' => 'get.dept.open', 'uses' => 'Agent\helpdesk\Ticket2Controller@getOpenTickets']);
//close tickets of deartment
Route::get('/get-closed-tickets/{id}', ['as' => 'get.dept.close', 'uses' => 'Agent\helpdesk\Ticket2Controller@getCloseTickets']);
//in progress ticket of department
Route::get('/get-under-process-tickets/{id}', ['as' => 'get.dept.inprocess', 'uses' => 'Agent\helpdesk\Ticket2Controller@getInProcessTickets']);
});
/*