From bab46160f25f32413fc42086f9689186dd443b31 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 28 Apr 2025 11:55:57 +0530 Subject: [PATCH] FIX_DASHBOARD_REDIRECT_ISSUE_AND_OTHERS : RV --- app/Config/Routes.php | 2 +- app/Controllers/ClientController.php | 1 + app/Controllers/DashboardController.php | 5 +- app/Controllers/EmpDataServiceController.php | 179 +++++++++--------- app/Controllers/EmployeeRestController.php | 14 +- .../PolicyTransactionController.php | 43 +++-- app/Controllers/TicketController.php | 2 +- app/Models/EmployeePolicyModel.php | 11 +- app/Models/PolicyTransactionModel.php | 12 +- app/Views/leads_dash.php | 10 +- 10 files changed, 158 insertions(+), 121 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 69871607..d70d1ab8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -362,7 +362,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("inception", ["filter" => "authMVC"], function ($routes) { - $routes->get("list", "PolicyTransactionController::viewInception"); + $routes->match(['get', 'post'], 'list', 'PolicyTransactionController::viewInception'); $routes->post("create", "PolicyTransactionController::createInceptionPolicy"); $routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1"); $routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4cf4ae87..4664d543 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4630,6 +4630,7 @@ class ClientController extends AdminController $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live // $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live + // $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live // $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data); // print_rr($result); die; diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 2adf141a..fc154a4b 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -755,12 +755,13 @@ class DashboardController extends AdminController case 'instalment_pending': $groupedData['instalment_pending'][] = $row; break; - default: + case 'under_process': $groupedData['under_process'][] = $row; break; + default: + break; } } - return $groupedData; } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index ff0f16b1..d13676aa 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -2420,8 +2420,17 @@ class EmpDataServiceController extends BaseController $client_policy_id = $file['client_policy_id']; $client_branch_id = $file['client_branch_id']; $batch_code = $file['batch_code']; + $insurer_or_tpa = $file['insurer_or_tpa']; $user_id = $file['created_by']; + $ref_data = [ + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'client_branch_id' => $client_branch_id, + 'insurer_or_tpa' => $insurer_or_tpa, + 'event_type' => $file['event_type'], + ]; + $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; @@ -2453,92 +2462,92 @@ class EmpDataServiceController extends BaseController } } + $endorsement_data = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($ref_data, 1); + // $db = \Config\Database::connect(); - $db = \Config\Database::connect(); + // // Raw SQL query + // $sql = " + // SELECT + // a.id as endorsement_primarykey, + // a.group_key, + // employee_polices.id AS primaryKey, + // employees.id AS emp_primary, + // employees.name AS emp_name, + // employees.emp_code AS emp_code, + // employees.dob AS emp_dob, + // employees.gender AS emp_gender, + // employees.relationship_code AS emp_relationship_code, + // 'Has Define' AS emp_type, + // employee_polices.uhid AS risk_id, + // 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, + // sidata.new_basic_cover_si, + // sidata.new_si_premium, + // sidata.date_of_coverage, + // DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days, + // sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium, + // ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum, + // ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst, + // ((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total + // FROM + // emp_endorsement a + // LEFT JOIN + // employees ON employees.emp_code = a.emp_code + // LEFT JOIN + // employee_polices ON employees.id = employee_polices.employee_id + // LEFT JOIN ( + // SELECT + // aa.emp_code, + // aa.new_value as new_basic_cover_si, + // bb.new_value as new_si_premium, + // cc.new_value as date_of_coverage + // FROM ( + // SELECT + // a1.emp_code, + // a1.field_name, + // a1.new_value + // FROM + // emp_endorsement as a1 + // WHERE + // a1.field_name = 'basic_cover_si' + // ) aa + // LEFT JOIN ( + // SELECT + // b1.emp_code, + // b1.field_name, + // b1.new_value + // FROM + // emp_endorsement as b1 + // WHERE + // b1.field_name = 'premium' + // ) bb ON aa.emp_code = bb.emp_code + // LEFT JOIN ( + // SELECT + // c1.emp_code, + // c1.field_name, + // c1.new_value + // FROM + // emp_endorsement as c1 + // WHERE + // c1.field_name = 'si_enhancement_date' + // ) cc ON aa.emp_code = cc.emp_code + // ) as sidata ON a.emp_code = sidata.emp_code + // WHERE + // employee_polices.client_policy_id = '$client_policy_id' + // AND employees.client_branch_id = '$client_branch_id' + // AND employee_polices.is_active = '1' + // AND (a.endorsement_id IS NULL OR a.endorsement_id = '') + // AND a.actions = 'si' + // GROUP BY group_key + // "; - // Raw SQL query - $sql = " - SELECT - a.id as endorsement_primarykey, - a.group_key, - employee_polices.id AS primaryKey, - employees.id AS emp_primary, - employees.name AS emp_name, - employees.emp_code AS emp_code, - employees.dob AS emp_dob, - employees.gender AS emp_gender, - employees.relationship_code AS emp_relationship_code, - 'Has Define' AS emp_type, - employee_polices.uhid AS risk_id, - 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, - sidata.new_basic_cover_si, - sidata.new_si_premium, - sidata.date_of_coverage, - DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days, - sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium, - ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum, - ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst, - ((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total - FROM - emp_endorsement a - LEFT JOIN - employees ON employees.emp_code = a.emp_code - LEFT JOIN - employee_polices ON employees.id = employee_polices.employee_id - LEFT JOIN ( - SELECT - aa.emp_code, - aa.new_value as new_basic_cover_si, - bb.new_value as new_si_premium, - cc.new_value as date_of_coverage - FROM ( - SELECT - a1.emp_code, - a1.field_name, - a1.new_value - FROM - emp_endorsement as a1 - WHERE - a1.field_name = 'basic_cover_si' - ) aa - LEFT JOIN ( - SELECT - b1.emp_code, - b1.field_name, - b1.new_value - FROM - emp_endorsement as b1 - WHERE - b1.field_name = 'premium' - ) bb ON aa.emp_code = bb.emp_code - LEFT JOIN ( - SELECT - c1.emp_code, - c1.field_name, - c1.new_value - FROM - emp_endorsement as c1 - WHERE - c1.field_name = 'si_enhancement_date' - ) cc ON aa.emp_code = cc.emp_code - ) as sidata ON a.emp_code = sidata.emp_code - WHERE - employee_polices.client_policy_id = '$client_policy_id' - AND employees.client_branch_id = '$client_branch_id' - AND employee_polices.is_active = '1' - AND (a.endorsement_id IS NULL OR a.endorsement_id = '') - AND a.actions = 'si' - GROUP BY group_key - "; + // // Execute the query + // $query = $db->query($sql); - // Execute the query - $query = $db->query($sql); - - // Fetch the results - $endorsement_data = $query->getResultArray(); + // // Fetch the results + // $endorsement_data = $query->getResultArray(); @@ -2745,11 +2754,11 @@ class EmpDataServiceController extends BaseController ]; } - if ($endorsement_value['pro_rata_premimum'] != $excel_data[$key][16]) { + if ($endorsement_value['pro_rata_premium'] != $excel_data[$key][16]) { $errors[$key][] = [ 'row' => $key, 'column' => 16, - 'db_data' => $endorsement_value['pro_rata_premimum'], + 'db_data' => $endorsement_value['pro_rata_premium'], 'excel_data' => $excel_data[$key][16] ]; } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 9b137fda..3feb5558 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3226,18 +3226,12 @@ class EmployeeRestController extends AdminController $message = 'Claim Iniated Successfully'; return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200); } else { - $mail_sent_status = json_decode($mail_sent_status); + $mail_sent_status_object = json_decode($mail_sent_status); } - // dd(gettype($mail_sent_status)); - if ($mail_sent_status->status == 'success') { - $sent_message_data['ticket_id'] = $ticket_id; - $sent_message_data['sender'] = 'staff'; - $sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail; - $sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject; - $sent_message_data['mail_content'] = $mail_sent_status->data->params->message; + if ($mail_sent_status_object->status == 'success') { - $message_insert_status = $this->ticketMessage->insert($sent_message_data); + $message_insert_status = $this->ticketController->autoMessageInsertBasedOnMailResponse($mail_sent_status, $ticket_id); if ($message_insert_status) { $message = 'Claim Initiated Successfully'; @@ -3248,11 +3242,11 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); } } else { - $message = 'Claim Initiated, Failed to send Mail '; $this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id "); return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); } + } else { $message = 'Something Went Wrong'; return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 99180333..310cc939 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -169,17 +169,38 @@ class PolicyTransactionController extends BaseController $issuer = empty($issuer) ? 0 : $issuer; $status = empty($status) ? 0 : $status; // Corrected from `$issuer` - // Fetch inception data list - $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData( - $start_date, - $end_date, - $client_id, - $insurer_id, - $policy_type_id, - $date_type, - $issuer, - $status - ); + if ($this->request->is('get')) { + + // Fetch inception data list + $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData( + $start_date, + $end_date, + $client_id, + $insurer_id, + $policy_type_id, + $date_type, + $issuer, + $status + ); + + }else{ + + $ids = $this->request->getPost('ids'); + $ids = array_filter(explode(',', $ids)); + $data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData( + $start_date = 0, + $end_date = 0, + $client_id = 0, + $insurer_id = 0, + $policy_type_id = 0, + $date_type = 0, + $issuer = 0, + $status = 0, + $ids + ); + } + + // Fetch additional data $data['client'] = $this->clientModel->where('is_active', 1)->findAll(); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 1a223689..9c37e1e8 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1678,7 +1678,7 @@ class TicketController extends BaseController } else { $this->myLogger->logme('error', "Failed to send Mail :$ticket_id "); - return true; + return false; } } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 0742cafa..7f6310af 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -594,7 +594,7 @@ class EmployeePolicyModel extends Model } - public function getSIEnhancementEmployeesDataForExportExcel($ref_data) + public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0) { $client_id = $ref_data['client_id']; @@ -732,7 +732,14 @@ class EmployeePolicyModel extends Model // Get the result set $results = $query->getResult(); - // dd($this->db->getLastQuery(), $results); + + if($return_type == 1){ + $results = $query->getResultArray(); + }else{ + $results = $query->getResult(); + } + + // dd($this->db->getLastQuery()); return $results; } diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index cb7a1ce4..2e697698 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -863,7 +863,7 @@ class PolicyTransactionModel extends Model if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) { - $fromDate = date('Y-m-d', strtotime('-30 days')); + $fromDate = date('Y-m-d', strtotime('-60 days')); $toDate = date('Y-m-d 23:59:59'); if (empty($where)) { @@ -962,7 +962,7 @@ class PolicyTransactionModel extends Model // return $result; // } - public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) + public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0, $where = null) { $builder = $this->db->table('policy_transaction') ->select(' @@ -1026,14 +1026,18 @@ class PolicyTransactionModel extends Model } // Default to Last 30 Days if No Filters Are Applied - if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer)) { - $fromDate = date('Y-m-d', strtotime('-30 days')); + if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) { + $fromDate = date('Y-m-d', strtotime('-60 days')); $toDate = date('Y-m-d 23:59:59'); $builder->where('policy_transaction.created_at >=', $fromDate) ->where('policy_transaction.created_at <=', $toDate); } + if (!empty($where)) { + $builder->whereIn('policy_transaction.id', $where); + } + // Optimize Query Execution $builder->orderBy('policy_transaction.id', 'desc'); diff --git a/app/Views/leads_dash.php b/app/Views/leads_dash.php index 4eb29dd7..dd0f06a6 100644 --- a/app/Views/leads_dash.php +++ b/app/Views/leads_dash.php @@ -268,13 +268,13 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t } function linkRedirectForPolicy(ids){ - var url = ""; + var url = ""; var data = { ids : ids, is_dashboard : 1 } - redirectWithPost(url,data); + redirectWithPost(url,data, "POST"); } function linkRedirectForLeads(status,ids){ @@ -285,14 +285,14 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t is_dashboard : 1 } - redirectWithPost(url,data); + redirectWithPost(url,data, "POST"); } - function redirectWithPost(url, data = {}) { + function redirectWithPost(url, data = {}, method = "GET") { $('.loader').fadeIn(); $('.loader-mask').fadeIn(); const form = document.createElement('form'); - form.method = 'POST'; + form.method = method; form.action = url; for (const key in data) {