From 83296fa4afbd914df90683ba6964e499c90174f4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 30 Jan 2026 09:16:27 +0530 Subject: [PATCH] FIX_HR_APIS_E_CARD_ATTACHMENTS_ISSUES --- app/Controllers/EmployeeRestController.php | 63 ++++++++++++++++++++-- app/Helpers/sendMailNotification.php | 17 +++++- app/Models/TicketMasterModel.php | 1 + 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index fa58834a..ebf26139 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2305,8 +2305,32 @@ class EmployeeRestController extends AdminController } + if($this->request->getGet('policy_status') == 0){ + $emp_policy_status = 'expired'; + }else{ + $emp_policy_status = 'active'; + } - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, DATE_FORMAT(client_policy.policy_end_date, "%d-%m-%Y") AS policy_expiry_date ') + $ClientPolicyData = $this->clientPolicyModel + ->select(" + client_policy.id as client_policy_id , + client_policy.client_id as client_id, + client_policy.policy_type_id as policy_type_id, + client_policy.is_addon as is_addon , + client_policy.open_for_enrollment as OpenForEnrollment , + client_policy.inception_type as inception_type, + client_policy.policy_no as policy_no, + client_policy.insurer_id as insurer_id, + DATE_FORMAT(client_policy.policy_start_date, '%d-%m-%Y') AS policy_start_date, + DATE_FORMAT(client_policy.policy_end_date, '%d-%m-%Y') AS policy_expiry_date, + ( + select round(sum(rata_premimum + gst)) + from employee_polices + where is_active = 1 + and status = $emp_policy_status + and client_policy_id = client_policy_id + ) as total_premium + ") ->where('md5(client_policy.client_id)', $this->request->getGet('client_id')) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id')) ->where('client_policy.is_active', 1) @@ -2443,7 +2467,12 @@ class EmployeeRestController extends AdminController if ($this->request->is('get')) { - $data['claim_status'] = $this->claimStatusModel->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll(); + $data['claim_status'] = $this->claimStatusModel + ->select('id,ticket_type, display_name as claim_status') + ->where('is_active', 1) + ->groupBy('display_name') + ->findAll(); + $data['ticket_type'] = [ ["ticket_type" => "1", "type_name" => "Claim-GMC"], ["ticket_type" => "2", "type_name" => "Claim-GPA"], @@ -2463,7 +2492,8 @@ class EmployeeRestController extends AdminController $from_date = isset($search_data['from_date']) ? $search_data['from_date'] : null; $to_date = isset($search_data['to_date']) ? $search_data['to_date'] : null; - unset($search_data['from_date'], $search_data['to_date']); + $claim_status_id = isset($search_data['claim_status_id']) ? $search_data['claim_status_id'] : null; + unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id']); $where = []; @@ -2474,6 +2504,11 @@ class EmployeeRestController extends AdminController } } + $claim_status_ids = []; + if(!empty($claim_status_id)){ + $claim_status_ids = $this->getTicketClaimStatusIdBasedOnTheDisplayName($claim_status_id); + } + $builder = $db->table('ticket_master tm'); $builder->select([ 'tm.id', @@ -2485,6 +2520,12 @@ class EmployeeRestController extends AdminController ELSE UPPER(tcs.display_name) END AS status ", + "CASE + WHEN tm.tpa_claim_type IS NOT NULL OR tm.tpa_claim_type != '' + THEN tm.tpa_claim_type + ELSE 'Reimbursement' + END AS cl_type + ", 'tm.claim_number AS claim_no', 'tm.claim_status_id', 'tm.is_head_approved', @@ -2568,6 +2609,10 @@ class EmployeeRestController extends AdminController $builder->where($where); } + if (!empty($claim_status_ids)) { + $builder->whereIn('claim_status_id', $claim_status_ids); + } + $builder->orderBy('tm.id', 'DESC'); $data = $builder->get()->getResultArray(); @@ -5305,6 +5350,18 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => false, 'code' => 400, 'message' => 'Failed to upload the file'], 200); } } + + public function getTicketClaimStatusIdBasedOnTheDisplayName($claim_status_id) + { + $claim_status_data_display_name = $this->claimStatusModel->where('is_active', 1)->where('id', $claim_status_id)->first(); + $claim_status_data_id = $this->claimStatusModel + ->select('id') + ->where('is_active', 1) + ->where('display_name', $claim_status_data_display_name['display_name']) + ->findAll(); + return $claim_status_data_id; + } + } diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index cc46a3cd..5327f8d5 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -116,6 +116,21 @@ class sendMailNotification $tpa_id = $params['tpa_id']; $common = $params['common']; + $mailAttachmentModel = new MailAttachmentModel(); + $attachment_data = $mailAttachmentModel + ->select('file_path, file_name') + ->where('notification_id', $notification['id']) + ->where('is_active', 1) + ->findAll(); + + $attachments = []; + foreach ($attachment_data as $data) { + $attachments[] = [ + "filePath" => WRITEPATH . $data['file_path'], + "fileName" => $data['file_name'] + ]; + } + $mail_content = $notification['mail_content']; $mail = $get_emp_email_and_other_details['email_corporate']; @@ -160,7 +175,7 @@ class sendMailNotification $mail_content = view('mail_template', $data); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'],'attachments' => $attachments, 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 845a6fe2..f2feb0d5 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -92,6 +92,7 @@ class TicketMasterModel extends Model 'claim_description', 'required_docs', 'policy_transaction_id', + 'tpa_claim_type', ];