From a3d7007f10324de55782ceafa8563d5a4728e599 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 8 Jan 2025 10:55:17 +0530 Subject: [PATCH 01/65] FIX_ROW_ON_CLICK_TABLE_ALIGNMENT --- app/Views/insurer_list.php | 53 +++--------------- app/Views/insurer_statement_list.php | 55 ++----------------- app/Views/kyc_list.php | 53 +++--------------- app/Views/leads_list.php | 53 +++--------------- .../policy_transaction_inception_list.php | 53 ++---------------- app/Views/tpa_list.php | 54 +++--------------- 6 files changed, 40 insertions(+), 281 deletions(-) diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 933ed3b4..150f9be2 100755 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -1,70 +1,31 @@
diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 2772907a..83dee914 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -108,75 +108,32 @@ table.dataTable tbody td { color: gray; } -custom-dropdown-menu { + .custom-dropdown-menu { display: none; - position: fixed; + position: absolute; background-color: #ffffff !important; - border: 1px solid rgba(0,0,0,.15); + border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 0.25rem; padding: 0.5rem 0; min-width: 10rem; z-index: 9999; - box-shadow: 0 0 10px rgba(0,0,0,0.1); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .custom-dropdown-menu .dropdown-item { display: block !important; width: 100% !important; padding: 0.5rem 1rem !important; - clear: both !important; - font-weight: 400 !important; color: #212529 !important; - text-align: inherit !important; - white-space: nowrap !important; - background-color: transparent !important; - border: 0 !important; text-decoration: none !important; - position: relative !important; + background-color: transparent !important; } .custom-dropdown-menu .dropdown-item:hover { background-color: #f8f9fa !important; color: #16181b !important; cursor: pointer !important; -} - -.custom-dropdown-menu .dropdown-item i { - margin-right: 8px !important; - vertical-align: middle !important; -} - -.table tbody tr { - cursor: pointer; -} - -/* Ensure the dropdown menu has a solid background */ -.custom-dropdown-menu::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #ffffff; - z-index: -1; -} - -/* Add a subtle backdrop effect */ -.custom-dropdown-menu::after { - content: ''; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgba(0,0,0,0.05); - z-index: -2; - pointer-events: none; -} - - - +}
diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index a28b2dfe..e6c0870f 100755 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -1,70 +1,31 @@
diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 78665e91..ddf4d238 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -37,72 +37,33 @@ table.dataTable tbody td { margin-bottom: 10px; } -custom-dropdown-menu { + +.custom-dropdown-menu { display: none; - position: fixed; + position: absolute; background-color: #ffffff !important; - border: 1px solid rgba(0,0,0,.15); + border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 0.25rem; padding: 0.5rem 0; min-width: 10rem; z-index: 9999; - box-shadow: 0 0 10px rgba(0,0,0,0.1); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .custom-dropdown-menu .dropdown-item { display: block !important; width: 100% !important; padding: 0.5rem 1rem !important; - clear: both !important; - font-weight: 400 !important; color: #212529 !important; - text-align: inherit !important; - white-space: nowrap !important; - background-color: transparent !important; - border: 0 !important; text-decoration: none !important; - position: relative !important; + background-color: transparent !important; } .custom-dropdown-menu .dropdown-item:hover { background-color: #f8f9fa !important; color: #16181b !important; cursor: pointer !important; -} - -.custom-dropdown-menu .dropdown-item i { - margin-right: 8px !important; - vertical-align: middle !important; -} - -.table tbody tr { - cursor: pointer; -} - -/* Ensure the dropdown menu has a solid background */ -.custom-dropdown-menu::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #ffffff; - z-index: -1; -} - -/* Add a subtle backdrop effect */ -.custom-dropdown-menu::after { - content: ''; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgba(0,0,0,0.05); - z-index: -2; - pointer-events: none; -} +} diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index 80f9fe62..0db12415 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -45,73 +45,32 @@ table.dataTable tbody td { .addbtnStyle{ margin-left: 20px !important; } -custom-dropdown-menu { +.custom-dropdown-menu { display: none; - position: fixed; + position: absolute; background-color: #ffffff !important; - border: 1px solid rgba(0,0,0,.15); + border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 0.25rem; padding: 0.5rem 0; min-width: 10rem; z-index: 9999; - box-shadow: 0 0 10px rgba(0,0,0,0.1); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .custom-dropdown-menu .dropdown-item { display: block !important; width: 100% !important; padding: 0.5rem 1rem !important; - clear: both !important; - font-weight: 400 !important; color: #212529 !important; - text-align: inherit !important; - white-space: nowrap !important; - background-color: transparent !important; - border: 0 !important; text-decoration: none !important; - position: relative !important; + background-color: transparent !important; } .custom-dropdown-menu .dropdown-item:hover { background-color: #f8f9fa !important; color: #16181b !important; cursor: pointer !important; -} - -.custom-dropdown-menu .dropdown-item i { - margin-right: 8px !important; - vertical-align: middle !important; -} - -.table tbody tr { - cursor: pointer; -} - -/* Ensure the dropdown menu has a solid background */ -.custom-dropdown-menu::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #ffffff; - z-index: -1; -} - -/* Add a subtle backdrop effect */ -.custom-dropdown-menu::after { - content: ''; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgba(0,0,0,0.05); - z-index: -2; - pointer-events: none; -} - +} +}
From a2ccebf83e70e767acd25b940b5a1b19305569ea Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 17 Jan 2025 18:15:46 +0530 Subject: [PATCH 02/65] FIX_ZEPTO_MAIL_BCC_CC_NOT_SEND_ISSUE_SRINIVAS --- app/Helpers/MailHelper.php | 224 +++++++++++++++++++++---------------- 1 file changed, 127 insertions(+), 97 deletions(-) diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 91e955b0..ecee92da 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -194,6 +194,11 @@ class MailHelper } else { $bcc = ''; } + if(isset($params['cc'])){ + $cc = $params['cc']; + }else{ + $cc = ''; + } $from_address = getenv('email.fromEmail'); @@ -255,7 +260,7 @@ class MailHelper } $apiResponse = json_decode($response, true); - + log_message('error',$apiResponse); if ($httpCode === 200) { return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200); } else { @@ -289,116 +294,141 @@ class MailHelper } public static function send_email($params) - { - $myLogger = \Config\Services::mylogger(); +{ + $myLogger = \Config\Services::mylogger(); + + $emaill = $params['mail']; + $subject = $params['subject']; + $message = $params['message']; + $attachments = isset($params['attachments']) ? $params['attachments'] : []; + $common = isset($params['common']) ? $params['common'] : ''; + $bcc = isset($params['bcc']) ? $params['bcc'] : ''; + $cc = isset($params['cc']) ? $params['cc'] : ''; + + $from_address = getenv('email.fromEmail'); + try { + $curl = curl_init(); - $emaill = $params['mail']; - $subject = $params['subject']; - $message = $params['message']; - $attachments = isset($params['attachments']) ? $params['attachments'] : []; - $common = isset($params['common']) ? $params['common'] : ''; - - $from_address = getenv('email.fromEmail'); - try { - $curl = curl_init(); - - $postData = [ - 'from' => [ - 'address' => $from_address - ], - 'to' => [ - [ - 'email_address' => [ - 'address' => $emaill - ] + $postData = [ + 'from' => [ + 'address' => $from_address + ], + 'to' => [ + [ + 'email_address' => [ + 'address' => $emaill ] - ], - 'subject' => $subject, - 'htmlbody' => $message - ]; + ] + ], + 'subject' => $subject, + 'htmlbody' => $message + ]; - // Handle attachments - if (!empty($attachments)) { - $postData['attachments'] = []; - foreach ($attachments as $attachment) { - if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) { - // Determine MIME type dynamically - $fileMimeType = mime_content_type($attachment['filePath']); - - $postData['attachments'][] = [ - 'content' => base64_encode(file_get_contents($attachment['filePath'])), - 'name' => $attachment['fileName'], - 'mime_type' => $fileMimeType, // Add mime_type field - ]; - } + // Add CC recipients if provided + if (!empty($cc)) { + $postData['cc'] = []; + // Handle both string and array inputs for CC + $ccEmails = is_array($cc) ? $cc : [$cc]; + foreach ($ccEmails as $ccEmail) { + $postData['cc'][] = [ + 'email_address' => [ + 'address' => $ccEmail + ] + ]; + } + } + + // Add BCC recipients if provided + if (!empty($bcc)) { + $postData['bcc'] = []; + // Handle both string and array inputs for BCC + $bccEmails = is_array($bcc) ? $bcc : [$bcc]; + foreach ($bccEmails as $bccEmail) { + $postData['bcc'][] = [ + 'email_address' => [ + 'address' => $bccEmail + ] + ]; + } + } + + // Handle attachments + if (!empty($attachments)) { + $postData['attachments'] = []; + foreach ($attachments as $attachment) { + if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) { + // Determine MIME type dynamically + $fileMimeType = mime_content_type($attachment['filePath']); + + $postData['attachments'][] = [ + 'content' => base64_encode(file_get_contents($attachment['filePath'])), + 'name' => $attachment['fileName'], + 'mime_type' => $fileMimeType, + ]; } } - + } - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.zeptomail.in/v1.1/email", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "POST", - CURLOPT_POSTFIELDS => json_encode($postData), - CURLOPT_HTTPHEADER => [ - "accept: application/json", - "authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'), - "cache-control: no-cache", - "content-type: application/json", - ], - ]); + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.zeptomail.in/v1.1/email", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => json_encode($postData), + CURLOPT_HTTPHEADER => [ + "accept: application/json", + "authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'), + "cache-control: no-cache", + "content-type: application/json", + ], + ]); - $mail_result = curl_exec($curl); - $err = curl_error($curl); - curl_close($curl); - // log_message('error','inside mail helper'); - // log_message('error', $response.' error->'.$err);die(); - $res['params'] = $params; - $MailDataHelper = new GmailResponseHandler(); - $apiResponse = json_decode($mail_result, true); - $res['zepto_api'] = $apiResponse; - if (isset($apiResponse['error'])) { - $response = $res; - $MailDataHelper->receive_and_distribute_param_to_functions($response); - return json_encode([ - 'status' => 'failed', - 'code' => 404, - 'message' => 'Email Sent Failed...' . $emaill, - 'data' => $res - ], 404); - } + $mail_result = curl_exec($curl); + $err = curl_error($curl); + curl_close($curl); - // $apiResponse = json_decode($response, true); - - // Check if request_id exists in response (indicates success) - if (isset($apiResponse['data'])) { - $response = $res; - $MailDataHelper->receive_and_distribute_param_to_functions($response); - return json_encode([ - 'status' => 'success', - 'code' => 200, - 'message' => 'Email Sent Successfully...' . $emaill, - 'data' => $res - ], 200); - } - - } catch (\Exception $e) { - $msg['error'] = $e->getMessage(); - $msg['params'] = $params; + $res['params'] = $params; + $MailDataHelper = new GmailResponseHandler(); + $apiResponse = json_decode($mail_result, true); + $res['zepto_api'] = $apiResponse; + + if (isset($apiResponse['error'])) { $response = $res; $MailDataHelper->receive_and_distribute_param_to_functions($response); return json_encode([ 'status' => 'failed', - 'code' => 500, - 'data' => $msg - ], 500); + 'code' => 404, + 'message' => 'Email Sent Failed...' . $emaill, + 'data' => $res + ], 404); } - } + if (isset($apiResponse['data'])) { + $response = $res; + $MailDataHelper->receive_and_distribute_param_to_functions($response); + return json_encode([ + 'status' => 'success', + 'code' => 200, + 'message' => 'Email Sent Successfully...' . $emaill, + 'data' => $res + ], 200); + } + + } catch (\Exception $e) { + $msg['error'] = $e->getMessage(); + $msg['params'] = $params; + $response = $res; + $MailDataHelper->receive_and_distribute_param_to_functions($response); + return json_encode([ + 'status' => 'failed', + 'code' => 500, + 'data' => $msg + ], 500); + } +} public static function bulk_mail(array $mails = []) { $model = new JobModel(); From 35def0111196a1f73d9657c7304be08399696bd6 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 17 Jan 2025 18:21:56 +0530 Subject: [PATCH 03/65] FIX_TYPO_SEND_MAIL_HELPER_SRINIVAS --- app/Helpers/MailHelper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index ecee92da..c55c2796 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -260,7 +260,6 @@ class MailHelper } $apiResponse = json_decode($response, true); - log_message('error',$apiResponse); if ($httpCode === 200) { return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200); } else { From 03a00ecccd50eb4babc8cf8c922308c4aa63474a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 20 Jan 2025 10:45:26 +0530 Subject: [PATCH 04/65] CHANGE_AGE_BAND_LGBTQ_EMAIL_MOBILE_EDIT_: RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 208 +++++++++++++++--- app/Controllers/EmployeeController.php | 5 +- app/Controllers/EmployeeServiceController.php | 9 +- app/Controllers/LeadsController.php | 189 +++++----------- app/Controllers/MasterController.php | 1 + app/Helpers/excel_util_helper.php | 37 +++- app/Models/ClientPolicyModel.php | 3 +- app/Models/EmployeePolicyModel.php | 13 +- app/Views/client_policy.php | 28 ++- app/Views/employee_data_list.php | 13 +- 11 files changed, 311 insertions(+), 196 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 83992845..a0c418f7 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -14,6 +14,7 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']); $routes->get("reminder_mail", "NotificationController::reminder_mail"); $routes->get("getClientData", "ClientController::getClientData"); $routes->get("testing_for_review_mail/(:any)", "ClientController::testingForReviewMail/$1"); +$routes->get("sendMemberReviewConfirmationMail/(:any)", "ClientController::sendMemberReviewConfirmationMail/$1"); $routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections"); $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 9e964863..cfe2a5e9 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -44,8 +44,7 @@ use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; use App\Helpers\sendMailNotification; - - +use App\Models\RFQModel; class ClientController extends AdminController { @@ -183,9 +182,12 @@ class ClientController extends AdminController print_rr($attachments); } + //Function for Testing Member Review and Summery Confirmation Mail public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic { + // dd($client_id, $emp_code, $mail_active); + $client_policy_ids = $this->employeeModel ->select('employee_polices.client_policy_id') ->join('employee_polices', 'employees.id = employee_polices.employee_id') @@ -213,7 +215,7 @@ class ClientController extends AdminController { $empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll(); - + // dd($empData); $filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self'); // dd($filteredEmpData); @@ -254,7 +256,7 @@ class ClientController extends AdminController // print_r($wholeData); die; if($mail_active > 0){ - $mail_send_return = MailHelper::send_email($wholeData[0]); + // $mail_send_return = MailHelper::send_email($wholeData[0]); $this->myLogger->logme("info", $mail_send_return); } @@ -269,7 +271,7 @@ class ClientController extends AdminController if($mail_active > 0){ foreach ($account_manager_wholeData as $key => $value) { - $mail_send_return1 = MailHelper::send_email($value); + // $mail_send_return1 = MailHelper::send_email($value); $this->myLogger->logme("info", $mail_send_return1); } @@ -288,7 +290,7 @@ class ClientController extends AdminController if($mail_active > 0){ foreach ($client_hr_wholeData as $key => $value) { - $mail_send_return2 = MailHelper::send_email($value); + // $mail_send_return2 = MailHelper::send_email($value); $this->myLogger->logme("info", $mail_send_return2); } } @@ -317,6 +319,123 @@ class ClientController extends AdminController // return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200); } + //Function for Send Member Review and Summery Confirmation Mail + public function sendMemberReviewConfirmationMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) + { + $client_policy_ids = $this->employeeModel + ->select('employee_polices.client_policy_id') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.client_id', $client_id) + ->where('employees.emp_code', $emp_code) + ->where('employee_polices.is_active', 1) + ->where('employees.is_active', 1) + ->findAll(); + + $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id'); + $client_policy_id = array_unique($client_policy_ids2); + + if (!is_null($client_policy_id) && is_array($client_policy_id)) { + + $empData = $this->employeeModel + ->where('emp_code', $emp_code) + ->where('client_id', $client_id) + ->where('is_active', 1) + ->findAll(); + + $filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self'); + + if (empty($filteredEmpData)) { + return $this->respond([ + 'status' => 'error', + 'code' => 404, + 'message' => 'No active employee data found for the given criteria.', + ], 404); + } + + $array_list = []; + foreach ($client_policy_id as $value) { + $find = $this->employeeModel->getEmpFamilybyEmpCode( + client_policy_id: $value, + emp_code: $emp_code, + client_id: $client_id, + emp_status: ['draft', 'enrolled'], + policy_status: ['draft', 'enrolled'] + ); + + if (count($find) > 0) { + $array_list[] = $find; + } + } + + $notification = $this->notificationModel + ->where('client_id', $client_id) + ->where('template_name', 'member_review_and_summary_mail') + ->first(); + + if ($notification && $notification['enabled'] == 1) { + + $params = [ + 'array_list' => $array_list, + 'client_policy_id' => $client_policy_id, + 'emp_code' => $emp_code, + 'client_id' => $client_id, + 'notification' => $notification, + 'common' => [ + 'client_id' => $filteredEmpData[0]['client_id'], + 'client_branch_id' => $filteredEmpData[0]['client_branch_id'], + 'client_policy_id' => null, + 'employee_policy_id' => null, + 'employee_id' => $filteredEmpData[0]['id'], + 'mail_type' => 'member_review_and_summary_mail', + ], + ]; + + $wholeData = sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params); + + if ($mail_active > 0) { + + $mail_send_result = MailHelper::send_email($wholeData[0]); + + if ($mail_send_result['status'] === 'success') { + return $this->respond([ + 'status' => 'success', + 'code' => 200, + 'message' => 'Email sent successfully.', + 'response' => $mail_send_result, + ], 200); + } else { + return $this->respond([ + 'status' => 'error', + 'code' => 500, + 'message' => 'Failed to send email.', + 'details' => $mail_send_result, + ], 500); + } + } + + return $this->respond([ + 'status' => 'success', + 'code' => 200, + 'message' => 'Notification prepared but email not sent as mail_active is 0.', + 'data' => $wholeData, + ], 200); + } + + return $this->respond([ + 'status' => 'error', + 'code' => 400, + 'message' => 'Member Review Mail configuration is not enabled for this client.', + ], 400); + } + + return $this->respond([ + 'status' => 'error', + 'code' => 404, + 'message' => 'No active client policy IDs found.', + ], 404); + } + + //-------------------------------------------------------------------------------------------------------- public function index() @@ -1056,6 +1175,7 @@ class ClientController extends AdminController $data['disclaimer'] = $this->request->getPost('disclaimer'); $data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; $data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0; + $data['is_lgbtq'] = $this->request->getPost('is_lgbtq') ? 1 : 0; @@ -1188,6 +1308,7 @@ class ClientController extends AdminController $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); $data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; + $data['is_lgbtq'] = $this->request->getPost('is_lgbtq') ? 1 : 0; if ($data['inception_type'] == 2) { $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); @@ -3831,24 +3952,27 @@ class ClientController extends AdminController public function sendextraparam() { - $batch_data = [ - 'client_id' => 17, - 'client_policy_id' => 30, - 'client_branch_id' => 18, - 'event_type' => "inception", - ]; - - // $batch_data['insurer_or_tpa'] = 'insurer'; - $batch_data['insurer_or_tpa'] = 'tpa'; + // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- - // dd($this->request); - // $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 721]); - + $employeeRestController = new EmployeeServiceController(); + // $employeeRestController->excelFileDataValidation(['file_id' => 823]); + // $employeeRestController->employeesOnboardPreprocess(['file_id' => 823]); // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); + // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- + + // $batch_data = [ + // 'client_id' => 17, + // 'client_policy_id' => 30, + // 'client_branch_id' => 18, + // 'event_type' => "inception", + // ]; + + // $batch_data['insurer_or_tpa'] = 'insurer'; + // $batch_data['insurer_or_tpa'] = 'tpa'; + // $dashBoardController = new DashboardController(); // $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126); // $dashBoardController->sendRemainderMail($client_policy_data); @@ -3877,33 +4001,47 @@ class ClientController extends AdminController // $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]); - $EmpDataServiceController = new EmpDataServiceController(); + // $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]); // $EmpDataServiceController->importDeletionValidation(['file_id' => 171]); // $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]); // $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]); - $array = [ - "employeeIds" => ["12800", "12798", "12797", "12799"], - "client_id" => "159", - "client_policy_id" => "336", - "client_branch_id" => "126", - "cd_ac_no" => "Apple_123", - "endorsement_no" => "ENDORSEMENT_ID", - "count" => 4, - "event_name" => "deletion", - "policy_name" => "GMC", - "user_id" => "1" - ]; + + // $array = [ + // "employeeIds" => ["12800", "12798", "12797", "12799"], + // "client_id" => "159", + // "client_policy_id" => "336", + // "client_branch_id" => "126", + // "cd_ac_no" => "Apple_123", + // "endorsement_no" => "ENDORSEMENT_ID", + // "count" => 4, + // "event_name" => "deletion", + // "policy_name" => "GMC", + // "user_id" => "1" + // ]; // $EmpDataServiceController->cashDepositCalculationForDeletion($array); - // $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]); - // $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data); // dd(db_connect()->getLastQuery()); + // ------------- LEADS CONTROLLER ---------------------------------------------------------- + + // $LeadsController = new LeadsController(); + // $RFQModel = new RFQModel(); + + // $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first(); + // // dd($data); + // $policy_type = 2; + // $proposel_name = "Proposal 2"; + // $insurer_name = "ICICI-P-ICICI002-V1"; + // $jsonArray = json_decode($data['json'], true); + // // dd($jsonArray); + + // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); + // dd($returndata); + } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b031e487..b479f5ff 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2177,6 +2177,9 @@ class EmployeeController extends AdminController //get policy details $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id); $policy_terms = (array)$policy_details[0]; + $is_lgbtq = $policy_terms['is_lgbtq']; + + // dd($policy_terms); $policy_terms = json_decode($policy_terms['policy_terms']); $policy_terms = (array) $policy_terms;// convert obj to array @@ -2184,7 +2187,7 @@ class EmployeeController extends AdminController //get file array or construnct dummy file array here $file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1]; //get familiy details in inception file format array from post method - $result = check_dependent_conflict($family_details, $policy_terms, $file['action']); + $result = check_dependent_conflict($family_details, $policy_terms, $file['action'],$is_lgbtq); return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['policy_terms' => $policy_terms['family_floaters'],'result' => $result] ], 200); diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 7eafb908..d7674712 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -977,6 +977,9 @@ class EmployeeServiceController extends AdminController // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); $policy_details = (array)$policy_terms[0]; + $is_lgbtq = $policy_details['is_lgbtq']; + + // dd($this->clientPolicyModel->getLastQuery()); $policy_terms = json_decode($policy_terms[0]->policy_terms); $policy_terms = (array) $policy_terms;// convert obj to array @@ -1071,7 +1074,7 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception'|| $file['action'] == 'missed_inception' || $file['action'] == 'enrollment') { - $res = check_dependent_conflict($family,$policy_terms,$file['action']); + $res = check_dependent_conflict($family,$policy_terms,$file['action'],$is_lgbtq); // dd($res); if(!$res['status']) { @@ -1159,7 +1162,6 @@ class EmployeeServiceController extends AdminController } - // calculate data points and premium public function employeesOnboardPreprocess($params) { @@ -1240,8 +1242,9 @@ class EmployeeServiceController extends AdminController // dd($family); } - // Kint::dump($family);die(); + // Kint::dump($family); $data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units); + // dd($data); $employee_data_group_by_family[$emp_id] = $data; $this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]); } diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 6140f45e..0a9c444c 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -461,7 +461,8 @@ class LeadsController extends BaseController $this->loadLayout('view_rfq.php', $data); } - public function createRFQ(){ + public function createRFQ() + { // print_r($this->request->getPost('json')); die(); @@ -1542,7 +1543,8 @@ class LeadsController extends BaseController } } - public function transformProposelData($data, $proposel, $insurer){ + public function transformProposelData($data, $proposel, $insurer) + { // print_r($data['premium_data']['data']); die; @@ -1933,107 +1935,23 @@ class LeadsController extends BaseController return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']); } - private function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name) - { - $GMC_Keys = [ - "sum_insured", - "family_floater", - "family_floaters", - "age_ratio", - "waiverofpreexistingdiseases", - "maternitycoverage", - "twindelivery", - "preandpostnatal", - "babyday1cover", - "9monthwaitingperiodwaived", - "coverfromthedateofjoining", - "waiverof1,2,3&4thyearexclusions", - "waiverof30dayswaitingperiod", - "prehospitalizationcover", - "congenitaldiseasesinternal", - "copayzonewisecopay", - "bioabsorbablestenttoriclensmultifocallens", - "roomrentlimit", - "proportionatedeductionclause", - "ailmentcapping", - "ambulancecharges", - "airambulance", - "familytransportationbenefit", - "reasonableandcustomarycharges", - "ayudhtreatmentcover", - "congenitaldiseasesexternal", - "optionalparentalcopay", - "posthospitalizationcover", - "corporatebuffer", - "sublimitofcorporatebuffer", - "ayushTreatmentCoverData", - "armdcovered", - "suminsuredenhancement", - "automaticsuminsuredreinstatement", - "additionalsicknessbenefit", - "lasiksurgery", - "midterminclusion", - "capd", - "organdonorexpenses", - "moderntreatmentsasperirdai", - "Wellness", - "days_of_discharge", - "days_from_dod", - "special_condition_label", - "special_condition_input", - "multiple_sum_insured", - "cataract", - "cataractData" - ]; - - $GPA_Keys = [ - "sumInsured2", - "totalSumInsured", - "age_ratio", - "accidentalDeathBenefit", - "permanentTotalDisablement", - "permanentPartialDisablement", - "temporaryTotalDisablementBenefit", - "accidentalHospitalizationExpenses", - "childrenEducationWelfareFund", - "compassionateVisitExpenses", - "compassionateVisitExpensesData", - "brokenBoneExpenses", - "brokenBoneExpensesData", - "ambulanceCharges", - "ambulanceChargesData", - "burnExpenses", - "burnExpensesData", - "carriageOfDeadBody", - "carriageOfDeadBodyData", - "animalSnakeInsectBite", - "terrorism", - "worldwideCover", - "gpa_special_condition_label", - "gpa_special_condition_input", - "multiple_sum_insured" - ]; - - // Select keys based on policy type - $termsKey = $policy_type == 1 ? $GPA_Keys : $GMC_Keys; - - // Initialize terms_array with default empty values - $terms_array = array_fill_keys($termsKey, ""); - $specialKeys = ['special_condition_label', 'special_condition_input', 'gpa_special_condition_label', 'gpa_special_condition_input', 'multiple_sum_insured']; - foreach ($specialKeys as $key) { - $terms_array[$key] = []; - } + //Function for convert the RFQ and QCR Json to Policy Terms Json + public function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name) + { + //transform the data into the currernt proposel and insurere ( get single proposel ) + $data = $this->transformProposelData($data, $proposel_name, $insurer_name); // Initialize age_ratio based on policy type - $terms_array['age_ratio'] = $policy_type == 2 ? [ - "self" => ["min" => "18", "max" => "60"], - "spouse" => ["min" => 0, "max" => 0], - "child" => ["min" => 0, "max" => "25"], - "elders" => ["min" => 0, "max" => 0], - ] : ["self" => ["min" => "18", "max" => "60"]]; + $age_ratio = $policy_type == 2 ? [ + 'self' => ['min' => '18', 'max' => '60'], + 'spouse' => ['min' => 0, 'max' => 0], + 'child' => ['min' => 0, 'max' => '25'], + 'elders' => ['min' => 0, 'max' => 0], + ] : [ + 'self' => ['min' => '18', 'max' => '60'] + ]; foreach ($data['table_data']['data'] as $dataRow) { - $item = $dataRow['items'] ?? ''; foreach ($dataRow['data'] as $cellData) { @@ -2043,45 +1961,52 @@ class LeadsController extends BaseController $value = $cellData['value'] ?? ''; // Skip unwanted keys - if ( - in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) || - in_array($subth, ['Quote Asked']) - ) { + if (in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) || in_array($subth, ['Quote Asked'])) { continue; } - // Handle special conditions - if (str_starts_with($item, "special_condition") && $parentth === $proposel_name && $subth === $insurer_name) { + switch (true) { - $parts = explode("-", $input_value); - $question = $parts[0] ?? ''; - $answer = $parts[1] ?? ''; - $labelKey = $policy_type == 1 ? 'gpa_special_condition_label' : 'special_condition_label'; - $inputKey = $policy_type == 1 ? 'gpa_special_condition_input' : 'special_condition_input'; + // CASE 1: Handle special conditions + case str_starts_with($item, 'special_condition') && $parentth === $proposel_name && $subth === $insurer_name: + $parts = explode('-', $input_value); + $labelKey = $policy_type == 1 ? 'gpa_special_condition_label' : 'special_condition_label'; + $inputKey = $policy_type == 1 ? 'gpa_special_condition_input' : 'special_condition_input'; - $terms_array[$labelKey][] = $question; - $terms_array[$inputKey][] = $answer; - continue; + $terms_array[$labelKey][] = $parts[0] ?? ''; + $terms_array[$inputKey][] = $parts[1] ?? ''; + break; + + // CASE 2: Handle sum insured + case in_array($item, ['sum_insured', 'sumInsured2']): + $si_amt = explode(',', $value); + $terms_array[$item] = $si_amt[0] ?? ''; + $terms_array['multiple_sum_insured'] = array_slice($si_amt, 1); + + // Add age_ratio after Sum insured + if ($policy_type == 1) { + $terms_array['age_ratio'] = $age_ratio; + } + + break; + + // CASE 3: Handle family floaters + case $item === 'family_composition': + $terms_array['family_floaters'] = isJsonString($input_value) ? json_decode($input_value, true) : $input_value; + + // Add age_ratio after family floaters + if ($policy_type == 2) { + $terms_array['age_ratio'] = $age_ratio; + } + + break; + + // DEFAULT CASE : + default: + // $terms_array[$item] = isJsonString($input_value) ? (json_decode($input_value, true)['key'] ?? '') : $value; + $terms_array[$item] = $value; + break; } - - // Handle sum insured - if (in_array($item, ['sum_insured', 'sumInsured2'])) { - $si_amt = explode(",", $value); - $terms_array[$item] = $si_amt[0] ?? ""; - $terms_array['multiple_sum_insured'] = array_slice($si_amt, 1); - continue; - } - - // Handle family floaters - if ($item === 'family_composition') { - $terms_array['family_floaters'] = isJsonString($input_value) ? json_decode($input_value, true) : $input_value; - continue; - } - - // Decode JSON if valid - $terms_array[$item] = isJsonString($input_value) ? - (json_decode($input_value, true)['key'] ?? '') : - $input_value; } } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 4b5c9032..d7f9628a 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -225,6 +225,7 @@ class MasterController extends AdminController 'New Basic Cover SI' => 'new_basic_cover_si', 'New SI Premium' => 'new_si_premium', 'Date of Coverage' => 'date_of_coverage', + 'Age Band' => 'age_band', ]; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 436ae854..0b6a3a7b 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -532,8 +532,10 @@ if (!function_exists('name_and_empid_check_in_db')) if (!function_exists('check_dependent_conflict')) { - function check_dependent_conflict($family_data,$policy_terms,$actionArr) - { + function check_dependent_conflict($family_data,$policy_terms,$actionArr,$is_lgbtq) + { + // dd($family_data,$policy_terms,$actionArr,$is_lgbtq); + $result = ['status' => true]; $self_gender = null; @@ -622,10 +624,14 @@ if (!function_exists('check_dependent_conflict')) // print_r(array_values(array_count_values($overall_famility_relationships))); // print_r(in_array(2,array_values(array_count_values($overall_famility_relationships)))); - if($self_gender && $spouse_gender && $self_gender == $spouse_gender) + //check if this policy is allowed LGBTQ + if($is_lgbtq == 0) { - $result['status'] = false; - $result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])]; + if($self_gender && $spouse_gender && $self_gender == $spouse_gender) + { + $result['status'] = false; + $result['error_data'][] = ['code' => 4,'col_name' => 'gender','msg' => 'Rule conflict: Self and Spouse cannot be same gender','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])]; + } } if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) ) @@ -1072,7 +1078,9 @@ if (!function_exists('transform_excel_data_to_db')) if (!function_exists('premium_calculation_manager')) { function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null) - { + { + // dd($emp_data,$policy_terms,$slab_details,$default_si); + $myLogger = \Config\Services::mylogger(); // grid type // 1 = premium => si @@ -1238,6 +1246,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1)); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; $is_match_found = true; break; } @@ -1246,12 +1255,12 @@ if (!function_exists('premium_calculation_manager')) case "5": //GMC - Employees Age + SI $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si; - $temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); - $age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y; - + $temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); + $age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y; + // kint::dump($age); foreach ($temp_slab_rates as $skey => $slab_value) { - + // dd($slab_value); if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) )) { $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; @@ -1261,6 +1270,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1)); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; $is_match_found = true; break; } @@ -1276,7 +1286,7 @@ if (!function_exists('premium_calculation_manager')) if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) )) { - // echo $emp_data['name']; + // echo $emp_data['name']; die; $emp_data['policy_details']['basic_cover_si'] = $slab_value['si']; $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']); $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; @@ -1284,6 +1294,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1)); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; $is_match_found = true; break; } @@ -1307,6 +1318,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1)); $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.',''); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; $is_match_found = true; break; @@ -1378,6 +1390,8 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],(calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days + 1)); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','')); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; + $is_match_found = true; break; } @@ -1459,6 +1473,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['premium'] = $slab_value['premium']; $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days'],calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst/100)),2,'.','')); + $emp_data['policy_details']['age_band'] = $slab_value['age_from'].'-'.$slab_value['age_to']; $is_match_found = true; break; } diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 6e9cc897..3f0d7a43 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -52,7 +52,8 @@ class ClientPolicyModel extends Model "disclaimer", "is_active", "is_member_modify_allowed", - "cd_ac_pk" + "cd_ac_pk", + "is_lgbtq", ]; // Callbacks diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 2c23c619..6a8d590d 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -35,7 +35,8 @@ class EmployeePolicyModel extends Model "claim_status", 'ecard_sent_status', 'payable_employee', - 'file_id' + 'file_id', + "age_band", ]; // Callbacks @@ -285,7 +286,10 @@ class EmployeePolicyModel extends Model employee_polices.premium, employee_polices.rata_premimum as pro_rata_premium, employee_polices.gst, + employee_polices.age_band, (employee_polices.rata_premimum + employee_polices.gst) AS total, + + batch_data.emp_policy_id, batch_data.bl AS batch_list_batch_code, batch_data.bf AS batch_files_batch_code, @@ -482,10 +486,13 @@ class EmployeePolicyModel extends Model employee_polices.pre_existing_alignments, employee_polices.policy_end_date, employee_polices.basic_cover_si as old_basic_cover_si, - employee_polices.rata_premimum as old_si_premium, + employee_polices.rata_premimum as old_si_premium, + employee_polices.age_band, + batch_data.emp_policy_id, batch_data.bl AS batch_list_batch_code, batch_data.bf AS batch_files_batch_code, + sidata.new_basic_cover_si, sidata.new_si_premium, sidata.date_of_coverage, @@ -814,6 +821,8 @@ class EmployeePolicyModel extends Model employee_polices.uhid as uhid, employee_polices.rata_premimum as premium, employee_polices.claim_status, + employee_polices.age_band, + batch_data.emp_policy_id AS emp_policy_id, batch_data.bl AS batch_list_batch_code, diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index cf219b6c..a4accd6b 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -175,14 +175,14 @@
- + +
@@ -825,6 +825,13 @@ $('#policy_visibility').prop('checked', false); } + if (res.data.is_lgbtq == 1) { + $('#is_lgbtq').prop('checked', true); + } else { + $('#is_lgbtq').prop('checked', false); + } + + // Member Modify Data Enable or Disable // if (res.data.is_member_modify_allowed == 1) { // $('#is_member_modify_allowed').prop('checked', true); @@ -1886,6 +1893,19 @@ $('#policy_visibility').prop('checked', false); } + console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') + + console.log(res.data.is_lgbtq) + + if (res.data.is_lgbtq == 1) { + $('#is_lgbtq').prop('checked', true); + } else { + $('#is_lgbtq').prop('checked', false); + } + + console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') + + if (res.data.policy_type_id == '4' || res.data.policy_type_id == '5') { diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 5e555ef2..d985fea1 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -147,13 +147,12 @@ +
+
+
+ + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index e8f0dd11..02c29f7d 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -717,6 +717,9 @@
  • Outstanding
  • +
  • + IRBA Reports +
  • From 09b3963653a04f3b1badebe8d015e97878d0681d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 24 Jan 2025 08:33:39 +0530 Subject: [PATCH 15/65] CHANGE_IRDA_REPORT_INS_CLT : RV --- app/Controllers/BDSReportController.php | 284 +++++++++++++++++- app/Controllers/ClientController.php | 14 + .../PolicyTransactionController.php | 21 +- app/Models/PolicyTypeModel.php | 2 +- app/Views/irda_bap_client_report_list.php | 226 ++++++++++++++ app/Views/irda_bap_insurer_report_list.php | 234 +++++++++++++++ app/Views/irda_client_report_list.php | 148 +++++++++ .../policy_transaction_endorsement_form.php | 21 +- .../policy_transaction_endorsement_list.php | 8 +- .../policy_transaction_inception_form.php | 33 +- 10 files changed, 964 insertions(+), 27 deletions(-) create mode 100644 app/Views/irda_bap_client_report_list.php create mode 100644 app/Views/irda_bap_insurer_report_list.php create mode 100644 app/Views/irda_client_report_list.php diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 09e872c3..dfcf2791 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -46,5 +46,287 @@ class BDSReportController extends BaseController // } - // ----------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + //Function for get BAP INSURE wise data for premium , policy count , revenue only + public function getBAPInsurerData($category = 0, $start_date = null, $end_date = null) + { + try { + $this->myLogger->logme('error', 'getBAPInsurerData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select ins.id, ins.name as insurer_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS health_revenue, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS misc_revenue, + + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS motor_revenue, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS engineering_revenue, + + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS fire_revenue, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS liability_revenue, + + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS life_revenue, + + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_cargoe_revenue, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue + + from insurers ins + left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $category + where ins.is_active = 1 + group by ins.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC; + + "); + + // Get the query + $result = $builder->getResultArray(); + $this->myLogger->logme('error', 'Query executed successfully.'); + // dd(db_connect()->getLastQuery(),$result); + return $result; + + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPInsurerData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get BAP CLIENT wise data for premium , policy count , revenue only + public function getBAPClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + $this->myLogger->logme('error', 'getBAPClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + SELECT + c.id AS client_id, + c.client_name, + + -- Health Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + + -- Misc Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + + -- Motor Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + + -- Engineering Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + + -- Fire Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + + -- Liability Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + + -- Life Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + + -- Marine Cargo Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + + -- Marine Hull Policies + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium + + FROM clients c + LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id + LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1 + LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1 + WHERE c.is_active = 1 + AND ptp.policy_category = $category + GROUP BY c.id + ORDER BY + health_premium DESC, + misc_premium DESC, + motor_premium DESC, + engineering_premium DESC, + fire_premium DESC, + liability_premium DESC, + life_premium DESC, + marine_cargo_premium DESC, + marine_hull_premium DESC + + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getBAPClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } + + //Function for get CLIENT wise data for premium and policy count only + public function getClientData($category = 0, $start_date = null, $end_date = null) + { + + try { + + $this->myLogger->logme('error', 'getClientData function called'); + $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = $start_date; + $toDate = $end_date; + } + + $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + $db = db_connect(); + $builder = $db->query(" + + select + c.id as client_id, + c.client_name, + + ( + select + count(policy_transaction.id) + from policy_transaction + left join policy_type on policy_transaction.policy_type_id = policy_type.id + where policy_transaction.client_id = c.id + and policy_transaction.action_type = 'inception' + and policy_transaction.is_active = 1 + + ) as policy_count, + + COALESCE(( + select + sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium + from co_share_stmt_details stmt + left join pt_co_share_details ptco on stmt.co_share_id = ptco.id + left join policy_transaction pt on ptco.pt_id = pt.id + where pt.client_id = c.id + and stmt.is_active = 1 + and ptco.is_active = 1 + and pt.is_active = 1 + + ), 0) as premium + + from clients c + join policy_transaction on c.id = policy_transaction.client_id + join policy_type on policy_transaction.policy_type_id = policy_type.id + where c.is_active = 1 + and policy_type.policy_category = $category + AND policy_transaction.policy_issue_date >= '$fromDate' + AND policy_transaction.policy_issue_date <= '$toDate' + group by client_name + order by premium desc + "); + + // Get the query + $result = $builder->getResultArray(); + // dd(db_connect()->getLastQuery(),$result); + return $result; + } catch (\Exception $e) { + + // Log the exception details for debugging + $this->myLogger->logme('error', 'Error occurred in getClientData: {message}', ['message' => $e->getMessage()]); + $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + return []; + } + } } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index eab0a10b..d6d1626a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4045,6 +4045,20 @@ class ClientController extends AdminController // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); // dd($returndata); + // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- + + $BDSReportController = new BDSReportController(); + + $data['data'] = $BDSReportController->getBAPInsurerData(); + return $this->loadLayout('irda_bap_insurer_report_list', $data); + + // $data['data'] = $BDSReportController->getBAPClientData(); + // return $this->loadLayout('irda_bap_client_report_list', $data); + + // $data['data'] = $BDSReportController->getClientData(); + // return $this->loadLayout('irda_client_report_list', $data); + + // $BDSReportController->getBAPClientData(); } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index ca4a1d66..8a03a1e4 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1103,20 +1103,30 @@ class PolicyTransactionController extends BaseController } - if(!empty($data['data_received_date'])){ + if(empty($data['data_received_date'])){ + $data['data_received_date'] = null; + }else{ $data['data_received_date'] = change_date_format($data['data_received_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['policy_issue_date'])){ + if(empty($data['policy_issue_date'])){ + $data['policy_issue_date'] = null; + }else{ $data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'd/m/Y', 'Y-m-d'); } - if(!empty($data['endorse_eff_date'])){ + if(empty($data['endorse_eff_date'])){ + $data['endorse_eff_date'] = null; + }else{ $data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'd/m/Y', 'Y-m-d'); + } - if(!empty($data['install_due_date'])){ + if(empty($data['install_due_date'])){ + $data['install_due_date'] = null; + }else{ $data['install_due_date'] = change_date_format($data['install_due_date'], 'd/m/Y', 'Y-m-d'); + } if(!empty($data['month'])){ @@ -1162,7 +1172,8 @@ class PolicyTransactionController extends BaseController 'policy_type_id' => $issue_type['policy_type_id'] ?? null, 'issue_type' => $issue_type['issue_type'] ?? null, 'source_client_policy_id' => $issue_type['source_client_policy_id'] ?? null, - 'cd_ac_no' => $issue_type['issue_type'] ?? null, + 'cd_ac_no' => $issue_type['cd_ac_no'] ?? null, + 'cd_ac_pk' => $issue_type['cd_ac_pk'] ?? null, // 'policy_issue_date' => $issue_type['policy_issue_date'] ?? null, 'policy_start_date' => $issue_type['policy_start_date'] ?? null, 'policy_end_date' => $issue_type['policy_end_date'] ?? null, diff --git a/app/Models/PolicyTypeModel.php b/app/Models/PolicyTypeModel.php index 29126484..90aa1758 100755 --- a/app/Models/PolicyTypeModel.php +++ b/app/Models/PolicyTypeModel.php @@ -22,6 +22,6 @@ class PolicyTypeModel extends Model "etp", "iep", "itp", - "question_json",'itep','etep' + "question_json",'itep','etep', 'policy_category', ]; } diff --git a/app/Views/irda_bap_client_report_list.php b/app/Views/irda_bap_client_report_list.php new file mode 100644 index 00000000..6ecbf234 --- /dev/null +++ b/app/Views/irda_bap_client_report_list.php @@ -0,0 +1,226 @@ + + +
    +
    +
    +
    +
    +

    BAP Client Report

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
    S. NoInsuredPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremiumPoliciesPremium
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/irda_bap_insurer_report_list.php b/app/Views/irda_bap_insurer_report_list.php new file mode 100644 index 00000000..6321f7a1 --- /dev/null +++ b/app/Views/irda_bap_insurer_report_list.php @@ -0,0 +1,234 @@ + + +
    +
    +
    +
    +
    +

    BAP Insurer Report

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EngineeringFireHealthLiabilityLifeMarine CargoMiscMotorMarine Hull
    S. NoInsurerPoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenuePoliciesPremiumRevenue
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/irda_client_report_list.php b/app/Views/irda_client_report_list.php new file mode 100644 index 00000000..70ba446f --- /dev/null +++ b/app/Views/irda_client_report_list.php @@ -0,0 +1,148 @@ + + +
    +
    +
    +
    +
    +

    Client Report

    +
    + +
    +
    + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + +
    S. NoInsuredPoliciesPremium
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 687891b4..c9d439b9 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1159,17 +1159,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1186,11 +1189,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index e08cb097..f1f00d52 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -548,10 +548,10 @@ document.addEventListener("DOMContentLoaded", function () { }); - // var closure_date = flatpickr("#policy_issue_date", { - // dateFormat: "d/m/Y", - // allowInput: false - // }); + var closure_date = flatpickr("#policy_issue_date", { + dateFormat: "d/m/Y", + allowInput: false + }); var install_due_date = flatpickr("#install_due_date", { dateFormat: "d/m/Y", diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 30df9f5a..af9416a2 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1842,17 +1842,20 @@ function amountCalculation(input) { console.log('gst_per_amt', gst_per_amt); // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2)); - if(gst_amount != 0){ - if (event.target.id.startsWith('non_comm_per_amt')) { + if (event.target.id.startsWith('non_comm_per_amt')) { + $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); + }else if (event.target.id.startsWith('gst_amount')) { + $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + }else{ + if(ncpa != 0 && ncpa != ""){ $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); }else{ - $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00'); + $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00'); } - }else{ - $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00'); } + let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt; console.log('Summed Amount:', finalTotal); @@ -1869,11 +1872,15 @@ function amountCalculation(input) { expectedAmount = agreed_amount; // console.log('Formula 1 AGREED AMOUNT'); }else if(sum_of_agreed_premium > 0){ - expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + //expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per)); + let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per; + expectedAmount = (tpTotal * sumOfTheAggreedPer); expectedAmount = expectedAmount / 100; // console.log('Formula 2 AGREED BP TP/TEP %'); }else{ - expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + // expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per)); + let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per; + expectedAmount = (tpTotal * sumOfTheStandardPer); console.log(expectedAmount) expectedAmount = expectedAmount / 100; // console.log('Formula 3 STANDARD BP TP/TEP %'); @@ -3890,9 +3897,11 @@ function populateTable(dataArray, cd_ac_pk) { case 2: // CD Account Number cell.find('select').val(cd_ac_pk); var selectElement = cell.find('select'); + console.log('selectElement', selectElement); selectElement.val(cd_ac_pk).prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) setTimeout(function(){ + console.log('selectElement', selectElement); selectElement.find('option[value="' + cd_ac_pk + '"]').prop('selected', true); selectElement.toggleClass('readonly-select', !!disable_td) }, 2000) @@ -4240,8 +4249,14 @@ function getCdAmount(cd_ac_pk, increment){ console.log('Data fetched successfully:', response); if (response.status == true) { - $('#cd_current_balance_'+increment).val(response.data.balance); - } + if(!response.data.balance){ + $('#cd_current_balance_'+increment).val(0.00); + }else{ + $('#cd_current_balance_'+increment).val(response.data.balance); + } + } else{ + $('#cd_current_balance_'+increment).val(0.00); + } }, function(xhr, status, error) { console.error('Error fetching data:', error); From c73564ec723a37c629aca2a190bc7d6e337af139 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 24 Jan 2025 09:52:14 +0530 Subject: [PATCH 16/65] FEAT_IRDA_REPORT_SRINIVAS --- app/Controllers/BDSReportController.php | 93 ++++----- app/Views/bds_report_Insurer_wise_Data.php | 153 +++++++------- app/Views/bds_report_bap_wise_data.php | 159 +++++++-------- app/Views/irba_report.php | 112 ++++++----- app/Views/layout/header.php | 219 +++++++++++---------- 5 files changed, 367 insertions(+), 369 deletions(-) diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 96ccb68f..8fbb8f3e 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -46,15 +46,13 @@ class BDSReportController extends AdminController $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->policyTypeModel = new PolicyTypeModel(); - - } - public function Insurer_wise_Data($insurerCategory,$fromDate,$toDate){ + public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) + { $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); - - if($insurerCategory == 0 || $insurerCategory == 1){ + try { $sql = " select ins.id,ins.name as insurers, COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, @@ -63,28 +61,29 @@ class BDSReportController extends AdminController from insurers ins left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 - left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) group by ins.id "; - - $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); - - - }else{ - $data['message'] = 'Insurer Category Not Valid'; - log_message('error',$data['message']); + + $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); + // log_message('error',$this->insurerModel->getLastQuery()); + // log_message('error',json_encode($data)); + } catch (\Exception $e) { + $data['message'] = 'No data Found'; + $this->myLogger->logme('error', $e->getMessage()); return $data; } - return view('bds_report_Insurer_wise_Data',$data); + return ($data); } - public function Bap_Wise_Data($insurerCategory,$fromDate,$toDate){ + public function Bap_Wise_Data($insurerCategory, $fromDate, $toDate) + { $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); - if($insurerCategory == 0 || $insurerCategory == 1){ + try { $sql = " SELECT pot.bap AS bap, @@ -92,7 +91,7 @@ class BDSReportController extends AdminController COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_amt), 0) AS Premium, COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue FROM policy_type AS pot - LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate + LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1 LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1 WHERE pot.is_active = 1 @@ -101,66 +100,70 @@ class BDSReportController extends AdminController "; $data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray(); - }else{ - $data['message'] = 'Insurer Category Not Valid'; - log_message('error',$data['message']); + } catch (\Exception $e) { + $data['message'] = 'No Data Found'; + $this->myLogger->logme('error', $e->getMessage()); return $data; } - - return view('bds_report_bap_wise_data',$data); + + return ($data); } - public function irba_report(){ + public function irba_report() + { - if ($this->request->getMethod()=='get'){ + if ($this->request->is('get')) { $default_start = new \DateTime(); $data['default_end'] = $default_start->format('d-m-Y'); $data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y'); $data['categories'] = [ - 'Life' => 'life','Non Life'=>'nonLife' + 'Life' => 'life', + 'Non Life' => 'nonLife' ]; $data['report_type'] = [ - 'Insurer'=> 'insurer', + 'Insurer' => 'insurer', 'BAP' => 'bap', 'BAP-Client' => 'bapClient', - 'BAP-Insurer' =>'bapInsurer', - 'Client' =>'client' + 'BAP-Insurer' => 'bapInsurer', + 'Client' => 'client' ]; - return $this->loadLayout('irba_report',$data); - }else{ + return $this->loadLayout('irba_report', $data); + } else { $fromDate = $this->request->getPost('fromDate'); $toDate = $this->request->getPost('toDate'); $category = $this->request->getPost('category'); $report_type = $this->request->getPost('report_type'); // log_message('error',json_encode($_POST));die(); - if($report_type == 'insurer'){ - $life = $category == 'life' ? 1:0; - $viewData = $this->Insurer_wise_Data($life,$fromDate,$toDate); - + if ($report_type == 'insurer') { + $life = $category == 'life' ? 1 : 0; + $viewData = $this->Insurer_wise_Data($life, $fromDate, $toDate); + if (isset($data['message'])) { + return $this->respond(['status'=> false,'message'=>$data['message']],200); + } // Ensure $viewData is an array if (!is_array($viewData)) { $viewData = []; } - + $html = view('bds_report_Insurer_wise_Data', $viewData); - return $this->respond(['status'=>true, 'html'=>$html], 200); - } - else if($report_type == 'bap'){ - $life = $category == 'life'?1:0; - $viewData = $this->Bap_wise_Data($life,$fromDate,$toDate); - + return $this->respond(['status' => true, 'html' => $html], 200); + } else if ($report_type == 'bap') { + $life = $category == 'life' ? 1 : 0; + $viewData = $this->Bap_wise_Data($life, $fromDate, $toDate); + if (isset($data['message'])) { + return $this->respond(['status'=> false,'message'=>$data['message']],200); + } // Ensure $viewData is an array if (!is_array($viewData)) { $viewData = []; } - + $html = view('bds_report_bap_wise_data', $viewData); - return $this->respond(['status'=>true, 'html'=>$html], 200); + return $this->respond(['status' => true, 'html' => $html], 200); } - + } } -} // ----------------------------------------------------------------------------------------- } diff --git a/app/Views/bds_report_Insurer_wise_Data.php b/app/Views/bds_report_Insurer_wise_Data.php index f93e5c55..2e7d9cff 100644 --- a/app/Views/bds_report_Insurer_wise_Data.php +++ b/app/Views/bds_report_Insurer_wise_Data.php @@ -1,5 +1,4 @@ +
    -
    -
    -
    -
    -

    Employees

    -
    +
    +
    +
    +
    +

    Employees

    -
    +
    +
    @@ -48,91 +47,85 @@ table.dataTable tbody td { - + - + - + - +
    Total AmountGrand Total
    +
    -
    + - diff --git a/app/Views/bds_report_bap_wise_data.php b/app/Views/bds_report_bap_wise_data.php index b05960a8..a75fc389 100644 --- a/app/Views/bds_report_bap_wise_data.php +++ b/app/Views/bds_report_bap_wise_data.php @@ -1,5 +1,4 @@ +
    -
    -
    -
    -
    -

    Employees

    -
    +
    +
    +
    +
    +

    Employees

    -
    - + +
    +
    + @@ -47,92 +47,85 @@ table.dataTable tbody td { - + - + - + - +
    Insurer Policies
    Total AmountGrand Total
    +
    -
    + - + // Calculate total for each column + var totalPolicies = api.column(1).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + var totalPremium = api.column(2).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + + var totalRevenue = api.column(3).data().reduce(function(a, b) { + return parseNumber(a) + parseNumber(b); + }, 0); + + // Update the footer with totals + $(api.column(1).footer()).html(totalPolicies.toLocaleString()); + $(api.column(2).footer()).html("₹ " + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })); + $(api.column(3).footer()).html("₹ " + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 })); + } + }); + } else { + console.error("Table not found."); + } + }); + \ No newline at end of file diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index 88f51ebb..97ee9cd5 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -12,15 +12,15 @@
    -
    - -
    -   - -
    - > - > +
    + +
    +   +
    + > + > +
    @@ -28,19 +28,19 @@
    - +

    @@ -59,8 +59,10 @@
    -
    +
    +
    +
    \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 02c29f7d..690cedc5 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -60,7 +60,7 @@ - + @@ -75,17 +75,15 @@ }); } - - - - - - - - + + + + + + + + +
    +
    +
    +
    + +
    +
    +

    Ticket

    +
    +
    + + + +
    +
    + + + + + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    + +
    \ No newline at end of file diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php new file mode 100644 index 00000000..8c381b92 --- /dev/null +++ b/app/Views/ticket_form_gmc.php @@ -0,0 +1,246 @@ +
    +
    +
    "> +
    + +
    +
    +

    Claim GMC

    +
    +
    + +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + +
    + +
    + +
    +
    +
    diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php new file mode 100644 index 00000000..6cac4d51 --- /dev/null +++ b/app/Views/ticket_form_gpa.php @@ -0,0 +1,173 @@ +
    +
    +
    "> +
    + +
    +
    +

    Claim GPA

    +
    +
    + +
    +
    +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/Views/ticket_history.php b/app/Views/ticket_history.php new file mode 100644 index 00000000..73e0850b --- /dev/null +++ b/app/Views/ticket_history.php @@ -0,0 +1,33 @@ +
    +
    +
    +
    + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + +
    FieldOld ValueNew ValueUserDate/Time
    +
    +
    +
    +
    diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php new file mode 100644 index 00000000..69bacaf5 --- /dev/null +++ b/app/Views/ticket_list.php @@ -0,0 +1,136 @@ + + +
    +
    +
    +
    +
    +

    Claim List

    +
    + +
    +
    + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + +
    StatusClaim numberTPA IDEmp nameInsured NameCorporate nameTAT
    + +
    +
    +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php new file mode 100644 index 00000000..f48b20d2 --- /dev/null +++ b/app/Views/ticket_mail_template.php @@ -0,0 +1,174 @@ + + +
    +
    +
    +
    +
    +

    Mail Template List

    +
    + +
    +
    + + + + + + + + + + + $row){ ?> + + + + + + + + +
    Template NameStatusPolicy Type
    + +
    +
    +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/app/Views/ticket_note.php b/app/Views/ticket_note.php new file mode 100644 index 00000000..7839c63c --- /dev/null +++ b/app/Views/ticket_note.php @@ -0,0 +1,62 @@ +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + \ No newline at end of file diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php new file mode 100644 index 00000000..0b719e33 --- /dev/null +++ b/app/Views/ticket_reply.php @@ -0,0 +1,67 @@ +
    +
    +
    +
    +
    +
    + +
    + + +
    + + +
    + + +
    + + +
    + + +
    +
    +
    + + +
    + +
    +
    +
    +
    +
    + + diff --git a/app/Views/ticket_search.php b/app/Views/ticket_search.php new file mode 100644 index 00000000..24317d79 --- /dev/null +++ b/app/Views/ticket_search.php @@ -0,0 +1,170 @@ + + +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + + +
    + +
    +
    +
    +
    + +
    +
    +
    + + +
    + +
    + + + \ No newline at end of file From 4d0070d1105b1fa203d945bd7449b05f9e27e168 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 27 Jan 2025 17:31:38 +0530 Subject: [PATCH 26/65] FIX_BDS_STMT_UPLOAD_UNICODE_CHAR_HANDLED --- app/Controllers/PolicyTransactionController.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index ca4a1d66..ea4d3901 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2204,16 +2204,19 @@ class PolicyTransactionController extends BaseController $is_row_empty = check_row_is_empty_or_null($excel_row); if(!$is_row_empty) { + // $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row); $is_source_found = 0; $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel + $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]);//policy_end_date from excel $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel - + // Kint::dump($policy_no); foreach ($source_data as $source_key => $source_row) { - $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : ""; + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; + // Kint::dump($source_endorsement_no); if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { $is_source_found = 1; @@ -2295,9 +2298,9 @@ class PolicyTransactionController extends BaseController $line_items = count($excel_data); // get uploaded month transactions data $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); - // Kint::dump($source_data);die; + // Kint::dump($source_data);//die; // Kint::dump($excel_data); - + // die; // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage $data_to_update = []; @@ -2311,13 +2314,14 @@ class PolicyTransactionController extends BaseController $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel + $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]);// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel foreach ($source_data as $source_key => $source_row) { // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); - $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : ""; + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { $is_source_found = 1; From b7154b17bc2ad96fb85b336d7d17987977a1874e Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 28 Jan 2025 09:59:42 +0530 Subject: [PATCH 27/65] FEAT_CLAIM_SEARCH_FILTER_SRINIVAS --- app/Controllers/LoginController.php | 8 ++- app/Controllers/TicketController.php | 72 +++++++++++++-------------- app/Models/TicketClaimStatusModel.php | 2 +- app/Models/TicketMasterModel.php | 8 ++- app/Views/ticket_search.php | 50 ++++++++++++++++--- 5 files changed, 90 insertions(+), 50 deletions(-) diff --git a/app/Controllers/LoginController.php b/app/Controllers/LoginController.php index b3ca2187..f5f31844 100755 --- a/app/Controllers/LoginController.php +++ b/app/Controllers/LoginController.php @@ -20,7 +20,7 @@ class LoginController extends BaseController // $isLoggedIn = check_session(); $isLoggedIn = check_session(); $hasCookie = check_cookie(); - if ($isLoggedIn || $hasCookie) { + if ($isLoggedIn && $hasCookie) { return redirect()->to(base_url('/dashboard/view')); } return view('login'); @@ -91,7 +91,11 @@ class LoginController extends BaseController { $path = getenv('cookie.Path'); session()->destroy(); - setcookie('session_data', '', time() - 3600, $path); + // setcookie('session_data', '', time() - 3600, $path); + $path = getenv('cookie.Path'); + $domain = getenv('cookie.Domain'); + $https = getenv('ccokie.secure'); + setcookie('session_data',null, time() -3600, $path, $domain, $https, true); return redirect()->to(base_url('login')); } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index f41e53b1..e13e1c75 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -4,7 +4,9 @@ namespace App\Controllers; use App\Controllers\BaseController; use CodeIgniter\HTTP\ResponseInterface; - +use App\Models\TicketMasterModel; +use App\Models\TicketClaimStatusModel; +use App\Models\ClientModel; use Psr\Log\LoggerInterface; use Kint\Kint; @@ -18,6 +20,9 @@ class TicketController extends BaseController protected $ticketType; protected $priorityType; protected $relationshipType; + protected $ticketMasterModel; + protected $claimStatus; + protected $clientModel; public function __construct() { @@ -41,6 +46,9 @@ class TicketController extends BaseController "father-in-law" => "Father-in-Law", "mother-in-law" => "Mother-in-Law" ]; + $this->ticketMasterModel = new TicketMasterModel(); + $this->claimStatus = new TicketClaimStatusModel(); + $this->clientModel = new ClientModel(); } public function ticketList() @@ -48,8 +56,8 @@ class TicketController extends BaseController if ($this->request->is('get')) { $data['page_name'] = "Claims"; $data['ticket_type'] = $this->ticketType; - $data['claim_status'] = []; - $data['client_list'] = []; + $data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active',1)->findAll(); + $data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active',1)->findAll(); return $this->loadLayout('ticket_search', $data); @@ -64,47 +72,35 @@ class TicketController extends BaseController public function ticketSearch() { $search_data = $this->request->getPost(); - // print_r($search_data); die; - - $data = [ - [ - 'id' => 1, - 'status' => 'Approved', - 'claim_no' => 'CL12345', - 'tpa_id' => 'TPA001', - 'emp_name' => 'John Doe', - 'insurer_name' => 'ABC Insurance', - 'client_name' => 'XYZ Corp', - 'tat' => '5 Days', - ], - [ - 'id' => 2, - 'status' => 'Pending', - 'claim_no' => 'CL12346', - 'tpa_id' => 'TPA002', - 'emp_name' => 'Jane Smith', - 'insurer_name' => 'DEF Insurance', - 'client_name' => 'LMN Ltd', - 'tat' => '3 Days', - ], - [ - 'id' => 3, - 'status' => 'Rejected', - 'claim_no' => 'CL12347', - 'tpa_id' => 'TPA003', - 'emp_name' => 'Alice Johnson', - 'insurer_name' => 'GHI Insurance', - 'client_name' => 'PQR Co', - 'tat' => '7 Days', - ], - ]; - + // print_r($search_data); + $where = []; + foreach ($search_data as $search_objects => $key){ + if ($key != null && $key != '' && $key!= 0 ){ + $where[$search_objects] = $key; + } + } + // print_rr($where); + $data = $this->ticketMasterModel + ->select('ticket_master.id, ticket_claim_status.claim_status as status, + ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, + insurers.name as insurer_name, clients.client_name, + DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ->join('insurers','insurers.id = ticket_master.insurer_id and insurers.is_active = 1','left') + ->join('clients','clients.id = ticket_master.client_id and clients.is_active = 1','left') + ->join('ticket_claim_status','ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1','left') + ->where('ticket_master.is_active',1) + ->where($where) + ->findAll(); + // print_rr($data); + // log_message('error',' Claims Master Data '.json_encode($data));die(); + // print_rr($data);die(); return $data; } public function ticket_form() { $data['ticket_form'] = 1; + $data['claim_status'] = ''; return $this->loadLayout('ticket_form_gmc', $data); } diff --git a/app/Models/TicketClaimStatusModel.php b/app/Models/TicketClaimStatusModel.php index d0e959e7..bc40b394 100644 --- a/app/Models/TicketClaimStatusModel.php +++ b/app/Models/TicketClaimStatusModel.php @@ -12,7 +12,7 @@ class TicketClaimStatusModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ["id", "ticket_type", "claim_status", "created_by", "updated_by", "is_active"]; // Callbacks protected $allowCallbacks = true; diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 060f1594..87e918a4 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -12,7 +12,13 @@ class TicketMasterModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ['id', 'ticket_type_id', 'claim_status_id', 'acm_id', 'insurer_id', + 'tpa_id', 'client_id', 'priority', 'policy_no', 'emp_code', 'tpa_no', 'emp_name', 'insured_name', + 'relationship', 'emp_mobile', 'emp_mail', 'mode_of_intimation', 'claim_type', 'hospital_name', + 'doa', 'dod', 'claim_amount', 'pod_no', 'created_by', 'updated_by', 'created_at', 'updated_at', + 'date_of_join', 'date_of_incep', 'dob', 'date_of_accident', 'date_of_death', 'date_of_intimat', + 'si_amt','claim_number' + ]; // Callbacks protected $allowCallbacks = true; diff --git a/app/Views/ticket_search.php b/app/Views/ticket_search.php index 24317d79..2e332cd7 100644 --- a/app/Views/ticket_search.php +++ b/app/Views/ticket_search.php @@ -10,10 +10,16 @@
    @@ -51,7 +57,7 @@ $value) { + foreach ($client_list as $key => $value) { echo ""; } } @@ -79,13 +85,13 @@
    @@ -113,6 +119,34 @@ \ No newline at end of file diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index 6cac4d51..87bf7052 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -1,11 +1,25 @@ + +
    -
    "> +
    " style="margin-right: 23px;">
    -
    -
    -

    Claim GPA

    + +
    +
    +

    Claim

    +
    +
    @@ -77,6 +91,21 @@ name="policy_no">
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    + + +
    +

    + Search by Client, Branch, and Policy + +

    +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index 69bacaf5..90b42568 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -106,7 +106,7 @@ $(document).ready(function() { text: 'New Claim', className: 'buttons-html5 addbtnStyle', action: function(e, dt, node, config) { - newClaim() + openTicketTypeAskModal() } } ], @@ -129,8 +129,4 @@ function viewTicket(ticket_id){ window.location.href = url } -function newClaim(){ - let url = '' - window.location.href = url -} \ No newline at end of file diff --git a/app/Views/ticket_type_modal.php b/app/Views/ticket_type_modal.php new file mode 100644 index 00000000..262698f5 --- /dev/null +++ b/app/Views/ticket_type_modal.php @@ -0,0 +1,47 @@ + + + \ No newline at end of file From 5a0c2698e2d7998acbe6760efe22d225024b62ce Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 28 Jan 2025 10:17:12 +0530 Subject: [PATCH 29/65] MODELS_ADDED_IN_CLAIM_SRI --- app/Controllers/TicketController.php | 10 ++++++++++ app/Models/TicketMasterModel.php | 2 +- app/Models/TicketNoteModel.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index e13e1c75..636c6b54 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -7,6 +7,10 @@ use CodeIgniter\HTTP\ResponseInterface; use App\Models\TicketMasterModel; use App\Models\TicketClaimStatusModel; use App\Models\ClientModel; +use App\Models\TicketHistoryModel; +use App\Models\TicketMailTemplateModel; +use App\Models\TicketMessageModel; +use App\Models\TicketNoteModel; use Psr\Log\LoggerInterface; use Kint\Kint; @@ -23,6 +27,10 @@ class TicketController extends BaseController protected $ticketMasterModel; protected $claimStatus; protected $clientModel; + protected $ticketHistoryModel; + protected $ticketMailTemplateModel; + protected $ticketMesageModel; + protected $ticketNoteModel; public function __construct() { @@ -49,6 +57,8 @@ class TicketController extends BaseController $this->ticketMasterModel = new TicketMasterModel(); $this->claimStatus = new TicketClaimStatusModel(); $this->clientModel = new ClientModel(); + $this->ticketHistoryModel = new TicketHistoryModel(); + } public function ticketList() diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 87e918a4..01c7679e 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -17,7 +17,7 @@ class TicketMasterModel extends Model 'relationship', 'emp_mobile', 'emp_mail', 'mode_of_intimation', 'claim_type', 'hospital_name', 'doa', 'dod', 'claim_amount', 'pod_no', 'created_by', 'updated_by', 'created_at', 'updated_at', 'date_of_join', 'date_of_incep', 'dob', 'date_of_accident', 'date_of_death', 'date_of_intimat', - 'si_amt','claim_number' + 'si_amt','claim_number,is_active' ]; // Callbacks diff --git a/app/Models/TicketNoteModel.php b/app/Models/TicketNoteModel.php index b3a62b94..c9c10746 100644 --- a/app/Models/TicketNoteModel.php +++ b/app/Models/TicketNoteModel.php @@ -12,7 +12,7 @@ class TicketNoteModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ['id,created_by','updated_by','is_active']; // Callbacks protected $allowCallbacks = true; From 5cbc1774025cbbf08c9ec6f4ce1a54d0eb97f34f Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 28 Jan 2025 10:31:35 +0530 Subject: [PATCH 30/65] CHANGE_TICKET_MASTER_MODEL_SRI --- app/Models/TicketMasterModel.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index ab41a1fe..51896dbc 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -12,15 +12,6 @@ class TicketMasterModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; -<<<<<<< HEAD - protected $allowedFields = ['id', 'ticket_type_id', 'claim_status_id', 'acm_id', 'insurer_id', - 'tpa_id', 'client_id', 'priority', 'policy_no', 'emp_code', 'tpa_no', 'emp_name', 'insured_name', - 'relationship', 'emp_mobile', 'emp_mail', 'mode_of_intimation', 'claim_type', 'hospital_name', - 'doa', 'dod', 'claim_amount', 'pod_no', 'created_by', 'updated_by', 'created_at', 'updated_at', - 'date_of_join', 'date_of_incep', 'dob', 'date_of_accident', 'date_of_death', 'date_of_intimat', - 'si_amt','claim_number,is_active' - ]; -======= protected $allowedFields = [ 'id', 'ticket_type_id', @@ -60,7 +51,6 @@ class TicketMasterModel extends Model 'claim_number' ]; ->>>>>>> 3a4f7b1e836fc71f477cb6ad32a635dcae0192d0 // Callbacks protected $allowCallbacks = true; From 060a41b6ac5cd591d3cdaa24b4d7921955bca5c7 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 28 Jan 2025 11:24:39 +0530 Subject: [PATCH 31/65] FIX_STMT_PRE_VARIANCE_ISSUE --- app/Models/PolicyTransactionModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 36fc097e..300a0eaa 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -758,7 +758,7 @@ class PolicyTransactionModel extends Model ( SELECT ( - SUM(co_share_stmt_details.actual_bp_amt) + SUM(co_share_stmt_details.actual_tp_amt) + SUM(co_share_stmt_details.actual_bp_per) + SUM(co_share_stmt_details.actual_bp_amt) + SUM(co_share_stmt_details.actual_tp_amt) + SUM(co_share_stmt_details.actual_tep_amt) ) AS total_stmt_amt FROM co_share_stmt_details @@ -778,7 +778,7 @@ class PolicyTransactionModel extends Model SELECT SUM(co_share_stmt_details.actual_bp_amt) + SUM(co_share_stmt_details.actual_tp_amt) + - SUM(co_share_stmt_details.actual_bp_per) + SUM(co_share_stmt_details.actual_tep_amt) FROM co_share_stmt_details JOIN From 5c87de3d730230296fdc3f3738bfb86fc37ed76f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Jan 2025 15:25:32 +0530 Subject: [PATCH 32/65] CHANGE_CLAIM_MODULE : RV --- app/Config/Routes.php | 3 +- app/Controllers/ClientController.php | 42 ++++++- app/Controllers/TicketController.php | 95 ++++++++++++--- app/Models/TicketMasterModel.php | 14 +-- app/Views/ticket_edit_onbording.php | 70 ++++++++++- app/Views/ticket_form_gmc.php | 73 +++++++----- app/Views/ticket_form_gpa.php | 125 +++++++++++-------- app/Views/ticket_form_handler.php | 172 ++++++++++++++++++++++----- 8 files changed, 445 insertions(+), 149 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index eb828452..08ad836a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -337,6 +337,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1'); $routes->get('transformMailContent', 'LeadsController::transformMailContent'); $routes->get('getCDAmount', 'ClientController::getCDAmount'); + $routes->get('getTheEmpDataForClaim/(:any)', 'ClientController::getTheEmpDataForClaim/$1'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { @@ -497,7 +498,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->match( ['get', 'post'], 'list','TicketController::ticketList'); $routes->get('new/(:any)','TicketController::ticket_form/$1'); $routes->post('create','TicketController::createTicket'); - $routes->get('update','TicketController::updateTicket'); + $routes->post('update','TicketController::updateTicket'); $routes->get('view/(:any)','TicketController::view_ticket/$1'); $routes->get('mail_template','TicketController::createMailTemplate'); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 38192213..ad47e155 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4138,6 +4138,46 @@ class ClientController extends AdminController } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); } - } + } + + public function getTheEmpDataForClaim($client_policy_id) + { + $data = $this->clientPolicyModel->select(" + + clients.id as client_id, + clients.client_name, + insurers.id as insurer_id, + insurers.name as insurer_name, + tpa.id as tpa_id, + tpa.name as tpa_name, + + employees.id as emp_id, + employees.name as emp_name, + employees.emp_code, + employees.mobile as emp_mobile, + employees.email_corporate as emp_email, + + employee_polices.uhid as policy_no, + ") + ->join('clients', 'client_policy.client_id = clients.id', 'left') + ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') + ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left') + ->join('employees', 'clients.id = employees.client_id', 'left') + ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') + ->where('client_policy.id',) + ->where('client_policy.is_active', 1) + ->where('insurers.is_active', 1) + ->where('tpa.is_active', 1) + ->where('employees.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('client_policy.id', $client_policy_id) + ->findAll(); + + if($data){ + return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found', "client_policy_id" =>$client_policy_id], 200); + } + } } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index c489e247..4da42c00 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -135,6 +135,12 @@ class TicketController extends BaseController public function ticket_form($ticket_type) { + $data = $this->ticket_form_data($ticket_type); + return $this->loadLayout('ticket_form_handler', $data); + } + + public function ticket_form_data($ticket_type) + { $data['ticket_form'] = 1; $data['ticket_type'] = $this->ticketType; $data['priorityType'] = $this->priorityType; @@ -156,12 +162,9 @@ class TicketController extends BaseController ->getResultArray(); if($ticket_type == 1){ - $data['modeOFIntimate'] = $this->claimType[1]; - return $this->loadLayout('ticket_form_handler', $data); + $data['claim_type'] = $this->claimType[1]; }else{ - - $data['modeOFIntimate'] = $this->claimType[2]; - + $data['claim_type'] = $this->claimType[2]; if($ticket_type == 2){ $data['ticket_form'] = 'GPA'; }else if($ticket_type = 3){ @@ -169,34 +172,79 @@ class TicketController extends BaseController }else if($ticket_type = 4){ $data['ticket_form'] = 'GTLI'; } - - return $this->loadLayout('ticket_form_handler', $data); } + + return $data; } public function view_ticket($ticket_id) - { - $data = []; + { + $ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); + $ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y'); + // dd($ticket_data); + $data = $this->ticket_form_data($ticket_data['ticket_type_id']); + $data['ticket_data'] = $ticket_data; return $this->loadLayout('ticket_edit_onbording', $data); } - public function createTicket() - { - $ticket_data = $this->request->getPost(); - // print_rr($ticket_data); die; + public function formatDateForClaim($ticket_data, $out_put_format = 'Y-m-d') + { if(empty($ticket_data['doa'])){ $ticket_data['doa'] = null; }else{ - $ticket_data['doa'] = change_date_format($ticket_data['doa']); + $ticket_data['doa'] = change_date_format($ticket_data['doa'], null, $out_put_format); } if(empty($ticket_data['dod'])){ $ticket_data['dod'] = null; }else{ - $ticket_data['dod'] = change_date_format($ticket_data['dod']); + $ticket_data['dod'] = change_date_format($ticket_data['dod'], null, $out_put_format); } + if(empty($ticket_data['dob'])){ + $ticket_data['dob'] = null; + }else{ + $ticket_data['dob'] = change_date_format($ticket_data['dob'], null, $out_put_format); + } + + if(empty($ticket_data['date_of_join'])){ + $ticket_data['date_of_join'] = null; + }else{ + $ticket_data['date_of_join'] = change_date_format($ticket_data['date_of_join'], null, $out_put_format); + } + + if(empty($ticket_data['date_of_incep'])){ + $ticket_data['date_of_incep'] = null; + }else{ + $ticket_data['date_of_incep'] = change_date_format($ticket_data['date_of_incep'], null, $out_put_format); + } + + if(empty($ticket_data['date_of_accident'])){ + $ticket_data['date_of_accident'] = null; + }else{ + $ticket_data['date_of_accident'] = change_date_format($ticket_data['date_of_accident'], null, $out_put_format); + } + + if(empty($ticket_data['date_of_death'])){ + $ticket_data['date_of_death'] = null; + }else{ + $ticket_data['date_of_death'] = change_date_format($ticket_data['date_of_death'], null, $out_put_format); + } + + if(empty($ticket_data['date_of_intimat'])){ + $ticket_data['date_of_intimat'] = null; + }else{ + $ticket_data['date_of_intimat'] = change_date_format($ticket_data['date_of_intimat'], null, $out_put_format); + } + + return $ticket_data; + } + + public function createTicket() + { + $ticket_data = $this->request->getPost(); + $ticket_data = $this->formatDateForClaim($ticket_data); // print_rr($ticket_data); die; if($ticket_data){ @@ -212,7 +260,22 @@ class TicketController extends BaseController } public function updateTicket() - { + { + $ticket_id = $this->request->getPost('ticket_master_id'); + $ticket_data = $this->request->getPost(); + $ticket_data = $this->formatDateForClaim($ticket_data); + // print_rr($ticket_data); die; + + if($ticket_data){ + $return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update(); + if($return_value){ + return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim updated successfully"], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update claim'], 200); + } + }else{ + return $this->respond(['status' => false, 'code' => 404, 'message' => 'claim data not found'], 200); + } } public function createMailTemplate() diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index ab41a1fe..1d980ed5 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -12,15 +12,6 @@ class TicketMasterModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; -<<<<<<< HEAD - protected $allowedFields = ['id', 'ticket_type_id', 'claim_status_id', 'acm_id', 'insurer_id', - 'tpa_id', 'client_id', 'priority', 'policy_no', 'emp_code', 'tpa_no', 'emp_name', 'insured_name', - 'relationship', 'emp_mobile', 'emp_mail', 'mode_of_intimation', 'claim_type', 'hospital_name', - 'doa', 'dod', 'claim_amount', 'pod_no', 'created_by', 'updated_by', 'created_at', 'updated_at', - 'date_of_join', 'date_of_incep', 'dob', 'date_of_accident', 'date_of_death', 'date_of_intimat', - 'si_amt','claim_number,is_active' - ]; -======= protected $allowedFields = [ 'id', 'ticket_type_id', @@ -57,10 +48,11 @@ class TicketMasterModel extends Model 'date_of_intimat', 'si_amt', 'is_active', - 'claim_number' + 'claim_number', + 'emp_id', + 'insured_emp_id', ]; ->>>>>>> 3a4f7b1e836fc71f477cb6ad32a635dcae0192d0 // Callbacks protected $allowCallbacks = true; diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index 22b50aba..20873990 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -22,25 +22,29 @@ diff --git a/app/Views/renewal_search.php b/app/Views/renewal_search.php index 7876090f..341020f9 100644 --- a/app/Views/renewal_search.php +++ b/app/Views/renewal_search.php @@ -12,7 +12,7 @@
    -
    +
    @@ -23,10 +23,24 @@ >
    +
    + + +
    +
    - - @@ -34,8 +48,8 @@
    - -
    @@ -55,11 +69,17 @@
    -
    -
    -
    +
    + - \ No newline at end of file From 75c00c20cea990b0dc48d89d7ecc00d83c813c18 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 31 Jan 2025 15:16:45 +0530 Subject: [PATCH 45/65] FEAT_UNLAYER_ADDED_TO_ALL_MAIL_TEMPLATES_SRI --- app/Views/notification old.php | 2009 +++++++++++++++++++++++++ app/Views/notification.php | 2594 +++++++++++++++----------------- 2 files changed, 3261 insertions(+), 1342 deletions(-) create mode 100644 app/Views/notification old.php diff --git a/app/Views/notification old.php b/app/Views/notification old.php new file mode 100644 index 00000000..ed5f8ee5 --- /dev/null +++ b/app/Views/notification old.php @@ -0,0 +1,2009 @@ + +
    + +
    +
    + +
    + + + +
    +

    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    + +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    +
    +
    + Submit +
    +
    +
    + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/notification.php b/app/Views/notification.php index cb738661..051d2f98 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -14,15 +14,14 @@ min-height: 600px; } -#account_maneger_summary_mail_modal .modal-dialog, -#member_review_and_summary_mail_modal .modal-dialog { +.modal-dialog { max-width: 90% !important; width: 90% !important; } /* Also ensure the modal body has proper height */ -#account_maneger_summary_mail_modal .modal-body, -#member_review_and_summary_mail_modal .modal-body { + +.modal-body { min-height: 600px; padding: 20px; } @@ -34,178 +33,178 @@
    - +
    -
    - +
    +
    -

    + ?>

    -
    +
    -
    -
    - - -
    -
    - - -
    +
    +
    + +
    - -
    -
    - - -
    -
    - - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    - -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    -
    -
    - Submit -
    +
    + +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    + +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    +
    +
    + Submit +
    +
    +
    +
    @@ -217,7 +216,7 @@
    -
    +
    - - - - - + \ No newline at end of file From d537185d2204ddd52f5b6b9defb5d8c91d3e0c80 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 31 Jan 2025 15:30:56 +0530 Subject: [PATCH 46/65] FIX_MAIL_SENDER_IN_EMPRESTCONTROLLER_SRI --- app/Controllers/EmployeeRestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 800f6941..0b26b442 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3159,7 +3159,7 @@ class EmployeeRestController extends AdminController if ($mail_sent_status->status == 'success') { $sent_message_data['ticket_id'] = $ticket_id; - $sent_message_data['sender'] = 'user'; + $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; From 491f3e001013b9ed15db7495d2be550908c2fed3 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 31 Jan 2025 18:08:24 +0530 Subject: [PATCH 47/65] FEAT_EMP_TABLE_VIA_AJAX, FIX_MAIL_TEMPLATE_IN_CLAIMS --- app/Controllers/EmployeeController.php | 7 ++++- app/Views/employee_list.php | 38 +++++++++++++++----------- app/Views/ticket_mail_template.php | 4 +-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 9e81f1a9..050437cd 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -97,7 +97,7 @@ class EmployeeController extends AdminController // Convert the status field to an array if it exists in the request data if (isset($filterData['status']) && !empty($filterData['status'])) { - $filterData['status'] = explode(",", $filterData['status']); + // $filterData['status'] = explode(",", $filterData['status']); }else{ $filterData['status'] = []; } @@ -114,6 +114,11 @@ class EmployeeController extends AdminController // log_message('error',json_encode($data['employees'])); // Set getData in $data array with the processed $filterData $data['getData'] = $filterData; + + // return view('employee_list',$data); + $html = view('employee_data_list', $data); + return $this->respond(['status' => true, 'html' => $html], 200); + } // dd($this->employeeModel->getLastQuery()); diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 255d8278..7c35a42d 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -135,8 +135,9 @@ table.dataTable tbody td { - + +
    @@ -502,24 +503,29 @@ function fetchEmpolyeeList(event) { const queryString = objectToQueryString(queryParams); const apiURL = $('#get-emp-list').attr('href') + "?" + queryString; // console.log(apiURL); - window.location.href = apiURL; + // window.location.href = apiURL; // var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value - // console.log(apiURL); - // $.ajax({ - // url: apiURL, - // method: 'GET', - // data: queryParams, - // success: function(response) { - // // Assuming response is a JSON array - // // displayDataTables(response); - // console.log(response); - // }, - // error: function(xhr, status, error) { - // console.error('Error:', error); - // } - // }); + console.log(apiURL); + $.ajax({ + url: apiURL, + method: 'GET', + data: queryParams, + success: function(response) { + if(response.status == true){ + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + $('#employee_table_list').html(response.html); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }, + error: function(xhr, status, error) { + console.error('Error:', error); + toastr.error('Failed to fetch Data','Error'); + } + }); } diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index e36b2718..1100e26a 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -191,10 +191,10 @@ table.dataTable tbody td { - +
    - +
    + name="policy_no">
    @@ -127,6 +127,20 @@ name="emp_name">
    +
    + + +
    + +
    + + +
    +
    diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 6e5532a3..9e9a6eb5 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -257,7 +257,16 @@ function toggleAccordion(id) { const content = document.getElementById(id); const arrow = document.querySelector(`#${id === 'mobileAccordion' ? 'mobileArrow' : 'clientBranchArrow'}`); - // Toggle the display of the accordion content + // Define the other accordion to close + const otherId = id === 'mobileAccordion' ? 'clientBranchAccordion' : 'mobileAccordion'; + const otherContent = document.getElementById(otherId); + const otherArrow = document.querySelector(`#${id === 'mobileAccordion' ? 'clientBranchArrow' : 'mobileArrow'}`); + + // Close the other accordion + otherContent.classList.remove('show'); + otherArrow.classList.remove('rotate'); + + // Toggle the current accordion if (content.classList.contains('show')) { content.classList.remove('show'); arrow.classList.remove('rotate'); @@ -267,6 +276,7 @@ function toggleAccordion(id) { } } + function openFetchEmpDataodal() { var myModal = new bootstrap.Modal(document.getElementById('empDetailsModal')); myModal.show(); @@ -343,6 +353,7 @@ function appendBranch(data) { //append the clients policy data to the modal function appendPolicy(data) { + let ticket_type = $('#ticket_type_id').val(); $('#emp_client_policy_data_list').empty(); $('#emp_client_policy_data_list').append($('
    -
    +
    -
    +
    -
    +
    @@ -480,7 +480,7 @@ function getMailTemplateData(id) { $('#template_name').val(res.data.template_name); $('#primaryKey').val(res.data.id); $('#policy_type').val(res.data.ticket_type).change(); - $('#trigger_type').val(res.data.ticket_type).change(); + $('#trigger_type').val(res.data.trigger_type).change(); $('.jodit-wysiwyg').html(res.data.mail_content); // Set the auto mail switch diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php index c3faa0b4..f26143fd 100644 --- a/app/Views/ticket_reply.php +++ b/app/Views/ticket_reply.php @@ -7,7 +7,7 @@
    - +
    From af64affae4043e8d9c1e1ef2b166349a6b399f56 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 3 Feb 2025 10:26:49 +0530 Subject: [PATCH 53/65] FEAT_CHATBOT_INIATED --- .../Chatbot/EcardDownloadConversation.php | 2 +- .../Chatbot/MainMenuConversation.php | 20 +++-- .../Chatbot}/NetworkHospitalConversation.php | 19 ++++- .../ReimbursementClaimProcessConversation.php | 47 +++++++++++ .../ReimbursementClaimStatusConversation.php | 47 +++++++++++ .../commonPolicyOptionConversations.php | 50 +++++++++++ .../doYouWantToContinueConversation.php | 48 +++++++++++ .../fourWheelerOptionsConversations.php | 50 +++++++++++ .../Chatbot/hospitalPolicyConversation.php | 49 +++++++++++ .../medicalClaimOptionConversations.php | 50 +++++++++++ .../Chatbot/policyConversation.php | 55 ++++++++++++ .../Chatbot/serviceExecutiveConversation.php | 60 ++++++++++++++ .../twoWheelerOptionsConversations.php | 50 +++++++++++ .../Chatbot/vehicleFormConversation.php | 83 +++++++++++++++++++ app/Controllers/ChatbotControllerNew.php | 4 +- app/Helpers/ChatbotHelper.php | 39 ++++++++- app/Models/EmployeePolicyModel.php | 13 +++ app/Views/chatbot.php | 4 +- composer.json | 2 +- 19 files changed, 678 insertions(+), 14 deletions(-) rename app/{ => Controllers/Chatbot}/NetworkHospitalConversation.php (61%) create mode 100644 app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php create mode 100644 app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php create mode 100644 app/Controllers/Chatbot/commonPolicyOptionConversations.php create mode 100644 app/Controllers/Chatbot/doYouWantToContinueConversation.php create mode 100644 app/Controllers/Chatbot/fourWheelerOptionsConversations.php create mode 100644 app/Controllers/Chatbot/hospitalPolicyConversation.php create mode 100644 app/Controllers/Chatbot/medicalClaimOptionConversations.php create mode 100644 app/Controllers/Chatbot/policyConversation.php create mode 100644 app/Controllers/Chatbot/serviceExecutiveConversation.php create mode 100644 app/Controllers/Chatbot/twoWheelerOptionsConversations.php create mode 100644 app/Controllers/Chatbot/vehicleFormConversation.php diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php index 0cc82314..19fad42f 100644 --- a/app/Controllers/Chatbot/EcardDownloadConversation.php +++ b/app/Controllers/Chatbot/EcardDownloadConversation.php @@ -51,7 +51,7 @@ class EcardDownloadConversation extends Conversation $link = base_url().'/download-e-card/' . explode('#',$answer->getValue())[1].'/1'; $this->say('Click here to downlad: Ecard'); - $this->bot->startConversation(new EcardDownloadConversation()); // ✅ Restart the + $this->bot->startConversation(new doYouWantToContinueConversation()); // ✅ Restart the break; diff --git a/app/Controllers/Chatbot/MainMenuConversation.php b/app/Controllers/Chatbot/MainMenuConversation.php index 01b1c576..8a36512c 100644 --- a/app/Controllers/Chatbot/MainMenuConversation.php +++ b/app/Controllers/Chatbot/MainMenuConversation.php @@ -2,6 +2,7 @@ namespace App\Controllers\Chatbot; +use App\Helpers\ChatbotHelper; use BotMan\BotMan\Messages\Conversations\Conversation; use BotMan\BotMan\Messages\Outgoing\Question; use BotMan\BotMan\Messages\Outgoing\Actions\Button; @@ -28,24 +29,30 @@ class MainMenuConversation extends Conversation $this->bot->ask($question, function ($answer) { switch ($answer->getValue()) { case "ecard_download": - $this->say("📄 Ecard Download Menu:"); - $this->bot->startConversation(new EcardDownloadConversation()); + + $message = ChatbotHelper::get_payload_data(); + $this->say($message); + // $this->say("📄 Ecard Download Menu:"); + // $this->bot->startConversation(new EcardDownloadConversation()); break; case "network_hospital": - $this->say("🏥 Network Hospital Menu:"); + $this->say("🏥 Network Hospital Menu:");log_message('error','Network Hospital clicked'); $this->bot->startConversation(new NetworkHospitalConversation()); break; case "reimbursement_claim": - $this->say("Reimbursement Claim Process selected. (Dummy Response)"); + // $this->say("Reimbursement Claim Process selected. (Dummy Response)"); + $this->bot->startConversation(new ReimbursementClaimProcessConversation()); break; case "reimbursement_status": $this->say("Reimbursement Claim Status selected. (Dummy Response)"); + $this->bot->startConversation(new ReimbursementClaimStatusConversation()); + break; case "new_policy": - $this->say("New Policy selected. (Dummy Response)"); + $this->bot->startConversation(new policyConversation()); break; case "renew_policy": - $this->say("Renew Policy selected. (Dummy Response)"); + $this->bot->startConversation(new policyConversation()); break; default: $this->say("Invalid selection. Please choose an option."); @@ -54,4 +61,5 @@ class MainMenuConversation extends Conversation } }); } + } diff --git a/app/NetworkHospitalConversation.php b/app/Controllers/Chatbot/NetworkHospitalConversation.php similarity index 61% rename from app/NetworkHospitalConversation.php rename to app/Controllers/Chatbot/NetworkHospitalConversation.php index 70e71340..004b6ef6 100644 --- a/app/NetworkHospitalConversation.php +++ b/app/Controllers/Chatbot/NetworkHospitalConversation.php @@ -7,8 +7,12 @@ use BotMan\BotMan\Messages\Conversations\Conversation; use BotMan\BotMan\Messages\Outgoing\Question; use BotMan\BotMan\Messages\Outgoing\Actions\Button; +use App\Helpers\ChatbotHelper; + class NetworkHospitalConversation extends Conversation { + + public function run() { $this->showHospitalMenu(); @@ -26,10 +30,20 @@ class NetworkHospitalConversation extends Conversation $this->bot->ask($question, function ($answer) { switch ($answer->getValue()) { case "search_city": - $this->say("Searching by City... (Dummy Response)"); + $this->bot->ask("Enter the City Name",function ($response){ + // $cityName = $response->getText(); + $hospital_link = ChatbotHelper::getHospitalLink(); + $this->say("Searching for hospitals in ....."); + + $this->say('Click here for hospital details'); + $this->bot->startConversation(new doYouWantToContinueConversation()); + }); break; case "search_pincode": - $this->say("Searching by Pincode... (Dummy Response)"); + $this->bot->ask("Enter the Pincode",function ($response){ + $pincode = $response->getText(); + $this->say("Searching for hospitals in ".$pincode.'.....'); + }); break; case "go_back": $this->bot->startConversation(new MainMenuConversation()); @@ -41,4 +55,5 @@ class NetworkHospitalConversation extends Conversation } }); } + } diff --git a/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php b/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php new file mode 100644 index 00000000..b1cf1ec0 --- /dev/null +++ b/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php @@ -0,0 +1,47 @@ +claimProcess(); + } + + protected function claimProcess() + { + $question = Question::create("Do you Need Anything Else ?") + ->addButtons([ + Button::create("🔹 Yes I need some more Help")->value("yes"), + Button::create("🔹 No, Thank You")->value("no"), + // Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "yes": + + $this->say("Sure, How can I help you "); + $this->bot->startConversation(new MainMenuConversation()); + break; + case "no": + $this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!"); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->askQuestion(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php b/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php new file mode 100644 index 00000000..4c6b58dc --- /dev/null +++ b/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php @@ -0,0 +1,47 @@ +claimStatus(); + } + + protected function claimStatus() + { + $question = Question::create("Do you Need Anything Else ?") + ->addButtons([ + Button::create("🔹 Yes I need some more Help")->value("yes"), + Button::create("🔹 No, Thank You")->value("no"), + // Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "yes": + + $this->say("Sure, How can I help you "); + $this->bot->startConversation(new MainMenuConversation()); + break; + case "no": + $this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!"); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->askQuestion(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/commonPolicyOptionConversations.php b/app/Controllers/Chatbot/commonPolicyOptionConversations.php new file mode 100644 index 00000000..e32c318b --- /dev/null +++ b/app/Controllers/Chatbot/commonPolicyOptionConversations.php @@ -0,0 +1,50 @@ +policyOptions(); + } + + protected function policyOptions() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🔹 Upload Vehicle Details")->value("upload_vehicle_details"), + Button::create("🔹 Talk to our Service Executive")->value("service_executive"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "upload_vehicle_details": + // $cityName = $response->getText(); + $this->bot->startConversation(new vehicleFormConversation()); + break; + case "service_executive": + $this->bot->startConversation(new serviceExecutiveConversation()); + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->policyOptions(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/doYouWantToContinueConversation.php b/app/Controllers/Chatbot/doYouWantToContinueConversation.php new file mode 100644 index 00000000..4da9aed7 --- /dev/null +++ b/app/Controllers/Chatbot/doYouWantToContinueConversation.php @@ -0,0 +1,48 @@ +askQuestion(); + } + + protected function askQuestion() + { + $question = Question::create("Do you Need Anything Else ?") + ->addButtons([ + Button::create("🔹 Yes I need some more Help")->value("yes"), + Button::create("🔹 No, Thank You")->value("no"), + // Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "yes": + + $this->say("Sure, How can I help you "); + $this->bot->startConversation(new MainMenuConversation()); + break; + case "no": + $this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!"); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->askQuestion(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/fourWheelerOptionsConversations.php b/app/Controllers/Chatbot/fourWheelerOptionsConversations.php new file mode 100644 index 00000000..6c850c03 --- /dev/null +++ b/app/Controllers/Chatbot/fourWheelerOptionsConversations.php @@ -0,0 +1,50 @@ +show4WOptions(); + } + + protected function show4WOptions() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🔹 Comprehensive")->value("comp"), + Button::create("🔹 Third-Party Only")->value("3p"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "3p": + // $cityName = $response->getText(); + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "comp": + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->showHospitalMenu(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/hospitalPolicyConversation.php b/app/Controllers/Chatbot/hospitalPolicyConversation.php new file mode 100644 index 00000000..4a29c918 --- /dev/null +++ b/app/Controllers/Chatbot/hospitalPolicyConversation.php @@ -0,0 +1,49 @@ +showMediclaimPolicyOptions(); + } + + protected function showMediclaimPolicyOptions() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🔹 Individual")->value("individual"), + Button::create("🔹 Floater")->value("floater"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "individual": + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "floater": + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->showHospitalMenu(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/medicalClaimOptionConversations.php b/app/Controllers/Chatbot/medicalClaimOptionConversations.php new file mode 100644 index 00000000..db66cda3 --- /dev/null +++ b/app/Controllers/Chatbot/medicalClaimOptionConversations.php @@ -0,0 +1,50 @@ +showMediclaimOptions(); + } + + protected function showMediclaimOptions() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🔹 Individual")->value("individual"), + Button::create("🔹 Floater")->value("floater"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "individual": + // $cityName = $response->getText(); + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "floater": + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->showHospitalMenu(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/policyConversation.php b/app/Controllers/Chatbot/policyConversation.php new file mode 100644 index 00000000..9a3c2669 --- /dev/null +++ b/app/Controllers/Chatbot/policyConversation.php @@ -0,0 +1,55 @@ +showNewPolicy(); + } + + protected function showNewPolicy() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🏍️ 2 Wheeler")->value("2_wheeler"), + Button::create("🚗 4 Wheeler")->value("4_wheeler"), + Button::create("🩺 Medical Claim")->value("mediclaim"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "2_wheeler": + // $cityName = $response->getText(); + $this->bot->startConversation(new twoWheelerOptionsConversations()); + break; + case "4_wheeler": + $this->bot->startConversation(new fourWheelerOptionsConversations()); + break; + case "mediclaim": + $this->bot->startConversation(new medicalClaimOptionConversations()); + + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->showHospitalMenu(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/serviceExecutiveConversation.php b/app/Controllers/Chatbot/serviceExecutiveConversation.php new file mode 100644 index 00000000..64a3e842 --- /dev/null +++ b/app/Controllers/Chatbot/serviceExecutiveConversation.php @@ -0,0 +1,60 @@ +askServiceExecutive(); + } + + protected function askServiceExecutive() + { + $mobile = ChatbotHelper::getPhoneNumber(); // Assuming this fetches the user's phone number + $question = Question::create("Is this Your Mobile Number: $mobile") + ->addButtons([ + Button::create("✅ Yes")->value("yes"), + Button::create("❌ No")->value("no"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "yes": + $this->say("Our executive will call you at the earliest."); + $this->bot->startConversation(new doYouWantToContinueConversation()); + break; + + case "no": + $this->ask('Enter Your Mobile Number?', function ($response) { + $this->mobile_number = $response->getText(); + $this->bot->userStorage()->save([ + 'mobile_number' => $this->mobile_number + ]); + // Use 'use' to bring the class context into the closure + $this->say("Our executive will call you at the earliest."); + $this->bot->startConversation(new doYouWantToContinueConversation()); + }); + break; + + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + + default: + $this->say("Invalid selection. Please choose an option."); + $this->askServiceExecutive(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/twoWheelerOptionsConversations.php b/app/Controllers/Chatbot/twoWheelerOptionsConversations.php new file mode 100644 index 00000000..44c1f4da --- /dev/null +++ b/app/Controllers/Chatbot/twoWheelerOptionsConversations.php @@ -0,0 +1,50 @@ +show2WOptions(); + } + + protected function show2WOptions() + { + $question = Question::create("Choose Policy Type:") + ->addButtons([ + Button::create("🔹 Third-Party")->value("3p"), + Button::create("🔹 Comprehensive")->value("comp"), + Button::create("◀️ Go Back")->value("go_back"), + ]); + + $this->bot->ask($question, function ($answer) { + switch ($answer->getValue()) { + case "3p": + // $cityName = $response->getText(); + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "comp": + $this->bot->startConversation(new commonPolicyOptionConversations()); + break; + case "go_back": + $this->bot->startConversation(new MainMenuConversation()); + break; + default: + $this->say("Invalid selection. Please choose an option."); + $this->showHospitalMenu(); + break; + } + }); + } + +} diff --git a/app/Controllers/Chatbot/vehicleFormConversation.php b/app/Controllers/Chatbot/vehicleFormConversation.php new file mode 100644 index 00000000..aa80c550 --- /dev/null +++ b/app/Controllers/Chatbot/vehicleFormConversation.php @@ -0,0 +1,83 @@ +askVehicleName(); + } + + protected function askVehicleName() + { + $this->ask('Enter Vehicle Name ?', function ($response) { + $this->vehicleName = $response->getText(); + if (empty($this->vehicleName)) { + $this->say('Vehicle Name Cannot be Empty'); + return $this->askVehicleName(); // Re-ask if empty + } + $this->askVehicleYOM(); // Ask next question + }); + } + + protected function askVehicleYOM() + { + $this->ask('Enter Vehicle Year of Manufacture ?', function ($response) { + $this->vehicleYOM = $response->getText(); + if (empty($this->vehicleYOM)) { + $this->say('Vehicle Year of Manufacture Cannot be Empty'); + return $this->askVehicleYOM(); // Re-ask if empty + } + $this->askVehicleEngineNo(); // Ask next question + }); + } + + protected function askVehicleEngineNo() + { + $this->ask('Enter Vehicle Engine Number ?', function ($response) { + $this->vehicleEngineNo = $response->getText(); + if (empty($this->vehicleEngineNo)) { + $this->say('Vehicle Engine Number Cannot be Empty'); + return $this->askVehicleEngineNo(); // Re-ask if empty + } + $this->askVehicleInvoiceNo(); // Ask next question + }); + } + + protected function askVehicleInvoiceNo() + { + $this->ask('Enter Vehicle Invoice Number ?', function ($response) { + $this->vehicleInvoiceNo = $response->getText(); + if (empty($this->vehicleInvoiceNo)) { + $this->say('Vehicle Invoice Number Cannot be Empty'); + return $this->askVehicleInvoiceNo(); // Re-ask if empty + } + $this->storeVehicleData(); // Proceed to store the data + }); + } + + protected function storeVehicleData() + { + // Save all collected data to user storage + $this->bot->userStorage()->save([ + 'vehicle_name' => $this->vehicleName, + 'vehicle_yom' => $this->vehicleYOM, + 'vehicle_engine_no' => $this->vehicleEngineNo, + 'vehicle_invoice_no' => $this->vehicleInvoiceNo + ]); + + $this->say('Vehicle Information Saved!'); + $this->bot->startConversation(new doYouWantToContinueConversation()); + + } +} diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index fc6bd75a..a43111eb 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -54,10 +54,12 @@ class ChatbotControllerNew extends BaseController { // Start the Main Menu when user says "hi" or "start" $this->botman->hears('start|hi|hello', function (BotMan $bot) { - $bot->reply('How how can i assit?'); + $bot->reply('Hi how can i assit?'); $bot->startConversation(new MainMenuConversation()); }); + + // $this->botman->hears('main_menu', function (BotMan $bot) { // BotService::sendMainOptions($bot); // }); diff --git a/app/Helpers/ChatbotHelper.php b/app/Helpers/ChatbotHelper.php index 0b547cd0..03abeeeb 100644 --- a/app/Helpers/ChatbotHelper.php +++ b/app/Helpers/ChatbotHelper.php @@ -5,6 +5,8 @@ namespace App\Helpers; use App\Models\EmployeeModel; use App\Models\CDMasterModel; +use App\Models\EmployeePolicyModel; +use App\Models\TPAModel; class ChatbotHelper { @@ -19,9 +21,44 @@ class ChatbotHelper $client_branch_id = 126; $relationship ='Father'; $EmployeeModel = new EmployeeModel(); - return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]); + return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]); } + public static function getHospitalLink(){ + $client_policy_id = 336; + $emp_id = 12288; + $EmployeePolicyModel = new EmployeePolicyModel(); + return $EmployeePolicyModel->getHospitalLinkByPolicyandEmp(336,12288); + } + + public static function getPhoneNumber(){ + $emp_id = 12288; + $EmployeeModel = new EmployeeModel(); + return $EmployeeModel->select('mobile')->where('id',$emp_id)->first()['mobile']; + } + + public static function get_payload_data(string $key = null) + { + // Get the request object using the service helper + $request = service('request'); + + // Get the raw input (JSON or other data) + $rawInput = $request->getBody(); + + // Check if the raw input is valid JSON + $payload = json_decode($rawInput, true); + + if (json_last_error() === JSON_ERROR_NONE) { + // JSON is valid, return the requested key or the entire payload + return $key ? ($payload[$key] ?? null) : $payload; + } else { + // JSON is invalid, fallback to raw input or POST data + $payload = $request->getRawInput() ?: $request->getPost(); + return $key ? ($payload[$key] ?? null) : $payload; + } + } + + } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 1d79f36d..67db3017 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1744,4 +1744,17 @@ class EmployeePolicyModel extends Model return $result[0]; } + + public function getHospitalLinkByPolicyandEmp($client_policy_id,$emp_id){ + $data = $this->db->table('employee_polices') + ->select('tpa.network_hospitals') + ->where('client_policy_id', $client_policy_id) + ->where('employee_polices.is_active', 1) + ->join('tpa', 'tpa.id = employee_polices.tpa_id AND tpa.is_active = 1') + ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id) + ->get()->getResultArray()[0]; + + // var_dump($this->db->getLastQuery()); + return $data; + } } \ No newline at end of file diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index 77adf697..adbeb587 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -24,8 +24,8 @@ var uid = Math.floor(100000 + Math.random() * 900000); console.log('CURRENT_USER' + uid); var botmanWidget = { - chatServer: "https://localhost/PHP828APPS/ruc/nhance/chat", // Make sure this URL is correct - frameEndpoint: 'https://localhost/PHP828APPS/ruc/nhance/widget', // This should match your CI4 + chatServer: ``, // Make sure this URL is correct + frameEndpoint: ``, // This should match your CI4 title: "Ask ஆதிரை", introMessage: "", bubbleBackground: "#007bff", diff --git a/composer.json b/composer.json index 467fb3a4..bbe0843f 100755 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "psr/http-message": "^1.0", "psr/log": "^1.1", "slim/slim": "^4.13", - "symfony/cache": "^7.2", + "symfony/cache": "^6.0", "zircote/swagger-php": "^4.8" }, "require-dev": { From b07a37fc8443bfe42d423bc3df5dc2e22a30e6b9 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 3 Feb 2025 10:53:06 +0530 Subject: [PATCH 54/65] FIX_FETCH_EMP_DATA --- app/Models/EmployeePolicyModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 274b0a0b..58f36daa 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1135,7 +1135,7 @@ class EmployeePolicyModel extends Model public function getEmployeePolicyForFileList($client_id, $policy_id) { - $result = $this->select(['employee_polices.*','pt.policy_type','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile']) + $result = $this->select(['employee_polices.*','pt.policy_type','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile','cp.policy_type_id']) ->join('employees emp', 'employee_polices.employee_id = emp.id') ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy ->join('policy_type pt', 'cp.policy_type_id = pt.id') //pm - policy master From be1b6734191c2ab554177857ef589a2385294437 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 3 Feb 2025 18:01:33 +0530 Subject: [PATCH 55/65] FEAT_SEND_AUTO_QUERY_MAIL_SRI --- app/Config/Routes.php | 1 + app/Controllers/TicketController.php | 203 +++++++++++++++++---------- app/Models/TicketMasterModel.php | 6 +- app/Models/TicketMessageModel.php | 2 +- app/Models/TicketNoteModel.php | 2 +- app/Views/ticket_auto_query.php | 98 +++++++++++++ app/Views/ticket_edit_onbording.php | 10 ++ app/Views/ticket_list.php | 26 +++- app/Views/ticket_note.php | 6 +- app/Views/ticket_reply.php | 2 +- 10 files changed, 271 insertions(+), 85 deletions(-) create mode 100644 app/Views/ticket_auto_query.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3d8b8f42..2f294b04 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -412,6 +412,7 @@ $routes->get('cli/sendZeptoMail', 'MasterController::testZeptoSMTP'); $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); +$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery'); $routes->get("processjob", "JobWorker::processJob"); $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken'); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index e3817ef5..43b0bf0d 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -109,6 +109,7 @@ class TicketController extends BaseController '((CLAIM_NO))' => 'claim_number', '((RELATIONSHIP))' => 'relationship', '((POLICY_TYPE))' => 'policy_type', + '((AUTO_QUERY_CONTENT))' => 'auto_query_content', ]; $this->ticketMasterModel = new TicketMasterModel(); @@ -145,9 +146,9 @@ class TicketController extends BaseController if ($action == 1) { $data = $this->ticketMasterModel ->select('ticket_master.id, ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, - insurers.name as insurer_name, clients.client_name, - DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, + insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, + DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') @@ -169,9 +170,9 @@ class TicketController extends BaseController // print_rr($where); $data = $this->ticketMasterModel ->select('ticket_master.id, ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, - insurers.name as insurer_name, clients.client_name, - DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, + insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, + DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') @@ -250,7 +251,7 @@ class TicketController extends BaseController $ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y'); // dd($ticket_data); $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); - if(!empty($template_data)){ + if (!empty($template_data)) { $template_data['mail_content'] = $this->replacePlaceholders($template_data['mail_content'], $ticket_data); $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); } @@ -423,8 +424,10 @@ class TicketController extends BaseController // action = 1 is read, action 2 is insert/update if ($action == 1) { $ticket_master_id = $this->request->getPost('id'); + $is_auto_query = $this->request->getPost('is_auto_query'); + // print_rr($is_auto_query); if (isset($ticket_master_id) && $ticket_master_id != '') { - $data = $this->ticketNoteModel->where('is_active', 1)->where('ticket_id', $ticket_master_id)->first(); + $data = $this->ticketNoteModel->where('is_active', 1)->where('ticket_id', $ticket_master_id)->where('is_auto_query', $is_auto_query)->first(); if ($data) { return $this->respond(['status' => true, 'data' => $data], 200); } else { @@ -434,10 +437,13 @@ class TicketController extends BaseController } elseif ($action == 2) { $data = $this->request->getPost(); // if (isset($data['id']) && $data['id'] != ''){ + // print_rr($data);die(); $status = $this->ticketNoteModel->save($data); + $id = isset($data['id']) ? $data['id'] : $this->ticketNoteModel->insertID(); + // } if ($status) { - return $this->respond(['status' => true], 200); + return $this->respond(['status' => true, 'id' => $id], 200); } else { return $this->respond(['status' => false], 200); } @@ -532,12 +538,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; } @@ -570,9 +576,9 @@ class TicketController extends BaseController if ($value == "emp_code") { $replaceData = $ticket_data[$value] ?? ''; - }else if($value == "policy_type"){ + } else if ($value == "policy_type") { $replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? ""); - }else{ + } else { $replaceData = strtoupper($ticket_data[$value]) ?? ''; } @@ -589,9 +595,9 @@ class TicketController extends BaseController public function sendTrigger($mail_content) { $this->myLogger->logme('error', "Sending email with content"); - if(!empty($mail_content)){ + if (!empty($mail_content)) { $response = MailHelper::send_email($mail_content); - }else{ + } else { $response = ['status' => false, 'code' => 404, 'message' => "Mail not sent, mail data empty"]; $this->myLogger->logme('error', "Mail not sent, mail data empty"); } @@ -615,14 +621,14 @@ class TicketController extends BaseController } $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($mail_data['ticket_id']); - + // print_rr($ticket_data);die(); if (!$ticket_data) { - $this->myLogger->logme('error', "No ticket data found for Ticket ID : " .$mail_data['ticket_id']); + $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)){ + 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); } @@ -653,10 +659,10 @@ class TicketController extends BaseController $mail_content = $this->constructMailContent($ticket_id); // print_r($mail_content); die; $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'); + } 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; @@ -733,61 +739,106 @@ class TicketController extends BaseController AND th.is_active = 1 ORDER BY th.created_at DESC"; - $data = $this->ticketHistoryModel->query($sql)->getResultArray(); - $priorityType = $this->priorityType; - $relationshipType = $this->relationshipType; - $modeOFIntimate = $this->modeOFIntimate; - $claim_type = $this->claimType; - foreach ($data as &$row) { - if ($row['field_name'] == 'claim_status_id') { - $new_old_value = isset($row['old_status_value']) ? $row['old_status_value'] : '-'; - $new_new_value = $row['new_status_value']; - $row['old_value'] = $new_old_value; - $row['new_value'] = $new_new_value; - } elseif ($row['field_name'] == 'acm_id') { - $new_old_value = isset($row['old_account_manager']) ? $row['old_account_manager'] : '-'; - $new_new_value = $row['new_account_manager']; - $row['old_value'] = $new_old_value; - $row['new_value'] = $new_new_value; - } elseif ($row['field_name'] == 'insured_emp_id') { - $new_old_value = isset($row['old_insured_id_name']) ? $row['old_insured_id_name'] : '-'; - $new_new_value = $row['new_insured_id_name']; - $row['old_value'] = $new_old_value; - $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 = 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 = 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 = 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 = 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; + $data = $this->ticketHistoryModel->query($sql)->getResultArray(); + $priorityType = $this->priorityType; + $relationshipType = $this->relationshipType; + $modeOFIntimate = $this->modeOFIntimate; + $claim_type = $this->claimType; + foreach ($data as &$row) { + if ($row['field_name'] == 'claim_status_id') { + $new_old_value = isset($row['old_status_value']) ? $row['old_status_value'] : '-'; + $new_new_value = $row['new_status_value']; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'acm_id') { + $new_old_value = isset($row['old_account_manager']) ? $row['old_account_manager'] : '-'; + $new_new_value = $row['new_account_manager']; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'insured_emp_id') { + $new_old_value = isset($row['old_insured_id_name']) ? $row['old_insured_id_name'] : '-'; + $new_new_value = $row['new_insured_id_name']; + $row['old_value'] = $new_old_value; + $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 = 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 = 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 = 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 = 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; + } + } - } - } + return ($data); + } - return ($data); + public function sendMailWithAutoQuery() + { + + $ticket_ids = $this->ticketMessageModel + ->select('ticket_master.id') + ->join('ticket_master', 'ticket_master.id = ticket_messages.ticket_id AND ticket_master.is_active = 1 and ticket_master.claim_status_id in (4,17,27,37)') + ->join('ticket_claim_status AS tcs', 'tcs.id = ticket_messages.claim_status AND (tcs.is_active = 1)') + ->join('ticket_notes', 'ticket_notes.ticket_id = ticket_messages.ticket_id AND ticket_notes.is_auto_query = 1 AND ticket_notes.is_active = 1') + ->where('ticket_messages.is_active', 1) + ->where('ticket_messages.claim_status in (4,17,27,37)') + ->groupBy('ticket_master.id') + ->having('DATEDIFF(CURDATE(), MAX(ticket_messages.created_at)) =', 7) + ->having('count(ticket_messages.id) < ', 6) + ->findAll(); + + + // var_dump($ticket_ids);die(); + foreach ($ticket_ids as $ticket) { + + $ticket_id = $ticket['id']; + $acm_mails = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + + $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); + + if (!empty($template_data)) { + $template_data['mail_content'] = $this->replacePlaceholders($template_data['mail_content'], $ticket_data); + $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); + } + $emailData = [ + 'mail' => $template_data['emp_mail'], + 'subject' => $template_data['subject'], + 'message' => $template_data['mail_content'], + 'common' => [], + 'cc' => $acm_mails['common_mails'], + 'attachments' => [] + ]; + + $this->myLogger->logme('error', "Final Reply Email Data"); + // var_dump($emailData); + $this->sendTrigger($emailData); + } + + return 'Ticket id\'s : '.json_encode($ticket_ids); } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 28b3215f..2d562005 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -105,7 +105,7 @@ class TicketMasterModel extends Model public function getTemplateDataByTicketID($ticket_id) { $template_data = $this - ->select("ticket_mail_template.*, ticket_master.emp_mail") + ->select("ticket_mail_template.*, ticket_master.emp_mail,ticket_master.claim_status_id") ->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1') ->join('ticket_mail_template', ' ticket_claim_status.trigger_type = ticket_mail_template.trigger_type @@ -131,11 +131,13 @@ class TicketMasterModel extends Model clients.client_name, insurers.name as insurer_name, - tpa.name as tpa_name + tpa.name as tpa_name, + ticket_notes.note as auto_query_content ") ->join('clients', 'ticket_master.client_id = clients.id', 'left') ->join('insurers', 'ticket_master.insurer_id = insurers.id', 'left') ->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left') + ->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1','left') ->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) diff --git a/app/Models/TicketMessageModel.php b/app/Models/TicketMessageModel.php index 37de2edb..88926fff 100644 --- a/app/Models/TicketMessageModel.php +++ b/app/Models/TicketMessageModel.php @@ -12,7 +12,7 @@ class TicketMessageModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['id','sender','ticket_id','mail_subject','emp_mail','mail_content','created_at']; + protected $allowedFields = ['id','sender','ticket_id','claim_status','mail_subject','emp_mail','mail_content','created_at']; // Callbacks diff --git a/app/Models/TicketNoteModel.php b/app/Models/TicketNoteModel.php index 7efe2281..24f54be3 100644 --- a/app/Models/TicketNoteModel.php +++ b/app/Models/TicketNoteModel.php @@ -12,7 +12,7 @@ class TicketNoteModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['id','ticket_id','note','created_by','updated_by','is_active']; + protected $allowedFields = ['id','ticket_id','note','is_auto_query','created_by','updated_by','is_active']; // Callbacks protected $allowCallbacks = true; diff --git a/app/Views/ticket_auto_query.php b/app/Views/ticket_auto_query.php new file mode 100644 index 00000000..68865fd2 --- /dev/null +++ b/app/Views/ticket_auto_query.php @@ -0,0 +1,98 @@ +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + +
    + +
    +
    +
    + + + \ No newline at end of file diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index 2928a664..778a16e1 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -49,6 +49,13 @@ History + @@ -72,6 +79,9 @@
    +
    + +
    diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index 90b42568..d340881a 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -25,6 +25,20 @@ table.dataTable tbody td { margin-left: 20px !important; } + + +
    @@ -52,12 +66,14 @@ table.dataTable tbody td { $row){ ?> - + + + - - + + @@ -77,6 +93,10 @@ table.dataTable tbody td { diff --git a/app/Views/claims_report_acc_manager_gpa.php b/app/Views/claims_report_acc_manager_gpa.php new file mode 100644 index 00000000..b1523e04 --- /dev/null +++ b/app/Views/claims_report_acc_manager_gpa.php @@ -0,0 +1,203 @@ + + +
    +
    +
    +
    +
    +

    Insurer List

    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OPENCLEARED
    Account MangerClaim IntimationIntimation to InsurerClient PendingInsurer PendingInvestigationApprovedOn HoldTotalNot CoveredClosedSettledTotal
    Grand Total
    +
    +
    +
    +
    + + diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php new file mode 100644 index 00000000..3682ca00 --- /dev/null +++ b/app/Views/claims_report_tpa_wise.php @@ -0,0 +1,210 @@ + + +
    +
    +
    +
    +
    +

    Insurer List

    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OPENCLEARED
    TPAID Not GeneratedNon-IDCDAInformation RequiredUnder ProcessApprovedPayment InitiatedTotalClosedSettledReturnedDeniedTotal
    Grand Total
    +
    +
    +
    +
    + + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index fa265d9c..f26439e5 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -658,6 +658,9 @@
  • Mail Template
  • +
  • + Claim Reports +
  • diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php index 28a782f4..fffb138d 100644 --- a/app/Views/ticket_reply.php +++ b/app/Views/ticket_reply.php @@ -34,7 +34,7 @@
    -
    +
    diff --git a/app/Views/ticket_reports.php b/app/Views/ticket_reports.php new file mode 100644 index 00000000..4fe9732d --- /dev/null +++ b/app/Views/ticket_reports.php @@ -0,0 +1,140 @@ +
    +
    +
    +
    +
    + + + +
    +
    +
    + +
    +
    + +
    +   + +
    + > + > +
    + + +
    +
    + +
    + + +
    +
    + +
    + + +
    +
    + +
    + Submit +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + + \ No newline at end of file From eba590d90767ff12e518d17d482091e0e055e9f3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 4 Feb 2025 15:39:18 +0530 Subject: [PATCH 58/65] FEAT_TAT_BAND_WISE : RV --- app/Controllers/ClientController.php | 16 +++- app/Models/TicketMasterModel.php | 120 ++++++++++++++++++++++++ app/Views/tat_report_band_wise_list.php | 101 ++++++++++++++++++++ 3 files changed, 234 insertions(+), 3 deletions(-) create mode 100644 app/Views/tat_report_band_wise_list.php diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4dd09ce2..7f340fa5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -45,6 +45,7 @@ use App\Controllers\GoogleDriveController; use App\Helpers\sendMailNotification; use App\Models\RFQModel; +use App\Models\TicketMasterModel; class ClientController extends AdminController { @@ -4047,11 +4048,11 @@ class ClientController extends AdminController // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- - $BDSReportController = new BDSReportController(); + // $BDSReportController = new BDSReportController(); - $data['data'] = $BDSReportController->getBAPInsurerData(); + // $data['data'] = $BDSReportController->getBAPInsurerData(); - return $this->loadLayout('irda_bap_insurer_report_list', $data); + // return $this->loadLayout('irda_bap_insurer_report_list', $data); // $data['data'] = $BDSReportController->getBAPClientData(); // return $this->loadLayout('irda_bap_client_report_list', $data); @@ -4080,6 +4081,15 @@ class ClientController extends AdminController // $result = MailHelper::send_email($data[0]); // echo json_encode($result); // log_message('error',json_encode($result)); + + //-------------------------------------------------------------------------------------------------------- + + $ticketModel = new TicketMasterModel(); + $reportData['data'] = $ticketModel->getTATReport(1); + // print_rr($reportData); + $this->loadLayout('tat_report_band_wise_list', $reportData); + // $data = $ticketModel->getTATReport(1); + } // ------------------------------------------------------------------------------------------------------- diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 2d562005..87998389 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -146,5 +146,125 @@ class TicketMasterModel extends Model return $ticket_data; } + //get TAT report BAND wise Data + public function getTATReport($ticket_type = null, $start_date = null, $end_date = null) + { + //set default last 3 months data date + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + if (!empty($start_date) && !empty($end_date)) { + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); + } + $ticket_type_data_1 = ""; + $ticket_type_data_2 = ""; + if(!empty($ticket_type)){ + $ticket_type_data_1 = "WHERE ticket_type = $ticket_type"; + $ticket_type_data_2 = "AND tm.ticket_type_id = $ticket_type"; + } + + // Fetch claim statuses from the `ticket_claim_status` table + $statusQuery = " SELECT + id, claim_status + FROM ticket_claim_status + $ticket_type_data_1 + "; + $statusResult = $this->db->query($statusQuery)->getResultArray(); + // dd($statusResult); + + // Initialize dynamic query parts + $dynamicSelect = ''; + + // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT + foreach ($statusResult as $status) { + // Dynamically add the COALESCE and CASE for each status in the SELECT part + $dynamicSelect .= " + COALESCE( + SUM( + CASE + WHEN subquery.status_id = {$status['id']} THEN 1 + ELSE 0 + END + ), + 0 + ) AS `{$status['claim_status']}`, "; + } + + // Remove the trailing comma from the SELECT part + $dynamicSelect = rtrim($dynamicSelect, ', '); + // dd($dynamicSelect); + + + // Construct the full SQL query + $sql = " + SELECT + tc.TAT_Category, + $dynamicSelect + FROM + ( + SELECT 'Above 20 Days' AS TAT_Category + UNION ALL + SELECT '13-20 Days' + UNION ALL + SELECT '7-12 Days' + UNION ALL + SELECT '0-6 Days' + ) AS tc + LEFT JOIN ( + SELECT + th.ticket_id, + tcs.claim_status, + tcs.id AS status_id, + CASE + WHEN DATEDIFF( + th.created_at, + COALESCE(tm.updated_at, th.created_at) + ) BETWEEN 0 AND 6 THEN '0-6 Days' + WHEN DATEDIFF( + th.created_at, + COALESCE(tm.updated_at, th.created_at) + ) BETWEEN 7 AND 12 THEN '7-12 Days' + WHEN DATEDIFF( + th.created_at, + COALESCE(tm.updated_at, th.created_at) + ) BETWEEN 13 AND 20 THEN '13-20 Days' + ELSE 'Above 20 Days' + END AS TAT_Category + FROM + ticket_master tm + JOIN ticket_history th ON tm.id = th.ticket_id + JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' + AND th.new_value = tcs.id + $ticket_type_data_2 + AND tm.created_at >= '$fromDate' + AND tm.created_at <= '$toDate' + ) AS subquery ON tc.TAT_Category = subquery.TAT_Category + GROUP BY + tc.TAT_Category + ORDER BY + FIELD( + tc.TAT_Category, + 'Above 20 Days', + '13-20 Days', + '7-12 Days', + '0-6 Days' + ); + "; + + // Execute the query and return the result + $data = $this->db->query($sql)->getResultArray(); + // dd($this->db->getLastQuery(), $data); + + $tableData = []; + if (!empty($data)) { + // Extract table headers from the first row keys + $headers = array_keys($data[0]); + $tableData['headers'] = $headers; + $tableData['body'] = $data; + } + + return $data; + } + } diff --git a/app/Views/tat_report_band_wise_list.php b/app/Views/tat_report_band_wise_list.php new file mode 100644 index 00000000..204b4542 --- /dev/null +++ b/app/Views/tat_report_band_wise_list.php @@ -0,0 +1,101 @@ + + +
    +
    +
    +
    +
    +

    TAT Band Wise Report

    +
    + +
    +
    + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    +
    +
    +
    + + + + \ No newline at end of file From 66dedc24e7d7d4722293fe66a42e8b7748661df4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 4 Feb 2025 15:51:27 +0530 Subject: [PATCH 59/65] CHANGE_ADD_TAT_WISE_REPORT_VIEW_FILE : RV --- app/Controllers/ClientController.php | 6 +++--- app/Controllers/TicketController.php | 8 +++++++- app/Models/TicketMasterModel.php | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7f340fa5..6714a44d 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4084,10 +4084,10 @@ class ClientController extends AdminController //-------------------------------------------------------------------------------------------------------- - $ticketModel = new TicketMasterModel(); - $reportData['data'] = $ticketModel->getTATReport(1); + // $ticketModel = new TicketMasterModel(); + // $reportData['data'] = $ticketModel->getTATReport(1); // print_rr($reportData); - $this->loadLayout('tat_report_band_wise_list', $reportData); + // $this->loadLayout('tat_report_band_wise_list', $reportData); // $data = $ticketModel->getTATReport(1); } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 3da804a2..d8af5e1c 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -865,7 +865,7 @@ class TicketController extends BaseController $fromDate = \DateTime::createFromFormat('d-m-Y', $from_Date)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $to_Date)->format('Y-m-d'); $policy_type = $received_data['policy_type']; -// print_rr($received_data); + // print_rr($received_data); if ($received_data['report_type'] == "acc_manager_wise_status"){ $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type,$fromDate,$toDate); @@ -884,6 +884,12 @@ class TicketController extends BaseController $html = view('claims_report_tpa_wise',$viewData); return $this->respond(['status' => true, 'html' => $html], 200); + }else if ($received_data['report_type'] == 'tat_band_wise'){ + + $viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate); + $html = view('tat_report_band_wise_list',$viewData); + return $this->respond(['status' => true, 'html' => $html], 200); + } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 87998389..def64345 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -160,7 +160,7 @@ class TicketMasterModel extends Model $ticket_type_data_1 = ""; $ticket_type_data_2 = ""; if(!empty($ticket_type)){ - $ticket_type_data_1 = "WHERE ticket_type = $ticket_type"; + $ticket_type_data_1 = "AND ticket_type = $ticket_type"; $ticket_type_data_2 = "AND tm.ticket_type_id = $ticket_type"; } @@ -168,6 +168,7 @@ class TicketMasterModel extends Model $statusQuery = " SELECT id, claim_status FROM ticket_claim_status + Where is_active = 1 $ticket_type_data_1 "; $statusResult = $this->db->query($statusQuery)->getResultArray(); @@ -239,6 +240,9 @@ class TicketMasterModel extends Model $ticket_type_data_2 AND tm.created_at >= '$fromDate' AND tm.created_at <= '$toDate' + AND tm.is_active = 1 + AND th.is_active = 1 + AND tcs.is_active = 1 ) AS subquery ON tc.TAT_Category = subquery.TAT_Category GROUP BY tc.TAT_Category @@ -256,13 +260,13 @@ class TicketMasterModel extends Model $data = $this->db->query($sql)->getResultArray(); // dd($this->db->getLastQuery(), $data); - $tableData = []; - if (!empty($data)) { - // Extract table headers from the first row keys - $headers = array_keys($data[0]); - $tableData['headers'] = $headers; - $tableData['body'] = $data; - } + // $tableData = []; + // if (!empty($data)) { + // // Extract table headers from the first row keys + // $headers = array_keys($data[0]); + // $tableData['headers'] = $headers; + // $tableData['body'] = $data; + // } return $data; } From 6fc54650de48ce6557d9a8625d19f0b97f8b008d Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 4 Feb 2025 15:51:39 +0530 Subject: [PATCH 60/65] FEAT_CHAT_CONTD --- .../Chatbot/MainMenuConversation.php | 9 +- .../Chatbot/NetworkHospitalConversation.php | 65 +++++--- .../ReimbursementClaimProcessConversation.php | 37 ++--- app/Controllers/Chatbot/TypingMiddleware.php | 27 ++++ .../doYouWantToContinueConversation.php | 4 +- app/Controllers/ChatbotControllerNew.php | 13 ++ app/Helpers/ChatbotHelper.php | 152 +++++++++++++++++- app/Models/EmployeePolicyModel.php | 6 +- app/Views/chatbot.php | 6 +- 9 files changed, 260 insertions(+), 59 deletions(-) create mode 100644 app/Controllers/Chatbot/TypingMiddleware.php diff --git a/app/Controllers/Chatbot/MainMenuConversation.php b/app/Controllers/Chatbot/MainMenuConversation.php index 011806f0..2c9059f9 100644 --- a/app/Controllers/Chatbot/MainMenuConversation.php +++ b/app/Controllers/Chatbot/MainMenuConversation.php @@ -11,6 +11,9 @@ class MainMenuConversation extends Conversation { public function run() { + + $this->bot->types(); // Typing indicator for the first message + sleep(0.5); // Delay $this->showMainMenu(); } @@ -30,10 +33,10 @@ class MainMenuConversation extends Conversation switch ($answer->getValue()) { case "ecard_download": - $message = ChatbotHelper::get_payload_data(); - $this->say($message); + // $message = ChatbotHelper::get_payload_data(); + // $this->say($message); // $this->say("📄 Ecard Download Menu:"); - // $this->bot->startConversation(new EcardDownloadConversation()); + $this->bot->startConversation(new EcardDownloadConversation()); break; case "network_hospital": $this->say("🏥 Network Hospital Menu:");log_message('error','Network Hospital clicked'); diff --git a/app/Controllers/Chatbot/NetworkHospitalConversation.php b/app/Controllers/Chatbot/NetworkHospitalConversation.php index 004b6ef6..10bc3b7d 100644 --- a/app/Controllers/Chatbot/NetworkHospitalConversation.php +++ b/app/Controllers/Chatbot/NetworkHospitalConversation.php @@ -15,42 +15,65 @@ class NetworkHospitalConversation extends Conversation public function run() { + $this->bot->types(); // Typing indicator for the first message + sleep(0.5); // Delay $this->showHospitalMenu(); } protected function showHospitalMenu() { - $question = Question::create("Choose your Network Hospital option:") - ->addButtons([ - Button::create("🔹 Search by City")->value("search_city"), - Button::create("🔹 Search by Pincode")->value("search_pincode"), - Button::create("◀️ Go Back")->value("go_back"), - ]); + $policy_list = ChatbotHelper::getListOfPolicies(); + $buttons = []; + $question = 'Choose Policy:'; + if(is_array($policy_list) && count($policy_list)) + { + foreach($policy_list as $policy) + { + // $question = Question::create("Choose Policy to Download Ecard:") + // ->addButtons([ + // Button::create("🔹 $policy['policy_name']")->value("$policy['emp_policy_id']"), + // Button::create("◀️ Go Back")->value("go_back"), + // ]); + $buttons[] = Button::create("🔹 {$policy['policy_name']}")->value($policy['emp_policy_id'].'#'.$policy['rand_string']); + } + } + else + { + $question = 'No policy found'; + } + $buttons = array_merge($buttons,[Button::create("◀️ Go Back")->value("go_back")]); + $question = Question::create($question) + ->addButtons($buttons); + // $this->bot->hears('.*', function ($bot) { + // $this->bot->types(); // Typing indicator for the first message + // sleep(0.5); // Delay + // }); + $this->bot->ask($question, function ($answer) { switch ($answer->getValue()) { - case "search_city": - $this->bot->ask("Enter the City Name",function ($response){ - // $cityName = $response->getText(); - $hospital_link = ChatbotHelper::getHospitalLink(); - $this->say("Searching for hospitals in ....."); + case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2: + + $client_poilicy_id = explode('#',$answer->getValue())[1]; + $hospital_link = ChatbotHelper::getHospitalLink($client_poilicy_id); - $this->say('Click here for hospital details'); - $this->bot->startConversation(new doYouWantToContinueConversation()); - }); - break; - case "search_pincode": - $this->bot->ask("Enter the Pincode",function ($response){ - $pincode = $response->getText(); - $this->say("Searching for hospitals in ".$pincode.'.....'); - }); + if($hospital_link) + { + $this->say('Click here for hospital details'); + } + else + { + $this->say('No Data found, please contact support team'); + } + + $this->bot->startConversation(new doYouWantToContinueConversation()); break; case "go_back": $this->bot->startConversation(new MainMenuConversation()); break; default: $this->say("Invalid selection. Please choose an option."); - $this->showHospitalMenu(); + $this->bot->startConversation(new EcardDownloadConversation()); break; } }); diff --git a/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php b/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php index b1cf1ec0..ca3bf60a 100644 --- a/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php +++ b/app/Controllers/Chatbot/ReimbursementClaimProcessConversation.php @@ -7,41 +7,30 @@ use BotMan\BotMan\Messages\Conversations\Conversation; use BotMan\BotMan\Messages\Outgoing\Question; use BotMan\BotMan\Messages\Outgoing\Actions\Button; +use App\Helpers\ChatbotHelper; class ReimbursementClaimProcessConversation extends Conversation { - - public function run() { + $this->bot->types(); // Typing indicator for the first message + sleep(0.5); // Delay $this->claimProcess(); } protected function claimProcess() { - $question = Question::create("Do you Need Anything Else ?") - ->addButtons([ - Button::create("🔹 Yes I need some more Help")->value("yes"), - Button::create("🔹 No, Thank You")->value("no"), - // Button::create("◀️ Go Back")->value("go_back"), - ]); + $res = ChatbotHelper::sendReimbursementProcessOverMail(); + if($res == true) + { + $this->say("Reimbursement process shared over your registered mail...!"); + } + else + { + $this->say("No email found in your profile / Please contact support team"); + } - $this->bot->ask($question, function ($answer) { - switch ($answer->getValue()) { - case "yes": + $this->bot->startConversation(new doYouWantToContinueConversation()); - $this->say("Sure, How can I help you "); - $this->bot->startConversation(new MainMenuConversation()); - break; - case "no": - $this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!"); - break; - default: - $this->say("Invalid selection. Please choose an option."); - $this->askQuestion(); - break; - } - }); } - } diff --git a/app/Controllers/Chatbot/TypingMiddleware.php b/app/Controllers/Chatbot/TypingMiddleware.php new file mode 100644 index 00000000..047d246b --- /dev/null +++ b/app/Controllers/Chatbot/TypingMiddleware.php @@ -0,0 +1,27 @@ +myLogger = \Config\Services::mylogger(); + $this->myLogger->logme('error', 'MIDDLEWARE'); + + // Simulate typing indicator + $bot->types(); + sleep(0.1); // Cap delay at 5 seconds (convert to microseconds) + // Proceed to the next middleware or response + return $next($bot); + } +} diff --git a/app/Controllers/Chatbot/doYouWantToContinueConversation.php b/app/Controllers/Chatbot/doYouWantToContinueConversation.php index 4da9aed7..ba5c1864 100644 --- a/app/Controllers/Chatbot/doYouWantToContinueConversation.php +++ b/app/Controllers/Chatbot/doYouWantToContinueConversation.php @@ -15,6 +15,8 @@ class doYouWantToContinueConversation extends Conversation public function run() { + $this->bot->types(); // Typing indicator for the first message + sleep(3); // Delay $this->askQuestion(); } @@ -31,7 +33,7 @@ class doYouWantToContinueConversation extends Conversation switch ($answer->getValue()) { case "yes": - $this->say("Sure, How can I help you "); + // $this->say("Sure, How can I help you "); $this->bot->startConversation(new MainMenuConversation()); break; case "no": diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index a43111eb..4311a9bb 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -8,7 +8,9 @@ use BotMan\BotMan\Drivers\DriverManager; use BotMan\BotMan\Cache\SymfonyCache; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use BotMan\Drivers\Web\WebDriver; + use App\Controllers\Chatbot\MainMenuConversation; +use App\Controllers\Chatbot\TypingMiddleware; use App\Helpers\ChatbotHelper; @@ -32,6 +34,12 @@ class ChatbotControllerNew extends BaseController // Setup BotMan with cache $cache = new SymfonyCache(new FilesystemAdapter()); $this->botman = BotManFactory::create([], $cache); + // Create a new instance of BotMan + // $botman = resolve('botman'); + + // Attach the TypingMiddleware + // $this->botman->middleware->received(new TypingMiddleware()); + // Retrieve user ID from session or request $extras = request()->getGet('conf'); @@ -52,6 +60,11 @@ class ChatbotControllerNew extends BaseController public function index() { + + $this->botman->hears('.*', function ($bot) { + $bot->types(); // Typing indicator for the first message + sleep(0.5); // Delay + }); // Start the Main Menu when user says "hi" or "start" $this->botman->hears('start|hi|hello', function (BotMan $bot) { $bot->reply('Hi how can i assit?'); diff --git a/app/Helpers/ChatbotHelper.php b/app/Helpers/ChatbotHelper.php index 03abeeeb..9fc63f25 100644 --- a/app/Helpers/ChatbotHelper.php +++ b/app/Helpers/ChatbotHelper.php @@ -8,6 +8,8 @@ use App\Models\CDMasterModel; use App\Models\EmployeePolicyModel; use App\Models\TPAModel; +use App\Helpers\MailHelper; + class ChatbotHelper { //get list of policies againest an employee_id @@ -24,11 +26,13 @@ class ChatbotHelper return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]); } - public static function getHospitalLink(){ - $client_policy_id = 336; - $emp_id = 12288; + public static function getHospitalLink($client_policy_id){ + // $client_policy_id = 336; + // $emp_id = 12288; $EmployeePolicyModel = new EmployeePolicyModel(); - return $EmployeePolicyModel->getHospitalLinkByPolicyandEmp(336,12288); + $res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($client_policy_id); + + return is_array($res) && count($res) ? $res[0]['network_hospitals'] : null; } public static function getPhoneNumber(){ @@ -58,6 +62,146 @@ class ChatbotHelper } } + public static function sendReimbursementProcessOverMail() + { + $emp_id = 12288; + $emp_code = 'HTL-007'; + $client_id = 159; + $policy_id = 0; + $client_branch_id = 126; + $relationship ='Father'; + $EmployeeModel = new EmployeeModel(); + $data = $EmployeeModel->find($emp_id); + if(isset($data) && isset($data['email_corporate'])) + { + $message = SELF::ReimbursementProcessMailTemplate(); + + $attachments = [ + ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"], + ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], + ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] + ]; + + + $common = ['mail_type'=>'reimbursement_mail_process_bot']; + $email_id = $data['email_corporate']; + $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); + + $res = json_decode($res); + if($res->status == 'success') + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + + } + + public static function ReimbursementProcessMailTemplate() + { + $template = ' + + + + + How to Claim Your Insurance Reimbursement + + + + +
    +

    How to Claim Your Insurance Reimbursement

    +

    Dear [Customer Name],

    +

    We are here to assist you in claiming your insurance reimbursement smoothly. Please follow the steps below:

    + +
    +
      +
    1. Gather Documents: Collect all required documents such as bills, invoices, and medical reports.
    2. +
    3. Complete the Claim Form: Fill out the insurance claim form accurately.
    4. +
    5. Attach Supporting Documents: Attach all necessary documents to support your claim.
    6. +
    7. Submit Your Claim: Send the completed form and documents via email or through our online portal.
    8. +
    9. Track Your Claim: Use our tracking system to monitor the status of your claim.
    10. +
    11. Receive Reimbursement: Once approved, the reimbursement will be processed to your registered account.
    12. +
    +
    + + Submit Your Claim + +

    If you have any questions, feel free to contact our support team.

    + + +
    + + + + '; + + return $template; + } + } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 1d989b80..d23b315e 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1746,14 +1746,14 @@ class EmployeePolicyModel extends Model return $result[0]; } - public function getHospitalLinkByPolicyandEmp($client_policy_id,$emp_id){ + public function getHospitalLinkByPolicyandEmp($client_policy_id){ $data = $this->db->table('employee_polices') ->select('tpa.network_hospitals') ->where('client_policy_id', $client_policy_id) ->where('employee_polices.is_active', 1) ->join('tpa', 'tpa.id = employee_polices.tpa_id AND tpa.is_active = 1') - ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id) - ->get()->getResultArray()[0]; + // ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id) + ->get()->getResultArray(); // var_dump($this->db->getLastQuery()); return $data; diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index adbeb587..359b4ce0 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -26,12 +26,12 @@ var botmanWidget = { chatServer: ``, // Make sure this URL is correct frameEndpoint: ``, // This should match your CI4 - title: "Ask ஆதிரை", + title: "Ask ILA", introMessage: "", bubbleBackground: "#007bff", mainColor: "#007bff", placeholderText: "Type your message here...", - aboutText: "Insurance AI Assistant ஆதிரை", + aboutText: "Insurance Assistant ILA", enableAttachments: false, // Add extra parameters parameters: { @@ -62,7 +62,7 @@ if (window.botmanWidget) { botmanChatWidget.open(); setTimeout(function(){ - botmanChatWidget.sayAsBot('hi user '+ uid +' , this is ஆதிரை your Insurance AI Assistant, plz choose the following options') + botmanChatWidget.sayAsBot('Hi user '+ uid +' ,This is ILA your Insurance AI Assistant, plz choose the following options') botmanChatWidget.whisper('hi'); },2000); From 9ce63504c0ebef0082429af158d3c3d90b5b97ce Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 4 Feb 2025 16:14:54 +0530 Subject: [PATCH 61/65] FIX_TOTAL_TAT : RV --- app/Views/tat_report_band_wise_list.php | 143 ++++++++++++++---------- 1 file changed, 87 insertions(+), 56 deletions(-) diff --git a/app/Views/tat_report_band_wise_list.php b/app/Views/tat_report_band_wise_list.php index 204b4542..0666ece7 100644 --- a/app/Views/tat_report_band_wise_list.php +++ b/app/Views/tat_report_band_wise_list.php @@ -1,25 +1,25 @@
    @@ -35,20 +35,51 @@ table.dataTable tbody td { - - + + + + + - - - - - + + $value): + // Convert numeric values to integer (ignore 'tat_category') + $numValue = is_numeric($value) ? (int) $value : 0; + + if ($key != 'TAT_Category') { + $columnTotals[$key] += $numValue; // Add to column total + $rowTotal += $numValue; // Add to row total + } + ?> + + + + + + + $total): ?> + + + + + + +
    TOTAL
    +
    @@ -61,41 +92,41 @@ table.dataTable tbody td { \ No newline at end of file From 8491a722131b891043bd9de54109047b827a72ca Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 5 Feb 2025 09:37:56 +0530 Subject: [PATCH 62/65] CHANGE_TAT_IN_CLAIM_LIST : RV --- app/Controllers/TicketController.php | 131 +++++++++++++++++++-------- app/Models/TicketMasterModel.php | 50 +++++++--- 2 files changed, 127 insertions(+), 54 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index d8af5e1c..630313e1 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -144,20 +144,52 @@ class TicketController extends BaseController { //action 1 get last 100 rows, action 2 filter and get all rows related to that if ($action == 1) { + $data = $this->ticketMasterModel - ->select('ticket_master.id, ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, - insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, - DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ->select(" + + ticket_master.id, + ticket_claim_status.claim_status as status, + ticket_master.claim_number as claim_no, + ticket_master.tpa_id, + ticket_master.emp_name, + insurers.name as insurer_name, + clients.client_name, + ticket_master.insured_name, + clients.short_name, + DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date, + CASE + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 0 AND 6 THEN '0-6 Days' + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 7 AND 12 THEN '7-12 Days' + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 13 AND 20 THEN '13-20 Days' + ELSE 'Above 20 Days' + END AS tat + + ") ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') + ->join('ticket_history', "ticket_master.id = ticket_history.ticket_id") ->where('ticket_master.is_active', 1) + ->where('ticket_history.is_active', 1) + ->groupBy('ticket_master.id') ->orderBy('ticket_master.id', 'DESC') ->limit(100) ->findAll(); + // dd($data); + return $data; + } else { $search_data = $this->request->getPost(); // print_r($search_data); @@ -169,15 +201,41 @@ class TicketController extends BaseController } // print_rr($where); $data = $this->ticketMasterModel - ->select('ticket_master.id, ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, - insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, - DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ->select(" + ticket_master.id, + ticket_claim_status.claim_status as status, + ticket_master.claim_number as claim_no, + ticket_master.tpa_id, + ticket_master.emp_name, + insurers.name as insurer_name, + clients.client_name,ticket_master.insured_name, + clients.short_name, + DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date, + CASE + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 0 AND 6 THEN '0-6 Days' + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 7 AND 12 THEN '7-12 Days' + WHEN DATEDIFF( + ticket_master.updated_at, + COALESCE(ticket_master.updated_at, ticket_history.created_at) + ) BETWEEN 13 AND 20 THEN '13-20 Days' + ELSE 'Above 20 Days' + END AS tat + ") ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') + ->join('ticket_history', "ticket_master.id = ticket_history.ticket_id") ->where('ticket_master.is_active', 1) + ->where('ticket_history.is_active', 1) ->where($where) + ->groupBy('ticket_master.id') + ->orderBy('ticket_master.id', 'DESC') ->findAll(); // print_rr($data); // log_message('error',' Claims Master Data '.json_encode($data));die(); @@ -842,23 +900,24 @@ class TicketController extends BaseController return 'Ticket id\'s : '.json_encode($ticket_ids); } - public function ticketReports(){ + public function ticketReports() + { - if ($this->request->is('get')){ + if ($this->request->is('get')) { $default_start = new \DateTime(); $data['default_end'] = $default_start->format('d-m-Y'); - $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); - - $data['policy_type'] = $this->ticketType; - $data['account_manager'] = $this->userModel->select('first_name')->where('is_active',1)->where('role',3)->findAll(); + $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); + + $data['policy_type'] = $this->ticketType; + $data['account_manager'] = $this->userModel->select('first_name')->where('is_active', 1)->where('role', 3)->findAll(); $data['report_type'] = [ - 'acc_manager_wise_status'=>'Account Manger Wise Status Report', + 'acc_manager_wise_status' => 'Account Manger Wise Status Report', 'tpa_wise_status' => 'TPA Wise Status Report', 'tat_band_wise' => 'TAT Wise Status Report' ]; // - $this->loadLayout('ticket_reports',$data); - }else{ + $this->loadLayout('ticket_reports', $data); + } else { $received_data = $this->request->getPost(); $from_Date = $received_data['fromDate']; $to_Date = $received_data['toDate']; @@ -866,38 +925,33 @@ class TicketController extends BaseController $toDate = \DateTime::createFromFormat('d-m-Y', $to_Date)->format('Y-m-d'); $policy_type = $received_data['policy_type']; // print_rr($received_data); - if ($received_data['report_type'] == "acc_manager_wise_status"){ + if ($received_data['report_type'] == "acc_manager_wise_status") { - $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type,$fromDate,$toDate); + $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type, $fromDate, $toDate); // print_rr($viewData); - if ($policy_type == 1){ + if ($policy_type == 1) { $html = view('claims_report_acc_manager_gmc', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - }else{ + } else { $html = view('claims_report_acc_manager_gpa', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); } + } elseif ($received_data['report_type'] == 'tpa_wise_status') { - }elseif ($received_data['report_type'] == 'tpa_wise_status'){ - - $viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type,$fromDate,$toDate); - $html = view('claims_report_tpa_wise',$viewData); + $viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type, $fromDate, $toDate); + $html = view('claims_report_tpa_wise', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - - }else if ($received_data['report_type'] == 'tat_band_wise'){ + } else if ($received_data['report_type'] == 'tat_band_wise') { $viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate); - $html = view('tat_report_band_wise_list',$viewData); + $html = view('tat_report_band_wise_list', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); - } } - - - } - public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ + public function accountManagerWiseReport($policy_type = null, $start_date = null, $end_date = null) + { if ($policy_type == 1) { $sql = "SELECT @@ -933,9 +987,7 @@ class TicketController extends BaseController // dd($result); return $result; - - - }else{ + } else { $sql = "SELECT u.first_name AS acc_manager_name, COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation, COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer, @@ -979,7 +1031,8 @@ class TicketController extends BaseController } } - public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){ + public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null) + { // $policy_type = 1; $sql = "SELECT tpa.name AS tpa_name, @@ -1022,9 +1075,9 @@ class TicketController extends BaseController "; - $result = $this->ticketMasterModel->query($sql)->getResultArray(); + $result = $this->ticketMasterModel->query($sql)->getResultArray(); - return $result; + return $result; } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index def64345..b22fbd1e 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -166,7 +166,7 @@ class TicketMasterModel extends Model // Fetch claim statuses from the `ticket_claim_status` table $statusQuery = " SELECT - id, claim_status + id, claim_status, ticket_type FROM ticket_claim_status Where is_active = 1 $ticket_type_data_1 @@ -176,20 +176,40 @@ class TicketMasterModel extends Model // Initialize dynamic query parts $dynamicSelect = ''; - + // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT foreach ($statusResult as $status) { - // Dynamically add the COALESCE and CASE for each status in the SELECT part + + $columnName = $status['claim_status']; // Default column name + + if (empty($ticket_type)) { + // Append the insurance type prefix based on `ticket_type` + switch ($status['ticket_type']) { + case 1: + $columnName = "GMC - {$status['claim_status']}"; + break; + case 2: + $columnName = "GPA - {$status['claim_status']}"; + break; + case 3: + $columnName = "EDLI - {$status['claim_status']}"; + break; + case 4: + $columnName = "GTLI - {$status['claim_status']}"; + break; + } + } + $dynamicSelect .= " - COALESCE( - SUM( - CASE - WHEN subquery.status_id = {$status['id']} THEN 1 - ELSE 0 - END - ), - 0 - ) AS `{$status['claim_status']}`, "; + COALESCE( + SUM( + CASE + WHEN subquery.status_id = {$status['id']} THEN 1 + ELSE 0 + END + ), + 0 + ) AS `$columnName`, "; } // Remove the trailing comma from the SELECT part @@ -219,15 +239,15 @@ class TicketMasterModel extends Model tcs.id AS status_id, CASE WHEN DATEDIFF( - th.created_at, + tm.updated_at, COALESCE(tm.updated_at, th.created_at) ) BETWEEN 0 AND 6 THEN '0-6 Days' WHEN DATEDIFF( - th.created_at, + tm.updated_at, COALESCE(tm.updated_at, th.created_at) ) BETWEEN 7 AND 12 THEN '7-12 Days' WHEN DATEDIFF( - th.created_at, + tm.updated_at, COALESCE(tm.updated_at, th.created_at) ) BETWEEN 13 AND 20 THEN '13-20 Days' ELSE 'Above 20 Days' From 04e75e85b340a27140b268de626c537ef20fd158 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 5 Feb 2025 09:48:31 +0530 Subject: [PATCH 63/65] FEAT_DYNAMIC_CLAIMS_REPORT_SRINIVAS --- app/Controllers/TicketController.php | 300 +++++++++++-------- app/Models/TicketMasterModel.php | 196 ++++++++++++ app/Views/claims_report_acc_manager_gmc.php | 169 ----------- app/Views/claims_report_acc_manager_gpa.php | 203 ------------- app/Views/claims_report_acc_manager_wise.php | 103 +++++++ app/Views/claims_report_tpa_wise.php | 205 +++---------- 6 files changed, 523 insertions(+), 653 deletions(-) delete mode 100644 app/Views/claims_report_acc_manager_gmc.php delete mode 100644 app/Views/claims_report_acc_manager_gpa.php create mode 100644 app/Views/claims_report_acc_manager_wise.php diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index d8af5e1c..a6b45f9e 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -867,20 +867,72 @@ class TicketController extends BaseController $policy_type = $received_data['policy_type']; // print_rr($received_data); if ($received_data['report_type'] == "acc_manager_wise_status"){ - - $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type,$fromDate,$toDate); + $viewData['policy_type'] = $received_data['policy_type']; + $viewData['account_manager_wise_data'] = $this->ticketMasterModel->accountManagerWiseReport($policy_type,$fromDate,$toDate); // print_rr($viewData); if ($policy_type == 1){ - $html = view('claims_report_acc_manager_gmc', $viewData); + $viewData['column_order'] = [ + 'ACM_NAME', 'ID NOT GENERATED', 'NON ID', 'CDA', 'INFORMATION REQUIRED', + 'UNDER PROCESS - CLAIM NO. UPDATION', 'UNDER PROCESS - INVESTIGATION STATUS', + 'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED', + 'TOTAL' + ]; + $ordered_data = []; + + foreach ($viewData['account_manager_wise_data'] as $tpa_data) { + $temp = []; + foreach ($viewData['column_order'] as $key) { + $temp[$key] = isset($tpa_data[$key]) ? $tpa_data[$key] : 0; // Default to 0 if key is missing + } + $ordered_data[] = $temp; + } + $viewData['tpa_wise_data'] = $ordered_data; + $html = view('claims_report_acc_manager_wise', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); }else{ - $html = view('claims_report_acc_manager_gpa', $viewData); + $viewData['column_order'] = [ + 'ACM_NAME', 'CLAIM INTIMATION', 'INTIMATION TO INSURER', 'CLIENT PENDING', + 'INSURER PENDING','INVESTIGATION','APPROVED','ON HOLD','TOTAL', 'NOT COVERED', + 'CLOSED', 'SETTLED', 'CLEARED_TOTAL' + ]; + $ordered_data = []; + + foreach ($viewData['account_manager_wise_data'] as $tpa_data) { + $temp = []; + foreach ($viewData['column_order'] as $key) { + $temp[$key] = isset($tpa_data[$key]) ? $tpa_data[$key] : 0; // Default to 0 if key is missing + } + $ordered_data[] = $temp; + } + $viewData['tpa_wise_data'] = $ordered_data; + $html = view('claims_report_acc_manager_wise', $viewData); return $this->respond(['status' => true, 'html' => $html], 200); } }elseif ($received_data['report_type'] == 'tpa_wise_status'){ - $viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type,$fromDate,$toDate); + $viewData['tpa_wise_data'] = $this->ticketMasterModel->tpaWiseReport($policy_type, $fromDate, $toDate); + + $viewData['column_order'] = [ + 'TPA_NAME', 'NON ID', 'ID NOT GENERATED', 'CDA', 'INFORMATION REQUIRED', + 'UNDER PROCESS - CLAIM NO. UPDATION', 'UNDER PROCESS - INVESTIGATION STATUS', + 'UNDER PROCESS - QUERY DOCUMENT RECEIVED', 'APPROVED', 'PAYMENT INITIATED', + 'TOTAL', 'SETTLED', 'CLOSED', 'CANCELLED', 'RETURNED', 'CLEARED_TOTAL' + ]; + + // Reorder data based on column order + $ordered_data = []; + + foreach ($viewData['tpa_wise_data'] as $tpa_data) { + $temp = []; + foreach ($viewData['column_order'] as $key) { + $temp[$key] = isset($tpa_data[$key]) ? $tpa_data[$key] : 0; // Default to 0 if key is missing + } + $ordered_data[] = $temp; + } + $viewData['tpa_wise_data'] = $ordered_data; + // $html = view('claims_report_tpa_wise', $viewData); + $html = view('claims_report_tpa_wise',$viewData); return $this->respond(['status' => true, 'html' => $html], 200); @@ -897,134 +949,134 @@ class TicketController extends BaseController } - public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ + // public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ - if ($policy_type == 1) { - $sql = "SELECT - u.first_name AS acc_manager_name, - COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) AS id_not_generated, - COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) AS non_id, - COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) AS cda, - COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) AS information_required, - COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) AS under_process, - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) AS approved, - COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) AS payment_initiated, - ( - COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) - ) AS total - FROM - ticket_master master - JOIN - user_profiles u ON master.acm_id = u.id and u.is_active = 1 - JOIN - ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 - WHERE - master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 - GROUP BY - u.id; - "; - $result = $this->ticketMasterModel->query($sql)->getResultArray(); - // dd($result); + // if ($policy_type == 1) { + // $sql = "SELECT + // u.first_name AS acc_manager_name, + // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) AS id_not_generated, + // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) AS non_id, + // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) AS cda, + // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) AS information_required, + // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) AS under_process, + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) AS approved, + // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) AS payment_initiated, + // ( + // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) + // ) AS total + // FROM + // ticket_master master + // JOIN + // user_profiles u ON master.acm_id = u.id and u.is_active = 1 + // JOIN + // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + // WHERE + // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 + // GROUP BY + // u.id; + // "; + // $result = $this->ticketMasterModel->query($sql)->getResultArray(); + // // dd($result); - return $result; + // return $result; - }else{ - $sql = "SELECT u.first_name AS acc_manager_name, - COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation, - COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer, - COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS client_pending, - COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, - COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS investigation, - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, - COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS on_hold, + // }else{ + // $sql = "SELECT u.first_name AS acc_manager_name, + // COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation, + // COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer, + // COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS client_pending, + // COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, + // COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS investigation, + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, + // COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS on_hold, - ( - COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ - COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ - COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) - ) AS total1, - COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS not_covered, - COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, - COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, - ( - COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) - ) AS total2 - FROM - ticket_master master - JOIN - user_profiles u ON master.acm_id = u.id and u.is_active = 1 - JOIN - ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 - WHERE - master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 and master.ticket_type_id = '$policy_type' - GROUP BY - u.id; - "; - $result = $this->ticketMasterModel->query($sql)->getResultArray(); + // ( + // COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ + // COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END)+ + // COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) + // ) AS total1, + // COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS not_covered, + // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, + // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, + // ( + // COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + // ) AS total2 + // FROM + // ticket_master master + // JOIN + // user_profiles u ON master.acm_id = u.id and u.is_active = 1 + // JOIN + // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + // WHERE + // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 and master.ticket_type_id = '$policy_type' + // GROUP BY + // u.id; + // "; + // $result = $this->ticketMasterModel->query($sql)->getResultArray(); - return $result; - } - } + // return $result; + // } + // } - public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){ - // $policy_type = 1; - $sql = "SELECT - tpa.name AS tpa_name, - COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS id_not_generated, - COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS non_id, - COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS cda, - COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, - COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS under_process, - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, - COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS payment_initiated, - ( - COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) - ) AS total, - COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, - COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, - COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS returned, - COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS denied, - ( - COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type'THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + - COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) - ) AS total2 - FROM - ticket_master master - JOIN - tpa ON master.tpa_id = tpa.id and tpa.is_active = 1 - JOIN - ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 - WHERE - master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 - GROUP BY - tpa.id; + // public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){ + // // $policy_type = 1; + // $sql = "SELECT + // tpa.name AS tpa_name, + // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS id_not_generated, + // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS non_id, + // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS cda, + // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required, + // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS under_process, + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved, + // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS payment_initiated, + // ( + // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + // ) AS total, + // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed, + // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled, + // COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS returned, + // COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS denied, + // ( + // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type'THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + + // COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) + // ) AS total2 + // FROM + // ticket_master master + // JOIN + // tpa ON master.tpa_id = tpa.id and tpa.is_active = 1 + // JOIN + // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1 + // WHERE + // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 + // GROUP BY + // tpa.id; - "; - $result = $this->ticketMasterModel->query($sql)->getResultArray(); + // "; + // $result = $this->ticketMasterModel->query($sql)->getResultArray(); - return $result; - } + // return $result; + // } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index def64345..6dd1a2a8 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -270,5 +270,201 @@ class TicketMasterModel extends Model return $data; } + + public function tpaWiseReport($policy_type = null ,$start_date = null, $end_date = null){ + $ticket_type_data_1 = ""; + $ticket_type_data_2 = ""; + + if (!empty($policy_type)) { + $ticket_type_data_1 = "AND ticket_type = $policy_type"; + $ticket_type_data_2 = "AND master.ticket_type_id = $policy_type"; + } + + // Fetch claim statuses dynamically + $statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1"; + $statusResult = $this->db->query($statusQuery)->getResultArray(); + + // Initialize dynamic query parts + $dynamicSelect = ''; + $dynamicTotal = ''; + $dynamicClosedTotal = ''; + + // Loop through each claim status and generate the CASE statements + foreach ($statusResult as $status) { + $dynamicSelect .= " + COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, "; + + if (in_array($status['claim_status'], ['ID NOT GENERATED', 'NON ID', 'CDA', 'INFORMATION REQUIRED','UNDER PROCESS - CLAIM NO. UPDATION', + 'UNDER PROCESS - INVESTIGATION STATUS','UNDER PROCESS - QUERY DOCUMENT RECEIVED','APPROVED','PAYMENT INITIATED'])) { + $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + } + // Include in total count + // $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + + // Include only closed-related statuses in total2 count + if (in_array($status['claim_status'], ['CLOSED', 'SETTLED', 'RETURNED', 'REJECTED'])) { + $dynamicClosedTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + } + } + + // Remove the trailing commas and `+` signs + $dynamicSelect = rtrim($dynamicSelect, ', '); + $dynamicTotal = rtrim($dynamicTotal, ' +'); + $dynamicClosedTotal = rtrim($dynamicClosedTotal, ' +'); + // print_rr($dynamicSelect); + // Construct the final SQL query + $sql = " + SELECT + tpa.name AS TPA_NAME, + $dynamicSelect, + ($dynamicTotal) AS TOTAL, + ($dynamicClosedTotal) AS CLEARED_TOTAL + FROM + ticket_master master + JOIN + tpa ON master.tpa_id = tpa.id AND tpa.is_active = 1 + WHERE + master.created_at BETWEEN '$start_date' AND '$end_date' + AND master.is_active = 1 + $ticket_type_data_2 + GROUP BY + tpa.id; + "; + + // Execute the query + $result = $this->db->query($sql)->getResultArray(); + + // print_rr($result);die(); + return $result; + + } + + public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ + + if ($policy_type == 1) { + $ticket_type_data_1 = ""; + $ticket_type_data_2 = ""; + + if (!empty($policy_type)) { + $ticket_type_data_1 = "AND ticket_type = $policy_type"; + $ticket_type_data_2 = "AND master.ticket_type_id = $policy_type"; + } + + // Fetch claim statuses dynamically + $statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1"; + $statusResult = $this->db->query($statusQuery)->getResultArray(); + + // Initialize dynamic query parts + $dynamicSelect = ''; + $dynamicTotal = ''; + + // Loop through each claim status and generate the CASE statements + foreach ($statusResult as $status) { + $dynamicSelect .= " + COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, "; + + + // Include in total count + $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + + // Include only closed-related statuses in total2 count + + } + + // Remove the trailing commas and `+` signs + $dynamicSelect = rtrim($dynamicSelect, ', '); + $dynamicTotal = rtrim($dynamicTotal, ' +'); + // print_rr($dynamicSelect); + // Construct the final SQL query + $sql = " + SELECT + user_profiles.first_name AS ACM_NAME, + $dynamicSelect, + ($dynamicTotal) AS TOTAL + FROM + ticket_master master + JOIN + user_profiles ON master.acm_id = user_profiles.id AND user_profiles.is_active = 1 + WHERE + master.created_at BETWEEN '$start_date' AND '$end_date' + AND master.is_active = 1 + $ticket_type_data_2 + GROUP BY + user_profiles.id; + "; + + $result = $this->db->query($sql)->getResultArray(); + // dd($result); + + return $result; + + + }else{ + $ticket_type_data_1 = ""; + $ticket_type_data_2 = ""; + + if (!empty($policy_type)) { + $ticket_type_data_1 = "AND ticket_type = $policy_type"; + $ticket_type_data_2 = "AND master.ticket_type_id = $policy_type"; + } + + // Fetch claim statuses dynamically + $statusQuery = "SELECT id, claim_status FROM ticket_claim_status WHERE is_active = 1 $ticket_type_data_1"; + $statusResult = $this->db->query($statusQuery)->getResultArray(); + + // Initialize dynamic query parts + $dynamicSelect = ''; + $dynamicTotal = ''; + $dynamicClosedTotal = ''; + + // Loop through each claim status and generate the CASE statements + foreach ($statusResult as $status) { + $dynamicSelect .= " + COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) AS `{$status['claim_status']}`, "; + + if (in_array($status['claim_status'], ['CLAIM INTIMATION', 'INTIMATION TO INSURER', 'CLIENT PENDING', 'INSURER PENDING','INVESTIGATION', + 'APPROVED','ON HOLD'])) { + $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + } + // Include in total count + // $dynamicTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + + // Include only closed-related statuses in total2 count + if (in_array($status['claim_status'], ['CLOSED', 'SETTLED', 'NOT COVERED'])) { + $dynamicClosedTotal .= "COUNT(CASE WHEN master.claim_status_id = {$status['id']} THEN master.id END) + "; + } + } + + // Remove the trailing commas and `+` signs + $dynamicSelect = rtrim($dynamicSelect, ', '); + $dynamicTotal = rtrim($dynamicTotal, ' +'); + $dynamicClosedTotal = rtrim($dynamicClosedTotal, ' +'); + // print_rr($dynamicSelect); + // Construct the final SQL query + $sql = " + SELECT + user_profiles.first_name AS ACM_NAME, + $dynamicSelect, + ($dynamicTotal) AS TOTAL, + ($dynamicClosedTotal) AS CLEARED_TOTAL + FROM + ticket_master master + JOIN + user_profiles ON master.acm_id = user_profiles.id AND user_profiles.is_active = 1 + WHERE + master.created_at BETWEEN '$start_date' AND '$end_date' + AND master.is_active = 1 + $ticket_type_data_2 + GROUP BY + user_profiles.id; + "; + + // Execute the query + $result = $this->db->query($sql)->getResultArray(); + + // print_rr($result);die(); + return $result; + } + } } diff --git a/app/Views/claims_report_acc_manager_gmc.php b/app/Views/claims_report_acc_manager_gmc.php deleted file mode 100644 index b24b462b..00000000 --- a/app/Views/claims_report_acc_manager_gmc.php +++ /dev/null @@ -1,169 +0,0 @@ - - -
    -
    -
    -
    -
    -

    Insurer List

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Account MangerID Not GeneratedNon-IDCDAInformation RequiredUnder ProcessApprovedPayment InitiatedTotal
    Grand Total
    -
    -
    -
    -
    - - diff --git a/app/Views/claims_report_acc_manager_gpa.php b/app/Views/claims_report_acc_manager_gpa.php deleted file mode 100644 index b1523e04..00000000 --- a/app/Views/claims_report_acc_manager_gpa.php +++ /dev/null @@ -1,203 +0,0 @@ - - -
    -
    -
    -
    -
    -

    Insurer List

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    OPENCLEARED
    Account MangerClaim IntimationIntimation to InsurerClient PendingInsurer PendingInvestigationApprovedOn HoldTotalNot CoveredClosedSettledTotal
    Grand Total
    -
    -
    -
    -
    - - diff --git a/app/Views/claims_report_acc_manager_wise.php b/app/Views/claims_report_acc_manager_wise.php new file mode 100644 index 00000000..a629a01c --- /dev/null +++ b/app/Views/claims_report_acc_manager_wise.php @@ -0,0 +1,103 @@ + + +
    +
    +
    +
    +
    +

    Account Manger Claim Status List

    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + {$totals[$col_name]}"; + } + } + ?> + + +
    OPENCLEARED
    Grand Total
    +
    +
    +
    +
    + + diff --git a/app/Views/claims_report_tpa_wise.php b/app/Views/claims_report_tpa_wise.php index 3682ca00..0a3fc65a 100644 --- a/app/Views/claims_report_tpa_wise.php +++ b/app/Views/claims_report_tpa_wise.php @@ -1,24 +1,23 @@
    @@ -26,7 +25,7 @@ table.dataTable tbody td {
    -

    Insurer List

    +

    TPA Claim Status List

    @@ -34,63 +33,40 @@ table.dataTable tbody td { OPEN - CLEARED + CLEARED - TPA - ID Not Generated - Non-ID - CDA - Information Required - Under Process - Approved - Payment Initiated - Total - Closed - Settled - Returned - Denied - Total - + + + - + - - - - - - - - - - - - - - + + + - + Grand Total - - - - - - - - - - - - - - + {$totals[$col_name]}"; + } + } + ?> @@ -106,102 +82,17 @@ table.dataTable tbody td { if (ticketsTable.length) { ticketsTable.DataTable({ scrollX: true, - dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right - "<'row'<'col-sm-12'tr>>" + - "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector + dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-5'i><'col-sm-7'p>>", buttons: [ - { - extend: 'csv', - text: 'CSV', - title: 'Insurer-Wise-Report-List', - }, - { - extend: 'excel', - text: 'Excel', - title: 'Insurer-Wise-Report-List', - exportOptions: { - orthogonal: 'sort' - }, - } + { extend: 'csv', text: 'CSV', title: 'Insurer-Wise-Report-List' }, + { extend: 'excel', text: 'Excel', title: 'Insurer-Wise-Report-List', exportOptions: { orthogonal: 'sort' } } ], - language: { - search: "_INPUT_", - searchPlaceholder: "Search..." - }, - paging: true, // Enable pagination - pageLength: 10, // Set default number of rows per page (optional) - ordering: false, - footerCallback: function(row, data, start, end, display) { - var api = this.api(); - - // Helper function to parse numbers - var parseNumber = function(value) { - return typeof value === 'string' ? - parseFloat(value.replace(/[\$,]/g, '')) : - typeof value === 'number' ? value : 0; - }; - - // Calculate total for each column - var total_id_not_generated = api.column(1).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - - var total_non_id = api.column(2).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - - var total_cda = api.column(3).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_information_required = api.column(4).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_under_process = api.column(5).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_approved = api.column(6).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_payment_initiated = api.column(7).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_of_total = api.column(8).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_closed = api.column(9).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_settled = api.column(10).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_returned = api.column(11).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_denied = api.column(12).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - var total_of_total2 = api.column(13).data().reduce(function(a, b) { - return parseNumber(a) + parseNumber(b); - }, 0); - - // Update the footer with totals - $(api.column(1).footer()).html(total_id_not_generated); - $(api.column(2).footer()).html(total_non_id); - $(api.column(3).footer()).html(total_cda); - $(api.column(4).footer()).html(total_information_required); - $(api.column(5).footer()).html(total_under_process); - $(api.column(6).footer()).html(total_approved); - $(api.column(7).footer()).html(total_payment_initiated); - $(api.column(8).footer()).html(total_of_total); - $(api.column(9).footer()).html(total_closed); - $(api.column(10).footer()).html(total_settled); - $(api.column(11).footer()).html(total_returned); - $(api.column(12).footer()).html(total_denied); - $(api.column(13).footer()).html(total_of_total2); - - - - } + language: { search: "_INPUT_", searchPlaceholder: "Search..." }, + paging: true, + pageLength: 10, + ordering: false }); } else { console.error("Table not found."); From 9a3988072a05e7a2432b245b43a186878a90d766 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 5 Feb 2025 12:44:23 +0530 Subject: [PATCH 64/65] FIX_LIST : RV --- app/Controllers/EmployeeController.php | 1 + app/Controllers/TicketController.php | 161 +++++++++++----------- app/Models/TicketMasterModel.php | 180 +++++++++++++++++++++++-- 3 files changed, 253 insertions(+), 89 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 06bb8532..a613c87b 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2225,6 +2225,7 @@ class EmployeeController extends AdminController } } + //UPDATE EMPLOYEE public function update_emp_data() { $data = $this->request->getPost(); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 630313e1..800ce03d 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -141,52 +141,68 @@ class TicketController extends BaseController } public function ticketSearch($action = null) - { + { + $db = db_connect(); + + $subquery = $db->table('ticket_history th') + ->select([ + 'th.ticket_id', + "CASE + WHEN DATEDIFF( + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) + ) BETWEEN 0 AND 6 THEN '0-6 Days' + WHEN DATEDIFF( + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) + ) BETWEEN 7 AND 12 THEN '7-12 Days' + WHEN DATEDIFF( + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) + ) BETWEEN 13 AND 20 THEN '13-20 Days' + ELSE 'Above 20 Days' + END AS tat" + ]) + ->join('ticket_master tm', 'tm.id = th.ticket_id', 'right') + ->where('tm.is_active', 1) + ->groupBy('th.ticket_id, tm.created_at'); + //action 1 get last 100 rows, action 2 filter and get all rows related to that if ($action == 1) { - $data = $this->ticketMasterModel - ->select(" + $query = $db->table('ticket_master tm') + ->select([ + 'tm.id', + 'tcs.claim_status AS status', + 'tm.claim_number AS claim_no', + 'tm.tpa_id', + 'tm.emp_name', + 'i.name AS insurer_name', + 'c.client_name', + 'tm.insured_name', + 'c.short_name', + 'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date', + 'COALESCE(tat_category.tat, "0-6 Days") AS tat' + ]) + ->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left') + ->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left') + ->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1', 'left') + ->join("({$subquery->getCompiledSelect()}) tat_category", 'tm.id = tat_category.ticket_id', 'left') + ->where('tm.is_active', 1) + ->orderBy('tm.id', 'DESC'); - ticket_master.id, - ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no, - ticket_master.tpa_id, - ticket_master.emp_name, - insurers.name as insurer_name, - clients.client_name, - ticket_master.insured_name, - clients.short_name, - DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date, - CASE - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 0 AND 6 THEN '0-6 Days' - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 7 AND 12 THEN '7-12 Days' - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 13 AND 20 THEN '13-20 Days' - ELSE 'Above 20 Days' - END AS tat + $data = $query->get()->getResultArray(); - ") - ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') - ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') - ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') - ->join('ticket_history', "ticket_master.id = ticket_history.ticket_id") - ->where('ticket_master.is_active', 1) - ->where('ticket_history.is_active', 1) - ->groupBy('ticket_master.id') - ->orderBy('ticket_master.id', 'DESC') - ->limit(100) - ->findAll(); - - // dd($data); + // dd(db_connect()->getLastQuery()); return $data; @@ -200,46 +216,33 @@ class TicketController extends BaseController } } // print_rr($where); - $data = $this->ticketMasterModel - ->select(" - ticket_master.id, - ticket_claim_status.claim_status as status, - ticket_master.claim_number as claim_no, - ticket_master.tpa_id, - ticket_master.emp_name, - insurers.name as insurer_name, - clients.client_name,ticket_master.insured_name, - clients.short_name, - DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date, - CASE - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 0 AND 6 THEN '0-6 Days' - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 7 AND 12 THEN '7-12 Days' - WHEN DATEDIFF( - ticket_master.updated_at, - COALESCE(ticket_master.updated_at, ticket_history.created_at) - ) BETWEEN 13 AND 20 THEN '13-20 Days' - ELSE 'Above 20 Days' - END AS tat - ") - ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') - ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') - ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') - ->join('ticket_history', "ticket_master.id = ticket_history.ticket_id") - ->where('ticket_master.is_active', 1) - ->where('ticket_history.is_active', 1) + $query = $db->table('ticket_master tm') + ->select([ + 'tm.id', + 'tcs.claim_status AS status', + 'tm.claim_number AS claim_no', + 'tm.tpa_id', + 'tm.emp_name', + 'i.name AS insurer_name', + 'c.client_name', + 'tm.insured_name', + 'c.short_name', + 'DATE_FORMAT(tm.created_at, "%d-%m-%Y") AS ticket_created_date', + 'COALESCE(tat_category.tat, "0-6 Days") AS tat' + ]) + ->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left') + ->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left') + ->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1', 'left') + ->join("({$subquery->getCompiledSelect()}) tat_category", 'tm.id = tat_category.ticket_id', 'left') + ->where('tm.is_active', 1) ->where($where) - ->groupBy('ticket_master.id') - ->orderBy('ticket_master.id', 'DESC') - ->findAll(); - // print_rr($data); - // log_message('error',' Claims Master Data '.json_encode($data));die(); + ->orderBy('tm.id', 'DESC'); + + $data = $query->get()->getResultArray(); + // print_rr($data); + // log_message('error',' Claims Master Data '.json_encode($data));die(); // print_rr($data);die(); + return $data; } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index b22fbd1e..adce7dff 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -147,6 +147,155 @@ class TicketMasterModel extends Model } //get TAT report BAND wise Data + // public function getTATReport($ticket_type = null, $start_date = null, $end_date = null) + // { + // //set default last 3 months data date + // $fromDate = date('Y-m-d', strtotime('-90 days')); + // $toDate = date('Y-m-d 23:59:59'); + + // if (!empty($start_date) && !empty($end_date)) { + // $fromDate = change_date_format($start_date); + // $toDate = change_date_format($end_date); + // } + // $ticket_type_data_1 = ""; + // $ticket_type_data_2 = ""; + // if(!empty($ticket_type)){ + // $ticket_type_data_1 = "AND ticket_type = $ticket_type"; + // $ticket_type_data_2 = "AND tm.ticket_type_id = $ticket_type"; + // } + + // // Fetch claim statuses from the `ticket_claim_status` table + // $statusQuery = " SELECT + // id, claim_status, ticket_type + // FROM ticket_claim_status + // Where is_active = 1 + // $ticket_type_data_1 + // "; + // $statusResult = $this->db->query($statusQuery)->getResultArray(); + // // dd($statusResult); + + // // Initialize dynamic query parts + // $dynamicSelect = ''; + + // // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT + // foreach ($statusResult as $status) { + + // $columnName = $status['claim_status']; // Default column name + + // if (empty($ticket_type)) { + // // Append the insurance type prefix based on `ticket_type` + // switch ($status['ticket_type']) { + // case 1: + // $columnName = "GMC - {$status['claim_status']}"; + // break; + // case 2: + // $columnName = "GPA - {$status['claim_status']}"; + // break; + // case 3: + // $columnName = "EDLI - {$status['claim_status']}"; + // break; + // case 4: + // $columnName = "GTLI - {$status['claim_status']}"; + // break; + // } + // } + + // $dynamicSelect .= " + // COALESCE( + // SUM( + // CASE + // WHEN subquery.status_id = {$status['id']} THEN 1 + // ELSE 0 + // END + // ), + // 0 + // ) AS `$columnName`, "; + // } + + // // Remove the trailing comma from the SELECT part + // $dynamicSelect = rtrim($dynamicSelect, ', '); + // // dd($dynamicSelect); + + + // // Construct the full SQL query + // $sql = " + // SELECT + // tc.TAT_Category, + // $dynamicSelect + // FROM + // ( + // SELECT 'Above 20 Days' AS TAT_Category + // UNION ALL + // SELECT '13-20 Days' + // UNION ALL + // SELECT '7-12 Days' + // UNION ALL + // SELECT '0-6 Days' + // ) AS tc + // LEFT JOIN ( + // SELECT + // tm.id AS ticket_id, + // tcs.claim_status, + // tcs.id AS status_id, + // CASE + // WHEN DATEDIFF( + // COALESCE(th.created_at, tm.created_at), + // COALESCE( + // (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = tm.id), + // tm.created_at + // ) + // ) BETWEEN 0 AND 6 THEN '0-6 Days' + // WHEN DATEDIFF( + // COALESCE(th.created_at, tm.created_at), + // COALESCE( + // (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = tm.id), + // tm.created_at + // ) + // ) BETWEEN 7 AND 12 THEN '7-12 Days' + // WHEN DATEDIFF( + // COALESCE(th.created_at, tm.created_at), + // COALESCE( + // (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = tm.id), + // tm.created_at + // ) + // ) BETWEEN 13 AND 20 THEN '13-20 Days' + // ELSE 'Above 20 Days' + // END AS TAT_Category + // FROM + // ticket_master tm + // JOIN ticket_history th ON tm.id = th.ticket_id + // JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' + // AND th.new_value = tcs.id + // WHERE + // tm.ticket_type_id = tcs.id + // $ticket_type_data_2 + // AND tm.created_at >= '$fromDate' + // AND tm.created_at <= '$toDate' + // AND tm.is_active = 1 + // AND th.is_active = 1 + // AND tcs.is_active = 1 + // ) AS subquery ON tc.TAT_Category = subquery.TAT_Category + // GROUP BY + // tc.TAT_Category + // ORDER BY + // FIELD(tc.TAT_Category, 'Above 20 Days', '13-20 Days', '7-12 Days', '0-6 Days'); + // "; + + // // Execute the query and return the result + // $data = $this->db->query($sql)->getResultArray(); + // // print_rr($this->db->getLastQuery(), $data); die; + + // // $tableData = []; + // // if (!empty($data)) { + // // // Extract table headers from the first row keys + // // $headers = array_keys($data[0]); + // // $tableData['headers'] = $headers; + // // $tableData['body'] = $data; + // // } + + // return $data; + // } + public function getTATReport($ticket_type = null, $start_date = null, $end_date = null) { //set default last 3 months data date @@ -161,7 +310,7 @@ class TicketMasterModel extends Model $ticket_type_data_2 = ""; if(!empty($ticket_type)){ $ticket_type_data_1 = "AND ticket_type = $ticket_type"; - $ticket_type_data_2 = "AND tm.ticket_type_id = $ticket_type"; + $ticket_type_data_2 = "WHERE tm.ticket_type_id = $ticket_type"; } // Fetch claim statuses from the `ticket_claim_status` table @@ -233,36 +382,47 @@ class TicketMasterModel extends Model SELECT '0-6 Days' ) AS tc LEFT JOIN ( + SELECT th.ticket_id, tcs.claim_status, tcs.id AS status_id, CASE WHEN DATEDIFF( - tm.updated_at, - COALESCE(tm.updated_at, th.created_at) + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) ) BETWEEN 0 AND 6 THEN '0-6 Days' WHEN DATEDIFF( - tm.updated_at, - COALESCE(tm.updated_at, th.created_at) + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) ) BETWEEN 7 AND 12 THEN '7-12 Days' WHEN DATEDIFF( - tm.updated_at, - COALESCE(tm.updated_at, th.created_at) + th.created_at, + COALESCE( + (SELECT MIN(created_at) FROM ticket_history th2 WHERE th2.ticket_id = th.ticket_id), + tm.created_at + ) ) BETWEEN 13 AND 20 THEN '13-20 Days' ELSE 'Above 20 Days' END AS TAT_Category + FROM ticket_master tm JOIN ticket_history th ON tm.id = th.ticket_id - JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' - AND th.new_value = tcs.id + JOIN ticket_claim_status tcs ON th.field_name = 'claim_status_id' AND th.new_value = tcs.id $ticket_type_data_2 AND tm.created_at >= '$fromDate' AND tm.created_at <= '$toDate' AND tm.is_active = 1 AND th.is_active = 1 AND tcs.is_active = 1 + ) AS subquery ON tc.TAT_Category = subquery.TAT_Category GROUP BY tc.TAT_Category @@ -278,7 +438,7 @@ class TicketMasterModel extends Model // Execute the query and return the result $data = $this->db->query($sql)->getResultArray(); - // dd($this->db->getLastQuery(), $data); + // print_rr($this->db->getLastQuery(), $data); die; // $tableData = []; // if (!empty($data)) { From 8c5872326a22d7ae88f99447021e11b1674b1bd5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 5 Feb 2025 14:38:02 +0530 Subject: [PATCH 65/65] FIX_CD_AC_PK : RV --- app/Controllers/EmpDataServiceController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 0cc8c4f4..b2190254 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -152,7 +152,7 @@ class EmpDataServiceController extends BaseController $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if ($policy_details['cd_ac_no'] == null) { + if ($policy_details['cd_ac_pk'] == null) { $this->myLogger->logme('error', 'The policy does not have a CD account number.'); return 5; } @@ -649,7 +649,7 @@ class EmpDataServiceController extends BaseController $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if ($policy_details['cd_ac_no'] == null) { + if ($policy_details['cd_ac_pk'] == null) { $this->myLogger->logme('error', 'The policy does not have a CD account number.'); return 1; } @@ -959,7 +959,7 @@ class EmpDataServiceController extends BaseController $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if ($policy_details['cd_ac_no'] == null) { + if ($policy_details['cd_ac_pk'] == null) { $this->myLogger->logme('error', 'The policy does not have a CD account number.'); return 5; }