Refinement update

#sending notification via email to user while  merging their duplicate
tickets
This commit is contained in:
Manish Verma
2016-12-30 18:32:53 +05:30
parent 2aab6a4b67
commit 2c207f7026
2 changed files with 30 additions and 4 deletions

View File

@@ -2425,7 +2425,7 @@ class TicketController extends Controller
$success = 0;
}
}
$this->sendMergeNotification($p_id, $t_id);
return $success;
}
@@ -2899,4 +2899,30 @@ class TicketController extends Controller
return $base64;
}
/**
*@category function to send notification of ticket merging to the owners
*@param srting array $t_id, $p_id
*@return null
*/
public function sendMergeNotification($p_id, $t_id)
{
try {
$ticket_details = Tickets::select('ticket_number', 'user_id', 'dept_id')->where('id', '=', $p_id)->first();
$user_detail = User::where('id', '=', $ticket_details->user_id)->first();
if ($user_detail->count() > 0) {
if ($user_detail->email !== null || $user_detail->email !== '') {
$meged_ticket_details = Tickets::select('ticket_number')->whereIn('id', $t_id)->get();
$child_ticket_numbers = [];
foreach ($meged_ticket_details as $value) {
array_push($child_ticket_numbers, $value->ticket_number);
}
// dd(implode(", ",$child_ticket_numbers), $ticket_details->ticket_number);
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket_details->dept_id), $to = ['user' => $user_detail->full_name, 'email' => $user_detail->email], $message = ['subject' => '', 'body' => '', 'scenario' => 'merge-ticket-notification',], $template_variables = ['user' => $user_detail->full_name, 'ticket_number' => $ticket_details->ticket_number, 'ticket_link' => route('ticket.thread',$p_id), 'merged_ticket_numbers' => implode(", ",$child_ticket_numbers),]);
}
}
} catch (\Exception $e) {
//catch the exception
}
}
}

View File

@@ -115,7 +115,7 @@ class PhpMailController extends Controller
$department_sign = $this->checkElement('department_sign', $template_variables);
$password_reset_link = $this->checkElement('password_reset_link', $template_variables);
$user_password = $this->checkElement('user_password', $template_variables);
$merged_ticket_numbers = $this->checkElement('merged_ticket_numbers', $template_variables);
$email_address = $this->checkElement('email_address', $template_variables);
$user = $this->checkElement('user', $template_variables);
@@ -145,9 +145,9 @@ class PhpMailController extends Controller
$subject = null;
}
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}'];
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}', '{!!$merged_ticket_numbers!!}'];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link, $merged_ticket_numbers];
foreach ($variables as $key => $variable) {
$messagebody = str_replace($variables[$key], $data[$key], $contents);