From 81bc0b7b8b7e72679e7221e47ead81fd29d4ca40 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 25 Oct 2025 16:53:18 +0530 Subject: [PATCH 01/46] New Report BDS CHanges - VADIVEL J 2025-10-25 --- app/Config/Routes.php | 2 +- .../PolicyTransactionController.php | 4 +- app/Models/PolicyTransactionModel.php | 382 +++++++++++++----- 3 files changed, 288 insertions(+), 100 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 52b921dc..c91d90a3 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -426,7 +426,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { }); $routes->group("report", ["filter" => "authMVC"], function ($routes) { - $routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDS"); + $routes->match(['get', 'post'],"list", "PolicyTransactionController::reportBDSNew"); $routes->match(['get', 'post'],"listNew", "PolicyTransactionController::reportBDSNew"); $routes->get("report-varience-list", "PolicyTransactionController::reportVarience"); $routes->get("report-business-list", "PolicyTransactionController::reportBusinessList"); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 94033074..739a163f 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2404,8 +2404,8 @@ class PolicyTransactionController extends BaseController // $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 - $endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]??''); //policy_end_date from excel + $endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]??''); //policy_end_date from excel // Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die(); foreach ($source_data as $source_key => $source_row) { diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index a9629d73..7b5b4874 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -1829,24 +1829,35 @@ class PolicyTransactionModel extends Model // ============================== if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) { $date_condition = " - AND insurer_statements.month >= '{$start_date}' - AND insurer_statements.month <= '{$end_date}' + AND insurer_statements_oq.month >= '{$start_date}' + AND insurer_statements_oq.month <= '{$end_date}' "; } // ============================== // BASE QUERY // ============================== - $builder = $this->db->table('policy_transaction') + + + // ============================== + // Without Statement Upload + // ============================== + + + $builder2 = $this->db->table('policy_transaction') ->select(" - policy_transaction.*, + policy_transaction.id AS id, + policy_transaction.endorsement_no AS endorsement_no, + policy_transaction.ref AS ref, DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date, - DATE_FORMAT( - IF(policy_transaction.month IS NULL, - policy_transaction.policy_issue_date, - policy_transaction.month - ), '%b %Y' - ) AS policy_issue_month, + + DATE_FORMAT( policy_transaction.policy_issue_date,, '%b %Y') AS policy_issue_month, + + CASE + WHEN 1 = 1 THEN 'no statement uploaded' + ELSE 'statement uploaded' + END AS statement_uploaded , + CASE WHEN clients.client_type = 1 THEN 'Group' @@ -1898,89 +1909,15 @@ class PolicyTransactionModel extends Model -- ============================== -- SUBQUERY: Total IRDA Amount + -- Alias Agreed Amount ...!! -- ============================== - ROUND(( - SELECT ( - SUM(co_share_stmt_details.actual_bp_brokerage_amt) + - SUM(co_share_stmt_details.actual_tp_brokerage_amt) + - SUM(co_share_stmt_details.actual_tep_brokerage_amt) + - SUM(co_share_stmt_details.reward) - ) - FROM co_share_stmt_details - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id - WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id - AND co_share_stmt_details.is_active = 1 - AND insurer_statements.is_active = 1 - {$date_condition} - ), 2) AS total_irda_amt, + ROUND(pt_co_share_details.exp_amt, 2) AS total_irda_amt, -- Reward Only - ROUND(( - SELECT SUM(co_share_stmt_details.reward) - FROM co_share_stmt_details - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id - WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id - AND co_share_stmt_details.is_active = 1 - AND insurer_statements.is_active = 1 - {$date_condition} - ), 2) AS reward, + ROUND(0, 2) AS reward, -- Billed Amount - ROUND(( - SELECT SUM( - COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.reward, 0) - ) - FROM co_share_stmt_details - JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id - WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id - AND co_share_stmt_details.is_active = 1 - AND pt_table.is_active = 1 - AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_status IS NOT NULL - {$date_condition} - ), 2) AS billed_amt, - - -- Unbilled Amount - ROUND( - ( - ( - SELECT - SUM( - COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.reward, 0) - ) - FROM co_share_stmt_details - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id - WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id - AND co_share_stmt_details.is_active = 1 - {$date_condition} - ) - - - ( - SELECT - SUM( - COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) + - COALESCE(co_share_stmt_details.reward, 0) - ) - FROM co_share_stmt_details - JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id - JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id - WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id - AND co_share_stmt_details.is_active = 1 - AND pt_table.is_active = 1 - AND insurer_statements.is_active = 1 - AND insurer_statements.invoice_status IS NULL - {$date_condition} - ) - ), 2) AS unbilled_amt, + ROUND(0, 2) AS billed_amt, created_user.first_name AS user_name, @@ -2012,9 +1949,255 @@ class PolicyTransactionModel extends Model ->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left') ->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left') ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left') - ->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left') + ->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left') + ->where('policy_transaction.is_active', 1) - ->where('pt_co_share_details.is_active', 1); + ->where('pt_co_share_details.is_active', 1) + + // ======================================================== + // GROUP BY Insurer Statement Months + // ======================================================= + ->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id '); + + // ============================== + // ROLE-BASED FILTERS + // ============================== + if ( + (!in_array(get_role_id(), [1, 5])) && + !( + in_array(MANAGEMENT_TEAM_ID, user_team()) || + in_array(FINANCE_TEAM_ID, user_team()) || + in_array(BUSINESS_TEAM_ID, user_team()) + ) + ) { + if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) { + $builder2->where('policy_transaction.created_by', get_session_userid()); + } + } + + // ============================== + // ADDITIONAL FILTERS + // ============================== + if (!empty($where)) { + log_message('info', 'Where condition: ' . json_encode($where)); + $builder2->where($where); + } + + if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') { + $startDate = date('Y-m-d 00:00:00', strtotime($start_date)); + $endDate = date('Y-m-d 23:59:59', strtotime($end_date)); + + $builder2->where("policy_transaction.{$date_type} >=", $startDate) + ->where("policy_transaction.{$date_type} <=", $endDate); + } + + + // ============================== + // FILTER BY IDs + // ============================== + if ($client_id != 0) $builder2->where('policy_transaction.client_id', $client_id); + if ($insurer_id != 0) $builder2->where('policy_transaction.insurer_id', $insurer_id); + if ($client_branch_id != 0) $builder2->where('policy_transaction.client_branch_id', $client_branch_id); + if ($insurer_branch_id != 0) $builder2->where('policy_transaction.insurer_branch_id', $insurer_branch_id); + if ($client_policy_id != 0) $builder2->where('policy_transaction.client_policy_id', $client_policy_id); + if ($user_id != 0) $builder2->where('policy_transaction.created_by', $user_id); + if ($policy_type_id != 0) $builder2->where('client_policy.policy_type_id', $policy_type_id); + if ($issuer != 0) $builder2->where('policy_transaction.issuer', $issuer); + + // ============================== + // DEFAULT 90-DAY FILTER + // ============================== + if ( + $client_id == 0 && + $insurer_id == 0 && + $policy_type_id == 0 && + $date_type == 0 && + $issuer == 0 + ) { + $fromDate = date('Y-m-d', strtotime('-90 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (empty($where)) { + $builder2->where('policy_transaction.created_at >=', $fromDate) + ->where('policy_transaction.created_at <=', $toDate); + } + } + + + + + + + + + + + + + + + + + + + + + + // ============================== + // With Statement Upload + // ============================== + + $builder = $this->db->table('policy_transaction') + ->select(" + policy_transaction.id AS id, + policy_transaction.endorsement_no AS endorsement_no, + policy_transaction.ref AS ref, + DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date, + DATE_FORMAT( + IF(insurer_statements_oq.month IS NULL, + policy_transaction.policy_issue_date, + insurer_statements_oq.month + ), '%b %Y' + ) AS policy_issue_month, + + CASE + WHEN insurer_statements_oq.month IS NULL THEN 'no statement uploaded' + ELSE 'statement uploaded' + END AS statement_uploaded , + + + CASE + WHEN clients.client_type = 1 THEN 'Group' + WHEN clients.client_type = 2 THEN 'Retail' + ELSE '-' + END AS client_type, + + CASE + WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh' + ELSE 'Renewal' + END AS revenue_type, + + CASE + WHEN policy_transaction.action_type = 'inception' THEN 'Policy' + ELSE 'Endorsement' + END AS action_type, + + clients.client_name AS client_name, + clients.short_name AS client_short_name, + client_branch.branch_name AS client_branch_name, + client_branch.address1 AS client_address, + policy_type.policy_type, + policy_type.bap, + insurers.name AS insurer_name, + insurers.short_name AS insurer_short_name, + insurer_branch.branch_name AS insurer_branch_name, + insurer_branch.branch_code AS insurer_branch_code, + user_profiles.first_name AS user_name, + vehicle.vehicle_no, + tpa.name AS tpa_name, + pt_co_share_details.remark AS remarks, + pt_co_share_details.cop_amt AS bp_amt, + pt_co_share_details.exp_amt, + pt_co_share_details.id AS pt_id, + sales_user.first_name AS salse_person_name, + service_user.first_name AS service_person_name, + + ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) AS premium_wo_gst, + ROUND((ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) * 18 / 100), 2) AS gst_amount, + ROUND( + ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) + + ROUND((ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) * 18 / 100), 2), + 2) AS total_premium, + + ROUND(pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) AS tp_or_ter, + DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days, + (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per, + pt_co_share_details.agreed_bp_per, + + -- ============================== + -- SUBQUERY: Total IRDA Amount + -- Alias Agreed Amount ...!! + -- ============================== + ROUND(pt_co_share_details.exp_amt, 2) AS total_irda_amt, + -- Reward Only + ROUND(( + SELECT SUM(co_share_stmt_details.reward) + FROM co_share_stmt_details + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + AND insurer_statements.is_active = 1 + AND insurer_statements.month = insurer_statements_oq.month + {$date_condition} + GROUP BY('policy_transaction.policy_no , insurer_statements.month , pt_co_share_details.insurer_id') + ), 2) AS reward, + + -- Billed Amount + ROUND(( + SELECT SUM( + COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) + + COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) + + COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) + + COALESCE(co_share_stmt_details.reward, 0) + ) + FROM co_share_stmt_details + JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id + JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id + WHERE co_share_stmt_details.co_share_id = pt_co_share_details.id + AND co_share_stmt_details.is_active = 1 + AND pt_table.is_active = 1 + AND insurer_statements.is_active = 1 + AND insurer_statements.invoice_status IS NOT NULL + AND insurer_statements.month = insurer_statements_oq.month + {$date_condition} + GROUP BY('policy_transaction.policy_no , insurer_statements.month , pt_co_share_details.insurer_id') + ), 2) AS billed_amt, + + created_user.first_name AS user_name, + + CASE + WHEN pt_co_share_details.co_share_type IN (0, 1) THEN policy_transaction.policy_no + WHEN pt_co_share_details.co_share_type > 1 THEN + CASE + WHEN pt_co_share_details.follower_policy_no IS NULL OR pt_co_share_details.follower_policy_no = '' + THEN policy_transaction.policy_no + ELSE pt_co_share_details.follower_policy_no + END + ELSE policy_transaction.policy_no + END AS policy_no + ") + + // ============================== + // JOINS + // ============================== + ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left') + ->join('clients', 'clients.id = policy_transaction.client_id') + ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left') + ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') + ->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left') + ->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left') + ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left') + ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left') + ->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left') + ->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left') + ->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left') + ->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left') + ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left') + ->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left') + + + ->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id','left') + ->join('insurer_statements insurer_statements_oq','insurer_statements_oq.id = co_share_stmt_details.statement_id','left') + + ->where('policy_transaction.is_active', 1) + ->where('pt_co_share_details.is_active', 1) + ->where('insurer_statements_oq.id IS NOT NULL') + + + // ======================================================== + // GROUP BY Insurer Statement Months + // ======================================================= + ->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ,insurer_statements_oq.month'); // ============================== // ROLE-BASED FILTERS @@ -2092,17 +2275,22 @@ class PolicyTransactionModel extends Model } } - // ============================== - // ORDER & EXECUTION - // ============================== - $builder->orderBy('policy_transaction.id', 'desc'); - $result = $builder->get()->getResultArray(); - // Uncomment if you need to debug SQL - // dd($this->db->getLastQuery()); + + + $sql1 = $builder2->getCompiledSelect(); + $sql2 = $builder->getCompiledSelect(); + + $finalSql = "($sql1) UNION ALL ($sql2) + ORDER BY policy_no DESC, insurer_branch_name ASC, statement_uploaded ASC, + STR_TO_DATE(policy_issue_month, '%b %Y') ASC"; + + + $result = $this->db->query($finalSql)->getResultArray(); return $result; + } From 4590bc45b869d09a07162b7b954fa1379a942d54 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 25 Oct 2025 17:15:15 +0530 Subject: [PATCH 02/46] New Report BDS CHanges-2 - VADIVEL J 2025-10-25 --- app/Views/report_bds.php | 109 ++++++++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 14 deletions(-) diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 446f2ada..ff3eba14 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -113,8 +113,91 @@ table.dataTable tbody td { - - $row){ ?> + + + + + $row){ + + $policy_no = $row['policy_no']; + + $policy_updated_month = $row['policy_issue_month']; + + $policy_type = $row['policy_type']; + + $statement_status = $row['statement_uploaded']; + + $client_name = $row['client_name']; + + $insurer_branch_name = $row['insurer_branch_name']; + + + + $uniqueRecord = "$policy_no-$policy_updated_month-$policy_type-$client_name-$insurer_branch_name" ; + + // irrespective of months or multiple months + $uniqueAgreedAmountPerInsurer = "$policy_no-$policy_type-$client_name-$insurer_branch_name" ; + + + + if(isset($uniquePoliciesReport[$uniqueRecord]) && $statement_status == "no statement uploaded" ){ + continue ; + } + else if(isset($uniquePoliciesReport[$uniqueRecord]) && $statement_status == "statement uploaded" ){ + unset($uniquePoliciesReport[$uniqueRecord]); + }else{ + + if(isset($uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer]) ){ + $uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer] -= $row['billed_amt']; + $row['total_irda_amt'] = 0; + $row['outstanding_amt'] = $uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer]; + $row['multiple_months'] = true; + } + else{ + $row['outstanding_amt'] = $row['total_irda_amt'] - $row['billed_amt']; + $uniqueAgreedAmountList[$uniqueAgreedAmountPerInsurer] = $row['total_irda_amt'] ; + $row['multiple_months'] = false; + } + + + + $uniquePoliciesReport[$uniqueRecord] = $row; + } + + + + + + + } + + + + + + + $report_list = array_values($uniquePoliciesReport); + + ?> + + + + $row){ + + ?>   " class="mdi mdi-pencil" > - + + @@ -149,17 +233,13 @@ table.dataTable tbody td {  %  % - - - - + + + + - - - + + @@ -394,7 +474,8 @@ $(document).ready(function() { $(sheet).find('sheetData').append(totalRow); }, exportOptions: { - orthogonal: 'sort' + orthogonal: 'sort' , + columns: ':not(:eq(3))' // skip the same 4th column }, customizeData: function (data) { for (var i = 0; i < data.body.length; i++) { From 5585d3668d13c2f76b138f40d44ae413df02d24b Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 25 Oct 2025 17:44:12 +0530 Subject: [PATCH 03/46] New Report BDS CHanges-3 - VADIVEL J 2025-10-25 --- test.http | 100 ------------------------------------------------------ 1 file changed, 100 deletions(-) delete mode 100644 test.http diff --git a/test.http b/test.http deleted file mode 100644 index a3e3125a..00000000 --- a/test.http +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - -POST https://testtips.vidalhealthtpa.com:7443/mobilerest/vidalbrokerservices/submitClaim -Authorization: Basic dmlkYWxicm9rZXJsb2dpbjp2aWRhbHN0YWdlQDEyMw== -Cookie: JSESSIONID=678ofNbsfB8svK1lyV6rON3w.worker1 -Content-Type: multipart/form-data; boundary=WebApiBoundary - ---WebApiBoundary -Content-Disposition: form-data; name="username" - -Web_api ---WebApiBoundary -Content-Disposition: form-data; name="password" - -Web@api ---WebApiBoundary -Content-Disposition: form-data; name="policyNo" - -CI/TEST/POLICY/123456 ---WebApiBoundary -Content-Disposition: form-data; name="enrollmentId" - -BLR-RG-H0351-043-0000002-A ---WebApiBoundary -Content-Disposition: form-data; name="typeOfClaim" - -Main hospitalization claim ---WebApiBoundary -Content-Disposition: form-data; name="claimSubType" - -Hospitalization ---WebApiBoundary -Content-Disposition: form-data; name="requestedAmount" - -4500 ---WebApiBoundary -Content-Disposition: form-data; name="ailmentType" - -Non covid ---WebApiBoundary -Content-Disposition: form-data; name="admissionDate" - -20-03-2025 ---WebApiBoundary -Content-Disposition: form-data; name="dischargeDate" - -23-03-2025 ---WebApiBoundary -Content-Disposition: form-data; name="hospitalName" - -A G HOSPITAL NEW ---WebApiBoundary -Content-Disposition: form-data; name="empanelmentNo" - -HOS-PON-010427 ---WebApiBoundary -Content-Disposition: form-data; name="documentType" - -Claim ---WebApiBoundary -Content-Disposition: form-data; name="ailmentName" - -Cold ---WebApiBoundary -Content-Disposition: form-data; name="hospitalAddress" - -abc ---WebApiBoundary -Content-Disposition: form-data; name="hospitalState" - -karnataka ---WebApiBoundary -Content-Disposition: form-data; name="hospitalCity" - -bangalore ---WebApiBoundary -Content-Disposition: form-data; name="hospitalPinCode" - -560036 ---WebApiBoundary -Content-Disposition: form-data; name="hospitalPhoneNo" - -7656879899 ---WebApiBoundary -Content-Disposition: form-data; name="File"; filename="tracker.pdf" -Content-Type: application/pdf - -< ./C:\Users\jvadi\Downloads\Tickets - Business Show_ Chennai (India) (06_11_2025 14_00_00) - vadivel.pdf ---WebApiBoundary-- - - -// claim - From 5af308f596907b511022ecc753db103166791c48 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 25 Oct 2025 18:29:08 +0530 Subject: [PATCH 04/46] CHANGE_email notification to acc manger while inception - VADIVEL J 2025-10-25 --- app/Controllers/EmployeeRestController.php | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1b7310b6..5b568b48 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -4174,7 +4174,11 @@ class EmployeeRestController extends AdminController ]; // Save into DB - $this->hrFileUploadModel->insert($data); + $result = $this->hrFileUploadModel->insert($data); + + if($result && $data['file_action'] == "addition"){ + $this->giveNotificationToClientsAccountManager($data); + } return $this->respondCreated([ 'status' => true, @@ -4188,6 +4192,39 @@ class EmployeeRestController extends AdminController } + private function giveNotificationToClientsAccountManager($data){ + + // $data = [ + // 'client_id' => $this->request->getPost('client_id'), + // 'client_branch_id' => $this->request->getPost('client_branch_id'), + // 'policy_id' => $this->request->getPost('policy_id'), + // 'policy_no' => $this->request->getPost('policy_no'), + // 'file_name' => $newFileName, + // 'file_action' => $this->request->getPost('file_action'), + // 'status' => 'Yet to start', + // 'created_by' => $this->request->getPost('created_by'), + // 'updated_by' => $this->request->getPost('created_by'), + // ]; + + + $account_manager_email = $this->clientRMModel->findAccountManagerEmail($data['client_id']); + + + + $from_mail = ""; + $to_mail = $account_manager_email; + $subject = "Inception Notification"; + $message = "Inception for Policy_No -" . $data['policy_no'] . " is uploaded . Awaiting Action..!!"; + $cc_string = ""; + $attachments = ""; + $reply_to = ""; + $bcc_string = ""; + + + MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]); + + } + public function updateHrFileUploadData() { try { From da6b733b731b90da7b36c5133306c4dca17c6fb2 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 27 Oct 2025 10:48:56 +0530 Subject: [PATCH 05/46] CHANGE_email notification to acc manger while inception - VADIVEL J 2025-10-27 --- app/Controllers/EmployeeRestController.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 5b568b48..69296a0c 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -53,6 +53,7 @@ use Illuminate\Http\Request; use App\Controllers\EmployeeServiceController; use App\Models\ClaimFilesModel; +use App\Models\TicketMailTemplateModel; use Kreait\Firebase\Factory; use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Notification; @@ -90,6 +91,7 @@ class EmployeeRestController extends AdminController protected $hrAccessControlModel; protected $insurerModel; protected $hrFileUploadModel; + protected $ticketMailTemplateModel; public function __construct() @@ -122,6 +124,7 @@ class EmployeeRestController extends AdminController $this->hrAccessControlModel = new HRAccessControlModel(); $this->insurerModel = new InsurerModel(); $this->hrFileUploadModel = new HrFileUploadModel(); + $this->ticketMailTemplateModel = new TicketMailTemplateModel(); } @@ -4206,15 +4209,27 @@ class EmployeeRestController extends AdminController // 'updated_by' => $this->request->getPost('created_by'), // ]; + $client_name = $this->clientModel->where('id',$data['client_id'])->findAll()[0]['client_name'] ?? [] ; $account_manager_email = $this->clientRMModel->findAccountManagerEmail($data['client_id']); + $templateName = "inception_addition"; + $mailTemplate = $this->ticketMailTemplateModel->where('template_name', $templateName)->findAll()[0] ?? []; + + if(empty($mailTemplate)){ + //empty mail template please update the template in database or create one..!! + log_message("error","Empty mail template for inception_addition please update the template in database or create one..!!"); + return ; + } + + $mailTemplate['mail_content'] = str_replace('%client_name%', $client_name ?? '', $mailTemplate['mail_content']); + $mailTemplate['mail_content'] = str_replace('%policy_no%', $data['policy_no'] ?? '', $mailTemplate['mail_content']); $from_mail = ""; $to_mail = $account_manager_email; - $subject = "Inception Notification"; - $message = "Inception for Policy_No -" . $data['policy_no'] . " is uploaded . Awaiting Action..!!"; + $subject = $mailTemplate['subject']; + $message = $mailTemplate['content']; $cc_string = ""; $attachments = ""; $reply_to = ""; From 653403e9b3639ce9e4bfc7058bee68a1b4613c30 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 27 Oct 2025 11:17:28 +0530 Subject: [PATCH 06/46] FEAT_MEMBER_DATA_COMPATIONSION_AND_M_MALE_CHANGE --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 17 +- app/Controllers/EmployeeController.php | 28 +- .../EmployeeMultiEventServiceController.php | 244 +++++++- app/Controllers/EmployeeServiceController.php | 530 +++++++++++++----- app/Controllers/JobWorker.php | 4 + app/Controllers/LeadsController.php | 4 +- app/Helpers/excel_util_helper.php | 34 +- app/Models/ClientPolicyModel.php | 1 + app/Models/FileModel.php | 1 + app/Views/employee_upload.php | 145 ++++- 11 files changed, 838 insertions(+), 171 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8ff3f4ac..96c36a35 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -400,6 +400,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster'); $routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster'); $routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount'); + $routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation'); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index e09c74ec..948ccbff 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5640,11 +5640,11 @@ class ClientController extends AdminController public function sendextraparam() { - // $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray(); - // // dd($data); - // $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true)); - // dd($return); - // die; + // $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray(); + // // dd($data); + // $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true)); + // dd($return); + // die; // $employeeController = new EmployeeController(); // $employeeController->truncateFileData('633'); @@ -5662,15 +5662,16 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $empServiceController = new EmployeeServiceController(); - $res = $empServiceController->excelFileFormatValidation(['file_id' => '2055']); + // $res = $empServiceController->excelFileFormatValidation(['file_id' => '1126']); // $res = $empServiceController->excelFileDataValidation(['file_id' => '865']); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]); // $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]); // $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]); // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']); // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); - // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); - dd($res); + // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); + // $res = $empServiceController->compareMemberDataAndInceptionData(['file_id' => '1126']); + // dd($res); $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController(); // $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 00d81e59..0dbac06f 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -171,7 +171,7 @@ class EmployeeController extends AdminController return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200); } else { - return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason']], 200); + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason'], 'is_comparison_skipped' => $file['is_comparison_skipped']], 200); } } @@ -3148,5 +3148,31 @@ class EmployeeController extends AdminController } } + // function for skip the Inception and Member data validation + public function proceedExcelFileDataValidation() + { + $file_id = $this->request->getGet('file_id'); + $not_skiped = $this->request->getGet('not_skiped') ?? null; + + if(!empty($not_skiped)){ + $file_model = new FileModel(); + $file_model->where('id', $file_id)->set(['is_comparison_skipped' => 0])->update(); + $message = "Inception and Member data comparision continuted by the user id : " . get_session_userid(); + $this->myLogger->logme('error', $message); + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision continued'], 200); + } + + if(!empty($file_id)){ + $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]); + $message = "Inception and Member data comparision skiped successfully by the user id : " . get_session_userid(); + $this->myLogger->logme('error', $message); + $file_model = new FileModel(); + $file_model->where('id', $file_id)->set(['is_comparison_skipped' => 1])->update(); + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision skiped successfully!'], 200); + }else{ + return $this->respond(['status' => false, 'code' => 500, 'message' => 'Failed to skip the comparison!'], 200); + } + } + } diff --git a/app/Controllers/EmployeeMultiEventServiceController.php b/app/Controllers/EmployeeMultiEventServiceController.php index e3027d01..50fbe300 100644 --- a/app/Controllers/EmployeeMultiEventServiceController.php +++ b/app/Controllers/EmployeeMultiEventServiceController.php @@ -26,6 +26,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use Kint\Kint; use App\Helpers\ExcelSanitizeHelper; +use App\Models\LeadsModel; class EmployeeMultiEventServiceController extends BaseController { @@ -140,7 +141,7 @@ class EmployeeMultiEventServiceController extends BaseController 'is_mandatory' => ['I', 'A', 'DA'], 'data_type' => 'str', 'format' => null, - 'allowed_values' => ['M', 'F'] + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] ], 'relationship' => [ 'col_idx' => 5, @@ -524,7 +525,7 @@ class EmployeeMultiEventServiceController extends BaseController 'is_mandatory' => ['I', 'A', 'DA', 'E'], 'data_type' => 'str', 'format' => null, - 'allowed_values' => ['M', 'F'] + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] ], 'relationship' => [ 'col_idx' => 5, @@ -889,8 +890,108 @@ class EmployeeMultiEventServiceController extends BaseController ] ]; - - + protected $member_data_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'Sl no', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_code' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'Emp Code', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'relationship' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Relationship', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => [ + 'Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother', + 'Father-in-law', 'Mother-in-law', + 'self', 'spouse', 'son', 'daughter', 'father', 'mother', + 'father-in-law', 'mother-in-law' + ], + 'custom' => 'check_relationship_for_member_data', + 'params' => ['row', 'relationship', 'columns_to_check'] + ], + 'gender' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Gender', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] + ], + 'dob' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'DOB', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'age_validation' => true, + // 'custom' => 'check_dob_diff', + // 'params' => ['row', 'relationship', 'default_age_ratio', 'policy_details'] + ], + 'age' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Age', + 'is_mandatory' => true, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null + ], + 'email' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Email', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'mobile' => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'Mobile', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'si' => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'SI', + 'is_mandatory' => false, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null, + ] + ]; public function __construct() { @@ -991,6 +1092,9 @@ class EmployeeMultiEventServiceController extends BaseController $params["action"] = "inception"; $params["file_path"] = $file_paths['inception']; $error[] = $this->excelFileFormatValidation($params); + if (isset($error['error_data']) && count($error['error_data']) == 0) { + $error[] = $this->compareMemberDataAndInceptionData($params); + } } //addition @@ -2125,10 +2229,9 @@ class EmployeeMultiEventServiceController extends BaseController foreach ($familiy_data as $fkey => $value) { if (is_array($value)) { - + if (isset($value['gender'])) { $value['gender'] = normalizeGender($value['gender'] );} if ($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && ($value['temp']['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data) { - $employee = $this->employeeModel->checkExistingEmp($value, $file['client_branch_id']); $policy_data = $value['policy_details']; $temp = $value['temp']; @@ -2881,6 +2984,135 @@ class EmployeeMultiEventServiceController extends BaseController return $temp; } + // --------- MEMBER DATA AND INCEPTION DATA COMPARISION ------------------------------------------------------------------------ + + public function compareMemberDataAndInceptionData($params) + { + $file_id = $params['file_id'] ?? null; + if (empty($file_id)) { + return ['status' => false, 'msg' => 'File ID is missing']; + } + + // ✅ Get File Data + $file = $this->fileModel->where(['is_active' => 1, 'id' => $file_id])->first(); + if (empty($file)) { + return ['status' => false, 'msg' => 'File not found in DB']; + } + + // ✅ Get Client Policy Data + $client_policy_data = $this->clientPolicyModel->where(['is_active' => 1, 'id' => $file['policy_id']])->first(); + if (empty($client_policy_data)) { + return ['status' => false, 'msg' => 'Client policy data not found in DB (policy_id: ' . $file['policy_id'] . ')']; + } + + // ✅ Get Lead Data + $leadModel = new LeadsModel(); + $lead_data = $leadModel->where(['is_active' => 1, 'id' => $client_policy_data['is_from_lead']])->first(); + if (empty($lead_data)) { + return ['status' => false, 'msg' => 'Lead data not found in DB (lead_id: ' . $client_policy_data['is_from_lead'] . ')']; + } + + // ✅ Define File Paths + // $inception_file_path = !empty($file['file_name']) ? WRITEPATH . "uploads/excel/" . $file['file_name'] : ''; + $member_file_path = !empty($lead_data['file_name']) ? WRITEPATH . "uploads/lead_files/" . $lead_data['file_name'] : ''; + + // ✅ Check Inception File + // if (empty($file['file_name']) || !file_exists($inception_file_path)) { + // $message = empty($file['file_name']) ? "Inception file name is missing" : "Inception physical file not found"; + // $this->myLogger->logme('error', "$message for file id $file_id"); + // $this->fileModel->update($file_id, [ + // 'status' => 'failed', + // 'reason' => json_encode(['error_summary' => [5], 'error_data' => $message]) + // ]); + // return ['error_summary' => [5], 'error_data' => $message]; + // } + + // ✅ Check Member File + if (empty($lead_data['file_name']) || !file_exists($member_file_path)) { + $message = empty($lead_data['file_name']) ? "Member file name is missing" : "Member data physical file not found"; + $this->myLogger->logme('error', "$message for lead id {$lead_data['id']}"); + $this->fileModel->update($file_id, [ + 'status' => 'failed', + 'reason' => json_encode(['error_summary' => [5], 'error_data' => $message]) + ]); + return ['error_summary' => [5], 'error_data' => $message]; + } + + + // ✅ Read Inception Excel + $inception_columns = $this->inception_excel_columns; + $inception_data = json_decode(file_get_contents($params['file_path'] ?? []), true); + // $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inception_file_path); + // $sheet = $spreadsheet->getActiveSheet(); + // $highestRow = $sheet->getHighestDataRow(); + // $allowedColumn = end($inception_columns)['col_cell_name']; + // $inception_data = $sheet->rangeToArray("A1:{$allowedColumn}{$highestRow}"); + // $inception_data = ExcelSanitizeHelper::sanitizeArrayData($inception_data); + + // ✅ Read Member Excel + $member_columns = $this->member_data_excel_columns; + $spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($member_file_path); + $sheet2 = $spreadsheet2->getSheet(0); + $highestRow2 = $sheet2->getHighestDataRow(); + $allowedColumn2 = end($member_columns)['col_cell_name']; + $member_data = $sheet2->rangeToArray("A1:{$allowedColumn2}{$highestRow2}"); + $member_data = ExcelSanitizeHelper::sanitizeArrayData($member_data); + + // dd($inception_data, $member_data); + + // ✅ Compare Inception Data with Member Data + $result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []]; + + $inception_data_count = count($inception_data); + $member_data_count = count($member_data); + + if ($inception_data_count !== $member_data_count) { + $result['error_summary'][] = 15; + $result['error_message'] = " + Inception Data Count: + {$inception_data_count}   + Member Data Count: + {$member_data_count}"; + } + + foreach ($inception_data as $inception_key => $inception_row) { + + // 🔹 If inception row is empty → stop all further processing + if (check_row_is_empty_or_null($inception_row)) { + break; + } + + $match_found = false; + + foreach ($member_data as $member_row) { + if ( + $inception_row[1] == $member_row[1] && // emp_id / emp_code + $inception_row[2] == $member_row[2] && // name_of_emp_dep / name + $inception_row[5] == $member_row[3] && // relationship + normalizeGender($inception_row[4]) == normalizeGender($member_row[4]) && // gender + $inception_row[3] == $member_row[5] && // dob + $inception_row[13] == $member_row[7] && // email + $inception_row[12] == $member_row[8] // phone / mobile + ) { + $match_found = true; + break; + } + } + + if (!$match_found) { + array_push($result['error_summary'], 14); + $result['error_data'][$inception_key]['sno']['error'][] = "This inception row was not found in the member data list."; + } + } + + // ✅ Handle Result + if (!empty($result['error_summary'])) { + $result['error_summary'] = array_count_values($result['error_summary']); + $this->myLogger->logme('error', "File ID $file_id comparison failed"); + } + + return $result; + } } diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 07bf7ad5..bee97fe1 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -29,7 +29,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use Kint\Kint; use App\Helpers\ExcelSanitizeHelper; - +use App\Models\LeadsModel; class EmployeeServiceController extends AdminController { @@ -144,7 +144,7 @@ class EmployeeServiceController extends AdminController 'is_mandatory' => ['I', 'A', 'DA'], 'data_type' => 'str', 'format' => null, - 'allowed_values' => ['M', 'F'] + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] ], 'relationship' => [ 'col_idx' => 5, @@ -529,7 +529,8 @@ class EmployeeServiceController extends AdminController 'is_mandatory' => ['I', 'A', 'DA','E'], 'data_type' => 'str', 'format' => null, - 'allowed_values' => ['M', 'F'] + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] + ], 'relationship' => [ 'col_idx' => 5, @@ -643,21 +644,121 @@ class EmployeeServiceController extends AdminController ]; protected $enrollment_to_inception_mapping = [ - 0 => 0, // enrollment: sno (Sno) -> inception: sno (S.No) - 1 => 1, // enrollment: emp_code (Emp_Code) -> inception: emp_id (EMP ID) - 2 => 2, // enrollment: name (NAME OF EMP/DEP) -> inception: name_of_emp_dep (NAME OF EMP/DEP) - 3 => 8, // enrollment: doj (DOJ) -> inception: doj (DOJ) - 4 => 4, // enrollment: gender (Gender) -> inception: gender (Gender) - 5 => 5, // enrollment: relationship (Relation) -> inception: relationship (RELATIONSHIP) - 6 => 3, // enrollment: dob (DOB) -> inception: dob (DOB) - 7 => 13, // enrollment: email (Email) -> inception: email (Email) - 8 => 12, // enrollment: phone (Mobile) -> inception: phone (Phone) - 9 => 6, // enrollment: basic_cover_si (SI) -> inception: basic_cover_si (BASIC COVER SI) - 10 => 10, // enrollment: band_grade (Grade) -> inception: band_grade (Band/Grade) - 11 => 9 // enrollment: basic_pay (Basic Pay) -> inception: basic_pay (Basic Pay) - ]; - - + 0 => 0, // enrollment: sno (Sno) -> inception: sno (S.No) + 1 => 1, // enrollment: emp_code (Emp_Code) -> inception: emp_id (EMP ID) + 2 => 2, // enrollment: name (NAME OF EMP/DEP) -> inception: name_of_emp_dep (NAME OF EMP/DEP) + 3 => 8, // enrollment: doj (DOJ) -> inception: doj (DOJ) + 4 => 4, // enrollment: gender (Gender) -> inception: gender (Gender) + 5 => 5, // enrollment: relationship (Relation) -> inception: relationship (RELATIONSHIP) + 6 => 3, // enrollment: dob (DOB) -> inception: dob (DOB) + 7 => 13, // enrollment: email (Email) -> inception: email (Email) + 8 => 12, // enrollment: phone (Mobile) -> inception: phone (Phone) + 9 => 6, // enrollment: basic_cover_si (SI) -> inception: basic_cover_si (BASIC COVER SI) + 10 => 10, // enrollment: band_grade (Grade) -> inception: band_grade (Band/Grade) + 11 => 9 // enrollment: basic_pay (Basic Pay) -> inception: basic_pay (Basic Pay) + ]; + protected $member_data_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'Sl no', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_code' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'Emp Code', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'relationship' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Relationship', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => [ + 'Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother', + 'Father-in-law', 'Mother-in-law', + 'self', 'spouse', 'son', 'daughter', 'father', 'mother', + 'father-in-law', 'mother-in-law' + ], + 'custom' => 'check_relationship_for_member_data', + 'params' => ['row', 'relationship', 'columns_to_check'] + ], + 'gender' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Gender', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female'] + ], + 'dob' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'DOB', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'age_validation' => true, + // 'custom' => 'check_dob_diff', + // 'params' => ['row', 'relationship', 'default_age_ratio', 'policy_details'] + ], + 'age' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Age', + 'is_mandatory' => true, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null + ], + 'email' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Email', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'mobile' => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'Mobile', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'si' => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'SI', + 'is_mandatory' => false, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null, + ] + ]; public function __construct() { @@ -923,7 +1024,14 @@ class EmployeeServiceController extends AdminController } else //trigger next data validation via job queue server - { + { + // check the condition if the policy from the Leads and check the lead id exist in the client policy table + if($file['action'] == 'inception' && $policy_details[0]->policy_entry_from == 3 && !empty($policy_details[0]->is_from_lead)){ + $r = Jobs::addJob(['job_name' => 'compareMemberDataAndInceptionData','payload' => ['file_id' => $file_id]]); + $this->myLogger->logme("error",'compareMemberDataAndInceptionData job pushed'); + return $result; + } + if($file['action'] == 'enrollment' && $file['uploaded_by'] != 1) // if current action is enrollment and uploaded by HR (0 or NULL) call next validation and return result { // dd(); @@ -1542,8 +1650,7 @@ class EmployeeServiceController extends AdminController return true; } - - //enhance of emp + //enhance of emp public function employeesSIEnhanceProcess($params) { helper('excel_util_helper'); @@ -1666,9 +1773,8 @@ class EmployeeServiceController extends AdminController return true; } - // insert or update in db for inception addition depent addition - public function employeesOnboardProcess($params) + public function employeesOnboardProcess($params) { // dd($params); @@ -1683,7 +1789,7 @@ class EmployeeServiceController extends AdminController if(is_array($value)) { - + if (isset($value['gender'])) { $value['gender'] = normalizeGender($value['gender'] );} if($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && ($value['temp']['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data) { @@ -1723,7 +1829,7 @@ class EmployeeServiceController extends AdminController $value['updated_by'] = $file['created_by']; $value['id'] = $employee[0]['id']; $value['emp_status'] = 'active'; - $value['family_floater_key'] = generate_family_floater_key($value['relationship']); + $value['family_floater_key'] = generate_family_floater_key($value['relationship']); $value['client_branch_id'] = $file['client_branch_id']; $value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ; $log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id']; @@ -1872,127 +1978,125 @@ class EmployeeServiceController extends AdminController } -// --------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------- - public function getExcelErrorData($file_id){ + public function getExcelErrorData($file_id) + { - try { - $file = $this->fileModel->find($file_id); - $error_data = json_decode($file['reason']); - // dd($error_data); - // return $error_data; + try { + $file = $this->fileModel->find($file_id); + $error_data = json_decode($file['reason']); + // dd($error_data); + // return $error_data; - $file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name']; + $file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name']; - //check the file exist or not - if(!file_exists($file_name_with_path)) - { - $error_message = "File not found"; - $this->myLogger->logme('error',($error_message . ' for file id ' . $file_id)); - return 0; - } - - $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); - $sheet = $spreadsheet->getActiveSheet(); - - $highestRowAndColumn = $sheet->getHighestRowAndColumn(); - $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); - $excelErrorData['excel_header'] = $excel_data[0]; - unset($excel_data[0]); - // echo '
';
-         // Kint::dump($excel_data);
-         if($error_data->error_type == 1){
-
-            $finalArray = [];
-            foreach ($error_data->error_data as $key => $value) {
-    
-                foreach ($value as $key2 => $value2) {
-                    $error_data = $value2->error;
-                    $data = ['value' => $excel_data[$key][$value2->col_idx], 'error'=>$error_data,];
-                    $excel_data[$key][$value2->col_idx] = $data;
-    
-                }
-                array_push($finalArray, $excel_data[$key]);
+            //check the file exist or not
+            if(!file_exists($file_name_with_path))
+            {
+                $error_message = "File not found";
+                $this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
+                return 0;
             }
-    
-            foreach ($finalArray as $fkey => $value){
-                foreach ($value as $vkey => $arrayData){
-                    if(!is_array($arrayData)){
-                        $data = ['value' => $arrayData];
-                        $finalArray[$fkey][$vkey] =  $data;
+
+            $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
+            $sheet = $spreadsheet->getActiveSheet();
+        
+            $highestRowAndColumn = $sheet->getHighestRowAndColumn();
+            $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
+            $excelErrorData['excel_header'] = $excel_data[0];
+            unset($excel_data[0]);
+            //  echo '
';
+            // Kint::dump($excel_data);
+            if($error_data->error_type == 1){
+
+                $finalArray = [];
+                foreach ($error_data->error_data as $key => $value) {
+        
+                    foreach ($value as $key2 => $value2) {
+                        $error_data = $value2->error;
+                        $data = ['value' => $excel_data[$key][$value2->col_idx], 'error'=>$error_data,];
+                        $excel_data[$key][$value2->col_idx] = $data;
+        
+                    }
+                    array_push($finalArray, $excel_data[$key]);
+                }
+        
+                foreach ($finalArray as $fkey => $value){
+                    foreach ($value as $vkey => $arrayData){
+                        if(!is_array($arrayData)){
+                            $data = ['value' => $arrayData];
+                            $finalArray[$fkey][$vkey] =  $data;
+                        }
                     }
                 }
-            }
-    
-            $excelErrorData['excel_data'] = $finalArray;
-            return $excelErrorData;
+        
+                $excelErrorData['excel_data'] = $finalArray;
+                return $excelErrorData;
 
-         }else if($error_data->error_type == 2){
+            }else if($error_data->error_type == 2){
 
 
-            $allErrors = [];
-            $typeTowArray = [];
+                $allErrors = [];
+                $typeTowArray = [];
 
-            foreach ($error_data->error_data as $index => $item) {
+                foreach ($error_data->error_data as $index => $item) {
 
-                foreach ($item as $field) {
-                    if (!isset($allErrors[$index])) {
-                        $allErrors[$index] = [];
+                    foreach ($item as $field) {
+                        if (!isset($allErrors[$index])) {
+                            $allErrors[$index] = [];
+                        }
+                        $allErrors[$index] = array_merge($allErrors[$index], $field->error);
                     }
-                    $allErrors[$index] = array_merge($allErrors[$index], $field->error);
                 }
-            }
 
-            // dd(array_keys($allErrors));
-            foreach ($allErrors as $key => $value){
-                // echo $key;
-                // print_r($value);
-                foreach($excel_data as $excel_data_index => $excel_data_value)
-                {
-                    if($excel_data_value[0] == $key)
+                // dd(array_keys($allErrors));
+                foreach ($allErrors as $key => $value){
+                    // echo $key;
+                    // print_r($value);
+                    foreach($excel_data as $excel_data_index => $excel_data_value)
                     {
-                        $data = ['value' => $excel_data[$excel_data_index][1], 'error'=>$value,];
-                        $excel_data[$excel_data_index][1] = $data;
-                        array_push($typeTowArray, $excel_data[$excel_data_index]);
-                        break;
+                        if($excel_data_value[0] == $key)
+                        {
+                            $data = ['value' => $excel_data[$excel_data_index][1], 'error'=>$value,];
+                            $excel_data[$excel_data_index][1] = $data;
+                            array_push($typeTowArray, $excel_data[$excel_data_index]);
+                            break;
+                        }
                     }
-                }
-               
                 
-            }
-            // dd($data);
-            foreach ($typeTowArray as $fkey => $value){
-                foreach ($value as $vkey => $arrayData){
-                    if(!is_array($arrayData)){
-                        $data = ['value' => $arrayData];
-                        $typeTowArray[$fkey][$vkey] =  $data;
+                    
+                }
+                // dd($data);
+                foreach ($typeTowArray as $fkey => $value){
+                    foreach ($value as $vkey => $arrayData){
+                        if(!is_array($arrayData)){
+                            $data = ['value' => $arrayData];
+                            $typeTowArray[$fkey][$vkey] =  $data;
+                        }
                     }
                 }
+
+                $excelErrorData['excel_data'] = $typeTowArray;
+                return $excelErrorData;
+
             }
 
-            $excelErrorData['excel_data'] = $typeTowArray;
-            return $excelErrorData;
+            }catch (\Exception $e) {
+                // Handle any exceptions
+                $errorMessage = $e->getMessage();//die();
+                $this->myLogger->logme('error', $errorMessage);
+                return false; // You can return an error response here
+            }
+    }
 
-         }
+    // ---------------------------------------------------------------------------------
 
-        }catch (\Exception $e) {
-            // Handle any exceptions
-            $errorMessage = $e->getMessage();//die();
-            $this->myLogger->logme('error', $errorMessage);
-            return false; // You can return an error response here
-        }
+    public function getFileMetaDataByFileId($file_id, $status = 'success')
+    {
 
-
-
- }
-
-
-// ---------------------------------------------------------------------------------
-
-public function getFileMetaDataByFileId($file_id, $status = 'success'){
-
-       $data = $this->fileModel
+        $data = $this->fileModel
         ->select('files.*, clients.client_name, clients.short_name, policy_type.policy_type as policy_name,client_branch.branch_code')
         ->join('clients', 'clients.id = files.client_id')
         ->join('client_policy', 'client_policy.id = files.policy_id')
@@ -2016,11 +2120,9 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
 
         return ['msg_txt' => $msg_txt, 'user_id' => $user_id, 'url' => $url, 'status' => $status, 'title' => $msg_title];
     }
-
-
-    public function setPullNotification($data){
-
-
+        
+    public function setPullNotification($data)
+    {
         $array = ['message_text' => $data['msg_txt'], 'action_url' => $data['url'], 'msg_status' => $data['status'], 'msg_title' => $data['title']];
         $jsonEncodeData = json_encode($array);
 
@@ -2031,17 +2133,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
             'role_id' => NULL,
             'team_id' => NULL,
             'message_type' => '1to1',
-         ];
+        ];
 
- 
-         $this->messageModel->insert($msg_data);
- 
-
-}
+        $this->messageModel->insert($msg_data);
+    }
 
     public function employeesEnrollmentInsert($params)
     {
-        // dd($this->request);
+            // dd($this->request);
             helper('excel_util_helper');
             //get file name
             $file_id = $params['file_id'];
@@ -2059,10 +2158,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
             if(!file_exists($file_name_with_path))
             {
                 //file not found  update status and reason 
-                 $message = "Physical file not found";
+                    $message = "Physical file not found";
                 // echo $message;
                 $this->myLogger->logme('error',($message . ' for file id ' . $file_id));
-                 $this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
+                    $this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
                 return  array('error_summary' => [5], 'error_data' => $message);
             }
 
@@ -2077,7 +2176,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
             $allowedHighestColumn = end($columns_to_check);
             $excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
             // print_r($keys);die();
-             //get existing units in the current branch
+            
+            //get existing units in the current branch
             $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
             //remove header
             unset($excel_data[0]);
@@ -2109,11 +2209,11 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
                     {
                         $temp_unit = $existing_units[0];
                     }
-                   
+                    
                     $value['emp_code'] = $row[1];
                     $value['name'] = $row[2];
                     $value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
-                    $value['gender'] = $row[4];
+                    $value['gender'] = normalizeGender($row[4]);
                     $value['relationship'] = ucfirst(trim($row[5]));
                     $value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');
                     $value['email_corporate'] = $row[7];
@@ -2149,10 +2249,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
                             $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
                             $policy_data['client_policy_id'] = $file['policy_id'];
 
-                             $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
-                             unset($value['temp']);
+                                $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
+                                unset($value['temp']);
                             //save employee table
-                             // dd($employee['id']);
+                                // dd($employee['id']);
                             if($employee !== null)
                             {
                                 $value['updated_by'] = $file['created_by'];
@@ -2170,11 +2270,11 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
                             
                             $value = ExcelSanitizeHelper::sanitizeArrayData($value);
                             $this->employeeModel->save($value);
-                             if (isset($value['id'])) 
-                             {  $emp_id = $value['id']; } 
-                             else { $emp_id = $this->employeeModel->getInsertID(); 
+                                if (isset($value['id'])) 
+                                {  $emp_id = $value['id']; } 
+                                else { $emp_id = $this->employeeModel->getInsertID(); 
                                     $log_message .= $emp_id;
-                             }
+                                }
 
                             // $emp_id = $this->employeeModel->getInsertID();
                             // if($emp_id != 0){  $log_message .= $emp_id; }
@@ -2232,8 +2332,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
                                         'employee_id' => $emp_id,
                                         'mail_type' => 'member_welcome_mail',
                                     ];
-                                   //store email and mail content via helper to send notification
-                                   $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
+                                    //store email and mail content via helper to send notification
+                                    $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
                                 }
                             }
                 }// endof if row is empty check
@@ -2241,7 +2341,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
 
             // dd($emp_emails);
 
-             // for bulk mail queue job push  
+                // for bulk mail queue job push  
             if (!empty($emp_emails) && count($emp_emails) > 0) {
 
                 $emp_emails = array_chunk($emp_emails, 20);
@@ -2259,6 +2359,140 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
 
 
             return true;
-    }//end of employeesEnrollmentInsert
+    } //end of employeesEnrollmentInsert
 
+    // --------- MEMBER DATA AND INCEPTION DATA COMPARISION ------------------------------------------------------------------------
+
+    public function compareMemberDataAndInceptionData($params)
+    {
+        $file_id = $params['file_id'] ?? null;
+        if (empty($file_id)) {
+            return ['status' => false, 'msg' => 'File ID is missing'];
+        }
+
+        // ✅ Get File Data
+        $file = $this->fileModel->where(['is_active' => 1, 'id' => $file_id])->first();
+        if (empty($file)) {
+            return ['status' => false, 'msg' => 'File not found in DB'];
+        }
+
+        // ✅ Get Client Policy Data
+        $client_policy_data = $this->clientPolicyModel->where(['is_active' => 1, 'id' => $file['policy_id']])->first();
+        if (empty($client_policy_data)) {
+            return ['status' => false, 'msg' => 'Client policy data not found in DB (policy_id: ' . $file['policy_id'] . ')'];
+        }
+
+        // ✅ Get Lead Data
+        $leadModel = new LeadsModel();
+        $lead_data = $leadModel->where(['is_active' => 1, 'id' => $client_policy_data['is_from_lead']])->first();
+        if (empty($lead_data)) {
+            return ['status' => false, 'msg' => 'Lead data not found in DB (lead_id: ' . $client_policy_data['is_from_lead'] . ')'];
+        }
+
+        // ✅ Define File Paths
+        $inception_file_path = !empty($file['file_name']) ? WRITEPATH . "uploads/excel/" . $file['file_name'] : '';
+        $member_file_path    = !empty($lead_data['file_name']) ? WRITEPATH . "uploads/lead_files/" . $lead_data['file_name'] : '';
+
+        // ✅ Check Inception File
+        if (empty($file['file_name']) || !file_exists($inception_file_path)) {
+            $message = empty($file['file_name']) ? "Inception file name is missing" : "Inception physical file not found";
+            $this->myLogger->logme('error', "$message for file id $file_id");
+            $this->fileModel->update($file_id, [
+                'status' => 'failed',
+                'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
+            ]);
+            return ['error_summary' => [5], 'error_data' => $message];
+        }
+
+        // ✅ Check Member File
+        if (empty($lead_data['file_name']) || !file_exists($member_file_path)) {
+            $message = empty($lead_data['file_name']) ? "Member file name is missing" : "Member data physical file not found";
+            $this->myLogger->logme('error', "$message for lead id {$lead_data['id']}");
+            $this->fileModel->update($file_id, [
+                'status' => 'failed',
+                'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
+            ]);
+            return ['error_summary' => [5], 'error_data' => $message];
+        }
+
+
+        // ✅ Read Inception Excel
+        $inception_columns = $this->inception_excel_columns;
+        $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inception_file_path);
+        $sheet = $spreadsheet->getActiveSheet();
+        $highestRow = $sheet->getHighestDataRow();
+        $allowedColumn = end($inception_columns)['col_cell_name'];
+        $inception_data = $sheet->rangeToArray("A1:{$allowedColumn}{$highestRow}");
+        $inception_data = ExcelSanitizeHelper::sanitizeArrayData($inception_data);
+
+        // ✅ Read Member Excel
+        $member_columns = $this->member_data_excel_columns;
+        $spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($member_file_path);
+        $sheet2 = $spreadsheet2->getSheet(0);
+        $highestRow2 = $sheet2->getHighestDataRow();
+        $allowedColumn2 = end($member_columns)['col_cell_name'];
+        $member_data = $sheet2->rangeToArray("A1:{$allowedColumn2}{$highestRow2}");
+        $member_data = ExcelSanitizeHelper::sanitizeArrayData($member_data);
+
+        //  dd($inception_data, $member_data);
+
+        // ✅ Compare Inception Data with Member Data
+        $result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
+
+        $inception_data_count = count($inception_data);
+        $member_data_count = count($member_data);
+
+        if ($inception_data_count !== $member_data_count) {
+            $result['error_summary'][] = 15;
+            $result['error_message'] = "
+                Inception Data Count: 
+                {$inception_data_count}  
+                Member Data Count: 
+                {$member_data_count}";
+        }
+
+        foreach ($inception_data as $inception_key => $inception_row) {
+
+            // 🔹 If inception row is empty → stop all further processing
+            if (check_row_is_empty_or_null($inception_row)) {
+                break;
+            }
+
+            $match_found = false;
+
+            foreach ($member_data as $member_row) {
+                if (
+                    $inception_row[1] == $member_row[1] &&  // emp_id / emp_code
+                    $inception_row[2] == $member_row[2] &&  // name_of_emp_dep / name
+                    $inception_row[5] == $member_row[3] &&  // relationship
+                    normalizeGender($inception_row[4]) == normalizeGender($member_row[4]) &&  // gender
+                    $inception_row[3] == $member_row[5] &&  // dob
+                    $inception_row[13] == $member_row[7] && // email
+                    $inception_row[12] == $member_row[8]    // phone / mobile
+                ) {
+                    $match_found = true;
+                    break;
+                }
+            }
+
+            if (!$match_found) {
+                array_push($result['error_summary'], 14);
+                $result['error_data'][$inception_key]['sno']['error'][] = "This inception row was not found in the member data list.";
+            }
+        }
+
+        // ✅ Handle Result
+        if (!empty($result['error_summary'])) {
+            $result['error_summary'] = array_count_values($result['error_summary']);
+            $this->fileModel->update($file_id, [
+                'status' => 'failed',
+                'reason' => json_encode($result)
+            ]);
+            $this->myLogger->logme('error', "File ID $file_id comparison failed");
+        } else {
+            Jobs::addJob(['job_name' => 'excelFileDataValidation', 'payload' => ['file_id' => $file_id]]);
+        }
+
+        return $result;
+    }
 }
\ No newline at end of file
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index 50c9820b..1dbf51b5 100755
--- a/app/Controllers/JobWorker.php
+++ b/app/Controllers/JobWorker.php
@@ -171,6 +171,10 @@ class JobWorker extends AdminController
         'type' => 'CC', // Handler Category
         'handler' => 'App\Controllers\LeadsController',
     ],
+    'compareMemberDataAndInceptionData' => [
+        'type' => 'CC', // Handler Category
+        'handler' => 'App\Controllers\EmployeeServiceController',
+    ],
 ];
 
     
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 6aeb4b73..ab968701 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -3673,7 +3673,7 @@ class LeadsController extends BaseController
     private function prepareClientData($data)
     {
         return [
-            'client_type'    => $data['client_type'] ?? null,
+            'client_type'    => 1,
             'entity_type_id' => $data['entity_type_id'] ?? null,
             'client_code'    => $data['client_code'] ?? null,
             'client_name'    => $data['client_name'] ?? null,
@@ -3723,6 +3723,8 @@ class LeadsController extends BaseController
             'policy_start_date' => $data['policy_start_date'],
             'policy_end_date'   => $data['policy_end_date'],
             'policy_status'     => 1,
+            'policy_entry_from' => 3,
+            'is_from_lead'      => $data['id'],
         ];
 
         $policy_type_id = $data['policy_type_id'];
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index e608b013..b17e2665 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -109,7 +109,8 @@ if (!function_exists('check_relationship')) {
 
                     $family_floaters = isset($policy_terms['family_floaters']);
                     if ($family_floaters) {
-                        if (isset($relationship[$col]) && $relationship[$col]['gender'] != $row[4]) {
+                        $relation_gender = normalizeGender($row[4]);
+                        if (isset($relationship[$col]) && $relationship[$col]['gender'] != $relation_gender) {
                             $error = "Gender relationship conflict: Expected " . $relationship[$col]['gender'] . ", received $row[4]";
                             return array('status' => false, 'error' => $error);
                         }
@@ -637,12 +638,19 @@ if (!function_exists('check_dependent_conflict')) {
 if (!function_exists('generate_relationship_code')) {
     function generate_relationship_code($arr)
     {
-        $gender = ['M' => 1, 'F' => 2];
+        $gender = [
+            'M' => 1, 
+            'Male' => 1, 
+            'male' => 1, 
+            'F' => 2,
+            'Female' => 2,
+            'female' => 2,
+        ];
         $relationship = ['self' => 1, 'spouse' => 2, 'son' => 3, 'daughter' => 4, 'father' => 5, 'mother' => 6, 'father-in-law' => 7, 'mother-in-law' => 8];
         $slug = \Config\Services::slug();
         $relationship_code = $slug->slugify($arr['relationship']);
         $emp_type_code = ($relationship_code == 'self' ? 'EMP_TYP_01' : 'EMP_TYP_03');
-        $relationship_code = $gender[trim($arr['gender'])] . $relationship[trim($relationship_code)];
+        $relationship_code = $gender[trim($arr['gender'])] ?? "" . $relationship[trim($relationship_code)] ?? "";
         return ['relationship_code' => $relationship_code, 'emp_type_code' => $emp_type_code];
     }
 }
@@ -2041,6 +2049,22 @@ if (!function_exists('formatIndianCurrency')) {
     }
 }
 
+if (!function_exists('normalizeGender')) {
+    function normalizeGender($gender)
+    {
+        $gender = strtoupper(trim($gender));
+
+        if (in_array($gender, ['M', 'MALE'])) {
+            return 'M';
+        } elseif (in_array($gender, ['F', 'FEMALE'])) {
+            return 'F';
+        }
+
+        // Optional: return null or original if not recognized
+        return null;
+    }
+}
+
 // ------------- FUNCTION FOR LEAD MEMBER DATA LIST VALIDATIONS --------------------------------------
 
 if (!function_exists('check_columns_name_exist')) {
@@ -2291,8 +2315,8 @@ if (!function_exists('validateFamily')) {
             // Validation 3: Validate spouse gender if spouse exists
             if ($spouseMember !== null) {
 
-                $selfGender = strtoupper(trim($selfMember[4])); // Gender field
-                $spouseGender = strtoupper(trim($spouseMember[4]));
+                $selfGender = normalizeGender(trim($selfMember[4])); // Gender field
+                $spouseGender = normalizeGender(trim($spouseMember[4]));
                 $selfName = $selfMember[2]; // Name field
                 $spouseName = $spouseMember[2];
                 
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 152cad7f..d3618eb6 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -56,6 +56,7 @@ class ClientPolicyModel extends Model
         "is_lgbtq",
         "placement_json",
         "policy_entry_from",
+        "is_from_lead",
     ];
 
     // Callbacks
diff --git a/app/Models/FileModel.php b/app/Models/FileModel.php
index ff4f584e..0f72c18f 100755
--- a/app/Models/FileModel.php
+++ b/app/Models/FileModel.php
@@ -22,6 +22,7 @@ class FileModel extends Model
         "uploaded_by",
         "updated_by",
         "hr_file_id",
+        "is_comparison_skipped",
     ];
 
 
diff --git a/app/Views/employee_upload.php b/app/Views/employee_upload.php
index 00718a37..0575d532 100755
--- a/app/Views/employee_upload.php
+++ b/app/Views/employee_upload.php
@@ -465,15 +465,22 @@ function fetchFileError(file_id) {
 
             $(this).find(".modal-body").html("");
             if (response.code === 200 && response.dataStatus === true && response.data !== "") {
+
                 try {
                     // console.log((JSON.parse(response.data)));
                     var file_error_data = (JSON.parse(response.data));
                     var file_error_html = "";
+                    let hasError14 = false;
+                    let hasError15 = false;
+                    let buttonAdded = false;
+                    let error_code = 0;
+                    let is_comparison_skipped = response.is_comparison_skipped ?? null;
 
                     for (var key in file_error_data['error_summary']) {
                         // console.log(key);
                         var err_id = parseInt(key);
                         var err_count = file_error_data['error_summary'][key];
+                        
                         switch (err_id) {
                              case 0:
                                 file_error_html +=
@@ -538,6 +545,20 @@ function fetchFileError(file_id) {
                                     "Rule conflict: Twofold relationship found within family " +
                                     err_count + "";
                                 break;
+                            case 14:
+                                hasError14 = true;
+                                error_code = 14;
+                                file_error_html +=
+                                    "This inception row was not found in the member data list. " +
+                                    err_count + "";
+                                break;
+                            case 15:
+                                hasError15 = true;
+                                error_code = 15;
+                                file_error_html += 
+                                    "Inception–member data count mismatch. " + err_count + " 
" + + file_error_data['error_message'] ?? "" ; + break; default: file_error_html += ""; @@ -565,13 +586,37 @@ function fetchFileError(file_id) { // console.log('file_error_html_2', file_error_html) } + + // ✅ Decide when to add buttons + if (!buttonAdded && is_comparison_skipped != 1 && is_comparison_skipped != 0) { + if (hasError15 && error_code == 15) { + // Add after 15 (preferred if both exist) + file_error_html += + "
" + + "

Do you want to skip the comparison?

" + + "" + + "" + + "
"; + buttonAdded = true; + } else if (hasError14 && !hasError15 && error_code == 14) { + // Add after 14 if 15 doesn't exist + file_error_html += + "
" + + "

Do you want to skip the comparison?

" + + "" + + "" + + "
"; + buttonAdded = true; + } + } + if (err_id != 5 && err_id != 6 && err_id != 0) { file_error_html += (file_error_html != "" ? "click here to more details..." : ""); + "' target=_blank class='text-center'>click here to more details..." : ""); } - + // console.log(file_error_html); $('#file-err-modal').find(".modal-body").html(file_error_html); return file_error_html; @@ -1043,5 +1088,101 @@ function checkValues() { // return true; } +$(document).on('click', '#confirmYes', function() { + let file_id = $(this).data('id'); + + Swal.fire({ + title: "Are you sure?", + text: "If you proceed, the comparison of the Inception and Member data list will be skipped, and the Inception file data validation process will start.", + icon: "warning", + showCancelButton: true, + confirmButtonText: "Yes, proceed", + cancelButtonText: "No, cancel", + confirmButtonColor: "#28a745", + cancelButtonColor: "#dc3545", + reverseButtons: true + }).then((result) => { + if (result.isConfirmed) { + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + $.ajax({ + url: '', // replace with actual API URL + type: 'GET', + data: { file_id: file_id }, + success: function(response) { + console.log('API response:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + } else { + toastr.warning(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + window.location.reload(); + }, + error: function(xhr) { + toastr.error('Failed to complete the action.'); + console.error('API error:', xhr.responseText); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + window.location.reload(); + } + }); + } + }); +}); + +$(document).on('click', '#confirmNo', function() { + let file_id = $(this).data('id'); + + Swal.fire({ + title: "Are you sure?", + text: "If you proceed, the comparison between the Inception and Member data list will continue without skipping, and the validation process will not start until the comparison is completed.", + icon: "warning", + showCancelButton: true, + confirmButtonText: "Yes, proceed", + cancelButtonText: "No, cancel", + confirmButtonColor: "#28a745", + cancelButtonColor: "#dc3545", + reverseButtons: true + }).then((result) => { + if (result.isConfirmed) { + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + $.ajax({ + url: '', // replace with actual API URL + type: 'GET', + data: { file_id: file_id, not_skiped : true }, + success: function(response) { + console.log('API response:', response); + + if (response.status === true) { + toastr.success(response.message, 'SUCCESS'); + } else { + toastr.warning(response.message, 'WARNING'); + } + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + window.location.reload(); + }, + error: function(xhr) { + toastr.error('Failed to complete the action.'); + console.error('API error:', xhr.responseText); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + window.location.reload(); + } + }); + } + }); +}); + //--------------------------------------------------------------------------------------------------------- \ No newline at end of file From 312673a134e7faff8abf592aeb5f6fa16cd737e3 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 27 Oct 2025 12:50:56 +0530 Subject: [PATCH 07/46] CHANGE_LEAD LIST PAGE HAVING MULTIPLE EDITS SORTED - VADIVEL J 2025-10-27 12:50 --- app/Views/layout/header.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index a8f91141..89457177 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -958,7 +958,21 @@ /* aligns text properly */ } + + + get()['userData']->role; + + + ?>
@@ -511,7 +518,16 @@ table.dataTable tbody td { @@ -522,7 +538,16 @@ table.dataTable tbody td { From eeb5e96a8b54d69d99aba43421e49903c005f9fc Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 27 Oct 2025 16:16:58 +0530 Subject: [PATCH 12/46] CHANGE_inception mail notification for mail bug fix - VADIVEL J 2025-10-27 16:16 --- app/Controllers/EmployeeRestController.php | 2 +- app/Helpers/sendMailNotification.php | 76 +++++++++++++++++ app/Views/mail_template.php | 98 ++++++++++++++++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 app/Views/mail_template.php diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 69296a0c..ecbba2f7 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -4229,7 +4229,7 @@ class EmployeeRestController extends AdminController $from_mail = ""; $to_mail = $account_manager_email; $subject = $mailTemplate['subject']; - $message = $mailTemplate['content']; + $message = $mailTemplate['mail_content']; $cc_string = ""; $attachments = ""; $reply_to = ""; diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index f9de6b09..b27a76b1 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -57,6 +57,13 @@ class sendMailNotification $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') { + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments, 'common' => $common]; } @@ -89,6 +96,12 @@ class sendMailNotification $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content); $mail = $emp_data['email_corporate']; + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; @@ -139,6 +152,13 @@ class sendMailNotification $mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "Download Insurance Card", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; @@ -523,6 +543,13 @@ class sendMailNotification $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + // print_r($mail_content); die; // $mail = "aadhavanvalli@gmail.com"; @@ -825,6 +852,13 @@ class sendMailNotification $full_name = $value['first_name'] .' ' .$value['last_name']; $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $full_name , $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + + $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common]; // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'}}; } @@ -1118,6 +1152,11 @@ class sendMailNotification $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); $hr_mails = $client_data['hr_mails']; $mail_array = explode(',', $hr_mails); @@ -1183,6 +1222,13 @@ class sendMailNotification $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); if ($mail != null || $mail != '') { + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments]; } @@ -1215,6 +1261,13 @@ class sendMailNotification if ((isset($notification_data) && $notification_data['enabled'] == 1)) { if (isset($mail) && !empty($mail)) { + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } @@ -1268,6 +1321,12 @@ class sendMailNotification $mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "Download Insurance Card", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'],'attachments' => $attachments, 'reply_to' => $client_data['reply_to']]; return $wholeData; @@ -1419,6 +1478,11 @@ class sendMailNotification $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; @@ -1568,6 +1632,13 @@ class sendMailNotification $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; return $wholeData; @@ -1717,6 +1788,11 @@ class sendMailNotification $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + + $data['params'] = $params;$data['client_logo'] = $client_logo; + $data['mail_content'] = $mail_content; + $mail_content = view('mail_template', $data); $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; diff --git a/app/Views/mail_template.php b/app/Views/mail_template.php new file mode 100644 index 00000000..22582cf5 --- /dev/null +++ b/app/Views/mail_template.php @@ -0,0 +1,98 @@ + + + + + + + Email Notification + + + + + + + + +
+ + + + + +
+ Client Logo + + Default Logo +
+
+ + + + + + + + + +
+ + + + + +
+ + + + + From e5df53f4cd9d2bb4e04e1498cea58dff59cf9ad7 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 27 Oct 2025 17:31:52 +0530 Subject: [PATCH 13/46] CHANGE_default mail template for post - VADIVEL J 2025-10-27 17:31 --- app/Helpers/sendMailNotification.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index b27a76b1..a726fe16 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -1221,9 +1221,9 @@ class sendMailNotification $mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "Review Details", $mail_content); - if ($mail != null || $mail != '') { - - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + if ( isset($mail) && !empty($mail) ) { + + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; @@ -1262,7 +1262,7 @@ class sendMailNotification if (isset($mail) && !empty($mail)) { - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; @@ -1321,7 +1321,7 @@ class sendMailNotification $mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "Download Insurance Card", $mail_content); $mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content); - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; @@ -1478,7 +1478,7 @@ class sendMailNotification $mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; @@ -1633,7 +1633,7 @@ class sendMailNotification $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; @@ -1788,7 +1788,7 @@ class sendMailNotification $mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name . ' (' . $emp_code . ')' , $mail_content); $mail_content = str_replace(["[[member_summary]]", "{{member_summary}}"], $table_content , $mail_content); - $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); + $mail_content = preg_replace('/]*>( |\s)*<\/p>/i', '', $mail_content); $data['params'] = $params;$data['client_logo'] = $client_logo; $data['mail_content'] = $mail_content; From 7c16c90d14b15dcef921715fe1f711269fbcefd1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 27 Oct 2025 18:10:13 +0530 Subject: [PATCH 14/46] CHANGE_SI_COMMA_SEPERATE_HANDLE --- .../EmployeeMultiEventServiceController.php | 34 +++++++++++++++++-- app/Controllers/EmployeeServiceController.php | 34 +++++++++++++++++-- app/Helpers/excel_util_helper.php | 13 ++++++- app/Helpers/utility_helper.php | 7 ++++ 4 files changed, 83 insertions(+), 5 deletions(-) diff --git a/app/Controllers/EmployeeMultiEventServiceController.php b/app/Controllers/EmployeeMultiEventServiceController.php index 50fbe300..19c3d65d 100644 --- a/app/Controllers/EmployeeMultiEventServiceController.php +++ b/app/Controllers/EmployeeMultiEventServiceController.php @@ -1461,6 +1461,13 @@ class EmployeeMultiEventServiceController extends BaseController $enrollment_keys = array_keys($enrollment_columns_to_check); } + // for this condition to avoid 5,00,000 to 500000 + if($current_column_action == 'SI'){ + $row[3] = removeNumberFormatting($row[3]); + }else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){ + $row[6] = removeNumberFormatting($row[6]); + } + //iterate each row for columns validations foreach ($row as $col_key => $col) { $is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory']; @@ -1599,6 +1606,16 @@ class EmployeeMultiEventServiceController extends BaseController $columns_to_check = $this->inception_excel_columns; } + $current_column_action = null; + if($file['action'] == 'inception'){ $current_column_action = 'I'; } + else if($file['action'] == 'addition'){ $current_column_action = 'A'; } + else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; } + else if($file['action'] == 'deletion'){ $current_column_action = 'D'; } + else if($file['action'] == 'correction'){ $current_column_action = 'C'; } + else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; } + else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; } + else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; } + $columns_to_check = $this->syncColIndex($this->multievent_excel_columns, $columns_to_check); // print_rr($columns_to_check); @@ -1626,7 +1643,7 @@ class EmployeeMultiEventServiceController extends BaseController if (in_array($file['action'], ['inception', 'missed_inception', 'addition', 'dependent_addition', 'deletion', 'correction', 'si_enhancement', 'enrollment'])) // the below funcitons are only for I,DA,A { - $employee_data_group_by_family = data_group_by_family($excel_data, 'excel', ($file['action'] == 'enrollment' ? 'enrollment' : '')); + $employee_data_group_by_family = data_group_by_family($excel_data, 'excel', ($file['action'] == 'enrollment' ? 'enrollment' : ''), $current_column_action); // dd($employee_data_group_by_family); $is_self_available_in_policy_terms = false; if ($policy_details['policy_type_id'] == 3) // GMC parents @@ -1798,6 +1815,16 @@ class EmployeeMultiEventServiceController extends BaseController $columns_to_check = $this->inception_excel_columns; } + $current_column_action = null; + if($file['action'] == 'inception'){ $current_column_action = 'I'; } + else if($file['action'] == 'addition'){ $current_column_action = 'A'; } + else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; } + else if($file['action'] == 'deletion'){ $current_column_action = 'D'; } + else if($file['action'] == 'correction'){ $current_column_action = 'C'; } + else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; } + else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; } + else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; } + // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'], $file['policy_id']); $policy_terms = (array) $policy_terms[0]; // convert obj to array @@ -1821,7 +1848,7 @@ class EmployeeMultiEventServiceController extends BaseController //get existing units in the current branch $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'], client_branch_id: $file['client_branch_id']); - $employee_data_group_by_family = data_group_by_family($excel_data); + $employee_data_group_by_family = data_group_by_family($excel_data, 'excel', '', $current_column_action); // dd($employee_data_group_by_family); foreach ($employee_data_group_by_family as $emp_id => $family) { @@ -2133,6 +2160,9 @@ class EmployeeMultiEventServiceController extends BaseController if (check_row_is_empty_or_null($row)) { break; } + + $row[3] = removeNumberFormatting($row[3]); + // echo '
START- ' . $row[2]; $employee = $this->employeeModel ->where('emp_code', $row[1]) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index bee97fe1..4a8a3fd2 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -910,6 +910,13 @@ class EmployeeServiceController extends AdminController $enrollment_columns_to_check = $this->enrollment_excel_columns; $enrollment_keys = array_keys($enrollment_columns_to_check); } + + // for this condition to avoid 5,00,000 to 500000 + if($current_column_action == 'SI'){ + $row[3] = removeNumberFormatting($row[3]); + }else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){ + $row[6] = removeNumberFormatting($row[6]); + } //iterate each row for columns validations foreach ($row as $col_key => $col) @@ -1086,6 +1093,16 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; } if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; } + $current_column_action = null; + if($file['action'] == 'inception'){ $current_column_action = 'I'; } + else if($file['action'] == 'addition'){ $current_column_action = 'A'; } + else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; } + else if($file['action'] == 'deletion'){ $current_column_action = 'D'; } + else if($file['action'] == 'correction'){ $current_column_action = 'C'; } + else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; } + else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; } + else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; } + // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); $policy_details = (array)$policy_terms[0]; @@ -1116,7 +1133,7 @@ class EmployeeServiceController extends AdminController if(in_array($file['action'],['inception','missed_inception','addition','dependent_addition','deletion','correction','si_enhancement','enrollment']))// the below funcitons are only for I,DA,A { - $employee_data_group_by_family = data_group_by_family($excel_data,'excel',($file['action'] == 'enrollment' ? 'enrollment' : '')); + $employee_data_group_by_family = data_group_by_family($excel_data,'excel',($file['action'] == 'enrollment' ? 'enrollment' : ''), $current_column_action); // dd($employee_data_group_by_family); $is_self_available_in_policy_terms = false; if($policy_details['policy_type_id'] == 3) // GMC parents @@ -1321,6 +1338,16 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; } if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; } + $current_column_action = null; + if($file['action'] == 'inception'){ $current_column_action = 'I'; } + else if($file['action'] == 'addition'){ $current_column_action = 'A'; } + else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; } + else if($file['action'] == 'deletion'){ $current_column_action = 'D'; } + else if($file['action'] == 'correction'){ $current_column_action = 'C'; } + else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; } + else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; } + else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; } + // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); $policy_terms = (array) $policy_terms[0];// convert obj to array @@ -1344,7 +1371,7 @@ class EmployeeServiceController extends AdminController //get existing units in the current branch $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']); - $employee_data_group_by_family = data_group_by_family($excel_data); + $employee_data_group_by_family = data_group_by_family($excel_data, 'excel', '', $current_column_action); // dd($employee_data_group_by_family); foreach ($employee_data_group_by_family as $emp_id => $family) { @@ -1681,6 +1708,9 @@ class EmployeeServiceController extends AdminController { break; } + + $row[3] = removeNumberFormatting($row[3]); + // echo '
START- ' . $row[2]; $employee = $this->employeeModel ->where('emp_code', $row[1]) diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index b17e2665..2c7ff2bb 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -370,13 +370,24 @@ if (!function_exists('check_dob_diff')) { } if (!function_exists('data_group_by_family')) { - function data_group_by_family($emp_data, $data_source = 'excel', $action = '') + function data_group_by_family($emp_data, $data_source = 'excel', $action = '', $current_column_action = null) { $result = []; // Kint::dump($emp_data); foreach ($emp_data as $rkey => $row) { + + + if ($data_source == 'excel') { if (!check_row_is_empty_or_null($row)) { + + // for this condition to avoid 5,00,000 to 500000 + if($current_column_action == 'SI'){ + $row[3] = removeNumberFormatting($row[3]); + }else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){ + $row[6] = removeNumberFormatting($row[6]); + } + if ($action == 'enrollment') //if action is enrollment transform current row into inception row, becoz we treat enrollment as inception { $row = transform_enrollment_row_to_inception_row($row); diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 86229e9d..ba3099de 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -866,3 +866,10 @@ if (!function_exists('getFileIfExists')) { return file_exists(FCPATH . $path) ? base_url($path) : ''; } } + +if (!function_exists('removeNumberFormatting')) { + function removeNumberFormatting($number) + { + return (float) str_replace(',', '', trim($number)); + } +} From 69f8243ac09117efd73572f019dad5c403a3789f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 10:31:04 +0530 Subject: [PATCH 15/46] FIX_ --- app/Controllers/LeadsController.php | 7 +++---- app/Helpers/utility_helper.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index ab968701..931146cb 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -773,7 +773,7 @@ class LeadsController extends BaseController $multi_file_data = []; foreach ($files as $index => $value) { - $file_name = file_Upload($value, $uploadFilePath); + $file_name = file_Upload_with_random_name($value, $uploadFilePath); $multi_file_data[] = [ 'file_name' => $file_name, 'docs_name' => $docs_names[$index], @@ -2605,7 +2605,6 @@ class LeadsController extends BaseController $this->myLogger->logme('error', (' no file found ' . $file_name_with_path)); return ['status' => 'failed', 'message' => 'no file found']; } - }catch(Exception $e){ $this->myLogger->logme("error", "Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); return ['status' => 'fail', 'error' => "File not found / Wrong file"]; @@ -5268,10 +5267,10 @@ class LeadsController extends BaseController 'filePath' => $fullPath ]; } else { - log_message('warning', 'File name is empty for ID: ' . $id); + log_message('error', 'File name is empty for ID: ' . $id); } } else { - log_message('warning', 'File does not exist at path: ' . $fullPath); + log_message('error', 'File does not exist at path: ' . $fullPath); } } else { log_message('warning', 'No active lead file found for ID: ' . $id . ' and lead_id: ' . $lead_id); diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index ba3099de..d85ae7c3 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -65,6 +65,20 @@ if (!function_exists('file_Upload')) { } } +if (!function_exists('file_Upload_with_random_name')) { + function file_Upload_with_random_name($fileToUpload, $filepath) + { + if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); + $fileName = $fileToUpload->getRandomName(); + $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); + return $fileName; + } else { + return ""; + } + } +} + // if (!function_exists('multi_file_Upload')) { // function multi_file_Upload($fileToUpload, $filepath) // { From e45ed190491dfd38120b3786cfce941e85bfb382 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 10:45:20 +0530 Subject: [PATCH 16/46] CHANGE_FILE_UPLOAD --- app/Controllers/LeadsController.php | 3 ++- app/Helpers/utility_helper.php | 16 +--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 931146cb..e84a15e2 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -773,7 +773,7 @@ class LeadsController extends BaseController $multi_file_data = []; foreach ($files as $index => $value) { - $file_name = file_Upload_with_random_name($value, $uploadFilePath); + $file_name = file_Upload($value, $uploadFilePath); $multi_file_data[] = [ 'file_name' => $file_name, 'docs_name' => $docs_names[$index], @@ -2605,6 +2605,7 @@ class LeadsController extends BaseController $this->myLogger->logme('error', (' no file found ' . $file_name_with_path)); return ['status' => 'failed', 'message' => 'no file found']; } + }catch(Exception $e){ $this->myLogger->logme("error", "Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); return ['status' => 'fail', 'error' => "File not found / Wrong file"]; diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index d85ae7c3..632218cd 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -57,21 +57,7 @@ if (!function_exists('file_Upload')) { if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { $fileToUpload->move($filepath); $fileName = $fileToUpload->getName(); - $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); - return $fileName; - } else { - return ""; - } - } -} - -if (!function_exists('file_Upload_with_random_name')) { - function file_Upload_with_random_name($fileToUpload, $filepath) - { - if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { - $fileToUpload->move($filepath); - $fileName = $fileToUpload->getRandomName(); - $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); + // $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); return $fileName; } else { return ""; From 543bdd41e7df56d2995caa065332685e189b004b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 11:04:27 +0530 Subject: [PATCH 17/46] CHANGE_FILE_UPLOAD_ISSUE --- app/Controllers/LeadsController.php | 2 +- app/Helpers/utility_helper.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index e84a15e2..98ec08c0 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -773,7 +773,7 @@ class LeadsController extends BaseController $multi_file_data = []; foreach ($files as $index => $value) { - $file_name = file_Upload($value, $uploadFilePath); + $file_name = file_Upload_for_lead($value, $uploadFilePath); $multi_file_data[] = [ 'file_name' => $file_name, 'docs_name' => $docs_names[$index], diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 632218cd..9130a991 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -57,7 +57,20 @@ if (!function_exists('file_Upload')) { if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { $fileToUpload->move($filepath); $fileName = $fileToUpload->getName(); - // $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); + $fileName = preg_replace('/[\s\x{00A0}\x{200B}-\x{200D}\x{FEFF}]/u', '', $fileName); + return $fileName; + } else { + return ""; + } + } +} + +if (!function_exists('file_Upload_for_lead')) { + function file_Upload_for_lead($fileToUpload, $filepath) + { + if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); + $fileName = $fileToUpload->getName(); return $fileName; } else { return ""; From c96a06fcfc41f0fe8860a5feb2d7cee0ec0ec38c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 11:37:09 +0530 Subject: [PATCH 18/46] CHANGE_STOP_VALIDATION --- app/Controllers/LeadsController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 98ec08c0..3d82fced 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -665,7 +665,10 @@ class LeadsController extends BaseController if ($value['lead_form_type'] == 1) { //for this push the job to the calculateMembersDemography() function $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [ + // $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [ + // 'lead_id' => $insert, + // ]]); + $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [ 'lead_id' => $insert, ]]); } @@ -809,7 +812,10 @@ class LeadsController extends BaseController if (!empty($lead_form_type) && $lead_form_type == 1 && $key == 0) { //for this push the job to the calculateMembersDemography() function $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [ + // $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [ + // 'lead_id' => $lead_id, + // ]]); + $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [ 'lead_id' => $lead_id, ]]); log_message('info', "calculateMembersDemography JOB PUSHED"); From 7e6ecd570dc55846905a61ca6d1f5b0e505a773f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 11:56:14 +0530 Subject: [PATCH 19/46] CHANGE_PLACEMENT_MAIL_TEMPLATE --- app/Controllers/LeadsController.php | 56 +++++++++++++++++++---------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 3d82fced..731202da 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1089,6 +1089,7 @@ class LeadsController extends BaseController // 7. Define mail templates as constants or config $mail_content = $this->getMailTemplate(); + $placement_mail_content = $this->getMailTemplate('placement'); $subject = $this->getSubjectTemplate($lead_data); // 8. Pre-calculate sum assured only for GPA @@ -1097,7 +1098,7 @@ class LeadsController extends BaseController // 9. Transform mail content once $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); - $data['placement_mail_content'] = $this->transformMailContent($lead_data, $mail_content, 'Placement'); + $data['placement_mail_content'] = $this->transformMailContent($lead_data, $placement_mail_content, 'Placement'); $data['placement_subject'] = $this->transformMailContent($lead_data, $subject, 'Placement'); // 10. Combine related queries @@ -1150,24 +1151,43 @@ class LeadsController extends BaseController } // 13. Extract mail template to separate method for reusability - private function getMailTemplate() - { - return ' -

Dear Sir,

-

Greetings From Nhance India!

-

Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}}.

-

Kindly request you to share the competitive quotes at the earliest.

-

In case of any query, please feel free to contact us.

-

Thank You!


-

Best regards,

+ private function getMailTemplate( $template_type = "" ) + { + if($template_type == 'placement'){ + return ' +

Dear Sir,

+

Greetings From Nhance India!

+

Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}}.

+

Kindly request you to issue the policy at the earliest.

+

In case of any query, please feel free to contact us.

+

Thank You!


+

Best regards,

+ +
+
{{LOGGED_USER_NAME}}
+
Mobile: {{LOGGED_USER_MOBILE}}
+
-
-
{{LOGGED_USER_NAME}}
-
Mobile: {{LOGGED_USER_MOBILE}}
-
- - Nhance Logo - '; + Nhance Logo + '; + }else{ + return ' +

Dear Sir,

+

Greetings From Nhance India!

+

Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}}.

+

Kindly request you to share the competitive quotes at the earliest.

+

In case of any query, please feel free to contact us.

+

Thank You!


+

Best regards,

+ +
+
{{LOGGED_USER_NAME}}
+
Mobile: {{LOGGED_USER_MOBILE}}
+
+ + Nhance Logo + '; + } } // 14. Extract subject template to separate method From 33ace21f99d43656481f5b8e57ac76a6426a0c16 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Tue, 28 Oct 2025 16:24:14 +0530 Subject: [PATCH 20/46] CHANGE__Default_mail_template__By__VADIVEL_J__2025-10-28_16:23 --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 73 +++++++ app/Controllers/TestingController.php | 275 ++++++++++++++++++-------- 3 files changed, 270 insertions(+), 79 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a0d62ffb..a685eb1f 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -719,6 +719,7 @@ $routes->group('test', function($routes) { $routes->get('membervalidation', 'TestingController::membervalidation'); $routes->get('generateExcel', 'TestingController::generateExcel'); $routes->get('logo_renaming','TestingController::logo_renaming'); + // $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInDB'); }); $routes->cli('cli/testcli', 'TestingController::testcli'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 948ccbff..2549d0ae 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -869,6 +869,12 @@ class ClientController extends AdminController if ($insert) { $client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first(); + + $client_id = $insert; + $default_template_creation = $this->createDefaultMailTemplate($client_id , $client_data); + if($default_template_creation == false){ + $this->myLogger->logme('error', 'Default Mail Template Creation Failed for Client ID: {data}', ['data' => $client_id]); + } return $this->respond(['status' => true, 'code' => 200, 'data' => $client_data], 200); } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); @@ -7732,9 +7738,76 @@ class ClientController extends AdminController return true; } + public function createDefaultMailTemplate($client_id , $client_data){ + + $member_welcome_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_welcome_mail')->get()->getResultArray()[0]??[]; + + $member_remainder_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_reminder_mail')->get()->getResultArray()[0]??[]; + + $member_review_and_summary_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_review_and_summary_mail')->get()->getResultArray()[0]??[]; + + $default_member_welcome_mail_template = [ + 'client_id' => $client_id, + 'template_name' => 'member_welcome_mail', + 'subject' => $member_welcome_mail_template['subject']??'', + 'mail_content' => $member_welcome_mail_template['mail_content']??'', + 'mail_content_json'=> $member_welcome_mail_template['mail_content_json']??'', + + 'created_by' => get_session_userid(), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_by' => null, + 'updated_at' => date('Y-m-d H:i:s'), + 'mail_content_copy'=> null + ]; + + $default_member_remainder_mail_template = [ + 'client_id' => $client_id, + 'template_name' => 'member_reminder_mail', + 'subject' => $member_remainder_mail_template['subject']??'', + 'mail_content' => $member_remainder_mail_template['mail_content']??'', + 'mail_content_json'=> $member_remainder_mail_template['mail_content_json']??'', + + 'created_by' => get_session_userid(), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_by' => null, + 'updated_at' => date('Y-m-d H:i:s'), + 'mail_content_copy'=> null + ]; + + $default_member_review_and_summary_mail_template = [ + 'client_id' => $client_id, + 'template_name' => 'member_review_and_summary_mail', + 'subject' => $member_review_and_summary_mail_template['subject']??'', + 'mail_content' => $member_review_and_summary_mail_template['mail_content']??'', + 'mail_content_json'=> $member_review_and_summary_mail_template['mail_content_json']??'', + + 'created_by' => get_session_userid(), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_by' => null, + 'updated_at' => date('Y-m-d H:i:s'), + 'mail_content_copy'=> null + ]; + + $this->myLogger->logme('error', 'Default Mail Template Data ' . json_encode([ + $default_member_welcome_mail_template, + $default_member_remainder_mail_template, + $default_member_review_and_summary_mail_template + ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + $default_templates_inserted = $this->notificationModel->insertBatch([ + $default_member_welcome_mail_template, + $default_member_remainder_mail_template, + $default_member_review_and_summary_mail_template + ]); + + + return $default_templates_inserted ? true : false; + + + } + diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index a7cdddd1..98257f4e 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -362,18 +362,18 @@ class TestingController extends BaseController $pre_clients_list = $this->getNonDuplicatePreClients(); - $log_post_clients_list = $post_clients_list ; + $log_post_clients_list = $post_clients_list; - $log_pre_clients_list = $pre_clients_list ; + $log_pre_clients_list = $pre_clients_list; log_message('error', 'Post Clients to be processed: ' . count($log_post_clients_list)); log_message('error', 'Pre Clients to be processed: ' . count($log_pre_clients_list)); - $matched_Count = 0 ; + $matched_Count = 0; $expected_match_count = min(count($post_clients_list), count($pre_clients_list)); - + if ( !empty($pre_clients_list) && @@ -444,31 +444,27 @@ class TestingController extends BaseController } } - + log_message('error', 'Expected Match Count : ' . $expected_match_count); log_message('error', 'Total Matched Count: ' . $matched_Count); log_message('error', 'Total UnMatched Count: ' . $expected_match_count - $matched_Count); - - - log_message('error','unmatched_reocrds'); + + + log_message('error', 'unmatched_reocrds'); $log_post_clients_list = array_values($log_post_clients_list); $log_pre_clients_list = array_values($log_pre_clients_list); - if( (count($log_pre_clients_list) < count($log_post_clients_list))){ - log_message('error',"unmatched records count from pre- ". count($log_pre_clients_list)); - log_message('error',print_r($log_pre_clients_list,true)); + if ((count($log_pre_clients_list) < count($log_post_clients_list))) { + log_message('error', "unmatched records count from pre- " . count($log_pre_clients_list)); + log_message('error', print_r($log_pre_clients_list, true)); } else { - log_message('error',"unmatched records count from post - ".count($log_post_clients_list)); - log_message('error',print_r($log_post_clients_list,true)); + log_message('error', "unmatched records count from post - " . count($log_post_clients_list)); + log_message('error', print_r($log_post_clients_list, true)); } - - - } + } return $this->response->setJSON(['status' => 'success', 'message' => 'Client and Branch mapping completed.'])->setStatusCode(200); - - } @@ -535,7 +531,7 @@ class TestingController extends BaseController return $results; } public function membervalidation($lead_id = 329) - { + { $lead_controll = new LeadsController(); // $lead_controll->getMemberDataExcelFileErrors(); $res = $lead_controll->memberDataListExcelFileFormatValidation(['lead_id' => $lead_id]); @@ -543,18 +539,81 @@ class TestingController extends BaseController } private $firstNames = [ - 'Rajesh', 'Priya', 'Amit', 'Sneha', 'Vikram', 'Anjali', 'Rahul', 'Deepika', - 'Sanjay', 'Kavita', 'Arun', 'Pooja', 'Manoj', 'Nisha', 'Suresh', 'Meera', - 'Karthik', 'Divya', 'Ravi', 'Lakshmi', 'Anand', 'Swathi', 'Vijay', 'Rekha', - 'Ashok', 'Sangeetha', 'Prakash', 'Uma', 'Ramesh', 'Vani', 'Kumar', 'Radha', - 'Dinesh', 'Shanti', 'Ganesh', 'Parvati', 'Mohan', 'Sita', 'Arjun', 'Geetha' + 'Rajesh', + 'Priya', + 'Amit', + 'Sneha', + 'Vikram', + 'Anjali', + 'Rahul', + 'Deepika', + 'Sanjay', + 'Kavita', + 'Arun', + 'Pooja', + 'Manoj', + 'Nisha', + 'Suresh', + 'Meera', + 'Karthik', + 'Divya', + 'Ravi', + 'Lakshmi', + 'Anand', + 'Swathi', + 'Vijay', + 'Rekha', + 'Ashok', + 'Sangeetha', + 'Prakash', + 'Uma', + 'Ramesh', + 'Vani', + 'Kumar', + 'Radha', + 'Dinesh', + 'Shanti', + 'Ganesh', + 'Parvati', + 'Mohan', + 'Sita', + 'Arjun', + 'Geetha' ]; private $lastNames = [ - 'Kumar', 'Sharma', 'Singh', 'Patel', 'Reddy', 'Nair', 'Iyer', 'Krishnan', - 'Rao', 'Gupta', 'Verma', 'Agarwal', 'Joshi', 'Mehta', 'Desai', 'Pillai', - 'Menon', 'Bhat', 'Naidu', 'Varma', 'Malhotra', 'Kapoor', 'Chopra', 'Saxena', - 'Pandey', 'Mishra', 'Tiwari', 'Dubey', 'Sinha', 'Jain', 'Shah', 'Thakur' + 'Kumar', + 'Sharma', + 'Singh', + 'Patel', + 'Reddy', + 'Nair', + 'Iyer', + 'Krishnan', + 'Rao', + 'Gupta', + 'Verma', + 'Agarwal', + 'Joshi', + 'Mehta', + 'Desai', + 'Pillai', + 'Menon', + 'Bhat', + 'Naidu', + 'Varma', + 'Malhotra', + 'Kapoor', + 'Chopra', + 'Saxena', + 'Pandey', + 'Mishra', + 'Tiwari', + 'Dubey', + 'Sinha', + 'Jain', + 'Shah', + 'Thakur' ]; private $relationships = ['Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother']; @@ -611,9 +670,9 @@ class TestingController extends BaseController for ($i = 1; $i <= $totalRecords; $i++) { $row = $i + 1; // Start from row 2 (row 1 is header) - + $record = $this->generateSampleRecord($i); - + $sheet->setCellValue('A' . $row, $record['sl_no']); $sheet->setCellValue('B' . $row, $record['emp_code']); $sheet->setCellValue('C' . $row, $record['name']); @@ -664,33 +723,33 @@ class TestingController extends BaseController $firstName = $this->firstNames[array_rand($this->firstNames)]; $lastName = $this->lastNames[array_rand($this->lastNames)]; $name = $firstName . ' ' . $lastName; - + $relationship = $this->relationships[array_rand($this->relationships)]; $gender = $this->genders[array_rand($this->genders)]; - + // Generate random age between 18 and 65 $age = rand(18, 65); - + // Calculate DOB based on age $year = date('Y') - $age; $month = str_pad(rand(1, 12), 2, '0', STR_PAD_LEFT); $day = str_pad(rand(1, 28), 2, '0', STR_PAD_LEFT); $dob = "{$day}-{$month}-{$year}"; - + // Generate employee code $empCode = 'EMP' . str_pad($index, 6, '0', STR_PAD_LEFT); - + // Generate email $email = strtolower($firstName . '.' . $lastName . $index) . '@' . $this->domains[array_rand($this->domains)]; - + // Generate mobile number (Indian format) $mobile = '+91' . rand(7000000000, 9999999999); - + // Generate insurance amounts $siOptions = [100000, 200000, 300000, 500000, 1000000]; $si = $siOptions[array_rand($siOptions)]; $si_enhancement = rand(0, 1) ? rand(50000, 200000) : 0; - + $proposed_si_1 = $si + rand(100000, 500000); $proposed_si_2 = $proposed_si_1 + rand(100000, 500000); $proposed_si_3 = $proposed_si_2 + rand(100000, 500000); @@ -716,64 +775,67 @@ class TestingController extends BaseController } - public function logo_renaming(){ - - $directory = ROOTPATH . 'public/uploads/logo/'; + public function logo_renaming() + { - if (!is_dir($directory)) { - die("Directory not found: $directory"); + $directory = ROOTPATH . 'public/uploads/logo/'; + + if (!is_dir($directory)) { + die("Directory not found: $directory"); + } + + $files = scandir($directory); + + $client_logo_files = $this->get_client_logo_files(); + + $rename_files = ""; + $failed_rename_files = ""; + + foreach ($files as $file) { + // Skip system entries + if ($file === '.' || $file === '..') { + continue; } - $files = scandir($directory); - $client_logo_files = $this->get_client_logo_files(); + $oldPath = $directory . $file; - $rename_files = ""; - $failed_rename_files = ""; + if (is_file($oldPath) && in_array(trim($file), $client_logo_files)) { - foreach ($files as $file) { - // Skip system entries - if ($file === '.' || $file === '..' ) { - continue; - } - + // Remove all spaces from filename + $newFileName = preg_replace('/\s+|\x{00A0}|\x{200B}|\x{200C}|\x{200D}|\x{FEFF}/u', '', $file); - $oldPath = $directory . $file; + $newPath = $directory . $newFileName; - if (is_file($oldPath) && in_array(trim($file) , $client_logo_files)) { - - // Remove all spaces from filename - $newFileName = preg_replace('/\s+|\x{00A0}|\x{200B}|\x{200C}|\x{200D}|\x{FEFF}/u', '', $file); - - $newPath = $directory . $newFileName; - - // Only rename if the name changed - if ($oldPath !== $newPath) { - if (rename($oldPath, $newPath)) { - $rename_files .= "\n Renamed: $file → $newFileName \n"; - } else { - $failed_rename_files .= "\n Failed file: $file \n"; - } + // Only rename if the name changed + if ($oldPath !== $newPath) { + if (rename($oldPath, $newPath)) { + $rename_files .= "\n Renamed: $file → $newFileName \n"; + } else { + $failed_rename_files .= "\n Failed file: $file \n"; } } } + } - $dbUpdated = $this->update_client_logo_files(); + $dbUpdated = $this->update_client_logo_files(); - log_message('error', 'Renamed Files: ' . $rename_files); - log_message('error', 'Failed Renames: ' . $failed_rename_files); - log_message('error', 'Database Update Status: ' . ($dbUpdated ? 'Success' : 'No changes made')); + log_message('error', 'Renamed Files: ' . $rename_files); + log_message('error', 'Failed Renames: ' . $failed_rename_files); + log_message('error', 'Database Update Status: ' . ($dbUpdated ? 'Success' : 'No changes made')); - return $this->response->setJSON(['status' => 'success', + return $this->response->setJSON([ + 'status' => 'success', 'message' => 'Logo renaming completed. kindly check backend logs for details', 'data' => [ 'renamed_files' => $rename_files, 'failed_renames' => $failed_rename_files ] - ])->setStatusCode(200); + ])->setStatusCode(200); } - public function get_client_logo_files(){ + public function get_client_logo_files() + { $db = \Config\Database::connect(); @@ -783,14 +845,15 @@ class TestingController extends BaseController $results = $query->getResultArray() ?? []; - $files = array_map(function($item) { + $files = array_map(function ($item) { return trim($item['client_logo']); }, $results); return $files; } - public function update_client_logo_files(){ + public function update_client_logo_files() + { $db = \Config\Database::connect(); @@ -803,9 +866,63 @@ class TestingController extends BaseController $query = $db->query($sql); return $db->affectedRows() > 0; - - } + public function createDefaultMailTempalteInDB() + { + $postDB = \Config\Database::connect(); // target DB + $preDB = \Config\Database::connect('preDB'); // source DB + + // Templates to copy + $templateNames = [ + 'member_welcome_mail', + 'member_reminder_mail', + 'member_review_and_summary_mail' + ]; + + + + + foreach ($templateNames as $template) { + + $exists = $postDB->table('notifications') + ->where('client_id', NULL) + ->where('template_name', $template) + ->countAllResults(); + + if ($exists > 0) { + continue; // Skip if already inserted + } + + // Fetch template from preDB + $templateData = $preDB->table('notifications') + ->where('client_id', NULL) + ->where('template_name', $template) + ->get() + ->getRowArray(); + + if (!empty($templateData)) { + + // Remove ID to avoid duplicate primary key issues + unset($templateData['id']); + + // Set created_by and timestamps if needed + $templateData['client_id'] = NULL; + $templateData['created_by'] = 1; + $templateData['cretaed_at'] = date('Y-m-d H:i:s'); + $templateData['updated_by'] = NULL; + $templateData['updated_at'] = NULL; + + // Insert into postDB + $postDB->table('notifications')->insert($templateData); + } + } + + + return $this->response->setJSON(['message'=>"Created Default Mail Tempalte In DB "])->setStatusCode(200); + } + + + } From 7c7f3ce07abb9e89173539f14e8cce549f608894 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 18:01:50 +0530 Subject: [PATCH 21/46] FIX_BDS_REPORT_ISSUE_CHANGE_0_RESTRICT_POLICY_IN_BDS --- .../policy_transaction_endorsement_form.php | 29 +++++++++++++++++-- .../policy_transaction_inception_form.php | 24 +++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 4071282f..06f02de4 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1005,6 +1005,7 @@ setTimeout(function(){ $('#policy_start_date').val(res.data.policy_start_date); $('#policy_end_date').val(res.data.policy_end_date); + $('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id); }, 1500) $('#policy_no').val(res.data.policy_no); @@ -1347,15 +1348,39 @@ // $('#co_ter_premium_' + input).val(cotep.toFixed(2)); // } - function checkAndDistributeTax(input) - { + function checkAndDistributeTax(input){ + const event = window.event; console.log("Event id:", event.target.id); + let policy_type_id = $('#client_policy_id').find('option:selected').attr('data-ptid'); + policy_type_id = parseInt(policy_type_id); + console.log('policy_type_id', policy_type_id); + let cgst = parseFloat($('#cgst_' + input).val()); let sgst = parseFloat($('#sgst_' + input).val()); let igst = parseFloat($('#igst_' + input).val()); + // ✅ Allow 0 only for policy types 2, 5, 7 + const allowZero = [1,2,3,4,5,6,7,38,39,40].includes(policy_type_id); + console.log("allowZero", allowZero); + + // 🔒 Validation: Disallow 0 or negative values for other policy types + if (!allowZero) { + if ((cgst <= 0 && (event.target.id).startsWith('cgst')) || + (sgst <= 0 && (event.target.id).startsWith('sgst')) || + (igst <= 0 && (event.target.id).startsWith('igst'))) { + + toastr.warning('Tax value must be greater than 0 for this policy type.'); + $('#'+ event.target.id).val(''); + $('#igst_' + input).val(''); + $('#cgst_' + input).val(''); + $('#sgst_' + input).val(''); + + return; + } + } + if (((event.target.id).startsWith('cgst'))) { if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) { diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index f196a35e..75a0376d 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -2322,13 +2322,37 @@ // } function checkAndDistributeTax(input){ + const event = window.event; console.log("Event id:", event.target.id); + let policy_type_id = parseInt($('#policy_type_id').val()); + console.log('policy_type_id', policy_type_id); + let cgst = parseFloat($('#cgst_' + input).val()); let sgst = parseFloat($('#sgst_' + input).val()); let igst = parseFloat($('#igst_' + input).val()); + // ✅ Allow 0 only for policy types 2, 5, 7 + const allowZero = [1,2,3,4,5,6,7,38,39,40].includes(policy_type_id); + console.log("allowZero", allowZero); + + // 🔒 Validation: Disallow 0 or negative values for other policy types + if (!allowZero) { + if ((cgst <= 0 && (event.target.id).startsWith('cgst')) || + (sgst <= 0 && (event.target.id).startsWith('sgst')) || + (igst <= 0 && (event.target.id).startsWith('igst'))) { + + toastr.warning('Tax value must be greater than 0 for this policy type.'); + $('#'+ event.target.id).val(''); + $('#igst_' + input).val(''); + $('#cgst_' + input).val(''); + $('#sgst_' + input).val(''); + + return; + } + } + if (((event.target.id).startsWith('cgst'))) { if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) { From 317e456dafcf3f447ee03f20e89122dbfa2e24f7 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Oct 2025 10:24:01 +0530 Subject: [PATCH 22/46] CHANGE_inception mail notification template updation - VADIVEL J 2025-10-27 10:23 --- app/Controllers/EmployeeRestController.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index ecbba2f7..d5cca1d8 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -4179,7 +4179,7 @@ class EmployeeRestController extends AdminController // Save into DB $result = $this->hrFileUploadModel->insert($data); - if($result && $data['file_action'] == "addition"){ + if($result){ $this->giveNotificationToClientsAccountManager($data); } @@ -4196,24 +4196,12 @@ class EmployeeRestController extends AdminController } private function giveNotificationToClientsAccountManager($data){ - - // $data = [ - // 'client_id' => $this->request->getPost('client_id'), - // 'client_branch_id' => $this->request->getPost('client_branch_id'), - // 'policy_id' => $this->request->getPost('policy_id'), - // 'policy_no' => $this->request->getPost('policy_no'), - // 'file_name' => $newFileName, - // 'file_action' => $this->request->getPost('file_action'), - // 'status' => 'Yet to start', - // 'created_by' => $this->request->getPost('created_by'), - // 'updated_by' => $this->request->getPost('created_by'), - // ]; $client_name = $this->clientModel->where('id',$data['client_id'])->findAll()[0]['client_name'] ?? [] ; $account_manager_email = $this->clientRMModel->findAccountManagerEmail($data['client_id']); - $templateName = "inception_addition"; + $templateName = "hr_endorsement_template"; $mailTemplate = $this->ticketMailTemplateModel->where('template_name', $templateName)->findAll()[0] ?? []; @@ -4223,9 +4211,13 @@ class EmployeeRestController extends AdminController return ; } + $mailTemplate['mail_content'] = str_replace('%file_action%', $data['file_action'] ?? '', $mailTemplate['mail_content']); $mailTemplate['mail_content'] = str_replace('%client_name%', $client_name ?? '', $mailTemplate['mail_content']); $mailTemplate['mail_content'] = str_replace('%policy_no%', $data['policy_no'] ?? '', $mailTemplate['mail_content']); + $mailTemplate['subject'] = str_replace('%subject%',$data['file_action']??'',$mailTemplate['subject']); + $mailTemplate['subject'] = str_replace('%client_name%',$client_name??'',$mailTemplate['subject']); + $from_mail = ""; $to_mail = $account_manager_email; $subject = $mailTemplate['subject']; From 53dffb08e90e2b3ccbba302e559aa5f355f8d976 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Oct 2025 11:09:04 +0530 Subject: [PATCH 23/46] CHANGE_inception mail notification template updation-2 - VADIVEL J 2025-10-27 11:08 --- app/Controllers/EmployeeRestController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index d5cca1d8..83015c20 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -54,6 +54,7 @@ use Illuminate\Http\Request; use App\Controllers\EmployeeServiceController; use App\Models\ClaimFilesModel; use App\Models\TicketMailTemplateModel; +use Composer\Pcre\Preg; use Kreait\Firebase\Factory; use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Notification; @@ -4210,6 +4211,8 @@ class EmployeeRestController extends AdminController log_message("error","Empty mail template for inception_addition please update the template in database or create one..!!"); return ; } + + $data['file_action'] = ucwords(preg_replace("/_/", " ", $data['file_action'])); $mailTemplate['mail_content'] = str_replace('%file_action%', $data['file_action'] ?? '', $mailTemplate['mail_content']); $mailTemplate['mail_content'] = str_replace('%client_name%', $client_name ?? '', $mailTemplate['mail_content']); From f6e6056a7625784e7f964feb5413b3a0d481d2f5 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Oct 2025 11:56:23 +0530 Subject: [PATCH 24/46] CHANGE_ADD_user_in_masters_minor_fix - VADIVEL J 2025-10-29 11:55 --- app/Views/UserList.php | 11 ++++---- app/Views/leads_list.php | 55 ++++++++++++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/app/Views/UserList.php b/app/Views/UserList.php index f7b7098a..82441b22 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -521,12 +521,13 @@ table.dataTable tbody td { diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 1b411599..1762f32c 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -164,7 +164,7 @@ table.dataTable tbody td { -
S.No 
+
S.No  
Lead Type  
Issuer  
Client Type  
@@ -209,8 +209,10 @@ table.dataTable tbody td {