From be69492e80503a35bb1b76066d6dd17ae798d700 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Thu, 6 Jun 2024 17:19:51 +0530 Subject: [PATCH 1/9] CHANGE_OAUTH_ISSUE : AADHAVAN --- app/Controllers/UserController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 184cbefa..f654dc40 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -71,7 +71,8 @@ class UserController extends AdminController $admin = 0; } foreach ($temp_team as $key => $value) { - if($value == 2){ + $team = $this->teamModel->where('id' , $value)->first(); + if($team['name'] == 'Claims'){ $hdz_staff = [ 'emp_code' => $userData['emp_code'], 'fullname' => $userData['first_name'], From 9d6c23ff4e5dccc6dd33a3f602fa5a00e03fc97b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 25 Jun 2024 15:08:21 +0530 Subject: [PATCH 2/9] FIX_DELETE_CONFIRM_ROLE_AND_OTHERS : RV --- app/Config/Routes.php | 2 +- app/Controllers/ClientController.php | 9 +- app/Controllers/MasterController.php | 22 +- app/Helpers/utility_helper.php | 9 + app/Models/CDMasterModel.php | 22 + app/Models/ClientPolicyModel.php | 2 + app/Views/cd_master_list.php | 56 +- app/Views/client_branch.php | 790 +++++++++++++++------------ app/Views/client_list.php | 71 ++- app/Views/client_policy.php | 11 +- app/Views/client_rm.php | 4 +- app/Views/insurer_branch.php | 70 ++- app/Views/insurer_list.php | 65 ++- app/Views/kyc_docs.php | 69 ++- app/Views/kyc_list.php | 68 ++- app/Views/policies.php | 72 +-- app/Views/policy_type_list.php | 65 ++- app/Views/tpa_branch.php | 66 ++- app/Views/tpa_list.php | 66 ++- 19 files changed, 890 insertions(+), 649 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 73ce3697..9567f9a7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "MasterController::createCDMasterData"); $routes->post("edit", "MasterController::editCDMasterData"); $routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1"); - // $routes->get("remove/(:any)", "MasterController::policyTypeRemove/$1"); + $routes->get("remove/(:any)", "MasterController::removeCDMaster/$1"); }); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 02269a95..2a3e5782 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -301,9 +301,9 @@ class ClientController extends AdminController $editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll(); $editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); $editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); - // dd('Hi'); + $editData['client_branch']['role'] = get_role_id(); $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id); - // dd($this->clientPolicyModel->getLastQuery()); + foreach ($clientPoliceData as $key => $value) { $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); @@ -311,12 +311,10 @@ class ClientController extends AdminController } $editData['client_policy'] = $clientPoliceData; - - $editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll(); $editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; - + // dd($editData); echo view('layout/header', $headerData); echo view('client_onboarding', $editData); echo view('layout/footer'); @@ -565,6 +563,7 @@ class ClientController extends AdminController if($insert){ $branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll(); + $branchData['role'] = get_role_id(); return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200); }else{ return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 04f1e336..5d6ec3b9 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1123,13 +1123,7 @@ class MasterController extends AdminController public function CDMasterList() { - $data['CD_Master_Data'] = $this->CDMasterModel - ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name as insurer_name, user_profiles.first_name as user_name') - ->join('clients', 'clients.id = cd_master.client_id') - ->join('insurers', 'insurers.id = cd_master.insurer_id') - ->join('user_profiles', 'user_profiles.id = cd_master.created_by') - ->where('cd_master.is_active', 1) - ->findAll(); + $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList(); $data['insurers'] = $this->insurerModel->findAll(); $data['clients'] = $this->clientModel->findAll(); $this->loadLayout('cd_master_list', $data); @@ -1217,4 +1211,18 @@ class MasterController extends AdminController } } + + public function removeCDMaster($id){ + + $this->myLogger->logme('error','CDMaster Remove function called'); + $data['updated_by'] = get_session_userid(); + $data['is_active'] = 0; + $update = $this->CDMasterModel->where('id', $id)->set($data)->update(); + if($update){ + return $this->respond(['status' => true,'code' => 200], 200); + }else{ + return $this->respond(['status' => false,'code' => 404], 200); + } + } + } \ No newline at end of file diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 2dbcb1ce..87945e48 100644 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -239,3 +239,12 @@ if (!function_exists('get_username')) { } +if (!function_exists('get_role_id')) { + function get_role_id() { + + $role_id = get_session_userdata()->role; + return $role_id; + } +} + + diff --git a/app/Models/CDMasterModel.php b/app/Models/CDMasterModel.php index 491d1007..0e5c39a1 100644 --- a/app/Models/CDMasterModel.php +++ b/app/Models/CDMasterModel.php @@ -61,4 +61,26 @@ class CDMasterModel extends Model return $data; } + public function getCDMasterList(){ + + $query = $this->db->table('cd_master') + ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count') + ->join('clients', 'clients.id = cd_master.client_id') + ->join('insurers', 'insurers.id = cd_master.insurer_id') + ->join('user_profiles', 'user_profiles.id = cd_master.created_by') + ->join( + '(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count + FROM cd_master + JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no + GROUP BY cd_master.cd_ac_no) AS cd_ac_counts', + 'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no', + 'left' + ) + ->where('cd_master.is_active', 1) + ->get(); + + $result = $query->getResultArray(); + return $result; + } + } diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index a339b142..a69cf852 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -77,12 +77,14 @@ class ClientPolicyModel extends Model ->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code') ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code') ->select('policy_type.policy_type as policy_type_name') + ->select('client_branch.branch_name as branch_name') ->join('insurers', 'insurers.id = client_policy.insurer_id') ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id') ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left') ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left') ->join('policies', 'policies.id = client_policy.policy_id') ->join('policy_type', 'policy_type.id = policies.policy_type_id') + ->join('client_branch', 'client_branch.id = client_policy.client_branch_id') ->where('client_policy.client_id', $client_id) ->where('client_policy.policy_status', 1) ->where('client_policy.is_active', 1) diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 7a001b39..21e599ce 100644 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -58,12 +58,12 @@ table.dataTable thead th { @@ -290,4 +290,50 @@ table.dataTable thead th { }) + +function removeCDMaster(element) { + + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this CD.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('CD removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove CD.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); + } + + }); + +} + \ No newline at end of file diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 213f47c2..81b308e4 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -1,11 +1,12 @@
- +
- +
-
- +
+ @@ -23,52 +24,51 @@
- +
- +
-
- - - + + + +
- +
- - + +
- +
- - + +
- - + +
@@ -79,26 +79,37 @@
- +
- +
- +
- +
- - + +
@@ -119,168 +130,196 @@ \ No newline at end of file diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4548631a..2d84afdf 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -59,7 +59,9 @@ table.dataTable thead th {
@@ -111,38 +113,47 @@ table.dataTable thead th { function removeClient(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this client.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Client removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove client.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - + + }); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e5626a3a..a27e1d92 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -7,14 +7,15 @@
-
+
+ - + @@ -263,8 +264,9 @@ + - + + - + @@ -316,6 +316,8 @@ $('#policy_form_action').val(''); $('#policy_status_field').hide() $('#base_policy_id').hide(); + $('#policy_PrimaryKey').val(""); + $('#insurer_policy_id').val(""); $('#first').hide(); @@ -635,6 +637,7 @@ }); + }); $(document).ready(function() { @@ -649,28 +652,35 @@ console.log('client_id', client_id) console.log('branch_id', branch_id) console.log('policy_type_id', dataId) + console.log('client_policy_id', $('#policy_PrimaryKey').val()) + + $('#policy_type_id').val(dataId); - var url = '' + id + '/' + dataId + '/' + branch_id + '/' + client_id + var url = '' + dataId + '/' + branch_id + '/' + client_id; - $.get(url, function(response){ + if (dataId && branch_id && client_id) { // Check if all parameters exist + if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) { + $.get(url, function(response) { + console.log(response); + console.log(response.count); - console.log(response) - //console.log(response.data) + if (response.count > 0) { + console.log('Policy already exist in the branch'); + toastr.error('Policy already exist in the branch', 'Error'); + $('#policy').val('').change(); + } + console.log('outer'); - if(response.count > 0){ - console.log('Policy already exist in the branch') - toastr.error('Policy already exist in the branch', 'Error'); - $('#policy').val('').change(); + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); } - console.log('outer') - - - }).fail(function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - }); + } else { + console.log('Missing parameter(s): dataId, branch_id, or client_id'); + } if (dataId == 1) { @@ -741,7 +751,7 @@ dataType: 'json', success: function(res) { - //console.log('client_policy_res', res) + console.log('client_policy_res', res) setTimeout(function() { $('.loader').fadeOut(); @@ -774,6 +784,7 @@ $('#policy_type_id').val(res.data.policy_type_id); $('#policy_PrimaryKey').val(res.data.id); + $('#insurer_policy_id').val(res.data.policy_id); $('#policy_no').val(res.data.policy_no); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); @@ -1305,8 +1316,6 @@ }); } - - if ($(this).val() == 3) { toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO'); } @@ -1440,54 +1449,58 @@ contentType: false, success: function(res) { - //console.log(res) + console.log(res) setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 500); + + if(res.status == true){ - $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) - .change(); - $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); - $('#policy_no').val(res.data.policy_no).change(); - $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) - .change(); - $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); + $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) + .change(); + $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); + $('#policy_no').val(res.data.policy_no).change(); + $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) + .change(); + $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); - var policeOptionHTML = ''; - $policy_type_value = $('#policy_type').val(); - $.each(res.policy, function(index, item) { + var policeOptionHTML = ''; + $policy_type_value = $('#policy_type').val(); + $.each(res.policy, function(index, item) { - // //console.log(item); + // //console.log(item); - policeOptionHTML += ''; + policeOptionHTML += ''; - }); + }); - $('#policy').html(policeOptionHTML); + $('#policy').html(policeOptionHTML); - if (dataId == 3 || policy_type == 1) { + if (dataId == 3 || policy_type == 1) { - // //console.log('step 1') + // //console.log('step 1') + + setTimeout(function() { + // //console.log('step 2') + var $option = $('#policy').find('option[data-id="3"]'); + if ($option.length > 0) { + // //console.log('step 3') + $option.prop('selected', true).change(); + } else { + // //console.log('step 4'); + toastr.warning( + 'The insurer does not have a GMC-Parents policy.', + 'Warning'); + } + }, 1500); + } - setTimeout(function() { - // //console.log('step 2') - var $option = $('#policy').find('option[data-id="3"]'); - if ($option.length > 0) { - // //console.log('step 3') - $option.prop('selected', true).change(); - } else { - // //console.log('step 4'); - toastr.warning( - 'The insurer does not have a GMC-Parents policy.', - 'Warning'); - } - }, 1500); } }, From 8a4859afb67057c5791ed106a3a1bde17ef92016 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 26 Jun 2024 10:40:10 +0530 Subject: [PATCH 4/9] CHANGE_THE CASH_DEPOSITE_CREDIT_DEBIT_BASDED_ON_THE_CD_MASTER_ACC_NO : RV --- app/Controllers/EmpDataServiceController.php | 61 +++++++++++++++--- app/Controllers/EmployeeController.php | 66 +++++++++++--------- app/Helpers/DepositHelper.php | 20 +++--- app/Views/client_policy.php | 2 +- composer.json | 2 +- 5 files changed, 103 insertions(+), 48 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 3cb36091..96537b76 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -140,15 +140,30 @@ class EmpDataServiceController extends BaseController // Fetch employee data for export from the database $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); - $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - $cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if($cash_balance == null){ + // dd($export_data, $policy_details['cd_ac_no']); + + if ($policy_details['cd_ac_no'] == null) { + // dd("The policy does not have a CD account number"); + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 5; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->first(); - $balance = $this->CDMasterModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); $cash_balance['balance'] = $balance['opening_bal']; } + // dd($cash_balance); // Calculate the total amount from the objects $totals = array_reduce($objects, function ($carry, $item) { @@ -158,9 +173,8 @@ class EmpDataServiceController extends BaseController $totals = round($totals, 2); if (!empty($cash_balance)) { - + if ((int) $cash_balance['balance'] < (int) $totals) { - $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.'); $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]); return 0; @@ -363,6 +377,26 @@ class EmpDataServiceController extends BaseController $ids = []; $objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); + + if ($policy_details['cd_ac_no'] == null) { + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 1; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->first(); + + $cash_balance['balance'] = $balance['opening_bal']; + } + $totals = 0; foreach ($objects as $obj) { @@ -374,6 +408,14 @@ class EmpDataServiceController extends BaseController // echo '
';
         // print_r($ids); die;
 
+        if (!empty($cash_balance)) {
+            if ((int) $cash_balance['balance']  < (int) $rounded_totals) {
+                $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
+                $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.  CASH BALANCE : {balance}  and  TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
+                return 0;
+            }
+        }
+
         $count = count($objects);
         $export_data['count'] = $count;
         $export_data['amount'] = $rounded_totals;
@@ -545,7 +587,7 @@ class EmpDataServiceController extends BaseController
     }
 
 
-
+    //not in use
     public function generateExcelForAdditionAndDependentAddition($export_data)
     {
         $ids = [];
@@ -628,7 +670,7 @@ class EmpDataServiceController extends BaseController
             }
         }
     }
-
+    //end not in use
 
     /**
      * The below functions are Imports data from an Excel file for :
@@ -2788,7 +2830,7 @@ class EmpDataServiceController extends BaseController
 
     //Endorsement Addition and Dependent Addition
 
-
+    //not in use
     public function AdditionAndDependentAddition($params)
     {
 
@@ -3179,6 +3221,7 @@ class EmpDataServiceController extends BaseController
 
     }
 
+    //end not in use
 
     /**
      * The below functions are Calculates and records cash deposits for employee policies at inception.
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index c2447397..ae32b9a4 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -411,10 +411,15 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -442,10 +447,14 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -1059,33 +1068,34 @@ class EmployeeController extends AdminController
     public function viewECard()
     {
 
-        $this->loadLayout('ecard_template/default_ecard');
+        // $this->loadLayout('ecard_template/default_ecard');
         
-        // Load the session library if it's not autoloaded
-        // $session = \Config\Services::session();
-        
-        // Access session data
-        $sessionData = session()->get();
-        
-        // Check if session data exists and if expiration time is set
-        if (!empty($sessionData) && isset($sessionData['isLoggedIn']) && isset($sessionData['session_expiration'])) {
-            // Get the session expiration timestamp
-            $expirationTimestamp = $sessionData['session_expiration'];
-        
-            // Get the current timestamp
-            $currentTimestamp = time();
-        
-            // Check if the current time is greater than the expiration time
-            if ($currentTimestamp > $expirationTimestamp) {
-                // Session has expired
-                echo "Session has expired";
-            } else {
-                // Session is active
-                echo "Session is active";
-            }
-        } else {
-            // Session data is not set or session is not started
-            echo "Session is not started or data is not set";
+        $empDataServiceController = new EmpDataServiceController();
+        $file_name = generate_filename("TCS", 'inception', 'export', 'insurer', 'policy', 'branch');
+
+        $batch_data = [
+            'client_id' => 12,
+            'client_policy_id' => 12,
+            'client_branch_id' => 1,
+            'insurer_or_tpa' => 'insurer',
+            'event_type' => 'inception',
+            'actions' => 'export',
+            'file_name' => $file_name,
+        ];
+
+        $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
+
+        if ($return == 0) {
+
+           dd('error', "Insufficient deposit amount.");
+
+        }else if($return == 1){
+
+            dd('error', "The policy does not have a CD account number.");
+        }
+
+        if (!$return) {
+            dd('error', "No data was found");
         }
         
     }
diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php
index 7d3c713d..f6d14a7c 100644
--- a/app/Helpers/DepositHelper.php
+++ b/app/Helpers/DepositHelper.php
@@ -33,7 +33,7 @@ class DepositHelper
     public static function saveDeposit(array $data, int $loggedInUserID): array
     {
         // Retrieve the last known balance
-        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id']);
+        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no']);
 
         // Calculate the new balance based on the transaction type
         $newBalance = self::calculateBalance(
@@ -87,24 +87,26 @@ class DepositHelper
      *
      * @return float The last known balance.
      */
-    public static function calculateLastBalance(int $clientId, int $insurerId): float
+    public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no): float
     {
         $model = new ClientDepositModel();
 
-        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-        $getLastBalanceParams = [$clientId, $insurerId];
+        // $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
+        // $getLastBalanceParams = [$clientId, $insurerId];
 
-        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance;
+        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+        $getLastBalanceParams = [$cd_ac_no];
 
-        if(!$lastBalance){
+        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
+
+        if(empty($lastBalance) && $lastBalance == null){
 
             $cd_model = new ClientDepositModel();
 
-            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-            $getLastBalanceParams = [$clientId, $insurerId];
+            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+            $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
     
             $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
-    
         }
 
         return $lastBalance;
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index fd79a58b..611fadd3 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -264,7 +264,7 @@
                     
- + diff --git a/composer.json b/composer.json index 2dd9d301..9f2ec667 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "laminas/laminas-escaper": "^2.9", "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", - "phpoffice/phpspreadsheet": "^2.0", + "phpoffice/phpspreadsheet": "^2.1", "psr/log": "^1.1", "slim/slim": "^4.13", "zircote/swagger-php": "^4.8" From bf11fedbf5eaf87327afa28cdda3c5abcf1d98b7 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 26 Jun 2024 12:41:16 +0530 Subject: [PATCH 5/9] CHANGE_CLIENT_VALIDATION_MVD_TO_BCKEND --- app/Controllers/EmployeeRestController.php | 23 +- app/Controllers/EmployeeServiceController.php | 634 +++++++++++++++++- app/Helpers/excel_util_helper.php | 149 +++- 3 files changed, 748 insertions(+), 58 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index cffff6ce..5540381a 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -27,6 +27,7 @@ use App\Models\NotificationModel; use App\Models\UserModel; use App\Models\FEContentModel; use App\Models\AddImgModel; +use App\Models\FileModel; use App\Controllers\Jobs ; @@ -40,6 +41,8 @@ use PhpOffice\PhpSpreadsheet\IOFactory; use CodeIgniter\API\ResponseTrait; use Illuminate\Http\Request; +use App\Controllers\EmployeeServiceController; + class EmployeeRestController extends AdminController { @@ -83,6 +86,7 @@ class EmployeeRestController extends AdminController $this->userModel = new UserModel(); $this->feContentModel = new FEContentModel(); $this->addImgModel = new AddImgModel(); + } @@ -659,9 +663,24 @@ class EmployeeRestController extends AdminController $sum_insured_amount_for_check_employee_1 = isset($policy_permium_1['si']) ? $policy_permium_1['si'] : null; $sum_insured_amount_for_check_employee_2 = isset($policy_permium_2['si']) ? $policy_permium_2['si'] : null; - $is_moved = $file->move(WRITEPATH . 'uploads/import_excel'); + $is_moved = $file->move(WRITEPATH . 'uploads/excel'); $filename = $file->getName(); - $file_name_with_path = WRITEPATH."/uploads/import_excel/".$filename; + $file_name_with_path = WRITEPATH."/uploads/excel/".$filename; + + //make an entry in DB + $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master + $this->myLogger->logme("error", '{file_id} - client uploaded success', ['file_id' => $file_id]); + + $empServiceController = new EmployeeServiceController(); + $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]); + // dd($result); + if(isset($result['error_summary']) && count($result['error_summary'])) + { + $result = $empServiceController->getExcelErrorData($file_id); + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors",'data' => $result], 200); + } + + //check the file exist or not if(!file_exists($file_name_with_path)) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 25b4f08d..c351d0b1 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -35,14 +35,576 @@ class EmployeeServiceController extends AdminController protected $policiesModel; protected $empEndorsementModel; protected $messageModel; - protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]]; - protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>null,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom' => 'check_doc','params' => ['row','policy_details']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; + + protected $general_relationships = [ + 'self' => [ + 'name' => 'Self', + 'gender' => 'M', + 'age_min' => 18, + 'age_max' => null + ], + 'spouse' => [ + 'name' => 'Spouse', + 'gender' => 'F', + 'age_min' => 18, + 'age_max' => null + ], + 'son' => [ + 'name' => 'Son', + 'gender' => 'M', + 'age_min' => null, + 'age_max' => 25 + ], + 'daughter' => [ + 'name' => 'Daughter', + 'gender' => 'F', + 'age_min' => null, + 'age_max' => 25 + ], + 'father' => [ + 'name' => 'Father', + 'gender' => 'M', + 'age_min' => 18, + 'age_max' => null + ], + 'mother' => [ + 'name' => 'Mother', + 'gender' => 'F', + 'age_min' => 18, + 'age_max' => null + ], + 'father-in-law' => [ + 'name' => 'Father in Law', + 'gender' => 'M', + 'age_min' => 18, + 'age_max' => null + ], + 'mother-in-law' => [ + 'name' => 'Mother in Law', + 'gender' => 'F', + 'age_min' => 18, + 'age_max' => null + ] + ]; + + protected $inception_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S.No', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_id' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'EMP ID', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name_of_emp_dep' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'NAME OF EMP/DEP', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'dob' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'DOB', + 'is_mandatory' => ['I', 'A', 'DA'], + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'custom' => 'check_dob_diff', + 'params' => ['row', 'relationship', 'default_age_ratio'] + ], + 'gender' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Gender', + 'is_mandatory' => ['I', 'A', 'DA'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['M', 'F'] + ], + 'relationship' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'RELATIONSHIP', + 'is_mandatory' => ['I', 'A', 'DA'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_relationship', + 'params' => ['row', 'relationship', 'policy_terms'] + ], + 'basic_cover_si' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'BASIC COVER SI', + 'is_mandatory' => null, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_si', + 'params' => ['row', 'policy_terms', 'slab_details'] + ], + 'doc' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Date of Coverage', + 'is_mandatory' => ['A', 'DA'], + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'custom' => 'check_doc', + 'params' => ['row', 'policy_details'] + ], + 'doj' => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'DOJ', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'custom' => 'check_doj', + 'params' => ['row'] + ], + 'basic_pay' => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'Basic Pay', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_basic_pay', + 'params' => ['row', 'policy_terms', 'slab_details'] + ], + 'band_grade' => [ + 'col_idx' => 10, + 'col_cell_name' => 'K', + 'col_name' => 'Band/Grade', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_employee_band', + 'params' => ['row', 'policy_terms', 'slab_details'] + ], + 'designation' => [ + 'col_idx' => 11, + 'col_cell_name' => 'L', + 'col_name' => 'Designation', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'phone' => [ + 'col_idx' => 12, + 'col_cell_name' => 'M', + 'col_name' => 'Phone', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_dup_mobileno', + 'params' => ['row', 'existing_mobilenos'] + ], + 'email' => [ + 'col_idx' => 13, + 'col_cell_name' => 'N', + 'col_name' => 'Email', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'pre_existing_ailments' => [ + 'col_idx' => 14, + 'col_cell_name' => 'O', + 'col_name' => 'PRE EXISTING AILMENTS', + 'is_mandatory' => ['I', 'A', 'DA'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['0', '1'] + ], + 'change_event' => [ + 'col_idx' => 15, + 'col_cell_name' => 'P', + 'col_name' => 'Change event', + 'is_mandatory' => ['A', 'DA', 'D'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'date_of_exit' => [ + 'col_idx' => 16, + 'col_cell_name' => 'Q', + 'col_name' => 'Date of exit', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null + ], + 'reason_for_exit' => [ + 'col_idx' => 17, + 'col_cell_name' => 'R', + 'col_name' => 'Reason for exit', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ] + ]; - protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]]; + protected $deletion_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S.No', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_id' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'EMP ID', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name_of_emp_dep' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'NAME OF EMP/DEP', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'change_event' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Change event', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'date_of_exit' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Date of exit', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null + ], + 'reason_for_exit' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'Reason for exit', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ] + ]; - protected $correction_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'field'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Field','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>['name','dob','relationship']],'value'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Value','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_correction'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Date of Correction','is_mandatory'=>true,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'change_event'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'Change event','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'remarks'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Remarks','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null]]; + protected $correction_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S.No', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_id' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'EMP ID', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name_of_emp_dep' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'NAME OF EMP/DEP', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'field' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Field', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['name', 'dob', 'relationship'] + ], + 'value' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Value', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'date_of_correction' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'Date of Correction', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null + ], + 'change_event' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Change event', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'remarks' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Remarks', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ] + ]; - protected $si_enhance_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'augmented_si'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Augmented SI','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'date_of_enhancement'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of SI Enhancement','is_mandatory'=>true,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null]]; + protected $si_enhance_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S.No', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_id' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'EMP ID', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name_of_emp_dep' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'NAME OF EMP/DEP', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'augmented_si' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Augmented SI', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_si', + 'params' => ['row', 'policy_terms', 'slab_details'] + ], + 'date_of_enhancement' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Date of SI Enhancement', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null + ] + ]; + + protected $enrollment_excel_columns = [ + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'Sno', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'emp_id' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'Emp code', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'name_of_emp_dep' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'doj' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'DOJ', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'custom' => null + ], + 'gender' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Gender', + 'is_mandatory' => ['I', 'A', 'DA','E'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['M', 'F'] + ], + 'relationship' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'Relation', + 'is_mandatory' => ['I', 'A', 'DA','E'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => null + ], + 'dob' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'DOB', + 'is_mandatory' => ['I', 'A', 'DA'], + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null, + 'custom' => null, + ], + 'email' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Mail', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + 'phone' => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'Mobile', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => null + ], + 'basic_cover_si' => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'SI', + 'is_mandatory' => null, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => null + ], + 'band_grade' => [ + 'col_idx' => 10, + 'col_cell_name' => 'K', + 'col_name' => 'Grade', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => null + ], + 'basic_pay' => [ + 'col_idx' => 11, + 'col_cell_name' => 'L', + 'col_name' => 'Basic Pay', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null, + 'custom' => null + ] + ]; + + protected $incetion_to_enrollment_mapping = [ + 0 => 0, // inception: sno (S.No) -> enrollment: sno (Sno) + 1 => 1, // inception: emp_id (EMP ID) -> enrollment: emp_code (Emp_Code) + 2 => 2, // inception: name_of_emp_dep (NAME OF EMP/DEP) -> enrollment: name (NAME OF EMP/DEP) + 3 => 6, // inception: dob (DOB) -> enrollment: dob (DOB) + 4 => 4, // inception: gender (Gender) -> enrollment: gender (Gender) + 5 => 5, // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation) + 6 => 9, // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI) + 7 => null, // inception: doc (Date of Coverage) -> No match in enrollment + 8 => 3, // inception: doj (DOJ) -> enrollment: doj (DOJ) + 9 => 11, // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay) + 10 => 10, // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade) + 11 => null, // inception: designation (Designation) -> No match in enrollment + 12 => 8, // inception: phone (Phone) -> enrollment: phone (Mobile) + 13 => 7, // inception: email (Email) -> enrollment: email (Email) + 14 => null, // inception: pre_existing_ailments (PRE EXISTING AILMENTS) -> No match in enrollment + 15 => null, // inception: change_event (Change event) -> No match in enrollment + 16 => null, // inception: date_of_exit (Date of exit) -> No match in enrollment + 17 => null // inception: reason_for_exit (Reason for exit) -> No match in enrollment + ]; + + 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) + ]; + + public function __construct() { @@ -100,6 +662,7 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; } if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; } if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; } + if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; } $result = ['error_type' => 1,'error_summary' => [], 'error_data' => [] ]; @@ -162,7 +725,6 @@ class EmployeeServiceController extends AdminController // dd($existing_mobilenos); foreach ($excel_data as $row_key => $row) { - //define row wise action/event in temporary variable $current_column_action = null; if($file['action'] == 'inception'){ $current_column_action = 'I'; } @@ -171,25 +733,44 @@ class EmployeeServiceController extends AdminController 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'; } //1. avoid empty rows if(check_row_is_empty_or_null($row)) { break; } - + // Kint::dump($keys); + if ($file['action'] == 'enrollment') + { + $row = transform_enrollment_row_to_inception_row($row); + $columns_to_check = $this->inception_excel_columns; + $keys = array_keys($columns_to_check); + $enrollment_columns_to_check = $this->enrollment_excel_columns; + $enrollment_keys = array_keys($enrollment_columns_to_check); + } + //iterate each row for columns validations foreach ($row as $col_key => $col) { - - $is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory']; $format = $columns_to_check[$keys[$col_key]]['format']; $allowed_values = $columns_to_check[$keys[$col_key]]['allowed_values']; $custom_function = isset($columns_to_check[$keys[$col_key]]['custom']) ? $columns_to_check[$keys[$col_key]]['custom'] : null; $binding_params = isset($columns_to_check[$keys[$col_key]]['params']) ? $columns_to_check[$keys[$col_key]]['params'] : null; + $column_dispaly_name = $columns_to_check[$keys[$col_key]]['col_name']; $column_index = $columns_to_check[$keys[$col_key]]['col_idx']; $column_cell = $columns_to_check[$keys[$col_key]]['col_cell_name']; + if($file['action'] == 'enrollment') + { + if(isset($enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]) && $enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]] != null && $enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]] != "") + { + $column_dispaly_name = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_name']; + $column_index = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_idx']; + $column_cell = $enrollment_columns_to_check[$enrollment_keys[$this->incetion_to_enrollment_mapping[$col_key]]]['col_cell_name']; + } + } + $row['current_action'] = $current_column_action; //mandatory check @@ -278,20 +859,27 @@ class EmployeeServiceController extends AdminController //set failure msg to pull notifications $this->setPullNotification($this->getFileMetaDataByFileId($file_id,'failure')); + } else //trigger next data validation via job queue server { - //proceed next data level validation in JOB queue + if($file['action'] == 'enrollment') // if current action is enrollment call next validation and return result + { + $res = $this->excelFileDataValidation(['file_id' => $file['id']]); + return $res; + } + + //proceed next data level validation in JOB queue $job_details = new Jobs(); $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]); // $jobWorker = new JobWorker(); - // JobWorker::processJob($r); + // JobWorker::processJob($r);s + } return $result; } - public function excelFileDataValidation($params) { helper('excel_util_helper'); @@ -325,6 +913,7 @@ class EmployeeServiceController extends AdminController if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; } if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; } if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; } + if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; } // get policy and rack details $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); @@ -347,13 +936,14 @@ class EmployeeServiceController extends AdminController //remove header unset($excel_data[0]); + // dd($columns_to_check); $relationship = $this->general_relationships; - if(in_array($file['action'],['inception','addition','dependent_addition','deletion','correction','si_enhancement']))// the below funcitons are only for I,DA,A + if(in_array($file['action'],['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); - + $employee_data_group_by_family = data_group_by_family($excel_data,'excel','enrollment'); + // dd($employee_data_group_by_family); $is_self_available_in_policy_terms = false; if($policy_details['policy_type_id'] == 3) // GMC parents { @@ -381,9 +971,9 @@ class EmployeeServiceController extends AdminController $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array } // kint::dump($family);//die(); + //check name dup within a family - - if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') + if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition' || $file['action'] == 'enrollment') { $res = name_dup_check_within_family($family,$file['action']);//in both file data & DB data // dd($res); @@ -398,11 +988,9 @@ class EmployeeServiceController extends AdminController } //check self availbale in uploaded file - if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon) + if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon) { - // dd('file check'); $res = check_self_available_in_family($family,$file['action']); - // dd($res); if(!$res['is_self_found']) { array_push($result['error_summary'],14); // Self not found @@ -423,7 +1011,7 @@ class EmployeeServiceController extends AdminController } - if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception') + if($file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'inception' || $file['action'] == 'enrollment') { $res = check_dependent_conflict($family,$policy_terms,$file['action']); // dd($res); @@ -494,7 +1082,7 @@ class EmployeeServiceController extends AdminController $r = Jobs::addJob(['job_name' => 'employeesCorrectionProcess','payload' => ['file_id' => $file_id]]); } - else //inception OR addition OR dependent addition + else if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')//inception OR addition OR dependent addition { //proceed next data level validation in JOB queue $job_details = new Jobs(); @@ -502,6 +1090,8 @@ class EmployeeServiceController extends AdminController // $jobWorker = new JobWorker(); // JobWorker::processJob($r); } + + return $result; } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 90d74c3d..11f9a5ee 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -65,10 +65,19 @@ if (!function_exists('check_excel_date_format')) { if($dateString == ""){ return array('status' => true); } $date = DateTime::createFromFormat('d-M-Y', $dateString); - if ($date !== false && !is_array($date::getLastErrors())) { + if ($date && $date->format('d-M-Y') == $dateString) { return array('status' => true); } else { - return array('status' => false,'error' => "wrong date format: Expected 'd-M-Y' and received $dateString"); + + $res = convert_string_to_date($dateString); + if(!$res) + { + return array('status' => false,'error' => "wrong date format: Expected 'd-M-Y' and received $dateString"); + } + else + { + return array('status' => true); + } } } } @@ -151,14 +160,22 @@ if(!function_exists('check_doc')) if($row['current_action'] != null && $row[7] != null && $row[7] != '' && in_array(strtoupper($row['current_action']), ['A','DA']))// check rule only of action column data available { // dd($policy_details); - $date = new DateTime($row[7]); - $startDate = new DateTime($policy_details[0]->policy_start_date); - $endDate = new DateTime($policy_details[0]->policy_end_date); + $dateString = convert_string_to_date($row[7]); + if($dateString) + { + $date = new DateTime($dateString); + $startDate = new DateTime($policy_details[0]->policy_start_date); + $endDate = new DateTime($policy_details[0]->policy_end_date); - if ($date >= $startDate && $date <= $endDate) { - return array('status' => true); - } else { - return array('status' => false,'error' => 'the given date of coverage is not between policy start/end date'); + if ($date >= $startDate && $date <= $endDate) { + return array('status' => true); + } else { + return array('status' => false,'error' => 'the given date of coverage is not between policy start/end date'); + } + } + else + { + return array('status' => false,'error' => 'date format error'); } } else { return array('status' => true); } // in else condition no need to check rule, just return true @@ -173,6 +190,7 @@ if(!function_exists('check_employee_band')) if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available { $is_emp_band_needed = $slab_details['grid_master']['emp_band']; + // $is_emp_band_needed = true; if($slab_details['grid_master']['ui_type'] == 1) //gpa rack rate 1 { if($slab_details['slab_rates'][0]['si_or_bp'] == 3) @@ -230,28 +248,31 @@ if(!function_exists('check_si')) // check age slab if(in_array(strtoupper($row['current_action']), ['I','A','DA']) && strtolower($row['5']) == 'self') { - if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob + if($row[3] != '' && $row[3] != null)// dob { - $dob = change_date_format($row[3],'d-M-Y','Y-m-d'); - // echo $row[3].' - '.$dob;echo '
'; - $currentDateTime = new DateTime();//die(); - $passedDateTime = new DateTime($dob); - $interval = $currentDateTime->diff($passedDateTime); - if(!$is_age_slab_found) - { - if(isset($slab_value['age_from']) && isset($slab_value['age_to'])) + $dob = convert_string_to_date($row[3]); + if($dob !== false) { - if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si) + // echo $row[3].' - '.$dob;echo '
'; + $currentDateTime = new DateTime();//die(); + $passedDateTime = new DateTime($dob); + $interval = $currentDateTime->diff($passedDateTime); + if(!$is_age_slab_found) { - $is_age_slab_found = true;// send true if age slab found + if(isset($slab_value['age_from']) && isset($slab_value['age_to'])) + { + if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si) + { + $is_age_slab_found = true;// send true if age slab found + } + } + else + { + $is_age_slab_found = true;// send true if age conditin is not applicable + } + } } - else - { - $is_age_slab_found = true;// send true if age conditin is not applicable - } - - } } } @@ -292,6 +313,7 @@ if(!function_exists('check_basic_pay')) if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available { $is_basic_pay_needed = $slab_details['grid_master']['basicpay']; + // $is_basic_pay_needed = true; $slug = \Config\Services::slug(); $relationship = $slug->slugify($row[5]); // echo $relationship;echo $row[7]; @@ -310,12 +332,13 @@ if (!function_exists('check_dob_diff')) { if($row[3] != null && $row[5] != null) { - if (DateTime::createFromFormat('d-M-Y', $row[3]) === false) + $dateString = convert_string_to_date($row[3]); + if ($dateString === false) { return array('status' => false,'error' => 'Not a valid Date'); } // return array('status' => true); - $dob = change_date_format($row[3],'d-M-Y','Y-m-d'); + $dob = $dateString; // echo $row[3].' - '.$dob;echo '
'; $currentDateTime = new DateTime();//die(); // print_r($currentDateTime); @@ -354,7 +377,7 @@ if (!function_exists('check_dob_diff')) if (!function_exists('data_group_by_family')) { - function data_group_by_family($emp_data,$data_source = 'excel') + function data_group_by_family($emp_data,$data_source = 'excel',$action = '') { $result = []; // Kint::dump($emp_data); @@ -364,6 +387,11 @@ if (!function_exists('data_group_by_family')) { if(!check_row_is_empty_or_null($row)) { + 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); + } + if(strtolower($row[5]) == 'self' && isset($result[$row[1]])) { array_unshift($result[$row[1]],$row); @@ -474,7 +502,7 @@ if (!function_exists('name_and_empid_check_in_db')) { array_push($result['del'],$row[0]); } - if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res)) + if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition' || $current_action == 'enrollment') && count($res)) { array_push($result['i'],$row[0]); } @@ -842,7 +870,7 @@ if (!function_exists('transform_excel_data_to_db')) // $policy['date_of_exit'] = isset($memArr[16]) ? change_date_format($memArr[16],'d-M-Y','Y-m-d') : NULL; // $policy['reason_for_exit'] = $memArr[17]; $policy['client_policy_id'] = $actionArr['policy_id']; - $policy['date_coverage'] = isset($memArr[7]) ? change_date_format($memArr[7],'d-M-Y','Y-m-d') : NULL;; + $policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL; $policy['policy_end_date'] = null; $policy['days'] = null; $policy['premium'] = null; @@ -852,11 +880,11 @@ if (!function_exists('transform_excel_data_to_db')) $result['emp_code'] = $memArr[1]; $result['name'] = $memArr[2]; - $result['dob'] = isset($memArr[3]) ? change_date_format($memArr[3],'d-M-Y','Y-m-d') : NULL; + $result['dob'] = isset($memArr[3]) ? convert_string_to_date($memArr[3],'Y-m-d') : NULL; $result['gender'] = $memArr[4]; $result['relationship'] = $memArr[5]; $result['relationship_code'] = $memArr[5]; - $result['doj'] = isset($memArr[8]) ? change_date_format($memArr[8],'d-M-Y','Y-m-d') : NULL; + $result['doj'] = isset($memArr[8]) ? convert_string_to_date($memArr[8],'Y-m-d') : NULL; $result['basic_pay'] = $memArr[9]; $result['band'] = $memArr[10]; $result['designation'] = $memArr[11]; @@ -926,7 +954,7 @@ if (!function_exists('premium_calculation_manager')) $slug = \Config\Services::slug(); $grid_type = $emp_data['temp']['grid_id']; $temp_slab_rates = $emp_data['temp']['grid_type'] == 'primary' ? $slab_details['slab_rates'] : $slab_details['additional_slab_info']['slab_rates']; - + //if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A') { @@ -1534,4 +1562,57 @@ if(!function_exists('generate_family_relationship_array')) return $family_relationships; } +} + +if(!function_exists('convert_string_to_date')) +{ + function convert_string_to_date($dateString,$defaultFormat = 'd-M-Y') + { + $formats = [ + 'd-M-Y', // 03-APr-2024 + 'd M Y', // 03 Apr 2024 + 'd/M/Y', // 03/Apr/2024 + 'j M Y', // 3 Apr 2024 + 'j/M/Y', // 3/Apr/2024 + 'j-M-Y', // 3-Apr-2024 + 'Y-m-d' // 2024-04-04 + ]; + + foreach ($formats as $format) { + $date = DateTime::createFromFormat($format, $dateString); + if ($date && $date->format($format) == $dateString) { + return $date->format($defaultFormat); + } + } + + return false; + } +} + + +if(!function_exists('transform_enrollment_row_to_inception_row')) +{ + function transform_enrollment_row_to_inception_row($row) + { + $res = []; + $res[0] = $row[0]; // inception: sno (S.No) -> enrollment: sno (Sno) + $res[1] = $row[1]; // inception: emp_id (EMP ID) -> enrollment: emp_code (Emp_Code) + $res[2] = $row[2]; // inception: name_of_emp_dep (NAME OF EMP/DEP) -> enrollment: name (NAME OF EMP/DEP) + $res[3] = $row[6]; // inception: dob (DOB) -> enrollment: dob (DOB) + $res[4] = $row[4]; // inception: gender (Gender) -> enrollment: gender (Gender) + $res[5] = $row[5]; // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation) + $res[6] = $row[9]; // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI) + $res[7] = null; // inception: doc (Date of Coverage) -> No match in enrollment + $res[8] = $row[3]; // inception: doj (DOJ) -> enrollment: doj (DOJ) + $res[9] = $row[11]; // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay) + $res[10] = $row[10]; // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade) + $res[11] = null; // inception: designation (Designation) -> No match in enrollment + $res[12] = $row[8]; // inception: phone (Phone) -> enrollment: phone (Mobile) + $res[13] = $row[7]; // inception: email (Email) -> enrollment: email (Email) + $res[14] = 1; // inception: pre_existing_ailments (PRE EXISTING AILMENTS) -> No match in enrollment + $res[15] = null; // inception: change_event (Change event) -> No match in enrollment + $res[16] = null; // inception: date_of_exit (Date of exit) -> No match in enrollment + $res[17] = null; // inception: reason_for_exit (Reason for exit) -> No match in enrollment + return $res; + } } \ No newline at end of file From 88b0a8c5ad2010b032748469bc093b3dac42709e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 27 Jun 2024 14:35:46 +0530 Subject: [PATCH 6/9] FIX_CLIENT_CHANGES_RACT_RATE_CD_TRANCTION_POLICY_NO_AND_OTHERS : RV --- app/Controllers/ClientController.php | 7 +- app/Controllers/EmployeeController.php | 15 ++- app/Models/ClientModel.php | 21 ++- app/Models/ClientPolicyModel.php | 3 +- app/Models/EmployeePolicyModel.php | 17 ++- app/Views/UserList.php | 15 +-- app/Views/batch_list.php | 22 ++-- app/Views/client_policy.php | 49 ++++--- app/Views/employee_data_list.php | 2 +- app/Views/employee_list.php | 2 +- app/Views/employee_upload.php | 3 +- app/Views/endorsement_list.php | 6 +- app/Views/file_list.php | 6 +- app/Views/insurer_or_tpa_data.php | 2 +- app/Views/policy_grid.php | 172 ++++++++++++++----------- app/Views/policy_grid_excel.php | 10 +- app/Views/view_deposit.php | 141 +++++++++++--------- 17 files changed, 297 insertions(+), 196 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 01f35d7c..185ff9ce 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -217,11 +217,13 @@ class ClientController extends AdminController // 3 => 'Refund', // 4 => 'Debit', // ]; + $subTypeOptions = [ 1 => 'Replenishment', 2 => 'Adjustment', 3 => 'Refund From Deletion', 4 => 'Debit', + 5 => 'Asset Policy', ]; $data['subTypeOptions'] = $subTypeOptions; @@ -660,6 +662,7 @@ class ClientController extends AdminController $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; $data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); + $data['gst'] = $this->request->getPost('gst'); @@ -756,9 +759,9 @@ class ClientController extends AdminController $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; $data['client_branch_id'] = $this->request->getPost('client_branch_id'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); + $data['gst'] = $this->request->getPost('gst'); - - + $policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first(); if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) { diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index ae32b9a4..ec8467e6 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -268,22 +268,33 @@ class EmployeeController extends AdminController '(SELECT SUM(ep.rata_premimum) + SUM(ep.gst) FROM employees e JOIN employee_polices ep ON e.id = ep.employee_id - WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as total' + WHERE e.file_id = files.id AND ep.client_policy_id = files.policy_id) as total', + 'policy_type.policy_type' , + 'cp.policy_no' , ]) ->join('user_profiles up', 'files.created_by = up.id') ->join('client_policy cp', 'files.policy_id = cp.id', 'left') ->join('client_branch cb', 'files.client_branch_id = cb.id', 'left') ->join('policies pm', 'cp.policy_id = pm.id', 'left') + ->join('policy_type', 'policy_type.id = pm.policy_type_id') ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left') ->where('files.created_by', get_session_userid()) ->orderBy('files.created_at', 'desc') ->findAll(); // dd($data['fileList']); - $data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name, client_branch.branch_name') + $data['batch_list'] = $this->batchFileModel->select( + 'batch_files.*, + policies.name as policy_name, + clients.short_name as client_short_name, + client_branch.branch_name, + client_policy.policy_no, + policy_type.policy_type + ') ->join('client_policy', 'client_policy.id = batch_files.client_policy_id') ->join('client_branch', 'client_branch.id = batch_files.client_branch_id') ->join('policies', 'policies.id = client_policy.policy_id') + ->join('policy_type', 'policy_type.id = policies.policy_type_id') ->join('clients', 'clients.id = client_policy.client_id') ->orderBy('batch_files.id', 'desc') ->findAll(); diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index fd1e8510..b6c81833 100644 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -36,9 +36,25 @@ class ClientModel extends Model //get client and its associated policies in same array public function clientsWithPolicies() { + + $role_id = get_role_id(); + $user_id = get_session_userid(); + + $columns = ['clients.id ', 'client_name','short_name']; + $clients = $this->select($columns) + ->where('is_active',1) + ->findAll(); + + if($role_id == 2 || $role_id == 3){ + + $clients = $this->select($columns) + ->join('client_rm', 'client_rm.client_id = clients.id') + ->where('client_rm.user_id', $user_id) + ->where('clients.is_active',1) + ->findAll(); + } - $columns = ['id', 'client_name','short_name']; - $clients = $this->select($columns)->where('is_active',1)->findAll(); + foreach ($clients as &$client) { $clientPolicyModel = new ClientPolicyModel(); @@ -51,6 +67,7 @@ class ClientModel extends Model 'client_branch.client_id', 'client_policy.id as client_policy_id', 'client_policy.policy_terms', + 'client_policy.policy_no', 'p.name', 'pt.policy_type', ]) diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index a69cf852..8d2af103 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -43,7 +43,8 @@ class ClientPolicyModel extends Model "reason_for_exit", "policy_no", "client_branch_id", - "cd_ac_no" + "cd_ac_no", + "gst", ]; public function getClientPolicyById($id){ diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 15bf295d..160eb71e 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -100,11 +100,14 @@ class EmployeePolicyModel extends Model 'emp.gender', 'emp.emp_status', 'emp.is_active as emp_is_active', - 'emp.mobile as mobile' + 'emp.mobile as mobile', + 'policy_type.policy_type', + 'cp.policy_no', ]) ->join('employees emp', 'employee_polices.employee_id = emp.id') ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('policy_type', 'policy_type.id = pm.policy_type_id') ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master @@ -702,7 +705,9 @@ class EmployeePolicyModel extends Model e.endorsement_id, ep.client_policy_id, policies.name as policy_name, - insurers.short_name as insurer_short_name + insurers.short_name as insurer_short_name, + client_policy.policy_no, + policy_type.policy_type '); $query1->distinct(); $query1->join('employee_polices ep', 'ep.id = e.pk'); @@ -710,6 +715,7 @@ class EmployeePolicyModel extends Model $query1->join('client_policy', 'client_policy.id = ep.client_policy_id'); $query1->join('client_branch', 'client_branch.id = employees.client_branch_id'); $query1->join('policies', 'policies.id = client_policy.policy_id'); + $query1->join('policy_type', 'policy_type.id = policies.policy_type_id'); $query1->join('insurers', 'insurers.id = policies.insurer_id'); $query1->whereIn('e.actions', ['c']); $query1->where('ep.client_policy_id', $policy_id); @@ -736,18 +742,21 @@ class EmployeePolicyModel extends Model e.remarks, ep.client_policy_id, policies.name as policy_name, - insurers.short_name as insurer_short_name + insurers.short_name as insurer_short_name, + client_policy.policy_no, + policy_type.policy_type '); $query2->join('employee_polices ep', 'ep.id = e.pk'); $query2->join('employees', 'employees.id = ep.employee_id'); $query2->join('client_policy', 'client_policy.id = ep.client_policy_id'); $query2->join('client_branch', 'client_branch.id = employees.client_branch_id'); $query2->join('policies', 'policies.id = client_policy.policy_id'); + $query2->join('policy_type', 'policy_type.id = policies.policy_type_id'); $query2->join('insurers', 'insurers.id = policies.insurer_id'); $query2->whereIn('e.actions', ['si', 'd']); $query2->where('ep.client_policy_id', $policy_id); $query2->where('employees.client_id', $client_id); - $query1->where('employees.client_branch_id', $branch_id); + $query2->where('employees.client_branch_id', $branch_id); if($status != 0 && !empty($status)){ $query2->where('e.status', $status); diff --git a/app/Views/UserList.php b/app/Views/UserList.php index c1794990..e53e341d 100644 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -269,20 +269,19 @@ $(document).ready(function () { $('body').on('click', '.btnDelete', function () { Swal.fire({ - title: "Are you sure?", - text: "You won't be able to revert this!", - icon: "warning", - showCancelButton: true, - confirmButtonColor: "#3085d6", - cancelButtonColor: "#d33", - confirmButtonText: "Yes, delete it!" + title: "Are you sure?", + text: "You need to remove this user", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", }).then((result) => { if (result.isConfirmed) { var student_id = $(this).attr('data-id'); $.get(''+student_id, function (data) { console.log(data); - // $('#tickets-table tbody #'+ student_id).remove(); + toastr.success('User removed successfully', 'success'); window.location.reload() }) } diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 0b28f477..a909008c 100644 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -6,6 +6,13 @@ .reload:hover { cursor: pointer; } + +.truncate { + max-width: 80px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +}
@@ -22,13 +29,13 @@
- + - + - - + + @@ -46,13 +53,12 @@ - - + diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 611fadd3..7ef31b9e 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -130,6 +130,12 @@ + +
+ + +
+
- + @@ -660,27 +668,28 @@ var url = '' + dataId + '/' + branch_id + '/' + client_id; - if (dataId && branch_id && client_id) { // Check if all parameters exist - if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) { - $.get(url, function(response) { - console.log(response); - console.log(response.count); + // if (dataId && branch_id && client_id) { + // // Check if all parameters exist + // if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) { + // $.get(url, function(response) { + // console.log(response); + // console.log(response.count); - if (response.count > 0) { - console.log('Policy already exist in the branch'); - toastr.error('Policy already exist in the branch', 'Error'); - $('#policy').val('').change(); - } - console.log('outer'); + // if (response.count > 0) { + // console.log('Policy already exist in the branch'); + // toastr.error('Policy already exist in the branch', 'Error'); + // $('#policy').val('').change(); + // } + // console.log('outer'); - }).fail(function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - }); - } - } else { - console.log('Missing parameter(s): dataId, branch_id, or client_id'); - } + // }).fail(function(xhr, status, error) { + // console.error(xhr.responseText); + // console.error(status, error); + // }); + // } + // } else { + // console.log('Missing parameter(s): dataId, branch_id, or client_id'); + // } if (dataId == 1) { diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index f59eb1c7..09e76ad1 100644 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -76,7 +76,7 @@ - + diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 65b8285b..c15e7f14 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -253,7 +253,7 @@ function appendPolicies(data) { $.each(data, function(index, item) { var option = $('
Insurer PolicyClient Branch TPA DateEnrollment
Status
Enrollment Status Status Action
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${(item.policy_start_date)} /
${(item.policy_end_date)}
${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -481,8 +483,9 @@
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${rearrangeDateFormat(item.policy_start_date)} /
${rearrangeDateFormat(item.policy_end_date)}
${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} diff --git a/app/Views/client_rm.php b/app/Views/client_rm.php index a47280ee..73ad031c 100644 --- a/app/Views/client_rm.php +++ b/app/Views/client_rm.php @@ -16,7 +16,7 @@
- +
- + +
@@ -259,7 +260,6 @@ tpaValue = item.tpa_short + '-' + item.tpa_branch_code; } - policyTable += `
${item.insurer_short} - ${item.insurer_branch_name}
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name}${item.branch_name ? item.branch_name : ' - '} ${tpaValue} ${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)}
SNOBatch
Code
Batch Code File Name ClientClient
Branch
Client Branch Client PolicyEvent
Type
Insurer/
TPA
Event TypeInsurer/ TPA Action Count (₹)Amount
- + + - -
${item.insurer_short} - ${item.insurer_branch_name}${item.policy_name} (${item.policy_type_name})${policy_name_data} ${item.branch_name ? item.branch_name : ' - '} ${tpaValue} ${(item.policy_start_date)} / ${(item.policy_end_date)}
( - ) - -
+
@@ -110,7 +110,7 @@ - + @@ -326,7 +326,7 @@ $.each(data, function(index, item) { var option = $(' - + - + diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index c068ec39..15b70b51 100644 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -415,7 +415,7 @@ $.each(data, function(index, item) { var option = $('
SNO
( ) - -
+ + - - ' . $file['first_name'] . '' ?>