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
}
}
}