diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index ac874545..92c19dc7 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -504,7 +504,7 @@ class TicketController extends BaseController $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); if (!$ticket_data) { - $this->myLogger->logme('ERROR', "No ticket data found for Ticket ID: $ticket_id"); + $this->myLogger->logme('error', "No ticket data found for Ticket ID: $ticket_id"); return null; } @@ -514,7 +514,7 @@ class TicketController extends BaseController $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); if (!$template_data) { - $this->myLogger->logme('ERROR', "No email template found for Claim Status ID: " . $ticket_data['claim_status_id']); + $this->myLogger->logme('error', "No email template found for Claim Status ID: " . $ticket_data['claim_status_id']); return null; } @@ -526,12 +526,12 @@ class TicketController extends BaseController // Validate Essential Fields if (empty($ticket_data['emp_mail'])) { - $this->myLogger->logme('ERROR', "Employee email is missing for Ticket ID: $ticket_id"); + $this->myLogger->logme('error', "Employee email is missing for Ticket ID: $ticket_id"); return null; } if (empty($subject) || empty($message)) { - $this->myLogger->logme('ERROR', "Generated email content is empty for Ticket ID: $ticket_id"); + $this->myLogger->logme('error', "Generated email content is empty for Ticket ID: $ticket_id"); return null; } @@ -548,7 +548,7 @@ class TicketController extends BaseController return $mailData; } catch (\Exception $e) { - $this->myLogger->logme('ERROR', "Exception in constructMailContent: " . $e->getMessage()); + $this->myLogger->logme('error', "Exception in constructMailContent: " . $e->getMessage()); return null; } } @@ -592,10 +592,24 @@ class TicketController extends BaseController $acm_mails = $this->ticketMasterModel->getTicketDataByTicketID($mail_data['ticket_id']); if (!$acm_mails) { - $this->myLogger->logme('ERROR', "No ACM mails found for Ticket ID: " . $mail_data['ticket_id']); + $this->myLogger->logme('error', "No ACM mails found for Ticket ID: " . $mail_data['ticket_id']); + $this->myLogger->logme('error', "Reply mail not send"); return false; } + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($mail_data['ticket_id']); + + if (!$ticket_data) { + $this->myLogger->logme('error', "No ticket data found for Ticket ID : " .$mail_data['ticket_id']); + $this->myLogger->logme('error', "Reply mail not send"); + return null; + } + + if(!empty($mail_data)){ + $mail_data['mail_content'] = $this->replacePlaceholders($mail_data['mail_content'], $ticket_data); + $mail_data['mail_subject'] = $this->replacePlaceholders($mail_data['mail_subject'], $ticket_data); + } + $this->myLogger->logme('error', "Fetched ACM emails"); $emailData = [ @@ -616,11 +630,15 @@ class TicketController extends BaseController public function sendAutoMailTrigger($ticket_id) { $auto_mail_enable = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); - + // print_rr($auto_mail_enable); $mail_responce = []; - if ($auto_mail_enable['is_auto_mail'] == 1) { + if (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 1) { $mail_content = $this->constructMailContent($ticket_id); $mail_responce = $this->sendTrigger($mail_content); + }elseif (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 0 ){ + $this->myLogger->logme('error','Auto Mail Not Sent, Reason: Automail Not Enabled'); + }else{ + $this->myLogger->logme('error','Auto Mail Not Sent, Reason: Mail Template Not Created'); } return $mail_responce; @@ -649,9 +667,9 @@ class TicketController extends BaseController -- Insured Employee ID Change old_insured_emp.name as old_insured_id_name, - new_insured_emp.name as new_insured_id_name + new_insured_emp.name as new_insured_id_name, - + ticket_master.ticket_type_id FROM ticket_history th @@ -665,6 +683,7 @@ class TicketController extends BaseController ON th.field_name = 'claim_status_id' AND th.old_value = old_status.id AND old_status.is_active = 1 + LEFT JOIN ticket_claim_status new_status ON th.field_name = 'claim_status_id' AND th.new_value = new_status.id @@ -685,6 +704,10 @@ class TicketController extends BaseController ON th.field_name = 'insured_emp_id' AND th.new_value = new_insured_emp.id + LEFT JOIN ticket_master as ticket_master + on th.field_name = 'claim_type' + AND th.ticket_id = ticket_master.id + WHERE @@ -715,32 +738,35 @@ class TicketController extends BaseController $row['new_value'] = $new_new_value; } elseif ($row['field_name'] == 'priority') { $new_old_value = isset($priorityType[$row['old_value']]) ? $priorityType[$row['old_value']] : '-'; - $new_new_value = $priorityType[$row['new_value']]; + $new_new_value = isset($priorityType[$row['new_value']]) ? $priorityType[$row['new_value']] : '-'; $row['old_value'] = $new_old_value; $row['new_value'] = $new_new_value; } elseif ($row['field_name'] == 'relationship') { $new_old_value = isset($relationshipType[$row['old_value']]) ? $relationshipType[$row['old_value']] : '-'; - $new_new_value = $relationshipType[$row['new_value']]; + $new_new_value = isset($relationshipType[$row['new_value']]) ? $relationshipType[$row['new_value']] : '-'; $row['old_value'] = $new_old_value; $row['new_value'] = $new_new_value; } elseif ($row['field_name'] == 'mode_of_intimation') { $new_old_value = isset($modeOFIntimate[$row['old_value']]) ? $modeOFIntimate[$row['old_value']] : "-"; - $new_new_value = $modeOFIntimate[$row['new_value']]; + $new_new_value = isset($modeOFIntimate[$row['old_value']]) ? $modeOFIntimate[$row['old_value']] : "-"; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'claim_type') { + $new_old_value = isset($claim_type[$row['ticket_type_id']][$row['old_value']]) ? $claim_type[$row['ticket_type_id']][$row['old_value']] : '-'; + $new_new_value = isset($claim_type[$row['ticket_type_id']][$row['new_value']])?$claim_type[$row['ticket_type_id']][$row['new_value']]:'-'; $row['old_value'] = $new_old_value; $row['new_value'] = $new_new_value; } elseif ($row['field_name'] == 'claim_type') { $new_old_value = isset($claim_type[$row['old_value']]) ? $claim_type[$row['old_value']] : '-'; - $new_new_value = $claim_type[$row['new_value']]; - $row['old_value'] = $new_old_value; - $row['new_value'] = $new_new_value; - } elseif ($row['field_name'] == 'claim_type') { - $new_old_value = isset($claim_type[$row['old_value']]) ? $claim_type[$row['old_value']] : '-'; - $new_new_value = $claim_type[$row['new_value']]; + $new_new_value = isset($claim_type[$row['new_value']]) ? $claim_type[$row['new_value']] : '-'; $row['old_value'] = $new_old_value; $row['new_value'] = $new_new_value; } else { $new_old_value = isset($row['old_value']) ? $row['old_value'] : '-'; + $new_new_value = isset($row['new_value']) ? $row['new_value'] : '-'; $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } } diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index af966114..d24e22c7 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -176,7 +176,7 @@ if (isset($claim_type) && count($claim_type)) { foreach ($claim_type as $key => $value) { $selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : ''; - echo ""; + echo ""; } } ?> diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index f50859ab..e36b2718 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -194,7 +194,7 @@ table.dataTable tbody td { member_mobile - diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php index 5bb94ef9..c3faa0b4 100644 --- a/app/Views/ticket_reply.php +++ b/app/Views/ticket_reply.php @@ -11,7 +11,7 @@ -