From 0cdd853d86c4e9348ead528ec4004d694ff892c0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 12 Apr 2024 09:44:37 +0530 Subject: [PATCH] CHANGE_NORMAL_DROPDOWN_TO_SEARCHABLE_DROPDOWN : RV --- app/Controllers/ClientController.php | 7 +- app/Controllers/EmpDataServiceController.php | 73 +++++++++++-- app/Helpers/excel_import_export_helper.php | 34 ++---- app/Models/ClientPolicyModel.php | 1 + app/Views/client_policy.php | 103 +++++++++++-------- app/Views/employee_list.php | 32 ++++-- app/Views/employee_upload.php | 58 ++++++----- app/Views/endorsement_list.php | 29 ++++-- app/Views/insurer_or_tpa_data.php | 12 +++ app/Views/layout/footer.php | 2 + app/Views/layout/header.php | 17 +++ app/Views/policies.php | 7 +- app/Views/policy_gmc_terms.php | 34 +++--- app/Views/policy_gpa_terms.php | 10 +- app/Views/policy_grid.php | 18 +++- 15 files changed, 292 insertions(+), 145 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7a2b274e..3be267b7 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -196,7 +196,8 @@ class ClientController extends AdminController $subTypeOptions = [ 1 => 'Deposit', 2 => 'Adjustment', - 3 => 'Deletion', + 3 => 'Refund', + 4 => 'Debit', // Add more options as needed ]; $data['subTypeOptions'] = $subTypeOptions; @@ -970,7 +971,7 @@ class ClientController extends AdminController ->where("employees.emp_status",'active') ->countAllResults(); - if($emp_count = 0){ + if($emp_count == 0){ $emp_count = true; }else{ $emp_count = false; @@ -1252,7 +1253,7 @@ class ClientController extends AdminController ->where("employees.emp_status",'active') ->countAllResults(); - if($emp_count = 0){ + if($emp_count == 0){ $emp_count = true; }else{ $emp_count = false; diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index a45837f3..31187cdb 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -22,7 +22,8 @@ use App\Models\ClientDepositModel; use App\Controllers\Jobs ; use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +// use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; class EmpDataServiceController extends BaseController { @@ -122,9 +123,27 @@ class EmpDataServiceController extends BaseController // Define headers for the Excel file $headers = [ - 'S.No', 'NAME OF EMP/DEP', 'EMP ID', 'EMP/DEP TYPE', 'RELATION', 'DOB', 'GENDER', 'PRE EXISTING AILMENTS', - 'BASIC COVER SI', 'DATE OF COVERAGE', 'AGE', 'RELATIONSHIP', 'REMARKS', 'POLICY END DATE', 'NO OF DAYS', 'TPA ID', 'UHID', - 'PREMIUM', 'PR0 RATA PREMIUM', 'GST', 'TOTAL' + 'S.No', + 'NAME OF EMP/DEP', + 'EMP ID', + 'EMP/DEP TYPE', + 'RELATION', + 'DOB', + 'GENDER', + 'PRE EXISTING AILMENTS', + 'BASIC COVER SI', + 'DATE OF COVERAGE', + 'AGE', + 'RELATIONSHIP', + 'REMARKS', + 'POLICY END DATE', + 'NO OF DAYS', + 'TPA ID', + 'UHID', + 'PREMIUM', + 'PR0 RATA PREMIUM', + 'GST', + 'TOTAL' ]; // Generate Excel file @@ -450,6 +469,12 @@ class EmpDataServiceController extends BaseController $client_policy_id = $import_data['client_policy_id']; $file = $import_data['file']; + // $data = $this->readExcelToArray($file); + // unset($data[0]); + // array_pop($data); + // $count = count($data);cmd + // dd($data); + $is_moved = $file->move(WRITEPATH . 'uploads/import_excel'); $filename = $file->getName(); @@ -678,7 +703,7 @@ class EmpDataServiceController extends BaseController { return 2; } - + $data = read_excel_file_to_array($file_name_with_path); unset($data[0]); $count = count($data); @@ -947,7 +972,7 @@ class EmpDataServiceController extends BaseController $data = [ 'amount' => $amount->total_sum, - 'sub_type_id' => 1, + 'sub_type_id' => 4, 'client_id' => $arrayData['client_id'], 'insurer_id' => $insurer_id['insurer_id'], 'description' => $description, @@ -986,7 +1011,7 @@ class EmpDataServiceController extends BaseController $data = [ 'amount' => $amount->total_sum, - 'sub_type_id' => 1, + 'sub_type_id' => 4, 'client_id' => $arrayData['client_id'], 'insurer_id' => $insurer_id['insurer_id'], 'description' => $description, @@ -1027,7 +1052,7 @@ class EmpDataServiceController extends BaseController $data = [ 'amount' => $amount->total_sum, - 'sub_type_id' => 1, + 'sub_type_id' => 3, 'client_id' => $arrayData['client_id'], 'insurer_id' => $insurer_id['insurer_id'], 'description' => $description, @@ -1219,4 +1244,36 @@ class EmpDataServiceController extends BaseController // ----------------------------------------------------------------------------------- + + + + public function readExcelToArray($file){ + + if ($file->isValid() && !$file->hasMoved()) { + $file = $file; + + $reader = new Xlsx(); + $spreadsheet = $reader->load($file->getPathname()); + + // Get the active sheet + $sheet = $spreadsheet->getActiveSheet(); + + // Iterate through rows to read data + $data = []; + foreach ($sheet->getRowIterator() as $row) { + $rowData = []; + foreach ($row->getCellIterator() as $cell) { + $rowData[] = $cell->getValue(); + } + $data[] = $rowData; + } + + return $data; + + } else { + + return false; + } + } + } diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php index ffb72f4c..95f164c8 100644 --- a/app/Helpers/excel_import_export_helper.php +++ b/app/Helpers/excel_import_export_helper.php @@ -268,39 +268,25 @@ if (! function_exists('transform_objects_to_array_for_deletion')) { if (!function_exists('add_totals_row')) { - function add_totals_row(Spreadsheet $spreadsheet, array $data, array $headers) - { - - //find the index value - $rata = array_search('PRO RATA PREMIUM', $headers); - $gst = array_search('GST', $headers); - $total = array_search('TOTAL', $headers); - - + function add_totals_row(Spreadsheet $spreadsheet, array $data) + { // Calculate GST, Pro Rata Premium, and Total sums $gstSum = 0; $proRataPremiumSum = 0; $totalSum = 0; foreach ($data as $row) { - $gstSum += $row[$gst]; - $proRataPremiumSum += $row[$rata]; - $totalSum += $row[$total]; + $gstSum += $row[18]; + $proRataPremiumSum += $row[19]; + $totalSum += $row[20]; } - $cellValue = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; - $prev_index = $rata - 1; - $cellValueTotal = $cellValue[$prev_index]; - $cellValueRata = $cellValue[$rata]; - $cellValueGST = $cellValue[$gst]; - $cellValueTotalSum = $cellValue[$total]; - // Add a new row with sums $lastRow = count($data) + 1; // To get the last row number - $spreadsheet->getActiveSheet()->setCellValue($cellValueTotal . ($lastRow + 1), 'TOTALS'); - $spreadsheet->getActiveSheet()->setCellValue($cellValueRata . ($lastRow + 1), $proRataPremiumSum); - $spreadsheet->getActiveSheet()->setCellValue($cellValueGST . ($lastRow + 1), $gstSum); - $spreadsheet->getActiveSheet()->setCellValue($cellValueTotalSum . ($lastRow + 1), $totalSum); + $spreadsheet->getActiveSheet()->setCellValue('R' . ($lastRow + 1), 'TOTALS'); + $spreadsheet->getActiveSheet()->setCellValue('S' . ($lastRow + 1), $gstSum); + $spreadsheet->getActiveSheet()->setCellValue('T' . ($lastRow + 1), $proRataPremiumSum); + $spreadsheet->getActiveSheet()->setCellValue('U' . ($lastRow + 1), $totalSum); } } @@ -543,4 +529,4 @@ if (!function_exists('format_Excel_BasedOn_Client')) return $data; } -} \ No newline at end of file +} diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 8ca450a4..1188601e 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -80,6 +80,7 @@ class ClientPolicyModel extends Model ->join('policies', 'policies.id = client_policy.policy_id') ->join('policy_type', 'policy_type.id = policies.policy_type_id') ->where('client_policy.client_id', $client_id) + ->orderBy('client_policy.id', 'asc') ->get() ->getResult(); diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 27da989b..4ccf7617 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -136,6 +136,14 @@ var policy_PrimaryKey = $('#client_id_policy').val(); var policy_client = $('#policy_PrimaryKey').val(); +$(document).ready(function() { + // Initialize select2 + $("#insurer").select2(); + $("#policy").select2(); + $("#tpa").select2(); + $("#base_policy").select2(); +}); + $(document).ready(function() { $('#policy_status_field').hide() @@ -398,53 +406,57 @@ $("#policy_form").submit(function(event) { }); }); -/********* To get th POLICY base on Insurer *******/ -$('#insurer').change(function() { - var id = $(this).val(); - var parts = id.split('-'); - var secondPart = parts[1]; - var url = "" + secondPart; +$(document).ready(function() { + /********* To get th POLICY base on Insurer *******/ + $('#insurer').change(function() { + var id = $(this).val(); + var parts = id.split('-'); + var secondPart = parts[1]; + var url = "" + secondPart; - $.get(url, function(res) { - // res = JSON.parse(res)// - // console.log(res) - var OptionsHTML = ''; - OptionsHTML += ''; - $.each(res.data, function(index, item) { - OptionsHTML += ''; + $.get(url, function(res) { + // res = JSON.parse(res)// + // console.log(res) + var OptionsHTML = ''; + OptionsHTML += ''; + $.each(res.data, function(index, item) { + OptionsHTML += ''; + }); + + $('#policy').html(OptionsHTML); + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); }); - - $('#policy').html(OptionsHTML); - }).fail(function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); }); }); -/********* set the Policy_Type_id for Form Submit *******/ -$('#policy').change(function() { +$(document).ready(function() { + /********* set the Policy_Type_id for Form Submit *******/ + $('#policy').change(function() { - var id = $(this).val(); - var dataId = $(this).children('option:selected').attr('data-id'); - console.log('id', id) - $('#policy_type_id').val(dataId); + var id = $(this).val(); + var dataId = $(this).children('option:selected').attr('data-id'); + console.log('id', id) + $('#policy_type_id').val(dataId); + + $('#base_policy option').each(function() { + var val = $(this).val(); + if (val == id) { + $(this).hide(); // Hide the option if its value matches the selected value of #policy + } else { + $(this).show(); // Show all other options + } + }); + + // if(dataId == 1){ + // appendPolicyFormFields(1); + // }else if (dataId >= 1){ + // appendPolicyFormFields(2); + // } - $('#base_policy option').each(function() { - var val = $(this).val(); - if (val == id) { - $(this).hide(); // Hide the option if its value matches the selected value of #policy - } else { - $(this).show(); // Show all other options - } }); - - // if(dataId == 1){ - // appendPolicyFormFields(1); - // }else if (dataId >= 1){ - // appendPolicyFormFields(2); - // } - }); // get the client policy data for edit @@ -482,9 +494,11 @@ $('body').on('click', '.btnPolicyEdit', function() { $('.btnBack').show(); $('.btnAdd').hide(); - $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id); - $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id); - $('#policy').val(res.data.policy_id); + $('#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').val(res.data.policy_id).change(); + + $('#policy_type_id').val(res.data.policy_type_id); $('#policy_PrimaryKey').val(res.data.id); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); @@ -529,6 +543,11 @@ $('body').on('click', '.btnPolicyEdit', function() { } }); $('#base_policy').html(OptionsHTML); + setTimeout(function() { + $('#policy').val(res.data.policy_id).change(); + $('#base_policy').change(); + }, 1000); + }, error: function(xhr, status, error) { console.error(xhr.responseText); diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 4b1e6633..f317dd20 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -75,6 +75,17 @@ table.dataTable tbody td { \ No newline at end of file diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index b3ed0c73..779f1dfb 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -173,6 +173,13 @@ table.dataTable tbody td { + + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 650b1a7d..99b24022 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -50,6 +50,9 @@ + + + @@ -215,6 +218,20 @@ + +