From 5d0ee48050077b8a3901251907565a63c641d470 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 22 Mar 2024 16:01:17 +0530 Subject: [PATCH 1/7] 'FIRST_COMMIT_FOR_TEST-BRANCH' --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00cdf704..8eaa7d72 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,5 @@ Additionally, make sure that the following extensions are enabled in your PHP: - json (enabled by default - don't turn it off) - [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL - [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library + +- first test release From df9c1a98fa56c2529d27b2de000baf1a892ceb6e Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 29 Mar 2024 10:55:15 +0530 Subject: [PATCH 2/7] FILES_CPANEL_YAML_ADDED --- .cpanel.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .cpanel.yml diff --git a/.cpanel.yml b/.cpanel.yml new file mode 100644 index 00000000..944de66e --- /dev/null +++ b/.cpanel.yml @@ -0,0 +1,5 @@ +--- +deployment: + tasks: + - export DEPLOYPATH=/home/example/public_html/ + - /bin/cp . $DEPLOYPATH \ No newline at end of file From 3f5ad1e7ac019b4424cdbb15ee19002034a64b27 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 17 Dec 2024 11:29:20 +0530 Subject: [PATCH 3/7] CHANGE_DUP_MAIL_CHECK --- app/Controllers/EmployeeServiceController.php | 6 ++++-- app/Helpers/excel_util_helper.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 7d4d22c7..6d5e6a98 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -236,7 +236,9 @@ class EmployeeServiceController extends AdminController 'is_mandatory' => false, 'data_type' => 'str', 'format' => null, - 'allowed_values' => null + 'allowed_values' => null, + 'custom' => 'check_dup_email', + 'params' => ['row', 'existing_mobilenos'] ], 'pre_existing_ailments' => [ 'col_idx' => 14, @@ -2029,7 +2031,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $value['family_floater_key'] = $relation; $policy_data['basic_cover_si'] = $row[9]; - $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null; + $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],null,'Y-m-d') : null; $policy_data['client_policy_id'] = $file['policy_id']; $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 76cf51a3..d1fdf7d2 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -1726,6 +1726,21 @@ if(!function_exists('check_dup_mobileno')) } } +if(!function_exists('check_dup_email')) +{ + function check_dup_email(array $row,array $existing_mobilenos) + { + foreach($existing_mobilenos as $k => $value) + { + if ($row['13'] == $value['email_corporate']) { + return array('status' => false,'error' => "Duplicate Email"); + // break; + } + } + return array('status' => true); + } +} + if(!function_exists('generate_family_relationship_array')) { function generate_family_relationship_array($family_structure_from_policy_terms) { From 9fb2bc75b9e1405deeead934afcdf0d23ba297fc Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 18 Dec 2024 11:48:59 +0530 Subject: [PATCH 4/7] CHANGE_ in agree api : GWM --- app/Controllers/EmployeeRestController.php | 72 +++++++++++++++++----- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index bf626b79..d43e56bf 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -223,6 +223,10 @@ class EmployeeRestController extends AdminController { try { $data = $this->request->getJSON(); + + $openForEnrollment = $this->findThePolicyIsOpenForEnrollment($data[0]->client_policy_id); + if($openForEnrollment == false){ return $this->respond(['status' => 'failed','code' => 404,'data' => 'Enrollment closed'], 404); } + if ($data) { $Count = 0; @@ -505,6 +509,10 @@ class EmployeeRestController extends AdminController try { $requestData = $this->request->getJSON(); + + $openForEnrollment = $this->findThePolicyIsOpenForEnrollment($requestData[0]->client_policy_id); + if($openForEnrollment == false){ return $this->respond(['status' => 'failed','code' => 404,'data' => 'Enrollment closed'], 404); } + foreach ($requestData as $key => $value) { @@ -1996,6 +2004,7 @@ class EmployeeRestController extends AdminController { $postData = json_decode($this->request->getBody(), true); + $this->myLogger->logme("error", $this->request->getBody()); $client_policy_id = $postData['client_policy_id']; sort($client_policy_id); @@ -2003,7 +2012,7 @@ class EmployeeRestController extends AdminController $client_id = $postData['client_id']; $empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll(); - + $employeeIds = array_column($empData, 'id'); //for mail common parameter $filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self'); @@ -2015,39 +2024,56 @@ class EmployeeRestController extends AdminController $policy = $this->clientPolicyModel->where('id',$value)->where('open_for_enrollment',1)->find(); if($policy) { - foreach ($empData as $empDataKey => $empDataValue) + $this->myLogger->logme("error", 'client policy id = '.$value.' is open for enrollment'); + + $empPolicyData = $this->employeePolicyModel->where('client_policy_id', $value ) + ->where('is_active', 1 ) + ->whereIn($employeeIds) + ->findAll(); + if(count($empPolicyData)) { + + $empIdsFromPolicyData = array_column($empPolicyData, 'employee_id'); + //update emp polict table $this->employeePolicyModel->where('client_policy_id', $value ) ->where('is_active', 1 ) - ->where('employee_id', $empDataValue['id'] ) - ->where('status', 'draft' ) + ->whereIn('employee_id', $empIdsFromPolicyData ) + ->groupStart() + ->where('status', 'draft') + ->orWhere('status', 'enrolled') + ->groupEnd() ->set(array('status'=>'enrolled')) ->update(); + //update Employee table + $this->employeeModel->where('emp_code', $emp_code) + ->where('id', $empIdsFromPolicyData) + ->where('client_id', $client_id) + ->where('is_active', 1) + ->groupStart() + ->where('emp_status', 'draft') + ->orWhere('emp_status', 'enrolled') + ->groupEnd() + ->set(['emp_status' => 'enrolled']) + ->update(); + } - + $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); if(count($find) > 0){ $array_list[] = $find; } - } + }else { $this->myLogger->logme("error", 'client policy id = '.$value.' is not open for enrollment');} } - //update Employee table - $this->employeeModel->where('emp_code', $emp_code)->where('client_id', $client_id)->where('is_active', 1) - ->groupStart() - ->where('emp_status', 'draft') - ->orWhere('emp_status', 'enrolled') - ->groupEnd() - ->set(['emp_status' => 'enrolled']) - ->update(); + $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first(); - if (isset($notification) && $notification['enabled'] == 1) { + if (isset($notification) && $notification['enabled'] == 1 && count($array_list)) { $params ['array_list'] = $array_list; $params ['client_policy_id'] = $client_policy_id; $params ['emp_code'] = $emp_code; @@ -2328,7 +2354,8 @@ class EmployeeRestController extends AdminController { try { - $clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id'))->findAll(); + $clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id')) + ->where('open_for_enrollment',1)->findAll(); if(count($clientPolicy)) { @@ -2990,6 +3017,19 @@ class EmployeeRestController extends AdminController return false; } } + + + public function findThePolicyIsOpenForEnrollment($plicy_id) + { + + $policy = $this->clientPolicyModel->where('id',$plicy_id)->where('open_for_enrollment',1)->find(); + + if($policy) + return true; + else + return false; + + } From f64db94a4ce7b7a07877ab557d0a958f9b891271 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 18 Dec 2024 14:16:31 +0530 Subject: [PATCH 5/7] CHANGE_ in agree api : GWM --- app/Controllers/EmployeeRestController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 21e0dea9..46d46589 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2028,7 +2028,7 @@ class EmployeeRestController extends AdminController $empPolicyData = $this->employeePolicyModel->where('client_policy_id', $value ) ->where('is_active', 1 ) - ->whereIn($employeeIds) + ->whereIn('employee_id',$employeeIds) ->findAll(); if(count($empPolicyData)) { @@ -2046,7 +2046,7 @@ class EmployeeRestController extends AdminController ->update(); //update Employee table $this->employeeModel->where('emp_code', $emp_code) - ->where('id', $empIdsFromPolicyData) + ->whereIn('id', $empIdsFromPolicyData) ->where('client_id', $client_id) ->where('is_active', 1) ->groupStart() From 085d4576f583a3a015687b7dfe50965d13193ed9 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 19 Dec 2024 14:31:31 +0530 Subject: [PATCH 6/7] CHANGE_MEMBERS_DEMOGRAPHY_STARTED --- app/Controllers/LeadsController.php | 86 +++++++++++++++++++++++++++- app/Helpers/sendMailNotification.php | 2 +- app/Models/RFQModel.php | 3 +- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 7c5eef43..856fb649 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -90,6 +90,11 @@ class LeadsController extends BaseController public function viewLeadsList() { + + // $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null); + // $d = $this->calculateMembersDemography(['lead_id' => 34]); + //$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null); + // dd($d); $data['page_name'] = 'Leads'; // Set basic data @@ -431,7 +436,7 @@ class LeadsController extends BaseController //FOR EXCEL public function exportExcelForQCRandRFQ($lead_id, $type) { - $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + //$filepath = $this->constructExcelToSaveTemp($lead_id, $type); $filepath = $filepath['filePath']; if (file_exists($filepath)) { @@ -662,6 +667,85 @@ class LeadsController extends BaseController 'fileName' => $filename, ]; } + + //Merge RFQ/QCR file with lead members file + public function mergeQuoteExcelFileWithMembersListExcelFile($lead_id, $type, $source_file_path) + { + $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); + + if($source_file_path && $rfq_data['file_name']) + { + + } + + return true; + } + + public function calculateMembersDemography($params) + { + $lead_id = $params['lead_id']; + $lead_data = $this->leadsModel->find($lead_id); + // print_rr($lead_data); + if($lead_data['file_name']) + { + $file_name_with_path = WRITEPATH."/uploads/lead_files/".$lead_data['file_name']; + + //check physical file + if(!file_exists($file_name_with_path)) + { + //file not found update status and reason + $message = "Lead Physcial file not found"; + // echo $message; + $this->myLogger->logme('error',($message . ' for file ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no physcial file']; + } + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + + //get members data + $members_sheet = $spreadsheet->getSheet(0); + $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); + // dd($highestRowAndColumn); + $members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + // dd($members); + + //get age band data + $age_band_sheet = $spreadsheet->getSheet(1); + $highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn(); + $age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + print_r($age_band_data); + + //check age or dob column + $members_heading = $members[0]; + Kint::dump($members_heading); + $available_col = null; + $col_index = null; + + if (in_array('age', array_map('strtolower',$members_heading))) { + $available_col = 'age'; + $col_index = array_search('age',array_map('strtolower',$members_heading)); + } elseif (in_array('dob', array_map('strtolower', $members_heading))) { + $available_col = 'dob'; + $col_index = array_search('dob', array_map('strtolower', $members_heading)); + } + + if ($available_col == null) { + $message = 'No DOB or Age column '; + $this->myLogger->logme('error',($message . $file_name_with_path)); + return ['status' => 'failed','message' => $message]; + } + + //convert age slab data into array + + } + else + { + $this->myLogger->logme('error',(' no file found ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no file found']; + } + + } + //this funciton for send mail to insurer and client with either RFQ/QCR public function sendMailWithAttachement() diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 3ac48a4d..2615b1fc 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -327,7 +327,7 @@ class sendMailNotification // dd($payable_employee_array); // dd(count($payable_employee_array['emp_data'])); - if(count($payable_employee_array['emp_data']) > 0){ + if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){ $table_content .= '

Policy Type :'; $temp_data = ''; diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php index d616e517..006ac637 100644 --- a/app/Models/RFQModel.php +++ b/app/Models/RFQModel.php @@ -67,7 +67,8 @@ class RFQModel extends Model tpa.name as tpa_name, tpa_branch.branch_name as tpa_branch_name, policy_type.policy_type, - rfq.json + rfq.json, + file_name ') ->join('leads', 'rfq.lead_id = leads.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id') From a6ff0b0b24c3f79332256ca64c495e6d6e9ad69b Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 19 Dec 2024 14:45:07 +0530 Subject: [PATCH 7/7] FEAT_EXCEL MERGE HELPER CREATED --- app/Helpers/ExcelMergeHelper.php | 93 +++++++++++++++++++++++++++++ composer.json | 1 + tests/unit/ExcelMergeHelperTest.php | 25 ++++++++ 3 files changed, 119 insertions(+) create mode 100644 app/Helpers/ExcelMergeHelper.php create mode 100755 tests/unit/ExcelMergeHelperTest.php diff --git a/app/Helpers/ExcelMergeHelper.php b/app/Helpers/ExcelMergeHelper.php new file mode 100644 index 00000000..06f68c66 --- /dev/null +++ b/app/Helpers/ExcelMergeHelper.php @@ -0,0 +1,93 @@ + $sheetsToMerge) { + // Load the current file + $currentSpreadsheet = IOFactory::load($filePath); + + // Debugging: Log the number of sheets in the current file + error_log("File: $filePath has " . $currentSpreadsheet->getSheetCount() . " sheets."); + + // If this is the first file, initialize the base spreadsheet + if ($spreadsheet === null) { + $spreadsheet = $currentSpreadsheet; + + // If specific sheets are provided for the first file, remove the others + if (!is_null($sheetsToMerge) && !empty($sheetsToMerge)) { + $sheetCount = $spreadsheet->getSheetCount(); + for ($i = $sheetCount - 1; $i >= 0; $i--) { + if (!in_array($i, $sheetsToMerge)) { + $spreadsheet->removeSheetByIndex($i); + } + } + } + } else { + // If we are not working with the first file, we need to merge specified sheets + if (is_null($sheetsToMerge) || empty($sheetsToMerge)) { + // If no specific sheets, merge all sheets + $sheetsToMerge = range(0, $currentSpreadsheet->getSheetCount() - 1); + } + + // Merge the specified sheets from the current file + foreach ($sheetsToMerge as $sheetIndex) { + // Check if sheet index is within bounds + if ($sheetIndex < 0 || $sheetIndex >= $currentSpreadsheet->getSheetCount()) { + throw new Exception("Invalid sheet index $sheetIndex in file $filePath"); + } + + // Retrieve the sheet to copy + $sheetToCopy = $currentSpreadsheet->getSheet($sheetIndex); + + // Handle sheet name collision by renaming the sheet with a counter + $baseName = $sheetToCopy->getTitle(); + $sheetName = $baseName; + $counter = 1; + while ($spreadsheet->sheetNameExists($sheetName)) { + $sheetName = $baseName . '_merged_' . $counter; + $counter++; + } + $sheetToCopy->setTitle($sheetName); + + // Clone and add the sheet to the base spreadsheet + $spreadsheet->addSheet(clone $sheetToCopy); + } + } + } + + // Save the merged file + $writer = new Xlsx($spreadsheet); + $writer->save($outputPath); + + return true; // Return true if merge was successful + } catch (Exception $e) { + // Log the error (optional) and return false on failure + error_log("Excel Merge Error: " . $e->getMessage()); + return false; + } + } +} diff --git a/composer.json b/composer.json index da1c83ff..73453d9c 100755 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "friendsofphp/php-cs-fixer": "^3.47.1", "kint-php/kint": "^5.0.4", "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.6", "nexusphp/cs-config": "^3.6", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0" diff --git a/tests/unit/ExcelMergeHelperTest.php b/tests/unit/ExcelMergeHelperTest.php new file mode 100755 index 00000000..e648f0b6 --- /dev/null +++ b/tests/unit/ExcelMergeHelperTest.php @@ -0,0 +1,25 @@ + [1,3,2], + '/home/venba/Downloads/enrollment.xlsx' => [] + ]; + $outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file + + // Call the mergeExcelFiles function + $result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); + var_dump($result); + // Check if the result is true (indicating success) + $this->assertTrue($result, 'Expected true, but got false'); + } + +} \ No newline at end of file