Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
Srinivas-Saravanan 2025-04-03 16:49:24 +05:30
commit 0918316715
5 changed files with 112 additions and 9 deletions

View File

@ -3112,6 +3112,8 @@ class EmployeeRestController extends AdminController
}
// ---------------- TICKET API's ---------------------------------------------------------------------------------------------------
//Get Data from post for inserting ticket and message
public function initiateClaim()
{
@ -3171,22 +3173,27 @@ class EmployeeRestController extends AdminController
->first()['id'];
$fetchData['priority'] = 1;
$fetchData['mode_of_intimation'] = 1;
$fetchData['mode_of_intimation'] = 3;
$fetchData['claim_type'] = 1;
$fetchData = array_merge($fetchData, $received_data);
$fetchData['relationship'] = strtolower($fetchData['relationship']) ?? $fetchData['relationship'];
// print_r($fetchData); die;
$insert_status = $this->ticketMaster->insert($fetchData);
$ticket_id = $this->ticketMaster->insertID();
if ($insert_status && !empty($ticket_id)) {
//insert first history
$this->ticketController->putHistoryAfterInsert($fetchData, $ticket_id);
$messagesData = [
'ticket_id' => $ticket_id ?? null,
'sender' => 'user',
'claim_status' => $fetchData['claim_status_id'] ?? null,
'emp_mail' => $fetchData['emp_mail'] ?? null,
'mail_subject' => $fetchData['subject'] ?? null,
'mail_content' => $fetchData['message'] ?? null,
'mail_subject' => $fetchData['subject'] ?? "New Claim",
'mail_content' => $fetchData['message'] ?? "New Claim",
];
if (!empty($messagesData['ticket_id'])) {

View File

@ -234,6 +234,7 @@ class TicketController extends BaseController
'tm.claim_number AS claim_no',
'tm.tpa_id',
'tm.emp_name',
'tm.emp_code',
'i.name AS insurer_name',
'c.client_name',
'tm.insured_name',
@ -274,6 +275,7 @@ class TicketController extends BaseController
'tm.is_head_approved',
'tm.tpa_id',
'tm.emp_name',
'tm.emp_code',
'i.name AS insurer_name',
'c.client_name',
'tm.insured_name',
@ -457,7 +459,18 @@ class TicketController extends BaseController
$data['placeHolders'] = $this->placeHolders;
$data['message_data'] = $this->getTicketMessage($ticket_id);
$data['view_ticket_page'] = [];
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
if($ticket_data['ticket_type_id'] == 1){
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
}else{
$data['member_data'] = array_filter(
$this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']),
function ($member) {
return isset($member['emp_relationship']) && $member['emp_relationship'] == 'Self';
}
);
}
$data['ticket_history'] = $this->ticketHistory($ticket_id);
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
if (!empty($ticket_data['client_policy_id'])){
@ -579,7 +592,9 @@ class TicketController extends BaseController
$return_value = $this->ticketMasterModel->insert($ticket_data);
if ($return_value) {
//mail trigger part
$this->putHistoryAfterInsert($ticket_data, $return_value);
$mail_responce = $this->sendAutoMailTrigger($return_value);
$this->autoMessageInsertBasedOnMailResponse($mail_responce, $return_value);
return $this->respond(['status' => true, 'ticket_id' => $return_value, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully", 'mail_responce' => $mail_responce], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200);
@ -602,8 +617,12 @@ class TicketController extends BaseController
$return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update();
if ($return_value) {
//mail trigger part
$mail_responce = $this->sendAutoMailTrigger($ticket_id);
$mail_responce = null;
if($old_ticket_data['claim_status_id'] != $ticket_data['claim_status_id']){
//mail trigger part
$mail_responce = $this->sendAutoMailTrigger($ticket_id);
$this->autoMessageInsertBasedOnMailResponse($mail_responce, $ticket_id);
}
//send mail to the head for rejected ticket approvel
if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){
@ -1450,6 +1469,73 @@ class TicketController extends BaseController
// -------------------------------------------------------------------------------------------------------------------------
public function autoMessageInsertBasedOnMailResponse($mail_sent_status, $ticket_id)
{
if (gettype($mail_sent_status) == 'array') {
$this->myLogger->logme('error', "auto Message Insert Based On Mail Response Failed because is array :$ticket_id ");
} else {
$mail_sent_status = json_decode($mail_sent_status);
$this->myLogger->logme('error', "mail_sent_status is object :$ticket_id ");
}
if (!empty($mail_sent_status) && isset($mail_sent_status->status) && $mail_sent_status->status == 'success') {
$sent_message_data['ticket_id'] = $ticket_id;
$sent_message_data['sender'] = 'staff';
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
$message_insert_status = $this->ticketMessageModel->insert($sent_message_data);
if ($message_insert_status) {
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, successfully store message:$ticket_id ");
} else {
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
}
return true;
} else {
$this->myLogger->logme('error', "Failed to send Mail :$ticket_id ");
return true;
}
}
public function putHistoryAfterInsert($ticket_data, $ticket_id)
{
$this->myLogger->logme('error', "Put History After Insert function called : $ticket_id");
if(!empty($ticket_data)){
$history_data = [
'ticket_id' => $ticket_id,
'field_name' => 'claim_status_id',
'display_name' => 'Ticket Created',
'old_value' => null,
'new_value' => $ticket_data['claim_status_id'],
'created_by' => get_session_userid(),
'is_active' => 1
];
$this->myLogger->logme('error', "Put History After Insert function called : " . json_encode($history_data));
$history_insert = $this->ticketHistoryModel->insert($history_data);
if($history_insert){
$this->myLogger->logme('error', "Put History After Insert Ticket Data Successfully");
}else{
$this->myLogger->logme('error', "Put History After Insert Ticket Data Failed");
}
}else{
$this->myLogger->logme('error', "Put History After Insert Ticket Data is empty");
}
return true;
}
public function viewClaimFeedbackForm($md5_ticket_id,$empView = null)
{

View File

@ -12,7 +12,7 @@ class TicketHistoryModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['id','field_name','display_name','old_value',
protected $allowedFields = ['id', "ticket_id", 'field_name','display_name','old_value',
'new_value','created_by','created_at','updated_by','updated_at','is_active'];
// Callbacks

View File

@ -20,7 +20,7 @@
<td><?php echo $row['display_name']; ?></td>
<td><?php echo $row['old_value'].' => '.$row['new_value']; ?></td>
<!-- <td><?php //echo $row['new_value']; ?></td> -->
<td><?php echo $row['modified_by']; ?></td>
<td><?php echo $row['modified_by'] ?? "Created by employee"; ?></td>
<td><?php echo $row['created_at']; ?></td>
</tr>
<?php } ?>

View File

@ -35,6 +35,10 @@ table.dataTable tbody td {
white-space: nowrap !important;
}
#scroll-horizontal-datatable tbody tr:hover {
background-color: #e0e0e0;
}
</style>
@ -57,6 +61,7 @@ table.dataTable tbody td {
<th>Policy Type</th>
<th>Claim number</th>
<th>TPA ID</th>
<th>Emp ID</th>
<th>Emp name</th>
<th>Insured Name</th>
<th>Corporate name</th>
@ -66,7 +71,7 @@ table.dataTable tbody td {
<tbody>
<?php if (isset($ticket_data)) { ?>
<?php foreach($ticket_data as $index => $row){ ?>
<tr onclick="viewTicket(<?php echo $row['id']; ?>)">
<tr onclick="viewTicket(<?php echo $row['id']; ?>)" style="cursor: pointer;">
<td data-toggle="tooltip" data-placement="top"
@ -110,6 +115,7 @@ table.dataTable tbody td {
<td><?php echo str_replace("Claim-", "", $ticket_type[$row['ticket_type_id']] ?? ""); ?></td>
<td><?php echo $row['claim_no']; ?></td>
<td><?php echo $row['tpa_id']; ?></td>
<td><?php echo $row['emp_code']; ?></td>
<td><?php echo $row['emp_name']; ?></td>
<td><?php echo $row['insured_name']; ?></td>
<td><?php echo $row['short_name']; ?></td>
@ -184,8 +190,12 @@ $(document).ready(function() {
function viewTicket(ticket_id){
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
let url = '<?= base_url('ticket/view/'); ?>' + ticket_id
window.location.href = url
}
</script>