From 5bebb7217feb1628276e60cae46434d7fc2bff65 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 11 Feb 2025 11:31:39 +0530 Subject: [PATCH 01/61] FEAT_HEAD_APPROVE_AND_REJECT_FOR_GPA_SRI --- app/Controllers/ChatbotControllerNew.php | 2 +- app/Views/ticket_form_gmc.php | 15 +++++++++++++++ app/Views/ticket_form_gpa.php | 5 +++++ app/Views/ticket_list.php | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index 9fc9be36..b68a9581 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -98,7 +98,7 @@ class ChatbotControllerNew extends BaseController }); // Start the Main Menu when user says "hi" or "start" $this->botman->hears('start|hi|hello', function (BotMan $bot) { - $bot->reply('Hi how can i assit?'); + $bot->reply('Hi how can i assist?'); $bot->startConversation(new MainMenuConversation()); }); diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 7162e546..c30dcadf 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -300,6 +300,7 @@ Rejected Approve + @@ -308,6 +309,20 @@ + + \ No newline at end of file diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index ddf4d238..cbe4d478 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -161,6 +161,7 @@ table.dataTable tbody td { \ No newline at end of file diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index ddf4d238..c031991d 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -435,10 +435,12 @@ $(document).ready(function(){ let client_id = $(this).val(); let client_type = $('#client_id option:selected').data('ct'); - if(branch_list != '' && client_id != '') { + if(branch_list[client_id] != '' && branch_list[client_id] != null && client_id != '') { console.log('branch_list', branch_list[client_id]); let data = branch_list[client_id]; appendBranch(data); + }else{ + toastr.warning("No Branch Found for the selected Client",'Warning'); } }) @@ -447,10 +449,12 @@ $(document).ready(function(){ let client_branch_id = $(this).val(); - if(policy_list != '' && client_branch_id != '') { + if(policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null && client_branch_id != ''&& client_branch_id != null) { console.log('policy_list', policy_list[client_branch_id]); let data = policy_list[client_branch_id]; appendRenewalPolicies(data); + }else{ + toastr.warning("No Policies Found for the selected Branch",'Warning'); } }) From e80b393cda098e9743915cff9ba950247e5eeebb Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 12 Feb 2025 14:51:46 +0530 Subject: [PATCH 05/61] CHANGE_CODE_CHANGE : RV --- app/Views/lead_filter.php | 24 +++++++++++++----------- app/Views/leads_form.php | 28 +++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/Views/lead_filter.php b/app/Views/lead_filter.php index d0a00908..441b363b 100644 --- a/app/Views/lead_filter.php +++ b/app/Views/lead_filter.php @@ -140,23 +140,25 @@ \ No newline at end of file From 599dfda3f6d86cf317b30487247241b27d336ee9 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 12 Feb 2025 14:52:51 +0530 Subject: [PATCH 06/61] FIX_RFQ_GMC_SRI --- app/Views/leads_form.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 92d6af73..438f6ead 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -494,7 +494,7 @@ function getLeadsDataForEdit(input) { $('#freshDiv').hide(); $('.proposed_div').show().find('select, input').attr('required', 'required'); $('#policy_end_date, #policy_start_date, #claim').removeAttr('required'); - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.emp_title').text('No of Employees at Inception') @@ -516,7 +516,7 @@ function getLeadsDataForEdit(input) { $('.depnd_title').text('No of Dependents') $('.total_title').text('Total Lives') }else{ - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.emp_title').text('No of Employees at Inception') @@ -527,7 +527,7 @@ function getLeadsDataForEdit(input) { } if(res.data.policy_type_id != 2){ - + $('.gpa_hide_div_'+increment).hide(); $('.gpa_show_div_'+increment).show(); $('.gpa_div_elements_'+increment).show(); @@ -1141,7 +1141,7 @@ function addHTMLInput(check) { // $('.proposed_div').show().find('select, input').attr('required', 'required'); $('.proposed_div').show(); - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.emp_title').text('No of Employees at Inception') @@ -1163,7 +1163,7 @@ function addHTMLInput(check) { $('.depnd_title').text('No of Dependents') $('.total_title').text('Total Lives') }else{ - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.emp_title').text('No of Employees at Inception') $('.depnd_title').text(' No of Dependents at Inception') @@ -1468,7 +1468,7 @@ $('#lead_type').change(function() { $('#policy_start_date').removeAttr('required'); $('#claims').removeAttr('required'); $('#freshDiv').hide(); - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.gpa_div_elements').show(); @@ -1516,7 +1516,7 @@ $('#lead_type').change(function() { $('.gpa_div_elements').show(); }else{ - $('.freashDiv').show() + // $('.freashDiv').show() $('.renewalDiv').hide() $('.emp_title').text('No of Employees at Inception') @@ -1614,12 +1614,14 @@ function showGpaColumns(input){ let policy_type_id = $(input).val() let increment = input.id.split("_").pop(); if(policy_type_id != 2){ + $('.freashDiv').hide() $('.gpa_hide_div_'+increment).hide(); $('.gpa_show_div_'+increment).show(); $('.gpa_div_elements_'+increment).show(); $('.emp_title').text('No of Employees at Inception') $('.total_title').text('Total Sum Insured at Inception') }else{ + $('.freashDiv').show() $('.gpa_hide_div_'+increment).show(); } @@ -1645,7 +1647,7 @@ function getURLParamsForReport() { console.log('lead_id', lead_id); // Retain the log if necessary } -$('#policy_type_id').change(function() { +$('.policy_type_id').change(function() { console.log("policy type changed"); var policy_type_id = $(this).val(); if (policy_type_id == 2) { From 9efc4a568fce00f7b4f139d1acd33dea92e7f0b5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 14 Feb 2025 11:59:48 +0530 Subject: [PATCH 07/61] FIX_RFQ_CHANGES : RV --- app/Controllers/ClientController.php | 68 +++-- app/Controllers/EmployeeController.php | 3 +- app/Controllers/LeadsController.php | 378 ++++++++++++++++++++----- app/Models/RFQModel.php | 1 + app/Views/view_rfq.php | 57 +++- 5 files changed, 388 insertions(+), 119 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d7581c63..1cb8e029 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -187,23 +187,28 @@ class ClientController extends AdminController } //Function for Testing Member Review and Summery Confirmation Mail - public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic + public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $policy_id = "", $mail_active = 0) //this function for only tsesting some logics not use for business logic { - // dd($client_id, $emp_code, $mail_active); + // dd($client_id, $emp_code, $policy_id, $mail_active); - $client_policy_ids = $this->employeeModel - ->select('employee_polices.client_policy_id') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.client_id', $client_id ) - ->where('employees.emp_code', $emp_code ) - ->where('employee_polices.is_active', 1 ) - ->where('employees.is_active', 1 ) - ->findAll(); + if(empty($policy_id)){ - $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id'); + $client_policy_ids = $this->employeeModel + ->select('employee_polices.client_policy_id') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.client_id', $client_id ) + ->where('employees.emp_code', $emp_code ) + ->where('employee_polices.is_active', 1 ) + ->where('employees.is_active', 1 ) + ->findAll(); - $client_policy_id = array_unique($client_policy_ids2); + $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id'); + $client_policy_id = array_unique($client_policy_ids2); + + }else{ + $client_policy_id = json_decode($policy_id, true); + } // echo '
';
         // dd($client_policy_id);
@@ -259,7 +264,7 @@ class ClientController extends AdminController
                 $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
                 // print_r($wholeData); die;
 
-                if($mail_active > 0){
+                if($mail_active == 1){
                     $mail_send_return =  MailHelper::send_email($wholeData[0]);
                     $this->myLogger->logme("info", $mail_send_return);
                 }
@@ -324,19 +329,29 @@ class ClientController extends AdminController
     }
 
     //Function for Send Member Review and Summery Confirmation Mail
-    public function sendMemberReviewConfirmationMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0)
+    public function sendMemberReviewConfirmationMail($client_id = 77, $emp_code = 'EMP001-K1', $policy_id = "", $mail_active = 0)
     {
-        $client_policy_ids = $this->employeeModel
-            ->select('employee_polices.client_policy_id')
-            ->join('employee_polices', 'employees.id = employee_polices.employee_id')
-            ->where('employees.client_id', $client_id)
-            ->where('employees.emp_code', $emp_code)
-            ->where('employee_polices.is_active', 1)
-            ->where('employees.is_active', 1)
-            ->findAll();
-    
-        $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
-        $client_policy_id = array_unique($client_policy_ids2);
+        // dd($client_id, $emp_code, $policy_id, $mail_active);
+
+        if(empty($policy_id)){
+
+            $client_policy_ids = $this->employeeModel
+                                ->select('employee_polices.client_policy_id')
+                                ->join('employee_polices', 'employees.id = employee_polices.employee_id')
+                                ->where('employees.client_id', $client_id ) 
+                                ->where('employees.emp_code', $emp_code )
+                                ->where('employee_polices.is_active', 1 )
+                                ->where('employees.is_active', 1 )
+                                ->findAll();
+
+            $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
+            $client_policy_id = array_unique($client_policy_ids2);
+
+        }else{
+            $client_policy_id = json_decode($policy_id, true);
+        }
+
+        // dd($client_policy_id);
     
         if (!is_null($client_policy_id) && is_array($client_policy_id)) {
 
@@ -396,8 +411,9 @@ class ClientController extends AdminController
     
                 $wholeData = sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
     
-                if ($mail_active > 0) {
+                if ($mail_active == 0) {
 
+                    // $mail_send_result = [];
                     $mail_send_result = MailHelper::send_email($wholeData[0]);
     
                     if ($mail_send_result['status'] === 'success') {
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index e81684f7..09092020 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -1605,9 +1605,8 @@ class EmployeeController extends AdminController
                     $db = db_connect();
                     $query = "
                                 UPDATE employee_polices 
-                                JOIN employees ON employees.id = employee_polices.employee_id
                                 SET employee_polices.status = 'truncated', employee_polices.is_active = 0 
-                                WHERE employees.file_id = $file_id
+                                WHERE employee_polices.file_id = $file_id
                             ";
                 
                     $db->query($query);
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index d274600b..bea4ebd8 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -12,6 +12,8 @@ use PhpOffice\PhpSpreadsheet\Style\Border;
 use PhpOffice\PhpSpreadsheet\Style\Alignment;
 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
 use PhpOffice\PhpSpreadsheet\Style\Fill;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
 
 use App\Models\UserModel;
 use App\Models\ClientModel;
@@ -31,7 +33,7 @@ use App\Helpers\MailHelper;
 use App\Helpers\ExcelMergeHelper;
 use App\Helpers\ExcelSanitizeHelper;
 use Google\Service\CloudSearch\PushItem;
-use Kint;
+use Kint\Kint;
 
 use App\Controllers\Jobs;
 use App\Controllers\JobWorker;
@@ -435,7 +437,9 @@ class LeadsController extends BaseController
                 ->where('lead_id', $id)
                 // ->where('type', $type)
                 ->where('is_active', 1)
+                ->orderBy('id', 'desc')
                 ->first();
+        // dd($data);
 
         $data['rfq_count'] = $this->RFQModel
                 ->where('lead_id', $id)
@@ -453,8 +457,15 @@ class LeadsController extends BaseController
 
         $data['lead_id'] = $id;
         $lead_data = $this->leadsModel
-                ->select('leads.*, policy_type.question_json, policy_type.policy_type')
+                ->select('
+                    leads.*, 
+                    policy_type.question_json, 
+                    policy_type.policy_type,
+                    policy_type.long_name, 
+                    user_profiles.email as created_person_email
+                ')
                 ->join('policy_type', 'leads.policy_type_id = policy_type.id')
+                ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
                 ->where('leads.id', $id)
                 ->where('leads.is_active', 1)
                 ->first();
@@ -472,7 +483,21 @@ class LeadsController extends BaseController
         $data['userList'] = $this->userModel->getUserListForRFQ();
         $data['lead_data'] = $lead_data;
 
-        $data['mail_content'] = $this->transformMailContent($id);
+        $mail_content = "
+            

Dear Sir,

+

Greetings From Nhance India!

+

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

+

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

+

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

+

Thank You!

+ "; + + + $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}"; + + $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']); + $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); + // dd($data); $this->loadLayout('view_rfq.php', $data); @@ -591,13 +616,13 @@ class LeadsController extends BaseController public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null) { $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); - + // dd($rfq_data, $lead_id, $type, $propsal_and_insurer); // print_r($propsal_and_insurer); die; - if($rfq_data['lead_type'] == 1){ + if ($rfq_data['lead_type'] == 1) { - if($rfq_data['policy_type_id'] == 2){ + if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ 'Insured' => $rfq_data['client_name'], @@ -607,23 +632,22 @@ class LeadsController extends BaseController 'No of Dependents' => $rfq_data['incept_dept_count'], 'Total Lives' => $rfq_data['incept_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), 'Policy Run Days' => $rfq_data['policy_run_days'], ]; - }else if($rfq_data['policy_type_id'] == 1){ + } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ 'Insured' => $rfq_data['client_name'], 'No of Employees at Inception' => $rfq_data['incept_emp_count'], 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], - 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), 'Policy Status' => $rfq_data['status'], 'Existing Insurer' => $rfq_data['insurer_name'], 'TPA ' => $rfq_data['tpa_name'], ]; } - - }else{ - if($rfq_data['policy_type_id'] == 2){ + } else { + if ($rfq_data['policy_type_id'] == 2) { $lead_data = [ 'Insured' => $rfq_data['client_name'], @@ -641,7 +665,7 @@ class LeadsController extends BaseController 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), 'Policy Run Days' => $rfq_data['policy_run_days'], 'Inception Premium' => $rfq_data['premium_at_inception'], 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], @@ -651,12 +675,12 @@ class LeadsController extends BaseController 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], ]; - }else if($rfq_data['policy_type_id'] == 1){ + } else if ($rfq_data['policy_type_id'] == 1) { $lead_data = [ 'Insured' => $rfq_data['client_name'], 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], - 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])), 'Policy Status' => $rfq_data['status'], 'Existing Insurer' => $rfq_data['insurer_name'], 'TPA ' => $rfq_data['tpa_name'], @@ -665,14 +689,15 @@ class LeadsController extends BaseController } $data = json_decode($rfq_data['json'], true); + // dd($data); - if($type == 2){ + if ($type == 2) { $data = $this->convertJsonForQCR($data, $type); - if($propsal_and_insurer !== null){ + if ($propsal_and_insurer !== null) { list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2); $data = $this->transformProposelData($data, $proposal_key, $insurer_key); } - }else if($type == 1){ + } else if ($type == 1) { $data = $this->convertJsonForQCR($data, $type); // dd($data); } @@ -680,17 +705,123 @@ class LeadsController extends BaseController $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); + // Start with lead_data at the top $rowNumber = 1; + + $mergeRange1 = "A{$rowNumber}:C{$rowNumber}"; + $sheet->mergeCells($mergeRange1); + $sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd"); + $sheet->getStyle("A{$rowNumber}")->applyFromArray([ + 'font' => [ + 'bold' => true, + 'size' => 20 + ], + 'alignment' => [ + 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + ], + ]); + + // Set column width to fit the image properly + $sheet->getColumnDimension('D')->setWidth(20); // Adjust as needed + $sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed + + $drawing = new Drawing(); + $path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path + $drawing->setPath($path); + $drawing->setCoordinates("D{$rowNumber}"); // Set position in column B + $drawing->setHeight(35); // Adjust image height + + // Center align the image in the cell + $drawing->setOffsetX(30); // Adjust horizontal offset + $drawing->setOffsetY(5); // Adjust vertical offset + + $drawing->setWorksheet($sheet); + + // Apply center alignment to the cell + $sheet->getStyle("D{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $sheet->getStyle("D{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); + + + $rowNumber = $rowNumber + 1; + + // Initialize max width tracking variables + $maxWidthA = 0; + $maxWidthB = 0; + foreach ($lead_data as $key => $value) { + + // Merge A:B for key and C:D for value + $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; + $mergeRangeValue = "C{$rowNumber}:D{$rowNumber}"; + $sheet->mergeCells($mergeRangeKey); + $sheet->mergeCells($mergeRangeValue); + + // Set values in merged cells $sheet->setCellValue("A{$rowNumber}", $key); - $sheet->setCellValue("B{$rowNumber}", $value); - $sheet->getStyle("A{$rowNumber}")->applyFromArray(['font' => ['bold' => true]]); + $sheet->setCellValue("C{$rowNumber}", $value); + + // Apply styles for alignment and bold text in A:B + $sheet->getStyle($mergeRangeKey)->applyFromArray([ + 'font' => ['bold' => true], + 'alignment' => [ + 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + ], + ]); + + // Apply bold style to B column if the key is "Insured" + if ($key == "Insured") { + $sheet->getStyle("C{$rowNumber}")->applyFromArray([ + 'font' => ['bold' => true], + ]); + } + + // Track max width needed for columns + $maxWidthA = max($maxWidthA, mb_strlen($key)); + $maxWidthB = max($maxWidthB, mb_strlen($value)); + $rowNumber++; } - $leadRange = "A1:B" . (count($lead_data)); - $sheet->getStyle($leadRange)->applyFromArray([ + // Set column width based on max content length (adjusted for padding) + $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); + $sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2); + $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2); + $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2); + + // $rowNumber += 2; + + // Add headers and subheaders + $headers = $data['table_data']['headers']; + + $sheet->setCellValue("A{$rowNumber}", "Details of Coverage"); + $sheet->getStyle("A{$rowNumber}")->applyFromArray([ + 'font' => [ + 'bold' => true, + ], + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => 'ADD8E6'], + ], + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['argb' => 'FF000000'], // Black color + ], + ], + ]); + $subheader_count = array_sum(array_map(fn($header) => count($header['subHeaders']), $data['table_data']['headers'])); + $subheader_count = $subheader_count - 2; + $headerCount = count($data['table_data']['headers']); + $lastColumn = Coordinate::stringFromColumnIndex($subheader_count); + // dd( $headerCount, $lastColumn); + + // Merge cells from A to the last column + $mergeRange = "A{$rowNumber}:{$lastColumn}{$rowNumber}"; + + $sheet->getStyle($mergeRange)->applyFromArray([ 'borders' => [ 'allBorders' => [ 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, @@ -699,21 +830,25 @@ class LeadsController extends BaseController ], ]); + $sheet->mergeCells($mergeRange); + $rowNumber = $rowNumber + 1; - $rowNumber += 2; - - // Add headers and subheaders - $headers = $data['table_data']['headers']; $subHeaderRow = $rowNumber + 1; $columnLetter = 'A'; foreach ($headers as $header) { + if (in_array($header['parentHeader'], ['Item Key', 'Action'])) { continue; } if ($header['parentHeader'] === 'Sno') { $header['parentHeader'] = 'S.No.'; + $sheet->getColumnDimension('A')->setWidth(10); + } + + if ($header['parentHeader'] === 'Particulars') { + $sheet->getColumnDimension('B')->setWidth(40); } $startColumn = $columnLetter; // Start of the current header range @@ -740,6 +875,13 @@ class LeadsController extends BaseController // Add subheaders foreach ($header['subHeaders'] as $subHeader) { $sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader); + + if ($columnLetter != "A" && $columnLetter != "B" && $columnLetter != "C" && $columnLetter != "D") { + $sheet->getColumnDimension($columnLetter)->setWidth(35); + } else { + $sheet->getColumnDimension('A')->setWidth(10); + } + $sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([ 'font' => ['bold' => true], 'alignment' => [ @@ -763,12 +905,13 @@ class LeadsController extends BaseController ]); // Increase row height for headers and subheaders - $sheet->getRowDimension($rowNumber)->setRowHeight(30); // Header row height - $sheet->getRowDimension($subHeaderRow)->setRowHeight(25); // Subheader row height + $sheet->getRowDimension($rowNumber)->setRowHeight(25); // Header row height + $sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height $rowNumber = $subHeaderRow + 2; $column_data = $data['table_data']['data']; $serial_no = 1; + $maxColumnWidths = []; // Add table data rows foreach ($column_data as $dataRow) { @@ -806,6 +949,7 @@ class LeadsController extends BaseController $rowNumber += 2; // Add premium data + // dd($data); $labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"]; $premiumData = $data['premium_data']['data']; $premium = [$labelArray[0]]; @@ -814,7 +958,7 @@ class LeadsController extends BaseController $total = [$labelArray[3]]; foreach ($premiumData as $proposal => $insurers) { - if($proposal != 'Particulars'){ + if ($proposal != 'Particulars') { foreach ($insurers as $insurer => $values) { $premium[] = $values[$labelArray[0]]; $gst[] = $values[$labelArray[1]]; @@ -836,7 +980,8 @@ class LeadsController extends BaseController $rowNumber++; } - $premiumRange = "B" . ($rowNumber - 3) . ":" . chr(ord($columnLetter) - 1) . ($rowNumber - 1); + $premiumRange = "B" . ($rowNumber - 4) . ":" . chr(ord($columnLetter) - 2) . ($rowNumber - 1); + // dd($premiumRange); $sheet->getStyle($premiumRange)->applyFromArray([ 'borders' => [ 'allBorders' => [ @@ -848,10 +993,53 @@ class LeadsController extends BaseController } // Auto-size columns - foreach ($sheet->getColumnIterator() as $column) { - $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); + // foreach ($sheet->getColumnIterator() as $column) { + // $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); + // } + + $dataRange = $sheet->calculateWorksheetDimension(); + + $sheet->getStyle($dataRange)->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_CENTER) + ->setVertical(Alignment::VERTICAL_CENTER) + ->setWrapText(true); + + $sheet->getStyle('A1')->applyFromArray([ + 'alignment' => [ + 'wrapText' => false, // Disables text wrapping for A1 + ], + ]); + + // Apply border to the entire sheet + preg_match('/([A-Z]+)(\d+):([A-Z]+)(\d+)/', $dataRange, $matches); + + if ($matches) { + $startColumn = $matches[1]; // A + $startRow = $matches[2]; // 1 + $endColumn = $matches[3]; // G + $endRow = $matches[4]; // 75 + + // Convert column letter to index, reduce by 1, and convert back + $endColumnIndex = Coordinate::columnIndexFromString($endColumn) - 1; + $newEndColumn = Coordinate::stringFromColumnIndex($endColumnIndex); + + // Generate the new range (e.g., "A1:F75" instead of "A1:G75") + $newDataRange = "{$startColumn}{$startRow}:{$newEndColumn}{$endRow}"; + // $sheet->getStyle($newDataRange)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN); } + $lastRow = count($lead_data) + 1; + $leadRange = "A1:D{$lastRow}"; + + $sheet->getStyle($leadRange)->applyFromArray([ + 'borders' => [ + 'allBorders' => [ + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'color' => ['argb' => 'FF000000'], // Black color + ], + ], + ]); + // Set filename $string = ($type == 2) ? 'QCR' : 'RFQ'; $filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx'; @@ -1495,8 +1683,10 @@ class LeadsController extends BaseController $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--'; // print_rr($message);calculate_days_bw_dates + $string = implode(", ", $cc_mails); + $bcc_string = implode(", ", $bcc_mails); - $res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_mails]); + $res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]); // !dd($res); $result_data[] = ['mail' => $recipient['email'], 'status' => $res]; } @@ -2053,54 +2243,90 @@ class LeadsController extends BaseController //------------------------------------------------------------------------------------------------ - public function transformMailContent($lead_id) + // public function transformMailContent($lead_id, $page_name) + // { + // helper('excel_util_helper'); + // // $params = $this->request->getGet(); + + // // print_r($params); die; + // // $lead_id = $params['lead_id']; + // // $file_type = $params['file_type']; //rfq or qcr + // // $recipient_type = $params['recipient_type']; //insurer or client or internal or placement + // // $recipient_mail = $params['recipient_mail']; // - only primary key of contacts + // // $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null; + + // // if ($recipient_type == 'insurer' && empty($recipient_mail)) { + // // return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200); + // // } + + // //gather lead info + // $lead_data = $this->leadsModel + // ->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email') + // ->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left') + // ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left') + // ->where('leads.id', $lead_id) + // ->first(); + + // // dd($lead_data); + + // if($lead_data){ + + // $recipient_data = ['name' => "Team"]; + // // $original_message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

© Nhance India Pvt Ltd. All rights reserved.

'; + // $original_message = `Dear Sir, + + // Greetings From Nhance India! + + // Please find attached the RFQ for {{POLICY_TYPE}} policy pertaining to {{RECIPIENT_NAME}} + // Kindly request you to share the competitive quotes at the earliest + // In case of any query, Please feel free to contact us. + // Thank You !`; + + // $message = $original_message; + // $message = str_replace("{{RECIPIENT_NAME}}", $lead_data['client_name'], $message); + // $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'] ?? $lead_data['policy_type'], $message); + // $message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'], $message); + // $message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message); + + // $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message); + // $message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message); + // $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--'; + + // dd($message); + // // return $this->respond(['status' => true, 'code' => 200, 'data' => $message], 200); + // return $message; + + // }else{ + + // // return $this->respond(['status' => false, 'code' => 404, 'message' => "This lead has not data"], 200); + // return ''; + // } + + + + // } + + public function transformMailContent($lead_data, $mail_content, $page_name) { - helper('excel_util_helper'); - // $params = $this->request->getGet(); + $current_year = date('Y'); + $next_year = $current_year + 1; + $policy_year = "$current_year-$next_year"; - // print_r($params); die; - // $lead_id = $params['lead_id']; - // $file_type = $params['file_type']; //rfq or qcr - // $recipient_type = $params['recipient_type']; //insurer or client or internal or placement - // $recipient_mail = $params['recipient_mail']; // - only primary key of contacts - // $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null; + if ($lead_data) { + + // Replacing placeholders with actual values + $message = $mail_content; + $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'] ?? "Valued Client", $message); + $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'] ?? $lead_data['policy_type'] ?? "Insurance Policy", $message); + $message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message); + $message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message); + $message = str_replace("{{POLICY_YEAR}}", $policy_year, $message); - // if ($recipient_type == 'insurer' && empty($recipient_mail)) { - // return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200); - // } - - //gather lead info - $lead_data = $this->leadsModel - ->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email') - ->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left') - ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left') - ->where('leads.id', $lead_id) - ->first(); - - // dd($lead_data); - - if($lead_data){ - - $recipient_data = ['name' => "Team"]; - $original_message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

© Nhance India Pvt Ltd. All rights reserved.

'; - - $message = $original_message; - $message = str_replace("{{RECIPIENT_NAME}}", $recipient_data['name'], $message); - $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message); - $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message); - $message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message); - $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--'; - - // return $this->respond(['status' => true, 'code' => 200, 'data' => $message], 200); return $message; - }else{ - - // return $this->respond(['status' => false, 'code' => 404, 'message' => "This lead has not data"], 200); - return ''; + } else { + return ''; // Return empty if no lead data found } - - - } + } diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php index 2b1560e0..2e51f2aa 100644 --- a/app/Models/RFQModel.php +++ b/app/Models/RFQModel.php @@ -77,6 +77,7 @@ class RFQModel extends Model ->where('rfq.lead_id', $lead_id) // ->where('rfq.type', $type) ->where('rfq.is_active', 1) + ->orderBy('rfq.id', 'desc') ->first(); } diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 11dbe2aa..a26313e5 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -58,6 +58,7 @@ left: 0; background-color: #bfe0e2; z-index: 2; + width: 10px; } .suggestion-box { @@ -194,6 +195,14 @@ background-color: #f0f0f0; color: #666; } + + table th.action, + table th.disableborder, + table td.action, + table td.disableborder { + border: none !important; + } + @@ -411,9 +420,9 @@ -
+
- + ">
@@ -508,9 +517,9 @@
-
+
- + " placeholder="Enter Subject">
@@ -3150,9 +3159,9 @@ function appendInput(data) { } html += ` -
+
- + '" placeholder="Subject">
`; @@ -3210,9 +3219,9 @@ function appendInput(data) { `; html += ` -
+
- + " type="text" id="mail_subject" class="form-control" placeholder="Subject">
`; @@ -3589,7 +3598,7 @@ function ajaxRequest(formData) { $('#cc').val('').select2({ placeholder : 'select CC Mail' }); - $('#subject').val(''); + // $('#subject').val(''); $('#proposals').val(''); $('#placement_to').val('').select2({ placeholder : 'select To Mail' @@ -3666,7 +3675,7 @@ $('.close').click(function(){ $('#cc').val('').select2({ placeholder : 'select CC Mail' }); - $('#subject').val(''); + // $('#subject').val(''); $('#proposals').val(''); $('#placement_to').val('').select2({ placeholder : 'select To Mail' @@ -4454,7 +4463,7 @@ function jsonToTable(json) { //Premium Calculation child table function populateTable(json) { - console.log(json); + console.log('populateTable json data', json); const table = document.getElementById("rfqTable_for_calc"); const thead = document.createElement("thead"); @@ -4471,7 +4480,7 @@ function populateTable(json) { let randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)'; // Skip unwanted parent headers - if (!["Item Key", "Action"].includes(header.parentHeader)) { + if (!["Item Key"].includes(header.parentHeader)) { // console.log(header.parentHeader); // Create the parent header @@ -4486,7 +4495,12 @@ function populateTable(json) { th.classList.add('sticky'); } - if(header.parentHeader !== 'Particulars' && header.parentHeader !== 'Sno'){ + if (header.parentHeader === "Action") { + th.classList.add('readonly-select'); + th.textContent = " "; + } + + if(header.parentHeader !== 'Particulars' && header.parentHeader !== 'Sno' && header.parentHeader !== "Action"){ th.style.backgroundColor = randomColor; } // Calculate colspan based on the number of subheaders @@ -4520,7 +4534,12 @@ function populateTable(json) { subTh.classList.add('sticky'); } - if(header.parentHeader != "Particulars" && header.parentHeader !== 'Sno'){ + if (header.parentHeader === "Action") { + subTh.classList.add('readonly-select'); + subTh.textContent = " "; + } + + if(header.parentHeader != "Particulars" && header.parentHeader !== 'Sno' && header.parentHeader !== "Action"){ subTh.style.backgroundColor = randomColor; } @@ -4567,7 +4586,7 @@ function populateTable(json) { // Create a td for each subheader json.table_data.headers.forEach((header, headerIndexForCalc) => { - if (!["Item Key", "Sno", "Particulars", "Action"].includes(header.parentHeader)) { + if (!["Item Key", "Sno", "Particulars"].includes(header.parentHeader)) { header.subHeaders.forEach((value, index) => { // if(value != '-'){ @@ -4581,6 +4600,13 @@ function populateTable(json) { td.setAttribute("contenteditable", "true"); } + if(header.parentHeader == "Action"){ + td.setAttribute("contenteditable", false); + td.classList.add('action'); + td.classList.add('disableborder'); + td.classList.add('readonly-select'); + } + td.classList.add( 'editablecolumnsforcalc', label.toLowerCase().replace(/\s+/g, '').replace(/[%₹()]/g, '') @@ -4595,6 +4621,7 @@ function populateTable(json) { } // td.id = `${label.toLowerCase()}`; + console.log('child table', header.parentHeader); td.textContent = json.premium_data?.data?.[header.parentHeader]?.[value]?.[label] || ""; tr.appendChild(td); // } From 917f0b4769afcf4c5c1f28cfe42d3f76e36adb73 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 14 Feb 2025 16:48:14 +0530 Subject: [PATCH 08/61] FIX_POLICY_LONG_NAME : RV --- app/Controllers/EmployeeRestController.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0b26b442..40e85cd0 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2502,7 +2502,7 @@ class EmployeeRestController extends AdminController function getEmployeeActiveOrInactivePolicy() { if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; } - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url, policy_type.long_name as policy_long_name') ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') @@ -2555,13 +2555,15 @@ class EmployeeRestController extends AdminController $data['network_hospitals_url'] = $ClientPolicyValue['network_hospitals_url']; $data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']); $data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']); + $data['heading'] = $ClientPolicyValue['policy_long_name']; // $data['policy_terms'] = $terms; - if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else - if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else - if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else - if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else - if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; } + // if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else + // if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else + // if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else + // if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else + // if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }else + // if($ClientPolicyValue['policy_type_id'] == 7){ $data['heading'] = 'Group Term Life Insurance'; } if($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 6 || $ClientPolicyValue['policy_type_id'] == 7) { From 91cc9f812cbaa0af5a65ad63ee22c7004b309bde Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Sat, 15 Feb 2025 11:40:17 +0530 Subject: [PATCH 09/61] FIX_RFQ_MODULE --- app/Controllers/LeadsController.php | 67 +- app/Views/leads_form.php | 2385 ++++++++++++++++----------- app/Views/leads_list.php | 48 +- 3 files changed, 1494 insertions(+), 1006 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index d274600b..ddd29387 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -64,6 +64,9 @@ class LeadsController extends BaseController protected $clientType; protected $leadType; protected $leadsStatus; + protected $claim_type_for_gpa; + protected $cause_of_death; + public function __construct() { @@ -96,6 +99,19 @@ class LeadsController extends BaseController 'completed_with_corrections' => 'Completed with Corrections', 'completed_without_corrections' => 'Completed w/o Corrections', ]; + $this->claim_type_for_gpa = [ + 'accident_death' => 'Accident Death', + 'permanent_total_disablement' => 'Permanent Total Disablement', + 'permanent_partial_disablement' => 'Permanent Partial Disablement', + 'temporary_total_disablement_benefit' => 'Temporary Total Disablement benefit' + ]; + + $this->cause_of_death = [ + 'natural_death' => 'Natural Death', + 'suicide' => 'Suicide', + 'accident' => 'Accident' + ]; + } public function viewLeadsList() @@ -123,7 +139,7 @@ class LeadsController extends BaseController // Fetch insurer and TPA branch data $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); - + // print_r($data['tpa']);die(); // Fetch sales team members who are active in team 5 $data['salse_team'] = $this->userModel ->select('user_profiles.*') @@ -134,7 +150,10 @@ class LeadsController extends BaseController ->findAll(); // dd($data); - + $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); + $data['gpaClaimType'] = $this->claim_type_for_gpa; + $data['causeOfDeath'] = $this->cause_of_death; + // dd($lastFiveYears); if ($this->request->is('get')) { // Fetch leads data $data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); @@ -270,7 +289,25 @@ class LeadsController extends BaseController $last_3_years_claims = null; if($value != 2){ - $last_3_years_claims = $data['finyear']; + $last_3_years_claims = []; + $finyear = json_decode($data['finyear']); + + foreach ($finyear as $year){ + $received_policy_type = ($year->finyear[0]->policy_type); + if ($value == $received_policy_type){ + array_push($last_3_years_claims,$year); + }else{ + continue; + } + // print_r($last_3_years_claims); + + // $last_3_years_claims = json_encode($last_3_years_claims); + } + $last_3_years_claims = json_encode($last_3_years_claims); + // print_r($last_3_years_claims); + // die(); + + // $last_3_years_claims = $data['finyear']; } $processedData[] = [ @@ -338,7 +375,7 @@ class LeadsController extends BaseController 'notes' => $data['notes'] ?? null, ]; } - + // print_r($processedData);die(); return $processedData; } @@ -2103,4 +2140,26 @@ class LeadsController extends BaseController } + function getLastFiveFinancialYears() { + $currentYear = date('Y'); + $currentMonth = date('m'); + + // In India, the financial year starts from April (04) + if ($currentMonth < 4) { + $currentYear--; // Adjust year if it's Jan-Mar + } + + $financialYears = []; + + for ($i = 0; $i < 5; $i++) { + $startYear = $currentYear - $i - 1; + $endYear = $currentYear - $i; + $financialYears[] = "$startYear-$endYear"; + } + + return $financialYears; + } + + + } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index fe5079b7..0587df3e 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1,38 +1,41 @@ @@ -82,11 +85,11 @@
@@ -103,11 +106,11 @@
@@ -117,11 +120,11 @@
@@ -233,11 +236,11 @@ @@ -247,16 +250,16 @@ @@ -280,242 +283,316 @@ \ No newline at end of file diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 9c6c8390..261083b4 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -161,28 +161,29 @@ table.dataTable tbody td { @@ -320,6 +332,7 @@ $(document).ready(function() { var insurerId = 'id; ?>'; var transactionTypeValue = $('input[name="transactionMode"]:checked').val(); var subType = ""; + var record_date = $('#record_date').val(); if(amount == ""){ toastr.warning('Amount field is required') @@ -372,7 +385,8 @@ $(document).ready(function() { transaction_type: transactionType, sub_type_id: subType, // Include sub_type_id client_id: clientId, - insurer_id: insurerId + insurer_id: insurerId, + record_date : record_date }, success: function(response) { // Handle success response From 392362fb0d5c814653d1f61faa2d82187dcc9054 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Sat, 15 Feb 2025 17:49:38 +0530 Subject: [PATCH 11/61] FEAT_EMP_HISTORY_SRI --- app/Config/Routes.php | 1 + app/Controllers/EmployeeController.php | 17 ++++ app/Views/employee_data_list.php | 135 +++++++++++++++++++++++++ 3 files changed, 153 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b3c5c7a4..f6311b6d 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -161,6 +161,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate"); $routes->get('test_members_list', 'EmployeeController::test_members_list'); + $routes->post('get_emp_history','EmployeeController::getEmpHistory'); }); $routes->group("/master", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 09092020..b27a0dae 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -25,6 +25,7 @@ use App\Models\InsurerExcelExportTemplateModel; use App\Models\InsurerModel; use App\Models\ClientDepositModel; use App\Models\PolicyPremium2Model; +use App\Models\AuditHistoryModel; use App\Controllers\Jobs; @@ -64,6 +65,7 @@ class EmployeeController extends AdminController protected $insurerModel; protected $cashDepositModel; protected $PolicyPremium2Model; + protected $auditHistory; public function __construct() { @@ -84,6 +86,7 @@ class EmployeeController extends AdminController $this->insurerModel = new InsurerModel(); $this->cashDepositModel = new ClientDepositModel(); $this->PolicyPremium2Model = new PolicyPremium2Model(); + $this->auditHistory = new AuditHistoryModel(); } public function list() @@ -2725,4 +2728,18 @@ class EmployeeController extends AdminController } } + public function getEmpHistory(){ + + $emp_id = $this->request->getPost('emp_id'); + + $data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->findAll(); + + $emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id']; + $data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll(); + + return $this->respond(['status' => true, 'data' => $data],200); + + + } + } diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 93fc893d..1f26c391 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -46,6 +46,38 @@ + +
@@ -154,6 +186,8 @@ ) { ?> Edit + Employee History + @@ -270,6 +304,20 @@
+ + + + From 0b7198a2854fdf51cc6edd5bddff5e92584798ee Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 17 Feb 2025 09:10:20 +0530 Subject: [PATCH 12/61] CHANGE_CLAIMS_MODULE_CHANGES : RV --- app/Controllers/TicketController.php | 159 +++++++++++++++++++++++++-- app/Models/TicketMasterModel.php | 8 +- app/Views/ticket_edit_onbording.php | 7 ++ app/Views/ticket_form_gmc.php | 52 ++++++++- app/Views/ticket_form_gpa.php | 56 +++++++++- app/Views/ticket_form_handler.php | 13 +++ 6 files changed, 276 insertions(+), 19 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 599ad4dd..e1302f55 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -33,6 +33,7 @@ class TicketController extends BaseController protected $claimType; protected $claimStatus; protected $placeHolders; + protected $extraFields; protected $clientModel; protected $ticketMasterModel; @@ -73,7 +74,8 @@ class TicketController extends BaseController 1 => "In Person", 2 => "Courier", 3 => "Online Mode - Email", - 4 => "Online Mode - To TPA" + 4 => "Smart Service Desk", + 5 => "Direct to TPA" ]; $this->claimType = [ 1 => [ @@ -111,6 +113,30 @@ class TicketController extends BaseController '((POLICY_TYPE))' => 'policy_type', '((AUTO_QUERY_CONTENT))' => 'auto_query_content', ]; + $this->extraFields = [ + + 3 => ['raised_date'], + 4 => ['raised_date'], + 5 => ['claim_number', 'registration_date'], + 7 => ['query_received_date'], + 8 => ['denial_reason','denial_date'], + 9 => ['approved_amount','approved_date', 'approved_letter'], + 11 => ['utr_details', 'settled_date', 'settle_letter'], + 40 => ['approved_amount','approved_date', 'approved_letter'], + 44 => ['utr_details', 'settled_date', 'settle_letter'], + 30 => ['approved_amount','approved_date', 'approved_letter'], + 34 => ['utr_details', 'settled_date', 'settle_letter'], + 20 => ['approved_amount','approved_date', 'approved_letter'], + 24 => ['utr_details', 'settled_date', 'settle_letter'], + 14 => ['return_remark', 'awb_no_courier_name'], + 48 => ['return_remark', 'awb_no_courier_name'], + 59 => ['return_remark', 'awb_no_courier_name'], + 54 => ['return_remark', 'awb_no_courier_name'], + 13 => ['cancel_remark'], + 47 => ['cancel_remark'], + 53 => ['cancel_remark'], + 58 => ['cancel_remark'], + ]; $this->ticketMasterModel = new TicketMasterModel(); $this->claimStatus = new TicketClaimStatusModel(); @@ -260,7 +286,7 @@ class TicketController extends BaseController return $this->loadLayout('ticket_form_handler', $data); } - public function ticket_form_data($ticket_type) + public function ticket_form_data($ticket_type, $claim_status_id = null) { $this->myLogger->logme('error', "Fetching ticket form data for Ticket Type: $ticket_type"); @@ -294,11 +320,23 @@ class TicketController extends BaseController ->getResultArray(); // Fetch Claim Status - $data['claim_status'] = $this->claimStatus - ->select('*') - ->where(['is_active' => 1, 'ticket_type' => $ticket_type]) - ->get() - ->getResultArray(); + + if(empty($claim_status_id)){ + + if($ticket_type == 2){ + $claim_status_id = 15; + }else if($ticket_type == 3){ + $claim_status_id = 25; + }else if($ticket_type == 4){ + $claim_status_id = 35; + }else{ + $claim_status_id = 1; + } + } + + $data['claim_status'] = $this->transFormClaimStatus($claim_status_id, $ticket_type); + $data['extra_fields'] = $this->getExtraFields($data['claim_status']); + $data['extra_fields_array_for_validate'] = $this->getExtraFields($data['claim_status'], 1); if ($ticket_type == 1) { $data['claim_type'] = $this->claimType[1]; @@ -311,6 +349,73 @@ class TicketController extends BaseController return $data; } + //transform the claim status + public function transFormClaimStatus($claimStatusId, $ticket_type) + { + // Fetch the main claim status by ID + $claimStatusData = $this->claimStatus + ->select('*') + ->where(['is_active' => 1, 'ticket_type' => $ticket_type]) + ->where('id', $claimStatusId) + ->first(); + // dd($claimStatusData); + + // Initialize the filtered claim status array + $filteredClaimStatus = []; + + if (!empty($claimStatusData)) { + // Add the main claim status to the result + $filteredClaimStatus[] = $claimStatusData; + + // Decode the allowed_status JSON field + $filterClaimStatusIds = json_decode($claimStatusData['allowed_status'], true); + + // Fetch additional claim statuses if IDs exist + if (!empty($filterClaimStatusIds) && is_array($filterClaimStatusIds)) { + $additionalClaimStatuses = $this->claimStatus + ->select('*') + ->where(['is_active' => 1, 'ticket_type' => $ticket_type]) + ->whereIn('id', $filterClaimStatusIds) + ->get() + ->getResultArray(); + + // Merge additional claim statuses into the result + $filteredClaimStatus = array_merge($filteredClaimStatus, $additionalClaimStatuses); + } + } + + return $filteredClaimStatus; + } + + public function getExtraFields(array $claimStatus, $nonFilterArray = 0): array + { + $extra_fields = []; + + if($nonFilterArray == 1){ + + foreach ($claimStatus as $value) { + if (isset($this->extraFields[$value['id']])) { + if (!isset($extra_fields[$value['id']])) { + $extra_fields[$value['id']] = []; + } + $extra_fields[$value['id']] = array_merge($extra_fields[$value['id']], $this->extraFields[$value['id']]); + } + } + + }else{ + + foreach ($claimStatus as $value) { + if (isset($this->extraFields[$value['id']])) { + $extra_fields[] = $this->extraFields[$value['id']]; + } + } + + $extra_fields = array_values(array_unique(array_merge(...$extra_fields))); + } + + return $extra_fields; + } + public function view_ticket($ticket_id) { // $ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); @@ -322,7 +427,7 @@ class TicketController extends BaseController $template_data['mail_content'] = $this->replacePlaceholders($template_data['mail_content'], $ticket_data); $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); } - $data = $this->ticket_form_data($ticket_data['ticket_type_id']); + $data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']); $data['ticket_data'] = $ticket_data; $data['reply_data'] = $template_data; $data['placeHolders'] = $this->placeHolders; @@ -430,6 +535,7 @@ class TicketController extends BaseController { $ticket_data = $this->request->getPost(); $ticket_data = $this->formatDateForClaim($ticket_data); + // $ticket_data = $this->getLastMatchedStatus($ticket_data, ); // print_rr($ticket_data); die; if ($ticket_data) { @@ -451,6 +557,7 @@ class TicketController extends BaseController $ticket_id = $this->request->getPost('ticket_master_id'); $ticket_data = $this->request->getPost(); $ticket_data = $this->formatDateForClaim($ticket_data); + $ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data); // print_rr($ticket_data); die; $old_ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); @@ -1242,4 +1349,40 @@ class TicketController extends BaseController $this->myLogger->logme('error', "Head Mail can't be sent because ticket data is empty"); } } + + public function getLastMatchedStatus($incoming_form_values) + { + if (empty($incoming_form_values) || !isset($incoming_form_values['claim_status_id']) || !isset($incoming_form_values['extra_fields_array_for_validate'])) { + return null; + } + + $lastMatchedStatus = $incoming_form_values['claim_status_id']; + + // Use the provided `extra_fields_array_for_validate` from the incoming data + $statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']); + + foreach ($statusMapping as $status => $requiredFields) { + // Ensure requiredFields is an array + if (!is_array($requiredFields)) { + $requiredFields = [$requiredFields]; + } + + // Check if all required fields exist and are not empty in the incoming form values + $allFieldsMatched = true; + foreach ($requiredFields as $field) { + if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) { + $allFieldsMatched = false; + break; + } + } + + // Update the last matched status if all fields are validated + if ($allFieldsMatched) { + $lastMatchedStatus = $status; + } + } + + return $lastMatchedStatus; + } + } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index fbcf696c..5587f943 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -64,7 +64,12 @@ class TicketMasterModel extends Model 'utr_details', 'settle_letter', 'is_head_approved', - ]; + + 'return_remark', + 'cancel_remark', + 'awb_no_courier_name', + + ]; // Callbacks @@ -126,6 +131,7 @@ class TicketMasterModel extends Model and ticket_mail_template.is_active = 1') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) + ->where('ticket_claim_status.is_active', 1) ->first(); return $template_data; diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index df9b3dd8..96064eb9 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -139,6 +139,13 @@ function submitClaimForm(event, form) { event.preventDefault(); + var isValid = $('#ticket_form_data').parsley().validate(); + + if (!isValid) { + toastr.warning('Form validation failed. Please check the required fields.', 'WARNING'); + return false; + } + const formAction = ''; // Show loader diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index f13c436b..c2543ca2 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -20,6 +20,7 @@ +
@@ -269,7 +270,7 @@ value="" name="approved_date">
- @@ -344,13 +361,16 @@ $(document).ready(function() { flatpickr("#approved_date", { dateFormat: "d/m/Y", allowInput: false }); flatpickr("#settled_date", { dateFormat: "d/m/Y", allowInput: false }); - updateClaimStatusDisplay("") + // updateClaimStatusDisplay("") + var extraFields = ; + console.log("extraFields", extraFields); + claimStatusFieldChanges(extraFields); }) function updateClaimStatusDisplay(value) { // Hide all sections first - $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu').hide(); + $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled').hide(); // Show relevant section based on value if (value == 3 || value == 4) { // CDA / INFORMATION REQUIRED @@ -365,11 +385,35 @@ function updateClaimStatusDisplay(value) { $('.approved').show(); } else if (value == 11) { // SETTLED $('.settled').show(); + }else if (value == 13) { // CANCELLED + $('.canceled').show(); + }else if (value == 14) { // RETURNED + $('.returned').show(); } } $('#claim_status_id').on('change', function() { updateClaimStatusDisplay($(this).val()); + // claimStatusFieldChanges() }); +function claimStatusFieldChanges(fields) { + + fields.forEach(function(fieldId) { + var $field = $("#" + fieldId); + + if ($field.length) { + $field.prop('required', true); + + var $parentDiv = $field.closest("div"); + $parentDiv.show(); + + var $label = $parentDiv.find("label[for='" + fieldId + "']"); + if ($label.length && !$label.find(".text-danger").length) { + $label.append(' *'); + } + } + }); +} + \ No newline at end of file diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index d8d7b98d..b076322c 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -30,7 +30,7 @@ - +
@@ -209,7 +209,7 @@ value="" name="approved_date">
-
@@ -285,7 +302,11 @@ $(document).ready(function() { flatpickr("#approved_date", { dateFormat: "d/m/Y", allowInput: false }); flatpickr("#settled_date", { dateFormat: "d/m/Y", allowInput: false }); - updateClaimStatusDisplay("") + // updateClaimStatusDisplay("") + var extraFields = ; + console.log("extraFields", extraFields); + claimStatusFieldChanges(extraFields); + }) @@ -294,18 +315,41 @@ function updateClaimStatusDisplay(value) { console.log('value', value); // Hide all sections first - $('.settled, .approved').hide(); + $('.settled, .approved, .canceled, .returned').hide(); // Show relevant section based on value if (value == 20 || value == 30 || value == 40) { // APPROVED $('.approved').show(); } else if (value == 24 || value == 34 || value == 44) { // SETTLED $('.settled').show(); + }else if (value == 47 || value == 53 || value == 58) { // CANCELLED + $('.canceled').show(); + }else if (value == 48 || value == 54 || value == 59) { // RETURNED + $('.returned').show(); } } $('#claim_status_id').on('change', function() { - updateClaimStatusDisplay($(this).val()); + // updateClaimStatusDisplay($(this).val()); }); +function claimStatusFieldChanges(fields) { + + fields.forEach(function(fieldId) { + var $field = $("#" + fieldId); + + if ($field.length) { + $field.prop('required', true); + + var $parentDiv = $field.closest("div"); + $parentDiv.show(); + + var $label = $parentDiv.find("label[for='" + fieldId + "']"); + if ($label.length && !$label.find(".text-danger").length) { + $label.append(' *'); + } + } + }); +} + \ No newline at end of file diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index e668bde6..2eef1eb5 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -417,6 +417,13 @@ function submitClaimForm(event, form) { event.preventDefault(); + var isValid = $('#ticket_form_data').parsley().validate(); + + if (!isValid) { + toastr.warning('Form validation failed. Please check the required fields.', 'WARNING'); + return false; + } + const formAction = ''; // Show loader @@ -704,6 +711,12 @@ function setMemberData(input) { $(this).prop('selected', true); } }); + + if(tpaNo == ""){ + $('#claim_status_id').val(1) + }else{ + $('#claim_status_id').val(2) + } } $('#employee_data_points').on('change', function() { From 4d9a4025c3de92fa91e5c63a11fc68bebe8b23db Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 17 Feb 2025 09:20:43 +0530 Subject: [PATCH 13/61] FIX_CHATBOT_MAIL_AND_CANCEL_IN_FORM --- .../Chatbot/medicalClaimFormConversations.php | 6 +++++- app/Controllers/Chatbot/vehicleFormConversation.php | 11 ++++++++--- app/Helpers/ChatbotHelper.php | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Controllers/Chatbot/medicalClaimFormConversations.php b/app/Controllers/Chatbot/medicalClaimFormConversations.php index d0d21e7e..da6bf3c5 100644 --- a/app/Controllers/Chatbot/medicalClaimFormConversations.php +++ b/app/Controllers/Chatbot/medicalClaimFormConversations.php @@ -246,7 +246,8 @@ class medicalClaimFormConversations extends Conversation $question = Question::create("Confirm all details:") ->addButtons([ Button::create("✅ Confirm")->value("confirm"), - Button::create("❌ Start Over")->value("restart"), + Button::create("🔁 Start Over")->value("restart"), + Button::create("❌ Cancel")->value('cancel') ]); $this->ask($question, function ($answer) use ($finalSummary) { @@ -271,6 +272,9 @@ class medicalClaimFormConversations extends Conversation ]); $this->run(); break; + case "cancel": + $this->bot->startConversation(new MainMenuConversation()); + break; default: $this->say("Invalid selection. Please choose an option."); $this->showSummary(); diff --git a/app/Controllers/Chatbot/vehicleFormConversation.php b/app/Controllers/Chatbot/vehicleFormConversation.php index 1595ae52..3bcf39fd 100644 --- a/app/Controllers/Chatbot/vehicleFormConversation.php +++ b/app/Controllers/Chatbot/vehicleFormConversation.php @@ -180,7 +180,8 @@ class vehicleFormConversation extends Conversation $question = Question::create("Confim your Details:") ->addButtons([ Button::create("✅ Confirm")->value("confirm"), - Button::create("❌ No")->value("no"), + Button::create("🔁 Start Over")->value("restart"), + Button::create("❌ Cancel")->value('cancel') ]); $this->bot->ask($question, function ($answer) use($vehicle_info) { $path = $this->bot->userStorage()->get('path'); @@ -201,8 +202,12 @@ class vehicleFormConversation extends Conversation $this->say("There was a problem while requesting for a quotation please try again later."); } break; - case "no": - $this->askVehicleName(); + case "restart": + $this->bot->startConversation(new vehicleFormConversation()); + break; + case "cancel": + $this->say("Redirecting you to main menu..."); + $this->bot->startConversation(new MainMenuConversation()); break; default: $this->say("Invalid selection. Please choose an option."); diff --git a/app/Helpers/ChatbotHelper.php b/app/Helpers/ChatbotHelper.php index 08fcbb83..e1f213d3 100644 --- a/app/Helpers/ChatbotHelper.php +++ b/app/Helpers/ChatbotHelper.php @@ -201,7 +201,7 @@ class ChatbotHelper $message = SELF::quotationRequestMailTemplate($data); $common = ['mail_type'=>'request_quotation_bot']; - $email_id = 'no-reply-otp@nhanceindia.in'; + $email_id = getenv('email.enquiryMail'); $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]); $res = json_decode($res); From 9568260f650c6b1054ad8734ee378f9fb98b6a98 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 17 Feb 2025 15:49:37 +0530 Subject: [PATCH 14/61] FIX_TICKET_MASTER_MAIL --- app/Controllers/EmployeeController.php | 31 ++++++++++++++++- app/Models/TicketMasterModel.php | 13 ++++++- app/Views/employee_data_list.php | 42 +++++++++++++++------- app/Views/notification.php | 48 ++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 14 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b27a0dae..f5289ae0 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -26,6 +26,7 @@ use App\Models\InsurerModel; use App\Models\ClientDepositModel; use App\Models\PolicyPremium2Model; use App\Models\AuditHistoryModel; +use App\Models\UserModel; use App\Controllers\Jobs; @@ -66,6 +67,7 @@ class EmployeeController extends AdminController protected $cashDepositModel; protected $PolicyPremium2Model; protected $auditHistory; + protected $userModel; public function __construct() { @@ -87,6 +89,7 @@ class EmployeeController extends AdminController $this->cashDepositModel = new ClientDepositModel(); $this->PolicyPremium2Model = new PolicyPremium2Model(); $this->auditHistory = new AuditHistoryModel(); + $this->userModel = new userModel(); } public function list() @@ -2732,8 +2735,20 @@ class EmployeeController extends AdminController $emp_id = $this->request->getPost('emp_id'); - $data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->findAll(); + $data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->orderBy('created_at', 'DESC')->findAll(); + foreach ($data['emp_history'] as &$emp_history) { + $emp_history['field_name'] = $this->formatFieldName($emp_history['field_name']); + $user = $emp_history['created_by']; + if ($user != null && $user != ''){ + $userData = $this->userModel->select('first_name, last_name')->where('id', $user)->where('is_active', 1)->first(); + $emp_history['created_by'] = ucwords($userData['first_name'] . ' ' . $userData['last_name']); + }else{ + $emp_history['created_by'] = '-'; + } + } + unset($emp_history); + $emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id']; $data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll(); @@ -2742,4 +2757,18 @@ class EmployeeController extends AdminController } + public function formatFieldName($unformattedString){ + + if (str_contains($unformattedString, '_')) { + $data = str_replace('_', ' ', $unformattedString); + }else{ + $data = $unformattedString; + } + + $format = ucwords($data); + + return $format; + + } + } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 5587f943..4ccaba9c 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -123,12 +123,17 @@ class TicketMasterModel extends Model public function getTemplateDataByTicketID($ticket_id) { $template_data = $this - ->select("ticket_mail_template.*, ticket_master.emp_mail,ticket_master.claim_status_id") + ->select("ticket_mail_template.*, CASE + WHEN employees.email_corporate IS NULL OR employees.email_corporate = '' + THEN ticket_master.emp_mail + ELSE employees.email_corporate + END as emp_mail, ,ticket_master.claim_status_id") ->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1') ->join('ticket_mail_template', ' ticket_claim_status.trigger_type = ticket_mail_template.trigger_type and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type and ticket_mail_template.is_active = 1') + ->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) ->where('ticket_claim_status.is_active', 1) @@ -141,6 +146,11 @@ class TicketMasterModel extends Model { $ticket_data = $this->select(" ticket_master.*, + CASE + WHEN employees.email_corporate IS NULL OR employees.email_corporate = '' + THEN ticket_master.emp_mail + ELSE employees.email_corporate + END as emp_mail, user_profiles.first_name as acm, user_profiles.mobile as acm_mobile, @@ -158,6 +168,7 @@ class TicketMasterModel extends Model ->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left') ->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1','left') ->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left') + ->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) ->first(); diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 1f26c391..9dd0956c 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -310,8 +310,8 @@
@@ -591,10 +591,28 @@ if (charcode >= 48 && charcode <= 57 || charcode == 46) return true; return false; } - function showModal() { - var myModal = new bootstrap.Modal(document.getElementById('emp_history_modal')); - myModal.show(); + var modalInstance; // Store the modal instance globally + +function showModal() { + var myModalEl = document.getElementById('emp_history_modal'); + modalInstance = new bootstrap.Modal(myModalEl, { + backdrop: true, // Ensures the backdrop is shown + keyboard: true // Allows closing with the Escape key + }); + modalInstance.show(); +} + +function closeModal() { + if (modalInstance) { + modalInstance.hide(); // Hide the modal and its backdrop + // Manually remove backdrop if it's still visible + setTimeout(function () { + document.querySelector('.modal-backdrop').classList.remove('show'); + }, 150); // Wait for animation to finish } +} + + function get_emp_history(input, emp_id) { $('.loader').fadeIn(); @@ -671,12 +689,12 @@ }); } -function closeModal(){ - var myModalEl = document.getElementById('emp_history_modal'); - var modalInstance = bootstrap.Modal.getInstance(myModalEl); - if (modalInstance) { - modalInstance.hide(); - } -} +// function closeModal(){ +// var myModalEl = document.getElementById('emp_history_modal'); +// var modalInstance = bootstrap.Modal.getInstance(myModalEl); +// if (modalInstance) { +// modalInstance.hide(); +// } +// } diff --git a/app/Views/notification.php b/app/Views/notification.php index 051d2f98..6b1f8f63 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -1972,4 +1972,52 @@ }); } } +$(document).on('click', '#notification_enable_form_submit', function() { + var formData = []; + console.log($('#hr_mail_id').val()); + + formData.push({name:'client_id', value: $('#general_PrimaryKey').val()}) + formData.push({ name: 'nhance_team_mail_ids', value: $('#nhance_team_mail_ids').val() }); + formData.push({ name: 'hr_mail_id', value: $('#hr_mail_id').val() }); + formData.push({ name: 'mail_domain', value: $('#mail_domain').val() }); + formData.push({ name: 'reply_to', value: $('#reply_to').val() }); + formData.push({ name: 'member_welcome_mail_btn', value: $('#member_welcome_mail_btn').prop('checked') }); + formData.push({ name: 'member_reminder_mail_btn', value: $('#member_reminder_mail_btn').prop('checked') }); + formData.push({ name: 'member_ecard_mail_btn', value: $('#member_ecard_mail_btn').prop('checked') }); + formData.push({ name: 'member_review_and_summary_mail_btn', value: $('#member_review_and_summary_mail_btn').prop('checked') }); + formData.push({ name: 'account_maneger_summary_mail_btn', value: $('#account_maneger_summary_mail_btn').prop('checked') }); + formData.push({ name: 'client_hr_summary_mail_btn', value: $('#client_hr_summary_mail_btn').prop('checked') }); + + var form_action = ''; + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + $.ajax({ + url: form_action, + type: "POST", + data: formData, + dataType: 'json', + success: function(res) + { + console.log(res); + if (res) + { + toastr.success('Update Successfully'); + } + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, + 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); + } + }); +}) + \ No newline at end of file From c2c013f4a16bb3a006c2ba8ba2120818e12b97b8 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 17 Feb 2025 15:50:34 +0530 Subject: [PATCH 15/61] FIX_TICKET_MASTER_MAIL --- app/Models/TicketMasterModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 4ccaba9c..4cb59773 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -133,7 +133,7 @@ class TicketMasterModel extends Model ticket_claim_status.trigger_type = ticket_mail_template.trigger_type and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type and ticket_mail_template.is_active = 1') - ->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1') + ->join('employees','employees.id = ticket_master.emp_id','left') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) ->where('ticket_claim_status.is_active', 1) @@ -168,7 +168,7 @@ class TicketMasterModel extends Model ->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left') ->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1','left') ->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left') - ->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1') + ->join('employees','employees.id = ticket_master.emp_id','left') ->where('ticket_master.id', $ticket_id) ->where('ticket_master.is_active', 1) ->first(); From 34ac39ca26958b65f7cad2f5be27fdf3d7e22018 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 18 Feb 2025 13:42:33 +0530 Subject: [PATCH 16/61] FIX_RFQ_SRI --- app/Controllers/EmployeeController.php | 2 ++ app/Controllers/LeadsController.php | 5 +++++ app/Views/leads_list.php | 7 ++++++- app/Views/notification.php | 2 +- app/Views/view_rfq.php | 6 +++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index f5289ae0..c14c9a77 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2746,6 +2746,8 @@ class EmployeeController extends AdminController }else{ $emp_history['created_by'] = '-'; } + + $emp_history['created_at'] = date("d-m-Y H:i:s", strtotime($emp_history['created_at'])); } unset($emp_history); diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b5f31223..049c5f88 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -236,6 +236,8 @@ class LeadsController extends BaseController // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) { list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]); + + }else{ $insurer_branch_id = 0; $insurer_id = 0; } @@ -1644,6 +1646,7 @@ class LeadsController extends BaseController //get file path to attach $file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer); + log_message('error','File Info'.json_encode($file_info)); if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') { $temp_file_path = $file_info['filePath']; $temp_file_name = $file_info['fileName']; @@ -1657,6 +1660,8 @@ class LeadsController extends BaseController $result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); // print_rr($result); } + }else{ + return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200); } // print_rr($lead_data); // print_rr($file_info); diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 261083b4..0f6c0199 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -127,7 +127,7 @@ table.dataTable tbody td { Edit - + RFQ From 785ac1bfbe9804a55f0a849ccb4bb7e4435f1eae Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 19 Feb 2025 10:54:45 +0530 Subject: [PATCH 17/61] CHANGES_CLAIMS_CHANGES : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 170 +++++++++++++++++- app/Controllers/EmployeeController.php | 16 +- app/Controllers/EmployeeServiceController.php | 4 +- app/Helpers/excel_util_helper.php | 25 +-- app/Models/EmployeePolicyModel.php | 7 +- app/Views/ticket_form_gmc.php | 137 ++++++++++++-- app/Views/ticket_form_gpa.php | 71 +++++++- 8 files changed, 382 insertions(+), 49 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f6311b6d..c5111235 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -30,6 +30,7 @@ $routes->get("updateRemainderDate", "ClientController::updateRemainderDate"); $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->get("sendextraparam", "ClientController::sendextraparam"); $routes->get("updateRenewalData", "ClientController::updateRenewalData"); +$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient"); // $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); // $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); // $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4252cff6..373d8e78 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -660,7 +660,7 @@ class ClientController extends AdminController $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); - // dd($data['insurerName']); + // dd($data); // print_r($data['depositdata'] );die; // Load the view for the new list page; @@ -691,6 +691,7 @@ class ClientController extends AdminController 'client_id' => $this->request->getPost('client_id'), 'client_policy_id' => null, 'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null, + 'cd_ac_pk' => $CD_Account_Number['id'] ?? null, 'endorsement_no' => null, 'insurer_id' => $this->request->getPost('insurer_id'), 'description' => $this->request->getPost('description'), @@ -3988,12 +3989,17 @@ class ClientController extends AdminController public function sendextraparam() { + + // $employeeController = new EmployeeController(); + // $employeeController->truncateFileData('633'); // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $employeeRestController = new EmployeeServiceController(); // $employeeRestController->excelFileDataValidation(['file_id' => 823]); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 823]); + // $employeeRestController->employeesOnboardPreprocess(['file_id' => 835]); + // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); + $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); @@ -4472,6 +4478,59 @@ class ClientController extends AdminController $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; } + kint::dump($successData); + } + + public function updateRenewalDataNotExistingClient() + { + $limit = $this->request->getGet('limit') ?? 10; + $group = $this->request->getGet('group') ?? 2; + $db = db_connect(); + $renewalData = $db->table('old_renewal_data_copy') + ->where('client_id IS NULL') + ->where('is_inserted = 0') + ->where('client_type_id', $group) + // ->limit($limit) + ->get() + ->getResultArray(); + // dd($renewalData); + + $successData = []; + foreach ($renewalData as $key => $value) { + + $client_data = $this->clientModel->where('client_name', $value['insured'])->where('is_active', 1)->first(); + if(!empty($client_data)){ + $branch = $this->clientBranchModel->where('client_id', $client_data['id'] ?? 0)->first(); + $value['branch_id'] = $branch['id'] ?? null; + $value['client_id'] = $client_data['id'] ?? null; + }else{ + $value['client_id'] = $this->prepareClient($value); + if($value['client_type_id'] == 1){ + $value['branch_id'] = $this->prepareClientBranch($value); + } + } + + // Fix vehicle_id key (previously "vehicel_id") + if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { + $value['vehicle_id'] = $this->prepareVehicleData($value); + }else{ + $value['vehicle_id'] = 0; + } + + // Process client policy, policy transaction, and co-share details + $value['client_policy_id'] = $this->prepareClientPolicy($value); + $value['pt_id'] = $this->preparePolicyData($value); + $value['pt_co_id'] = $this->preparePtCoShareDetails($value); + + // Update is_inserted field in DB + $db->table('old_renewal_data_copy') + ->where('id', $value['id']) + ->set(['is_inserted' => 1]) + ->update(); + + $successData[] = ['id' => $value['id'], 'client' => $value['insured'], 'vehicle_id' => $value['vehicle_id']]; + } + kint::dump($successData); } @@ -4481,7 +4540,7 @@ class ClientController extends AdminController 'issuer' => $renewalData['issuer_type_id'] ?? null, 'client_id' => $renewalData['client_id'] ?? null, 'client_branch_id' => $renewalData['branch_id'] ?? 0, - 'vehicle_id' => $renewalData['vehicel_id'] ?? null, + 'vehicle_id' => $renewalData['vehicle_id'] ?? null, 'insurer_id' => $renewalData['insurer_id'] ?? null, 'insurer_branch_id' => $renewalData['insurer_branch_id'], 'tpa_id' => null, @@ -4547,20 +4606,36 @@ class ClientController extends AdminController } private function prepareVehicleData($renewalData) - { + { + $VehicleModel = new VehicleModel(); + + if ($renewalData['client_type_id'] == 1) { + $veh_no = explode(" ", $renewalData['insured'])[0] . "_veh_no"; + } else { + $veh_no = $renewalData['insured'] . "_veh_no"; + } + + $vehicleData = $VehicleModel->where('owner', $renewalData['client_id']) + ->where('is_active', 1) + ->findAll(); + + if (!empty($vehicleData)) { + $increment = count($vehicleData); + $veh_no = $increment . "_" . $veh_no; + } + + $vehicleData = [ - 'vehicle_no' => $renewalData['veh_no'], + 'vehicle_no' => $veh_no, 'type' => null, 'description' => null, 'owner' => $renewalData['client_id'], // client_id - 'branch_id' => $renewalData['client_type_id'] == 1 ? $renewalData['branch_id'] : null, // client_branch_id + 'branch_id' => $renewalData['client_type_id'] == 1 ? $renewalData['branch_id'] : 0, // client_branch_id 'old_owner' => null, 'rc' => null, ]; - // dd($vehicleData); - $VehicleModel = new VehicleModel(); $id = $VehicleModel->insert($vehicleData); return $id; } @@ -4628,7 +4703,7 @@ class ClientController extends AdminController { $client_policy = [ 'client_id' => $renewalData['client_id'], - 'client_branch_id' => $renewalData['branch_id'], + 'client_branch_id' => $renewalData['branch_id'] ?? 0, 'policy_type_id' => $renewalData['policy_type_id'], 'insurer_id' => $renewalData['insurer_id'], 'insurer_branch_id' => $renewalData['insurer_branch_id'], @@ -4659,6 +4734,83 @@ class ClientController extends AdminController $id = $ClientPolicyModel->insert($client_policy); return $id; } + + private function prepareClientBranch($renewalData) + { + $branch_code = "BRANCH001"; + $short_name = explode(" ", $renewalData['insured'])[0]; + $unit = $short_name . " - " . $branch_code; + + $clientBranchData = [ + 'client_id' => $renewalData['client_id'], + 'branch_name' => "Branch 1", + 'branch_code' => $branch_code, + 'city' => null, + 'district' => null, + 'state' => null, + 'pincode' => null, + 'address1' => null, + 'address2' => null, + 'gst' => null, + 'sez' => 0, + 'is_active' => 1, + 'units' => $unit + ]; + + + $ClientBranchModel = new ClientBranchModel(); + $id = $ClientBranchModel->insert($clientBranchData); + return $id; + } + + private function prepareClient($renewalData) + { + + if($renewalData['client_type_id'] == 1){ + $short_name = explode(" ", $renewalData['insured'])[0]; + }else{ + $short_name = $renewalData['insured']; + } + + $clientData = [ + 'client_type' => $renewalData['client_type_id'], + 'entity_type_id' => null, + 'client_name' => $renewalData['insured'], + 'short_name' => $short_name, + 'cost_center' => null, + 'client_code' => null, // Auto-generated + 'pan' => null, + 'gst' => null, + 'address1' => null, + 'address2' => null, + 'city' => null, + 'state' => null, + 'pincode' => null, + 'is_download_btn' => 0, // Assuming a default value if not specified + 'client_logo' => null, + 'created_by' => null, + 'created_at' => null, // Will be set automatically by MySQL + 'updated_by' => null, + 'updated_at' => null, // Will be set automatically by MySQL + 'is_active' => 1, // Default value is 1 + 'common_mails' => null, + 'hr_mails' => null, + 'mail_domain' => null, + 'reply_to' => null, + 'dob' => null, + 'aadhar' => null, + 'reference' => null, + 'phone' => null, + 'email' => null, + 'addon_subheading' => null + ]; + + + + $ClientModel = new ClientModel(); + $id = $ClientModel->insert($clientData); + return $id; + } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b27a0dae..8262fcb7 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -375,7 +375,7 @@ class EmployeeController extends AdminController ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->join('clients', 'clients.id = client_policy.client_id') ->orderBy('batch_files.id', 'desc') - ->limit(100) + ->limit(1000) ->find(); @@ -1298,7 +1298,7 @@ class EmployeeController extends AdminController ->orderBy('id', 'desc') ->first(); - // print_r($file); die; + // dd($cd_tranction, db_connect()->getLastQuery()); if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment' || $file['action'] == 'missed_inception') { @@ -1455,6 +1455,7 @@ class EmployeeController extends AdminController ->get() ->getResult(); + // dd($res); // print_r($this->empEndorsementModel->getLastQuery()); // echo $res[0]->count;die(); @@ -1464,14 +1465,15 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]); $transaction_type = 'Credit'; - $cd_amount = $cd_tranction['amount']; + $cd_amount = 0; - if($file['action'] == 'deletion'){ + if($file['action'] == 'deletion' && $res[0]->count > 0){ + $transaction_type = 'Debit'; //get cd amount for the particular file id to reverse entry to the cash deposite for only deletion $cd_amount_total = $this->employeePolicyModel->getDeletionDataForTruncated($file['id']); $totalSum = array_sum(array_column($cd_amount_total, 'total')); - $cd_amount = $totalSum; + $cd_amount = $totalSum ?? 0; $this->myLogger->logme('error', 'Deletion CD Amount : {data}', ['data' => $cd_amount]); } @@ -1488,7 +1490,7 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'emp_endorsement table updated'); //STEP 2: - if($file['action'] == 'deletion') { + if($file['action'] == 'deletion' && $res[0]->count > 0) { //update the employee policy table reverse the data $this->employeePolicyModel->updateEmployeePolicyTruncateReverse($file_id); $this->myLogger->logme('error', 'employee_polices table updated for deletion'); @@ -1504,7 +1506,7 @@ class EmployeeController extends AdminController $this->myLogger->logme('error', 'files table updated'); - if($cd_tranction && $file['action'] != 'correction'){ + if(!empty($cd_amount) && $file['action'] != 'correction'){ $cd_data = [ 'amount' => $cd_amount, diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index d7674712..fd0c5455 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1647,7 +1647,7 @@ class EmployeeServiceController extends AdminController // echo 'insert emp'; } else - { + { $value['emp_status'] = 'active'; $value['created_by'] = $file['created_by']; $value['client_branch_id'] = $file['client_branch_id']; @@ -2056,6 +2056,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ } $value['family_floater_key'] = $relation; + // dd($value['family_floater_key']); + $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['client_policy_id'] = $file['policy_id']; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 31bb0f1b..a5cd1bda 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -2173,20 +2173,21 @@ if(!function_exists('group_slab_rates_basedon_name')) //this key generating mandantory for display employee info in enrolment app w/o error -if(!function_exists('generate_family_floater_key')) -{ +if (!function_exists('generate_family_floater_key')) { function generate_family_floater_key($relationship) { if (strtolower(trim($relationship)) === 'mother' || strtolower(trim($relationship)) === 'father') { - $relation = 'parent'; - } else if(strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter'){ - $relation = 'child'; - }else if(strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law'){ - $relation = 'parent_in_law'; - }else if(strtolower(trim($relationship)) === 'spouse'){ - $relation = 'spouse'; - }else{ - $relation = 'self'; - } + $relation = 'parent'; + } else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') { + $relation = 'child'; + } else if (strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') { + $relation = 'parent_in_law'; + } else if (strtolower(trim($relationship)) === 'spouse') { + $relation = 'spouse'; + } else { + $relation = 'self'; + } + + return $relation; } } \ No newline at end of file diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 0f030dae..e0e65966 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1682,7 +1682,10 @@ class EmployeePolicyModel extends Model // reverse the employee policy table data for the truncated the deletion file public function updateEmployeePolicyTruncateReverse($file_id) - { + { + log_message('error', 'updateEmployeePolicyTruncateReverse model function called'); + log_message('error', 'FILE ID : {data}', ['data' => $file_id]); + $this->db->query(" UPDATE employee_polices SET @@ -1690,7 +1693,7 @@ class EmployeePolicyModel extends Model status = 'active', date_of_exit = NULL, reason_for_exit = NULL, - claim_status = 0, + claim_status = 0 WHERE id IN ( SELECT pk diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index c2543ca2..f72160f1 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -293,6 +293,7 @@ + \ No newline at end of file From ebd7fe14ce74736c2e44ab46f5495e953ef53557 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 19 Feb 2025 15:40:55 +0530 Subject: [PATCH 18/61] CHANGE_RFQ_CHANGES : RV --- app/Controllers/ClientController.php | 161 +- app/Controllers/EmpDataServiceController.php | 2 +- app/Controllers/LeadsController.php | 7 +- app/Views/policy_gmc_terms.php | 2534 +++++++++--------- app/Views/policy_gpa_terms.php | 1565 ++++++----- 5 files changed, 2333 insertions(+), 1936 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 373d8e78..ad575e27 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3839,6 +3839,8 @@ class ClientController extends AdminController continue; } + // dd($policyTerms); + $is_addon = $data[$i]['is_addon']; $payable_arr = []; @@ -3861,7 +3863,7 @@ class ClientController extends AdminController if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){ // Set default value of copayzonewisecopay to "empty" - $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; + // $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; // add is_payable_employee for the GMC Policy if (isset($policyTerms['age_ratio'])) { @@ -3875,31 +3877,31 @@ class ClientController extends AdminController } } - // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ - if (isset($policyTerms['copayzonewisecopay'])) { + // // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ + // if (isset($policyTerms['copayzonewisecopay'])) { - if(!isset($policyTerms['co_pay_details'])){ + // if(!isset($policyTerms['co_pay_details'])){ - $co_pay_details_value = ""; - if (strtolower($ans) == "nil" || $ans == 0) { - $policyTerms['copayzonewisecopay'] = 0; - $co_pay_details_value = ""; - } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { - $policyTerms['copayzonewisecopay'] = 1; - $co_pay_details_value = $ans; - } + // $co_pay_details_value = ""; + // if (strtolower($ans) == "nil" || $ans == 0) { + // $policyTerms['copayzonewisecopay'] = 0; + // $co_pay_details_value = ""; + // } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { + // $policyTerms['copayzonewisecopay'] = 1; + // $co_pay_details_value = $ans; + // } - $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms)); - $orderedPolicyTerms[] = [ - "key" => "co_pay_details", - "value" => $co_pay_details_value, - "position" => $co_pay_index + 2, - ]; + // $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms)); + // $orderedPolicyTerms[] = [ + // "key" => "co_pay_details", + // "value" => $co_pay_details_value, + // "position" => $co_pay_index + 2, + // ]; - unset($policyTerms['optionalparentalcopay']); + // unset($policyTerms['optionalparentalcopay']); - } - } + // } + // } // Add ailmentcapping and ailmentcappingdata if they exist if (isset($policyTerms['ailmentcapping'])) { @@ -3908,7 +3910,7 @@ class ClientController extends AdminController $orderedPolicyTerms[] = [ "key" => "ailment_capping_details", "value" => "", - "position" => $aliment_index + 3, + "position" => $aliment_index + 2, ]; } } @@ -3942,8 +3944,6 @@ class ClientController extends AdminController } - - foreach ($orderedPolicyTerms as $term) { $position = $term['position']; $key = $term['key']; @@ -3955,8 +3955,117 @@ class ClientController extends AdminController ); } + if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){ + + if (!isset($policyTerms['waiver_of_90_days_waiting_period'])) { + $policyTerms['waiver_of_90_days_waiting_period'] = ""; + } + + if (!isset($policyTerms['waiver_of_other_waiting_periods'])) { + $policyTerms['waiver_of_other_waiting_periods'] = ""; + } + + if (!isset($policyTerms['maternity_benefit'])) { + $policyTerms['maternity_benefit'] = ""; + } + + if (!isset($policyTerms['well_baby_well_mother_expenses'])) { + $policyTerms['well_baby_well_mother_expenses'] = ""; + } + + if (!isset($policyTerms['icu_limit'])) { + $policyTerms['icu_limit'] = ""; + } + + if (!isset($policyTerms['infertility_treatment_coverage'])) { + $policyTerms['infertility_treatment_coverage'] = ""; + } + + if (!isset($policyTerms['mid_term_addition_of_new_born_newly_wedded_spouse'])) { + $policyTerms['mid_term_addition_of_new_born_newly_wedded_spouse'] = ""; + } + + if (!isset($policyTerms['non_admissible_contingency_corporate_buffer'])) { + $policyTerms['non_admissible_contingency_corporate_buffer'] = ""; + } + + if (!isset($policyTerms['terrorism'])) { + $policyTerms['terrorism'] = ""; + } + + if (!isset($policyTerms['widower_cover'])) { + $policyTerms['widower_cover'] = ""; + } + + if (!isset($policyTerms['breavement_cover'])) { + $policyTerms['breavement_cover'] = ""; + } + + if (!isset($policyTerms['enrollment_display_key'])) { + $policyTerms['enrollment_display_key'] = []; + } + + } else if($data[$i]['policy_type_id'] == 1){ + + if (!isset($policyTerms['medical_expenses_medical_extension'])) { + $policyTerms['medical_expenses_medical_extension'] = ""; + } + + if (!isset($policyTerms['opd_treatment_cover'])) { + $policyTerms['opd_treatment_cover'] = ""; + } + + if (!isset($policyTerms['repatriation_of_mortal_remains'])) { + $policyTerms['repatriation_of_mortal_remains'] = ""; + } + + if (!isset($policyTerms['family_transportation_benefits'])) { + $policyTerms['family_transportation_benefits'] = ""; + } + + if (!isset($policyTerms['fractures_dislocation_burns'])) { + $policyTerms['fractures_dislocation_burns'] = ""; + } + + if (!isset($policyTerms['coma'])) { + $policyTerms['coma'] = ""; + } + + if (!isset($policyTerms['travel_expenses_for_medical_treatment'])) { + $policyTerms['travel_expenses_for_medical_treatment'] = ""; + } + + if (!isset($policyTerms['daily_cash_allowance'])) { + $policyTerms['daily_cash_allowance'] = ""; + } + + if (!isset($policyTerms['artifical_limb_and_prosthesis'])) { + $policyTerms['artifical_limb_and_prosthesis'] = ""; + } + + if (!isset($policyTerms['air_ambulance'])) { + $policyTerms['air_ambulance'] = ""; + } + + if (!isset($policyTerms['enrollment_display_key'])) { + $policyTerms['enrollment_display_key'] = []; + } + + } + + foreach ($policyTerms as $key => $term) { + if ($term == "0") { + $policyTerms[$key] = "No"; // Use = for assignment + } elseif ($term == "1") { + $policyTerms[$key] = "Yes"; // Use = for assignment + } + } + + + // dd($policyTerms); // Re-encode the ordered policy terms $updatedPolicyTerms = json_encode($policyTerms); + // dd($updatedPolicyTerms); // dd($orderedPolicyTerms, $updatedPolicyTerms); $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); @@ -3997,9 +4106,9 @@ class ClientController extends AdminController $employeeRestController = new EmployeeServiceController(); // $employeeRestController->excelFileDataValidation(['file_id' => 823]); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 835]); + // $employeeRestController->employeesOnboardPreprocess(['file_id' => 644]); // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); - $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); + // $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 83cdbaf0..76d44b73 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -975,7 +975,7 @@ class EmpDataServiceController extends BaseController $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']) + ->where('id', $policy_details['cd_ac_pk']) ->first(); $cash_balance['balance'] = $balance['opening_bal']; diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 049c5f88..abbc6984 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1642,7 +1642,7 @@ class LeadsController extends BaseController } // dd($lead_data); - $reply_to = $lead_data['created_person_email']; + $reply_to = $lead_data['created_person_email'] ?? ""; //get file path to attach $file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer); @@ -1661,9 +1661,10 @@ class LeadsController extends BaseController // print_rr($result); } }else{ - return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200); + $result = $file_info['filePath']; + // return $this->respond(['status' => 'fail', 'code' => 200, 'messgae' => 'File Not Found'], 200); } - // print_rr($lead_data); + // print_rr($result); die; // print_rr($file_info); // $file_path = WRITEPATH."uploads/excel/sample/correction.xls"; // $file_name = $file_type.'.xlsx'; diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index dd3138d6..93f24a59 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1,71 +1,75 @@