diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4de017b2..a5b7b952 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -27,6 +27,7 @@ $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderM $routes->get("sendextraparam", "ClientController::sendextraparam"); // $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); // $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); +// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); $routes->get("add_image_index", "AppContentManagementController::add_image_index"); @@ -135,6 +136,11 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->get("list/(:any)", "ClientController::listVehicleFiles/$1"); $routes->get("delete/(:any)", "ClientController::deleteVehicleFiles/$1"); }); + + + $routes->group("others", ["filter" => "authMVC"], function ($routes) { + $routes->post("create", "ClientController::createOtherTabContent"); + }); }); $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 71dda843..40f52992 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -181,7 +181,7 @@ class ClientController extends AdminController print_rr($attachments); } - public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 1) //this function for only tsesting some logics not use for business logic + 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 { $client_policy_ids = $this->employeeModel @@ -315,6 +315,8 @@ class ClientController extends AdminController // return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200); } + //-------------------------------------------------------------------------------------------------------- + public function index() { $this->myLogger->logme('error', 'Client list function called'); @@ -2079,6 +2081,11 @@ class ClientController extends AdminController $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") : 0; $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age") ? $this->request->getPost("other_member_max_age") : 0; + $data['is_payable_employee']['self'] = $this->request->getPost("is_payable_employee_for_self") ? 1 : 0; + $data['is_payable_employee']['spouse'] = $this->request->getPost("is_payable_employee_for_spouse") ? 1 : 0; + $data['is_payable_employee']['childern'] = $this->request->getPost("is_payable_employee_for_child") ? 1 : 0; + $data['is_payable_employee']['elders'] = $this->request->getPost("is_payable_employee_for_elders") ? 1 : 0; + // if (!in_array("self", $data['family_floaters'])) { @@ -2309,6 +2316,8 @@ class ClientController extends AdminController $data['totalSumInsured'] = str_replace(',', '', $this->request->getPost("totalSumInsured")); $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age"); $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age"); + $data['is_payable_employee']['self'] = 0; + $data['accidentalDeathBenefit'] = str_replace(',', '', $this->request->getPost("accidentalDeathBenefit")); $data['permanentTotalDisablement'] = str_replace(',', '', $this->request->getPost("permanentTotalDisablement")); $data['permanentPartialDisablement'] = $this->request->getPost("permanentPartialDisablement"); @@ -2892,6 +2901,13 @@ class ClientController extends AdminController $client_policy_id = $this->request->getPost("client_policy_id"); $policy_terms = $this->request->getPost("policy_terms"); + if (!empty($policy_terms)) { + $policy_terms = json_decode($policy_terms, true); + $policy_terms['is_payable_employee']['self'] = 0; + $policy_terms = json_encode($policy_terms); + } + + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); if ($record) { @@ -3602,15 +3618,22 @@ class ClientController extends AdminController dd($result); } + // --------------------------------------------------------------------------------------------------------- + public function updatePolicyTermsKey() { + $client_id = $this->request->getGet('client_id'); - $data = $this->clientPolicyModel + $query = $this->clientPolicyModel ->where("policy_terms IS NOT NULL AND policy_terms <> ''") - ->where('policy_type_id', 2) - ->where('is_active', 1) - ->findAll(); - + ->where('is_active', 1); + + if (!empty($client_id)) { + $query->where('client_id', $client_id); + } + + $data = $query->findAll(); + for ($i = 0; $i < count($data); $i++) { if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) { @@ -3619,49 +3642,110 @@ class ClientController extends AdminController continue; } - // Set default value of copayzonewisecopay to "empty" - $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; + $is_addon = $data[$i]['is_addon']; + + $payable_arr = []; + if (in_array($data[$i]['policy_type_id'], [2,3]) && $is_addon == 1) { + + $payable_arr = [ "self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0, ]; + + } else if ($data[$i]['policy_type_id'] == 3 && $is_addon == 3) { + + $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,]; + + } else if (in_array($data[$i]['policy_type_id'], [4, 5])) { + + $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,]; + } // Initialize an empty array for the ordered policy terms $orderedPolicyTerms = []; - // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ - if (isset($policyTerms['copayzonewisecopay'])) { + if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){ - if(!isset($policyTerms['co_pay_details'])){ + // Set default value of copayzonewisecopay to "empty" + $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; - $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; + // add is_payable_employee for the GMC Policy + if (isset($policyTerms['age_ratio'])) { + if(!isset($policyTerms['is_payable_employee'])){ + $aliment_index = array_search('age_ratio', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "is_payable_employee", + "value" => $payable_arr, + "position" => $aliment_index + 1, + ]; } - - $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms)); - $orderedPolicyTerms[] = [ - "key" => "co_pay_details", - "value" => $co_pay_details_value, - "position" => $co_pay_index + 1, - ]; - - unset($policyTerms['optionalparentalcopay']); - } + + // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ + if (isset($policyTerms['copayzonewisecopay'])) { + + 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_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']); + + } + } + + // Add ailmentcapping and ailmentcappingdata if they exist + if (isset($policyTerms['ailmentcapping'])) { + if(!isset($policyTerms['ailment_capping_details'])){ + $aliment_index = array_search('ailmentcapping', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "ailment_capping_details", + "value" => "", + "position" => $aliment_index + 3, + ]; + } + } + + }else { + + // add is_payable_employee for the GMC Policy + if (isset($policyTerms['age_ratio'])) { + if(!isset($policyTerms['is_payable_employee'])){ + $aliment_index = array_search('age_ratio', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "is_payable_employee", + "value" => [ + "self" => 0, + ], + "position" => $aliment_index + 1, + ]; + } + }else{ + + if(!isset($policyTerms['is_payable_employee'])){ + $orderedPolicyTerms[] = [ + "key" => "is_payable_employee", + "value" => [ + "self" => 0, + ], + "position" => 2, + ]; + } + } + } - // Add ailmentcapping and ailmentcappingdata if they exist_ - if (isset($policyTerms['ailmentcapping'])) { - if(!isset($policyTerms['ailment_capping_details'])){ - $aliment_index = array_search('ailmentcapping', array_keys($policyTerms)); - $orderedPolicyTerms[] = [ - "key" => "ailment_capping_details", - "value" => "", - "position" => $aliment_index + 2, - ]; - } - } + foreach ($orderedPolicyTerms as $term) { $position = $term['position']; @@ -3706,10 +3790,15 @@ class ClientController extends AdminController dd($days); } - public function sendextraparam(){ + public function sendextraparam() + { + // dd($this->request); // $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->employeesEnrollmentInsert(['file_id' => 715]); + // $employeeRestController->employeesEnrollmentInsert(['file_id' => 721]); + + // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); + // $dashBoardController = new DashboardController(); // $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126); @@ -3719,6 +3808,28 @@ class ClientController extends AdminController // $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12); // $ids = array_column($emp_data, 'id'); // $EmpDataServiceController->sendMailForDownloadingECard($ids); + + // $empServiceController = new EmployeeServiceController(); + // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']); } + + // ------------------------------------------------------------------------------------------------------- + + public function createOtherTabContent() + { + $this->myLogger->logme('error', 'Client Others function called'); + $data = $this->request->getPost(); + $data['created_by'] = get_session_userid(); + $client_id = $data['client_id']; + unset($data['client_id']); + + $insert = $this->clientModel->where('id', $client_id)->set($data)->update(); + + if ($insert) { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Client others data updated', 'data' => $data], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to update'], 200); + } + } } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 92bc9d15..e3d10177 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -934,11 +934,13 @@ class EmployeeRestController extends AdminController } } } + $emp_policy_data =[ 'employee_id'=>$emp_id, 'client_policy_id'=>$policy_id, 'status'=> 'draft', 'date_coverage' => $date_coverage, + 'payable_employee' => check_pay_by_employee_or_company($client_policy['policy_terms'], $dataToInsert[$a]['relationship']), 'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null ]; @@ -2065,11 +2067,21 @@ class EmployeeRestController extends AdminController // retun array public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null , $client_branch_id = null)//family level { + // dd($clientPolicyId, $empCode, $default_si, $client_branch_id); helper('excel_util_helper'); - $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId; - $emp_code = $this->request->getVar('emp_code') ?? $empCode; - $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy - $client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id; + + if($this->request){ // + $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId; + $emp_code = $this->request->getVar('emp_code') ?? $empCode; + $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy + $client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id; + }else{ + //Cli and enrollment + $client_policy_id = $clientPolicyId; + $emp_code = $empCode; + $default_si = $default_si;// si amt which choosed in add on policy + $client_branch_id =$client_branch_id; + } // dd($client_policy_id); diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 7d4d22c7..e1f58ee2 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1580,9 +1580,15 @@ class EmployeeServiceController extends AdminController // insert or update in db for inception addition depent addition public function employeesOnboardProcess($params) - { + { + // dd($params); + $familiy_data = $params['familiy_data']; $file = $params['file']; + + $policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first(); + // dd($policy_details); + foreach($familiy_data as $fkey => $value) { if(is_array($value)) @@ -1658,7 +1664,8 @@ class EmployeeServiceController extends AdminController $policy_data['updated_by'] = $file['created_by']; $policy_data['id'] = $employee_policy[0]['id']; $policy_data['status'] = 'active'; - + $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']); + $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; // echo 'insert policy'; } @@ -1668,6 +1675,8 @@ class EmployeeServiceController extends AdminController $policy_data['client_policy_id'] = $file['policy_id']; $policy_data['created_by'] = $file['created_by']; $policy_data['status'] = 'active'; + $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']); + $log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si']; // echo 'update policy'; } @@ -1930,7 +1939,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ public function employeesEnrollmentInsert($params) { - + // dd($this->request); helper('excel_util_helper'); //get file name $file_id = $params['file_id']; @@ -1982,7 +1991,9 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ // dd($policy_details); //get policy slab rates - $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']); + // $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']); + // dd($slab_details); + foreach ($excel_data as $key => $row) { $is_row_empty = check_row_is_empty_or_null($row); @@ -2029,7 +2040,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $value['family_floater_key'] = $relation; $policy_data['basic_cover_si'] = $row[9]; - $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null; + $policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],null,'Y-m-d') : null; $policy_data['client_policy_id'] = $file['policy_id']; $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); @@ -2071,6 +2082,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $policy_data['updated_by'] = $file['created_by']; $policy_data['id'] = $employee_policy[0]['id']; $policy_data['status'] = 'draft'; + $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']); $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; // echo 'insert policy'; @@ -2081,6 +2093,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $policy_data['client_policy_id'] = $file['policy_id']; $policy_data['created_by'] = $file['created_by']; $policy_data['status'] = 'draft'; + $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']); + $log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si']; // echo 'update policy'; } @@ -2089,6 +2103,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $emp_policy_id = $this->employeePolicyModel->getInsertID(); $this->myLogger->logme('error',$log_message); + $employeeRestController = new EmployeeRestController(); + $employeeRestController->updatePremiumAmount($file['policy_id'], $value['emp_code'], $file['client_branch_id']); + + //save email of self for send mail later if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') { @@ -2097,7 +2115,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ $params['dataToInsert'] = $value; //holds employee master data $params['notification'] = $notification; $params['client_data'] = $client_details; - $params['common'] = []; + $params['common'] = [ + 'client_id' => $file['client_id'], + 'client_branch_id' => $file['client_branch_id'], + 'client_policy_id' => $file['policy_id'], + 'employee_policy_id' => $emp_policy_id ?? null, + 'employee_id' => $emp_id, + 'mail_type' => 'member_welcome_mail', + ]; //store email and mail content via helper to send notification $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params); } @@ -2105,6 +2130,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){ }// endof if row is empty check } //end of for loop + // dd($emp_emails); // for bulk mail queue job push if (!empty($emp_emails) && count($emp_emails) > 0) { diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index fdde0e1b..cb87e28f 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -191,7 +191,11 @@ class sendMailNotification // echo '
';
                 // print_r($array_list); die;
 
+               
+
                 foreach ($array_list as $item) {
+
+                    $payable_employee_array = [];
                     
                     if (count($item) != 0) {
 
@@ -211,6 +215,10 @@ class sendMailNotification
                             }
                             //end of getting policy premium data
 
+                            if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
+                                $payable_employee_array[] = $inner_item;
+                            }
+
                             // dd($policy_premium_data);
 
                             $policy_name = $inner_item['policy_name'];
@@ -228,7 +236,7 @@ class sendMailNotification
                             
                             // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
                                 $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
-                                $premium = '₹ ' .format_indian_number(round($inner_item['premium']));
+                                $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
                                 $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
                             // }
                     
@@ -296,6 +304,89 @@ class sendMailNotification
                         $addtional_premium = 0;
                         $gst = 0;
                     }
+
+                    if(count($payable_employee_array) > 0){
+
+                        $table_content .= '

Policy Type :'; + $temp_data = ''; + $is_addon = ''; + + foreach ($payable_employee_array as $inner_item) { + + + //getting policy premium data + $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); + if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + }else{ + $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + } + //end of getting policy premium data + + + $si = ''; + $premium = ''; + $gst_forself = ''; + + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + + $temp_data .= ''; + $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; + $temp_data .= '' . $inner_item['relationship'] . ''; + $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; + $temp_data .= '' . $si . ''; + $temp_data .= '' . $premium . ''; + $temp_data .= '' . $gst_forself . ''; + + $temp_data .= ''; + + $is_addon = $inner_item['is_addon']; + + $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; + $gst = $inner_item['gst'] + $gst; + } + + $policy_name_for_policy_type = $inner_item['policy_name']; + if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; + } + + $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; + $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; + + + $addon_list_array = [ + 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', + 'addtional_premium' => round($addtional_premium), + 'gst' => round($gst) + ]; + $Addon_list[] = $addon_list_array; + + + $temp_data = ''; + $addtional_premium = 0; + $gst = 0; + + } } if (count($Addon_list) > 0) { @@ -337,6 +428,7 @@ class sendMailNotification // $table_content .= '
' . $sum_total_words . '
'; } + // dd($payable_employee_array, $Addon_list); // print_r($table_content); die; $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); @@ -406,6 +498,9 @@ class sendMailNotification $Addon_list = []; foreach ($array_list as $item) { + + $payable_employee_array = []; + if (count($item) != 0) { $table_content .= '

Policy Type :'; $temp_data = ''; @@ -423,6 +518,10 @@ class sendMailNotification } //end of getting policy premium data + if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){ + $payable_employee_array[] = $inner_item; + } + $policy_name = $inner_item['policy_name']; if ($inner_item['relationship'] == 'Self') { @@ -434,11 +533,11 @@ class sendMailNotification $si = ''; $premium = ''; $gst_forself = ''; - if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ + // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); $premium = '₹ ' .format_indian_number(round($inner_item['premium'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - } + // } $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . $emp_code . ''; @@ -504,6 +603,90 @@ class sendMailNotification $addtional_premium = 0; $gst = 0; } + + if(count($payable_employee_array) > 0){ + + $table_content .= '

Policy Type :'; + $temp_data = ''; + $is_addon = ''; + + foreach ($payable_employee_array as $inner_item) { + + + //getting policy premium data + $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); + if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + }else{ + $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + } + //end of getting policy premium data + + + $si = ''; + $premium = ''; + $gst_forself = ''; + + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + + $temp_data .= ''; + $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; + $temp_data .= '' . $inner_item['relationship'] . ''; + $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; + $temp_data .= '' . $si . ''; + $temp_data .= '' . $premium . ''; + $temp_data .= '' . $gst_forself . ''; + + $temp_data .= ''; + + $is_addon = $inner_item['is_addon']; + + $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; + $gst = $inner_item['gst'] + $gst; + } + + $policy_name_for_policy_type = $inner_item['policy_name']; + if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; + } + + $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; + $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; + + + $addon_list_array = [ + 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', + 'addtional_premium' => round($addtional_premium), + 'gst' => round($gst) + ]; + $Addon_list[] = $addon_list_array; + + + $temp_data = ''; + $addtional_premium = 0; + $gst = 0; + + } + } if (count($Addon_list) > 0) { @@ -611,8 +794,11 @@ class sendMailNotification $gst = 0; $array_list = $params['array_list']; $Addon_list = []; - + foreach ($array_list as $item) { + + $payable_employee_array = []; + if (count($item) != 0) { $table_content .= '

Policy Type :'; $temp_data = ''; @@ -630,6 +816,10 @@ class sendMailNotification } //end of getting policy premium data + if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){ + $payable_employee_array[] = $inner_item; + } + $policy_name = $inner_item['policy_name']; if ($inner_item['relationship'] == 'Self') { @@ -644,11 +834,11 @@ class sendMailNotification // dd($policy_premium_data, $client_policy_data, $inner_item); - if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ + // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); $premium = '₹ ' .format_indian_number(round($inner_item['premium'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - } + // } $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . $emp_code . ''; @@ -714,6 +904,89 @@ class sendMailNotification $addtional_premium = 0; $gst = 0; } + + if(count($payable_employee_array) > 0){ + + $table_content .= '

Policy Type :'; + $temp_data = ''; + $is_addon = ''; + + foreach ($payable_employee_array as $inner_item) { + + + //getting policy premium data + $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); + if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){ + $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + }else{ + $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first(); + } + //end of getting policy premium data + + + $si = ''; + $premium = ''; + $gst_forself = ''; + + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + + $temp_data .= ''; + $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; + $temp_data .= '' . $inner_item['relationship'] . ''; + $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; + $temp_data .= '' . $si . ''; + $temp_data .= '' . $premium . ''; + $temp_data .= '' . $gst_forself . ''; + + $temp_data .= ''; + + $is_addon = $inner_item['is_addon']; + + $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium; + $gst = $inner_item['gst'] + $gst; + } + + $policy_name_for_policy_type = $inner_item['policy_name']; + if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){ + $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents'; + } + + $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )

'; + $table_content .= ''; + + // Add text-align: center to the table head + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + $table_content .= ''; + + $table_content .= ''; + $table_content .= ''; + + // Add text-align: center to the table body + $table_content .= '' . $temp_data . ''; + $table_content .= '
NameRelationDate Of BirthSum InsuredPremiumGST
'; + + + $addon_list_array = [ + 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )', + 'addtional_premium' => round($addtional_premium), + 'gst' => round($gst) + ]; + $Addon_list[] = $addon_list_array; + + + $temp_data = ''; + $addtional_premium = 0; + $gst = 0; + + } } if (count($Addon_list) > 0) { diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index ca339500..79523f60 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -404,67 +404,68 @@ if(!function_exists('checkFamilyFloaters')){ } } +if (!function_exists('numberToWords')) { + function numberToWords($number) + { + $words = array( + '0' => 'Zero', + '1' => 'One', + '2' => 'Two', + '3' => 'Three', + '4' => 'Four', + '5' => 'Five', + '6' => 'Six', + '7' => 'Seven', + '8' => 'Eight', + '9' => 'Nine', + '10' => 'Ten', + '11' => 'Eleven', + '12' => 'Twelve', + '13' => 'Thirteen', + '14' => 'Fourteen', + '15' => 'Fifteen', + '16' => 'Sixteen', + '17' => 'Seventeen', + '18' => 'Eighteen', + '19' => 'Nineteen', + '20' => 'Twenty', + '30' => 'Thirty', + '40' => 'Forty', + '50' => 'Fifty', + '60' => 'Sixty', + '70' => 'Seventy', + '80' => 'Eighty', + '90' => 'Ninety' + ); -function numberToWords($number) -{ - $words = array( - '0' => 'Zero', - '1' => 'One', - '2' => 'Two', - '3' => 'Three', - '4' => 'Four', - '5' => 'Five', - '6' => 'Six', - '7' => 'Seven', - '8' => 'Eight', - '9' => 'Nine', - '10' => 'Ten', - '11' => 'Eleven', - '12' => 'Twelve', - '13' => 'Thirteen', - '14' => 'Fourteen', - '15' => 'Fifteen', - '16' => 'Sixteen', - '17' => 'Seventeen', - '18' => 'Eighteen', - '19' => 'Nineteen', - '20' => 'Twenty', - '30' => 'Thirty', - '40' => 'Forty', - '50' => 'Fifty', - '60' => 'Sixty', - '70' => 'Seventy', - '80' => 'Eighty', - '90' => 'Ninety' - ); - - if ($number < 21) { - return $words[$number]; - } - - if ($number < 100) { - $tens = (int)($number / 10) * 10; - $units = $number % 10; - return $words[$tens] . ($units ? ' ' . $words[$units] : ''); - } - - if ($number < 1000) { - $hundreds = (int)($number / 100); - $remainder = $number % 100; - return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : ''); - } - - $levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion'); - - for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) { - if ($number < $unit * 1000) { - $current = (int)($number / $unit); - $remainder = $number % $unit; - return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : ''); + if ($number < 21) { + return $words[$number]; } - } - return $number; // Fallback for numbers beyond the supported range + if ($number < 100) { + $tens = (int)($number / 10) * 10; + $units = $number % 10; + return $words[$tens] . ($units ? ' ' . $words[$units] : ''); + } + + if ($number < 1000) { + $hundreds = (int)($number / 100); + $remainder = $number % 100; + return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : ''); + } + + $levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion'); + + for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) { + if ($number < $unit * 1000) { + $current = (int)($number / $unit); + $remainder = $number % $unit; + return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : ''); + } + } + + return $number; // Fallback for numbers beyond the supported range + } } if (!function_exists('print_rr')) { @@ -493,6 +494,7 @@ if (!function_exists('get_server_details')) { ]; } } + if (!function_exists('isJsonString')) { function isJsonString($input) @@ -509,9 +511,7 @@ if (!function_exists('isValidDate')) { } } - -if (!function_exists('change_date_format')) -{ +if (!function_exists('change_date_format')) { function change_date_format($date_str, $source_format = null, $output_format = 'Y-m-d') { @@ -584,3 +584,80 @@ if (!function_exists('change_date_format')) return null; } } + +// if (!function_exists('check_pay_by_employee_or_company')) +// { + +// function check_pay_by_employee_or_company($is_payable_employee = null, $relationship = null) { + +// $relationship = strtolower(str_replace(" ", "_", $relationship)); + +// $result = 0; + +// if($relationship == 'self'){ + +// $result = $is_payable_employee['self'] == 1 ? 1 : 0; + +// }else if($relationship == 'spouse'){ + +// $result = $is_payable_employee['spouse'] == 1 ? 1 : 0; + +// }else if(in_array($relationship, ['son', 'daughter'])){ + +// $result = $is_payable_employee['childern'] == 1 ? 1 : 0; + +// }else if(in_array($relationship, ['father', 'mother', 'father_in_law', 'mother_in_law'])){ + +// $result = $is_payable_employee['elders'] == 1 ? 1 : 0; + +// } + +// return $result; +// } +// } + +if (!function_exists('check_pay_by_employee_or_company')) { + + function check_pay_by_employee_or_company($policy_terms = null, $relationship = null) + { + + // dd($policy_terms, $relationship); + + if (!$policy_terms || !($policy_terms = json_decode($policy_terms, true))) { + return 0; + } + + // dd($policy_terms, $relationship); + + if (!isset($policy_terms['is_payable_employee'])) { + return 0; + } + + $is_payable_employee = $policy_terms['is_payable_employee']; + + $relationship = strtolower(str_replace(" ", "_", $relationship)); + + // dd($is_payable_employee, $relationship); + + $relationshipMap = [ + 'self' => 'self', + 'spouse' => 'spouse', + 'son' => 'childern', + 'daughter' => 'childern', + 'father' => 'elders', + 'mother' => 'elders', + 'father_in_law' => 'elders', + 'mother_in_law' => 'elders' + ]; + + if (array_key_exists($relationship, $relationshipMap)) { + $key = $relationshipMap[$relationship]; + + return isset($is_payable_employee[$key]) && $is_payable_employee[$key] == 1 ? 1 : 0; + } + + return 0; + } + +} + diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index 2151ec97..1013d0d0 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -39,6 +39,7 @@ class ClientModel extends Model "email", "reply_to", "mail_domain", + "addon_subheading", ]; diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 9fd8fbdb..06c39c7f 100755 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -106,7 +106,7 @@ class EmployeeModel extends Model public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = []) { - $result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon']) + $result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee']) ->join('employee_polices', 'employee_polices.employee_id = employees.id') ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left') diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 6708da05..2eda9d79 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -33,7 +33,8 @@ class EmployeePolicyModel extends Model "rand_string", "is_active", "claim_status", - 'ecard_sent_status' + 'ecard_sent_status', + 'payable_employee', ]; // Callbacks diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 267f3029..814a97cd 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -88,10 +88,16 @@ body { Policies +
+ - diff --git a/app/Views/client_others_tab.php b/app/Views/client_others_tab.php new file mode 100644 index 00000000..e7f0979c --- /dev/null +++ b/app/Views/client_others_tab.php @@ -0,0 +1,81 @@ +
+
+
+
+
+ + +
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ +
+ + + + \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index b7e6c9a8..ff2b1925 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -107,7 +107,7 @@
-
+
@@ -116,9 +116,9 @@
-
+
-
+
@@ -126,16 +126,16 @@
-
+
Yes No
-
+
-
+
@@ -143,12 +143,16 @@ + + + + @@ -162,6 +166,8 @@ + +
Min Age:
Max Age:
Is Payable by employee:
Spouse:
Min Age:
Max Age:
Is Payable by employee:
Children:
Min Age:
Max Age:
Is Payable by employee:
@@ -192,6 +198,8 @@
Elders Count:
Min Age:
Max Age:
+ Is Payable by employee: + @@ -202,7 +210,7 @@
-
+
@@ -406,7 +414,7 @@