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

@@ -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) {