MERGE_CONFILICT : RV
This commit is contained in:
commit
f9eee7c9ac
@ -398,6 +398,7 @@ $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationControlle
|
||||
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
||||
$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
|
||||
$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin");
|
||||
$routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId");
|
||||
|
||||
//HR login api's
|
||||
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
|
||||
@ -452,7 +453,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||
|
||||
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
$routes->get("getFamilyPolicyDetails", "EmployeeRestController::getFamilyPolicyDetails");
|
||||
|
||||
// Ticketing System
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ class ClientController extends AdminController
|
||||
print_rr($attachments);
|
||||
}
|
||||
|
||||
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', $mail_active = 1) //this function for only tsesting some logics not use for business logic
|
||||
{
|
||||
|
||||
$client_policy_ids = $this->employeeModel
|
||||
@ -3708,8 +3708,8 @@ class ClientController extends AdminController
|
||||
|
||||
public function sendextraparam(){
|
||||
|
||||
$employeeRestController = new EmployeeServiceController();
|
||||
$employeeRestController->employeesEnrollmentInsert(['file_id' => 683]);
|
||||
// $employeeRestController = new EmployeeServiceController();
|
||||
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 715]);
|
||||
|
||||
// $dashBoardController = new DashboardController();
|
||||
// $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
|
||||
|
||||
@ -457,8 +457,9 @@ class DashboardController extends AdminController
|
||||
|
||||
// Send the mail notification
|
||||
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
|
||||
// dd($mail_result);
|
||||
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
$reminder_whole_mail[] = $mail_result[0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,7 +550,7 @@ class DashboardController extends AdminController
|
||||
// Send the mail notification
|
||||
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
|
||||
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
$reminder_whole_mail[] = $mail_result[0];
|
||||
}
|
||||
|
||||
}
|
||||
@ -568,14 +569,14 @@ class DashboardController extends AdminController
|
||||
}
|
||||
|
||||
// dd($reminder_whole_mail);
|
||||
// print_rr($reminder_whole_mail); die;
|
||||
|
||||
// Process and queue bulk emails
|
||||
if (!empty($reminder_whole_mail) && count($reminder_whole_mail) > 0) {
|
||||
|
||||
$reminder_whole_mail = array_chunk($reminder_whole_mail, 20);
|
||||
|
||||
foreach ($reminder_whole_mail as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
// $job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
}
|
||||
@ -589,6 +590,8 @@ class DashboardController extends AdminController
|
||||
|
||||
public function sendManualReminder($client_id, $client_branch_id, $client_policy_id = null)
|
||||
{
|
||||
$this->myLogger->logme('error','Log Works');
|
||||
|
||||
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}");
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id, $client_policy_id);
|
||||
@ -598,6 +601,8 @@ class DashboardController extends AdminController
|
||||
|
||||
if ($client_policy_data) {
|
||||
$result = $this->sendRemainderMail($client_policy_data);
|
||||
log_message('error',json_encode($result));
|
||||
$this->myLogger->logme('error',$result);
|
||||
$this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure'));
|
||||
|
||||
if ($result) {
|
||||
@ -624,6 +629,7 @@ class DashboardController extends AdminController
|
||||
{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200);
|
||||
}
|
||||
|
||||
|
||||
$emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id);
|
||||
if(count($emp_data) == 0)
|
||||
|
||||
@ -108,7 +108,7 @@ class EmployeeController extends AdminController
|
||||
emp_name : $filterData['emp_name'] ?? null,
|
||||
status : $filterData['status'] ?? [],
|
||||
);
|
||||
|
||||
log_message('error',json_encode($data['employees']));
|
||||
// Set getData in $data array with the processed $filterData
|
||||
$data['getData'] = $filterData;
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ class EmployeeRestController extends AdminController
|
||||
->where('client_policy_id',$value['policy_details']['client_policy_id'] )
|
||||
->where('employee_id' , $value['temp']['emp_id'] )
|
||||
->where('is_active', 1 )
|
||||
->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
|
||||
->set(array('basic_cover_si' => $value['policy_details']['basic_cover_si'],'premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
|
||||
->update();
|
||||
|
||||
}
|
||||
@ -845,7 +845,7 @@ class EmployeeRestController extends AdminController
|
||||
'basic_pay'=> $extra['11'][$index],
|
||||
'unit'=> isset($extra['12'][$index]) ? $extra['12'][$index] : null,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'date_coverage' => $extra['13'][$index]
|
||||
'date_coverage' => $extra['13'][$index] != "" && $extra['13'][$index] != null ? change_date_format($extra['13'][$index],'d-M-Y','Y-m-d') : null
|
||||
|
||||
];
|
||||
$basic_cover_si_value = null;
|
||||
@ -1082,9 +1082,11 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
|
||||
// Construct value for policy type GPA
|
||||
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA" && $this->request->getGet('policy') == 'GPA'){
|
||||
// $getSlabAndGridData['grid_master']['policy_type'] == "GPA"
|
||||
if($array->policy_type_id == 1 && $this->request->getGet('policy') == 'GPA')
|
||||
{
|
||||
|
||||
// Filter employee data where the family_floater_key is 'self'
|
||||
// Filter employee data where the family_floater_key is 'self'
|
||||
$selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self');
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow();
|
||||
|
||||
@ -1119,7 +1121,9 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
// Construct value for policy type GMC
|
||||
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC" && $this->request->getGet('policy') == 'GMC' ){
|
||||
// $getSlabAndGridData['grid_master']['policy_type'] == "GMC"
|
||||
}else if($array->policy_type_id == 2 && $this->request->getGet('policy') == 'GMC' )
|
||||
{
|
||||
|
||||
|
||||
|
||||
@ -1493,6 +1497,9 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($array as $key => $value) {
|
||||
if ($value > 0 && $key != 'elders_count') {
|
||||
if ($value != 0 && $key === 'childrens') {
|
||||
|
||||
if($value > 2){ $value = 2; }
|
||||
|
||||
for ($i = 1; $i <= $value; $i++) {
|
||||
$result[] = "child" . $i;
|
||||
}
|
||||
@ -1649,6 +1656,7 @@ class EmployeeRestController extends AdminController
|
||||
$responce['OpenForEnrollment'] = $array['open_for_enrollment'];
|
||||
$responce['policy_terms'] = $decodedArray;
|
||||
$responce['policy_type_id'] = $array['policy_type_id'];
|
||||
$responce['is_member_modify_allowed'] = $array['is_member_modify_allowed'];
|
||||
$responce['disclaimer'] = $array['disclaimer'];
|
||||
|
||||
$tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string')
|
||||
@ -1683,6 +1691,10 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy
|
||||
{
|
||||
|
||||
if($this->request->getGet('client_id') == 8) // This changes only for client "sterling"
|
||||
{
|
||||
|
||||
$selfGMC = $this->employeeModel->select('employees.name , employee_polices.basic_cover_si')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id AND client_policy.policy_type_id = 2')
|
||||
@ -1701,6 +1713,9 @@ class EmployeeRestController extends AdminController
|
||||
// To reindex the array to have a proper 0 index
|
||||
$responce['SlabRates'] = array_values($filteredSlabRates);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Map family floaters that already exist in the employee table
|
||||
$familyFloates = $policy_terms->family_floaters;
|
||||
// remove parent and parent-in-law from familyFloaters
|
||||
@ -1721,7 +1736,7 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($addOnEmployeeData as $key => $value) {
|
||||
if ($value['family_floater_key'] === $dependent) {
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
|
||||
if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = $employee_policy->basic_cover_si; }
|
||||
if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; }
|
||||
if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;}
|
||||
if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
|
||||
|
||||
@ -1820,8 +1835,12 @@ class EmployeeRestController extends AdminController
|
||||
$whereArray = [];
|
||||
foreach ( $decodedArray->family_floaters as $key => $value) {
|
||||
if($value != 0){
|
||||
if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
|
||||
array_push($whereArray,$text);
|
||||
if($key == 'parents'){ $text = ["parent"]; }
|
||||
else if($key == 'childrens'){ $text = ["child"]; }
|
||||
else if($key == 'parents-in-law'){ $text = ["parent_in_law"];}
|
||||
else if($key ==='either-parents-pil') { $text = ["parent", "parent_in_law"];}
|
||||
else{ $text = [$key]; }
|
||||
$whereArray = array_merge($whereArray, $text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1838,7 +1857,7 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($BasePolicyEmployeeData as $key => $value) {
|
||||
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
|
||||
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
|
||||
if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; }
|
||||
if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
|
||||
if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
|
||||
$temp3['is_value_exist'] = true;
|
||||
@ -1870,8 +1889,12 @@ class EmployeeRestController extends AdminController
|
||||
$whereArray = [];
|
||||
foreach ( $decodedArray->family_floaters as $key => $value) {
|
||||
if($value != 0){
|
||||
if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
|
||||
array_push($whereArray,$text);
|
||||
if($key == 'parents'){ $text = ["parent"]; }
|
||||
else if($key == 'childrens'){ $text = ["child"]; }
|
||||
else if($key == 'parents-in-law'){ $text = ["parent_in_law"];}
|
||||
else if($key ==='either-parents-pil') { $text = ["parent", "parent_in_law"];}
|
||||
else{ $text = [$key]; }
|
||||
$whereArray = array_merge($whereArray, $text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1887,7 +1910,7 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($BasePolicyEmployeeData as $key => $value) {
|
||||
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
|
||||
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
|
||||
if(isset($employee_policy->basic_cover_si)){ $only_si_value = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; }
|
||||
if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
|
||||
if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
|
||||
$temp3['is_value_exist'] = true;
|
||||
@ -1941,6 +1964,7 @@ class EmployeeRestController extends AdminController
|
||||
$this->employeeModel->where('emp_code', $emp_code )
|
||||
->where('client_id', $client_id )
|
||||
->where('is_active', 1 )
|
||||
->where('emp_status', 'draft' )
|
||||
->set(array('emp_status'=>'enrolled'))
|
||||
->update();
|
||||
|
||||
@ -1962,6 +1986,7 @@ class EmployeeRestController extends AdminController
|
||||
$this->employeePolicyModel->where('client_policy_id', $value )
|
||||
->where('is_active', 1 )
|
||||
->where('employee_id', $empDataValue['id'] )
|
||||
->where('status', 'draft' )
|
||||
->set(array('status'=>'enrolled'))
|
||||
->update();
|
||||
}
|
||||
@ -2257,8 +2282,19 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if($clientPolicy[0]['is_addon'] == 2)//Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 0 )->findAll();
|
||||
|
||||
if($clientPolicy[0]['policy_type_id'] == 4)//GMC-Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 0 )
|
||||
->findAll();
|
||||
}else if($clientPolicy[0]['policy_type_id'] == 5)//GMC-Parent-Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 1 )
|
||||
->findAll();
|
||||
}
|
||||
|
||||
if(count($empData))
|
||||
{
|
||||
foreach ($empData as $key => $value) {
|
||||
@ -2627,6 +2663,62 @@ class EmployeeRestController extends AdminController
|
||||
// log_message('error', $e->getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function getFamilyPolicyDetails()
|
||||
{
|
||||
// Get query parameters
|
||||
$empCode = $this->request->getGet('emp_code');
|
||||
$clientId = $this->request->getGet('client_id');
|
||||
$clientBranchId = $this->request->getGet('client_branch_id');
|
||||
|
||||
if (!$empCode || !$clientId || !$clientBranchId) {
|
||||
return $this->fail("emp_code, client_id, and client_branch_id are required parameters.");
|
||||
}
|
||||
|
||||
// Fetch employee family details
|
||||
$employees = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value')->where([
|
||||
'emp_code' => $empCode,
|
||||
'client_id' => $clientId,
|
||||
'client_branch_id' => $clientBranchId,
|
||||
'is_active' => 1
|
||||
])->findAll();
|
||||
|
||||
if (empty($employees)) {
|
||||
return $this->failNotFound("No employees found for the provided parameters.");
|
||||
}
|
||||
|
||||
// Collect employee IDs
|
||||
$employeeIds = array_column($employees, 'id');
|
||||
|
||||
// Fetch policies related to the employee IDs
|
||||
$policies = $this->employeePolicyModel->whereIn('employee_id', $employeeIds)->where('is_active',1)->findAll();
|
||||
|
||||
if (empty($policies)) {
|
||||
return $this->failNotFound("No policies found for the provided employees.");
|
||||
}
|
||||
|
||||
// Structure the response
|
||||
$result = [];
|
||||
foreach ($policies as $policy) {
|
||||
$policyEmployees = array_filter($employees, function ($emp) use ($policy) {
|
||||
return $emp['id'] === $policy['employee_id'];
|
||||
});
|
||||
|
||||
$result[] = [
|
||||
'policy_id' => $policy['id'],
|
||||
'client_policy_id' => $policy['client_policy_id'],
|
||||
'uhid' => $policy['uhid'],
|
||||
'status' => $policy['status'],
|
||||
'basic_cover_si' => $policy['basic_cover_si'],
|
||||
'date_coverage' => $policy['date_coverage'],
|
||||
'policy_end_date' => $policy['policy_end_date'],
|
||||
'members' => array_values($policyEmployees),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->respond(['family_policies' => $result]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1036,7 +1036,7 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if(($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
|
||||
if((($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
|
||||
{
|
||||
$res = check_self_available_in_family($family,$file['action']);
|
||||
if(!$res['is_self_found'])
|
||||
@ -1049,7 +1049,7 @@ class EmployeeServiceController extends AdminController
|
||||
//check self avaialbe either same policy DB level(i.e.) gMC parents
|
||||
if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon)
|
||||
{
|
||||
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
|
||||
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active','draft','enrolled'],policy_status:['active','draft','enrolled'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
|
||||
// dd($self_details);
|
||||
if(!count($self_details))
|
||||
{
|
||||
@ -1928,297 +1928,202 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
}
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->fileModel->find($file_id);
|
||||
// dd($file);
|
||||
$return = [];
|
||||
if (!isset($file)) {
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH . "/uploads/excel/" . $file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error', ($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
//get excel data
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
|
||||
$columns_to_check = $this->enrollment_excel_columns;
|
||||
$keys = array_keys($columns_to_check);
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'], client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
$emp_emails = [];
|
||||
|
||||
//check is welcome notification enabled
|
||||
$notification = $this->notificationModel->where('client_id', $file['client_id'])->where('template_name', 'member_welcome_mail')->first();
|
||||
// dd($notification);
|
||||
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
|
||||
|
||||
// dd($excel_data);
|
||||
$emp_emails = []; // Initialize an empty array to store employee email.
|
||||
|
||||
foreach ($excel_data as $key => $row) {
|
||||
$is_row_empty = check_row_is_empty_or_null($row);
|
||||
if (!$is_row_empty) {
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
$temp_unit = '';
|
||||
if (empty($row[12])) {
|
||||
$temp_unit = $existing_units[0];
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->fileModel->find($file_id);
|
||||
// dd($file);
|
||||
$return = [];
|
||||
if(!isset($file))
|
||||
{
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3], 'Y-m-d') : null);
|
||||
$value['gender'] = $row[4];
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = convert_string_to_date($row[6], 'Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $temp_unit;
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$value['file_id'] = $file_id;
|
||||
//get excel data
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
|
||||
$columns_to_check = $this->enrollment_excel_columns;
|
||||
$keys = array_keys($columns_to_check);
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
$emp_emails = [];
|
||||
|
||||
//check is welcome notification enabled
|
||||
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
|
||||
// dd($notification);
|
||||
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
|
||||
$policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
|
||||
|
||||
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
|
||||
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
|
||||
$relation = 'parent';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter') {
|
||||
$relation = 'child';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') {
|
||||
$relation = 'parent_in_law';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'spouse') {
|
||||
$relation = 'spouse';
|
||||
} else {
|
||||
$relation = 'self';
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
// dd($policy_details);
|
||||
|
||||
//get policy slab rates
|
||||
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
|
||||
foreach ($excel_data as $key => $row)
|
||||
{
|
||||
$is_row_empty = check_row_is_empty_or_null($row);
|
||||
if(!$is_row_empty)
|
||||
{
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['date_coverage'] = $row[13];
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if ($employee !== null) {
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
|
||||
} else {
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id'])) {
|
||||
$emp_id = $value['id'];
|
||||
} else {
|
||||
$emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
|
||||
if (count($employee_policy)) {
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$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';
|
||||
} else {
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$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';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
// $emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$emp_policy_id = isset($policy_data['id']) ? $policy_data['id'] : $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
|
||||
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
$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);
|
||||
// Kint::dump($emp_emails);
|
||||
// Kint::dump($key.'-'.count($excel_data));
|
||||
// if mail count is 20 send bulk mail and reset emp_emails variable
|
||||
// if (count($emp_emails) == 20 || $key == count($excel_data) ) {
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
|
||||
// // echo 'Mail triggered';
|
||||
// $emp_emails = [];
|
||||
// }
|
||||
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['date_coverage'] = $row[13];
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if ($employee !== null) {
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
|
||||
} else {
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id'])) {
|
||||
$emp_id = $value['id'];
|
||||
} else {
|
||||
$emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
|
||||
if (count($employee_policy)) {
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$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';
|
||||
} else {
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$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';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
$emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
|
||||
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
$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);
|
||||
// Kint::dump($emp_emails);
|
||||
// Kint::dump($key.'-'.count($excel_data));
|
||||
// if mail count is 20 send bulk mail and reset emp_emails variable
|
||||
// if (count($emp_emails) == 20 || $key == count($excel_data)) {
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $emp_emails]);
|
||||
// // echo 'Mail triggered';
|
||||
// $emp_emails = [];
|
||||
// }
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
$temp_unit = '';
|
||||
if(empty($row[12]))
|
||||
{
|
||||
$temp_unit = $existing_units[0];
|
||||
}
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
|
||||
$value['gender'] = $row[4];
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $temp_unit;
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$value['file_id'] = $file_id;
|
||||
$value['is_addon_value'] = $policy_details['policy_type_id'] == 3 ? 1 : 0;
|
||||
|
||||
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
|
||||
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
|
||||
$relation = 'parent';
|
||||
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
|
||||
$relation = 'child';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
|
||||
$relation = 'parent_in_law';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
|
||||
$relation = 'spouse';
|
||||
}else{
|
||||
$relation = 'self';
|
||||
}
|
||||
$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['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if($employee !== null)
|
||||
{
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id']))
|
||||
{ $emp_id = $value['id']; }
|
||||
else { $emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
|
||||
if(count($employee_policy))
|
||||
{
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$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';
|
||||
}
|
||||
else
|
||||
{
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$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';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
$emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
|
||||
{
|
||||
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
|
||||
{
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
$params['common'] = [];
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
}
|
||||
}
|
||||
}// endof if row is empty check
|
||||
} //end of for loop
|
||||
|
||||
|
||||
// for bulk mail queue job push
|
||||
if (!empty($emp_emails) && count($emp_emails) > 0) {
|
||||
|
||||
$emp_emails = array_chunk($emp_emails, 20);
|
||||
|
||||
foreach ($emp_emails as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
} // 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) {
|
||||
|
||||
$emp_emails = array_chunk($emp_emails, 20);
|
||||
|
||||
foreach ($emp_emails as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
|
||||
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
|
||||
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
|
||||
|
||||
$this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
|
||||
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}//end of employeesEnrollmentInsert
|
||||
|
||||
}
|
||||
@ -30,6 +30,8 @@ use App\Models\StateModel;
|
||||
use App\Models\PolicyTypeModel;
|
||||
use App\Models\CDMasterModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\VehicleModel;
|
||||
@ -1574,7 +1576,7 @@ class MasterController extends AdminController
|
||||
$to = $this->request->getPost('to');
|
||||
$subject = $this->request->getPost('subject');
|
||||
$mail_content = $this->request->getPost('content');
|
||||
|
||||
$common = ['mail_type'=>'test_mail_ui'];
|
||||
/*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
|
||||
|
||||
/*****CALLING DIRECLT USING LIB******/
|
||||
@ -1591,7 +1593,7 @@ class MasterController extends AdminController
|
||||
/*****CALLING DIRECLT USING LIB******/
|
||||
|
||||
/*****CALLING VIA MAIL HELPER******/
|
||||
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject, 'message' => $mail_content]);
|
||||
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject,'common'=>$common ,'message' => $mail_content]);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
|
||||
/*****CALLING VIA MAIL HELPER******/
|
||||
|
||||
@ -1623,10 +1625,10 @@ class MasterController extends AdminController
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
|
||||
|
||||
$common = ['mail_type'=>'test_mail_cli'];
|
||||
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments]);
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
echo "Inside the master controller";
|
||||
print_r($res);
|
||||
|
||||
}
|
||||
|
||||
@ -90,23 +90,55 @@ class RestAuthenticationController extends AdminController
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyEmployeeWithEmailId()
|
||||
{
|
||||
try {
|
||||
$email = $this->request->getJSON()->email;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('email', $email)
|
||||
->where('relationship', 'self')
|
||||
->where('emp_status !=', 'truncated')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if ($employeeData) {
|
||||
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
$result = ['user_verification' => false , 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getVerifiedUserData()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
|
||||
if (isset($this->request->getJSON()->login_by_hr))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first();
|
||||
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
@ -217,11 +249,20 @@ class RestAuthenticationController extends AdminController
|
||||
public function saveMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
@ -248,12 +289,20 @@ class RestAuthenticationController extends AdminController
|
||||
public function updateMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$old_mpin = $this->request->getJSON()->old_mpin;
|
||||
$mpin = $this->request->getJSON()->new_mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
@ -280,10 +329,17 @@ class RestAuthenticationController extends AdminController
|
||||
public function verifyMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
if ($employeeData && $mpin == $employeeData["mpin"]) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
@ -315,10 +371,19 @@ class RestAuthenticationController extends AdminController
|
||||
public function checkMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
|
||||
if ($employeeData && $employeeData["mpin"] != null) {
|
||||
|
||||
|
||||
125
app/Helpers/GmailResponseHandler.php
Normal file
125
app/Helpers/GmailResponseHandler.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\GmailSentHistoryModel;
|
||||
use Exception;
|
||||
|
||||
|
||||
class GmailResponseHandler{
|
||||
private $myLogger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function receive_and_distribute_param_to_functions($params)
|
||||
{
|
||||
try{
|
||||
|
||||
$this->store_gmail_response_data($params);
|
||||
$this->gmail_response_logger($params);
|
||||
$this->client_id_flag_setter($params);
|
||||
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
$error = $e->getMessage();
|
||||
echo "An Error Occured" . $error;
|
||||
log_message('error',$error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function store_gmail_response_data($params){
|
||||
// foreach ($params as $key => $value){
|
||||
// $prepare_data = [
|
||||
// $key => $value
|
||||
// ];
|
||||
// }
|
||||
// $data = [
|
||||
// 'email' => isset($params['params']['mail']) ? $params['params']['mail'] : null,
|
||||
// 'bcc' => isset($params['params']['bcc']) ? json_encode($params['params']['bcc']) : null,
|
||||
// 'cc' => isset($params['params']['cc']) ? json_encode($params['params']['cc']) : null,
|
||||
// 'message' => isset($params['params']['message']) ? $params['params']['message'] : null,
|
||||
// 'attachments' => isset($params['params']['attachments']) ? json_encode($params['params']['attachments']) : null,
|
||||
// 'client_id' => isset($params['params']['common']['client_id']) ? $params['params']['common']['client_id'] : null,
|
||||
// 'client_branch_id' => isset($params['params']['common']['client_branch_id']) ? $params['params']['common']['client_branch_id'] : null,
|
||||
// 'client_policy_id' => isset($params['params']['common']['client_policy_id']) ? $params['params']['common']['client_policy_id'] : null,
|
||||
// 'employee_policy_id' => isset($params['params']['common']['employee_policy_id']) ? $params['params']['common']['employee_policy_id'] : null,
|
||||
// 'employee_id' => isset($params['params']['common']['employee_id']) ? $params['params']['common']['employee_id'] : null,
|
||||
// 'mail_type' => isset($params['params']['common']['mail_type']) ? $params['params']['common']['mail_type'] : null,
|
||||
// 'gmail_api_status' => isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null,
|
||||
// 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null
|
||||
// ];
|
||||
// Initialize data array
|
||||
$data = [];
|
||||
// print_r($params['params']['common']);die();
|
||||
if (isset($params['params']['common'])) {
|
||||
foreach ($params['params']['common'] as $key => $value) {
|
||||
$data[$key] = isset($value) ? $value : null;
|
||||
}
|
||||
unset($params['params']['common']);
|
||||
}
|
||||
if (isset($params['params'])){
|
||||
foreach($params['params'] as $key => $value){
|
||||
$arr = ['bcc','cc','attachments'];
|
||||
if(in_array($key,$arr)){
|
||||
$data[$key] = isset($value)?json_encode($value):null;
|
||||
}else{
|
||||
$data[$key] = isset($value)?$value:null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == 1 ){
|
||||
$data['gmail_api_status'] = isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null;
|
||||
$data['gmail_api_id'] = isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null;
|
||||
$data['received_message'] = isset($params['gmail_api']['data']['labelIds']) ? json_encode($params['gmail_api']['data']['labelIds']) : null;
|
||||
|
||||
}
|
||||
elseif(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == false ){
|
||||
$data['gmail_api_status'] = $params['gmail_api']['status'];
|
||||
if(isset($params['gmail_api']['data'])){
|
||||
$data['received_message'] = json_encode($params['gmail_api']['data']);
|
||||
}
|
||||
}
|
||||
|
||||
$gmailModel = new GmailSentHistoryModel();
|
||||
$save_status = $gmailModel->insert($data);
|
||||
}
|
||||
|
||||
public function gmail_response_logger($params)
|
||||
{
|
||||
$this->myLogger->logme('error',json_encode($params));
|
||||
}
|
||||
|
||||
public function client_id_flag_setter($params)
|
||||
{
|
||||
try{
|
||||
if (isset($params['params']['common']['mail_type'])){
|
||||
if($params['params']['common']['mail_type'] == 'member_ecard_mail'){
|
||||
$employeePolicyModel = new EmployeePolicyModel();
|
||||
$update_status = $employeePolicyModel->where('id',$params['params']['common']['employee_policy_id'])->set('ecard_sent_status',1)->update();
|
||||
if($update_status){
|
||||
$this->myLogger->logme('error',"ecard_sent_status updated for ".$params['params']['common']['employee_policy_id']);
|
||||
}else{
|
||||
$this->myLogger->logme('error','ecard_sent_status failed to update');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$error = $e->getMessage();
|
||||
$this->myLogger->logme('error','An Error Occured - '.$error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -11,7 +11,7 @@ use Firebase\JWT\SignatureInvalidException;
|
||||
// use Psr\Http\Message\RequestInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
use Exception;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\LevelContactModel;
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
use App\Models\JobModel;
|
||||
|
||||
|
||||
class MailHelper
|
||||
{
|
||||
public static function send_email_smtp($params)
|
||||
@ -94,7 +93,7 @@ class MailHelper
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
|
||||
|
||||
$common = isset($params['common'])?$params['common']:'';
|
||||
//check BCC mail
|
||||
if (isset($params['bcc'])) {
|
||||
$bcc = $params['bcc'];
|
||||
@ -118,32 +117,42 @@ class MailHelper
|
||||
if(isset($params['reply_to']) && !empty($params['reply_to'])){
|
||||
$reply_to = $params['reply_to'];
|
||||
}
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
|
||||
$res['params'] = $params;
|
||||
try {
|
||||
|
||||
$res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
|
||||
if($res['status'])
|
||||
$res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
if($res['gmail_api']['status'])
|
||||
{
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
|
||||
}
|
||||
else
|
||||
{
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$msg['error'] = $e->getMessage();
|
||||
$msg['params'] = $params;
|
||||
$myLogger->logme('error', "mail sent failed - $msg");
|
||||
$response = $msg;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
// print_r();die;
|
||||
// print_r($mails);die;
|
||||
$model = new JobModel();
|
||||
$start = microtime(true);
|
||||
$runtime= 0;
|
||||
@ -156,7 +165,9 @@ class MailHelper
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return json_encode(['status' => 'failed','code' => 500],500);
|
||||
$error = $th->getMessage();
|
||||
log_message('error',$error);
|
||||
return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1091,25 +1091,25 @@ if (!function_exists('premium_calculation_manager'))
|
||||
//check emp records
|
||||
if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft')
|
||||
{
|
||||
$original_emp_records = get_emp_records_from_audit_history($emp_data['temp']['emp_id']);
|
||||
if(is_array($original_emp_records))
|
||||
{
|
||||
// Kint::dump($original_emp_records);
|
||||
$emp_data = replace_original_data(original_data:$original_emp_records,current_data:$emp_data);
|
||||
// Kint::dump($value);
|
||||
}
|
||||
// $original_emp_records = get_emp_records_from_audit_history($emp_data['temp']['emp_id']);
|
||||
// if(is_array($original_emp_records))
|
||||
// {
|
||||
// // Kint::dump($original_emp_records);
|
||||
// // $emp_data = replace_original_data(original_data:$original_emp_records,current_data:$emp_data);
|
||||
// // Kint::dump($value);
|
||||
// }
|
||||
}
|
||||
|
||||
//check emp policy records
|
||||
if($emp_data['file_id'] == null && $emp_data['temp']['emp_status'] == 'draft' && $emp_data['temp']['policy_status'] == 'draft')
|
||||
{
|
||||
$original_emp_policy_records = get_emp_policy_records_from_audit_history($emp_data['temp']['emp_policy_id']);
|
||||
if(is_array($original_emp_policy_records))
|
||||
{
|
||||
// Kint::dump($original_emp_records);
|
||||
$emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']);
|
||||
// Kint::dump($policy_data);
|
||||
}
|
||||
// $original_emp_policy_records = get_emp_policy_records_from_audit_history($emp_data['temp']['emp_policy_id']);
|
||||
// if(is_array($original_emp_policy_records))
|
||||
// {
|
||||
// // Kint::dump($original_emp_records);
|
||||
// $emp_data['policy_details'] = replace_original_data(original_data:$original_emp_policy_records,current_data:$emp_data['policy_details']);
|
||||
// // Kint::dump($policy_data);
|
||||
// }
|
||||
|
||||
}//end of fetching data from audit history table
|
||||
|
||||
@ -1209,7 +1209,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
|
||||
{
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
|
||||
@ -1232,7 +1232,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
// dd($slab_value);
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
@ -1253,7 +1253,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
|
||||
{
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
|
||||
@ -1273,7 +1273,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
// echo $emp_data['name'];
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
@ -1295,7 +1295,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
|
||||
@ -1317,7 +1317,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && $slab_value['si'] == $employee_received_si && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
// $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
@ -1339,7 +1339,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
|
||||
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
|
||||
@ -1366,7 +1366,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] &&
|
||||
($slab_value['age_from'] <= $max_age && $slab_value['age_to'] >= $max_age) &&
|
||||
(($slab_value['premium_type'] == 1 &&
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ) )
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ) )
|
||||
{
|
||||
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
|
||||
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date'];
|
||||
@ -1391,7 +1391,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
{
|
||||
|
||||
if($slab_value['si'] == $employee_received_si && $slab_value['grade'] == $employee_received_band && $slab_value['unit'] == $emp_data['unit'] && (($slab_value['premium_type'] == 1 &&
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
|
||||
( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] )) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
|
||||
{
|
||||
//calculate premium based on count
|
||||
// echo $emp_data['name'];
|
||||
@ -1420,7 +1420,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$emp_data['policy_details']['basic_cover_si'] = null;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
{
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
|
||||
@ -1445,7 +1445,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
foreach ($temp_slab_rates as $skey => $slab_value)
|
||||
{
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
|
||||
{
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
|
||||
@ -1466,6 +1466,13 @@ if (!function_exists('premium_calculation_manager'))
|
||||
default:
|
||||
$myLogger->logme('error',($emp_data['emp_code'].'-'.$emp_data['name'].' - grid type not found'));
|
||||
}
|
||||
|
||||
//this if condition for premium calculated & premium type 3 (familiy floater but premium calculated every individual implemented later) then remove si amount only for dependents (not self)
|
||||
if($is_match_found && strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 3)
|
||||
{
|
||||
//set dependent si to 0
|
||||
$emp_data['policy_details']['basic_cover_si'] = 0;
|
||||
}
|
||||
if(!$is_match_found)
|
||||
{
|
||||
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
|
||||
|
||||
@ -227,7 +227,6 @@ class sendMailNotification
|
||||
$gst_forself = '';
|
||||
|
||||
// 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']));
|
||||
|
||||
@ -24,9 +24,9 @@ if (!function_exists('generate_uuid')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('change_date_format')) {
|
||||
if (!function_exists('change_date_format2')) {
|
||||
|
||||
function change_date_format($data, $source_format, $output_format)
|
||||
function change_date_format2($data, $source_format, $output_format)
|
||||
{
|
||||
$data = trim($data);
|
||||
// echo $data, $source_format, $output_format;return true;
|
||||
@ -501,3 +501,86 @@ if (!function_exists('isJsonString')) {
|
||||
return (json_last_error() === JSON_ERROR_NONE); // Check if the last JSON error is "no error"
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('isValidDate')) {
|
||||
function isValidDate($date, $format) {
|
||||
$parsed_date = DateTime::createFromFormat($format, $date);
|
||||
return $parsed_date && $parsed_date->format($format) === $date;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('change_date_format'))
|
||||
{
|
||||
|
||||
function change_date_format($date_str, $source_format = null, $output_format = 'Y-m-d') {
|
||||
|
||||
$date_str = trim($date_str);
|
||||
// Allowed date formats
|
||||
$allowed_formats = [
|
||||
// Day Month Year (clear unambiguous formats)
|
||||
'd M Y', // 01 Dec 2024
|
||||
'd-M-Y', // 01-Dec-2024
|
||||
'd/M/Y', // 01/Dec/2024
|
||||
'd.M.Y', // 01.Dec.2024
|
||||
'd,M,Y', // 01,Dec,2024
|
||||
|
||||
// Month Day Year (clear unambiguous formats)
|
||||
'M d Y', // Dec 01 2024
|
||||
'M-d-Y', // Dec-01-2024
|
||||
'M/d/Y', // Dec/01/2024
|
||||
'M.d.Y', // Dec.01.2024
|
||||
'M,d,Y', // Dec,01,2024
|
||||
|
||||
// Year Month Day (clear unambiguous formats)
|
||||
'Y M d', // 2024 Dec 01
|
||||
'Y-M-d', // 2024-Dec-01
|
||||
'Y/M/d', // 2024/Dec/01
|
||||
'Y.M.d', // 2024.Dec.01
|
||||
'Y,M,d', // 2024,Dec,01
|
||||
|
||||
// Year Numeric Month Numeric Day
|
||||
'Y-m-d', // 2024-12-01
|
||||
'Y/m/d', // 2024/12/01
|
||||
'Y.m.d', // 2024.12.01
|
||||
'Y,m,d', // 2024,12,01
|
||||
];
|
||||
|
||||
try {
|
||||
// Case 1: Source and Output formats are provided
|
||||
if ($source_format !== null && $output_format !== null) {
|
||||
$date = DateTime::createFromFormat($source_format, $date_str);
|
||||
if (!$date) {
|
||||
throw new Exception("Invalid date string for source format: $source_format");
|
||||
}
|
||||
return $date->format($output_format);
|
||||
}
|
||||
|
||||
// Case 2: Source format is provided, Output format is null
|
||||
if ($source_format !== null && $output_format === null) {
|
||||
$date = DateTime::createFromFormat($source_format, $date_str);
|
||||
if (!$date) {
|
||||
throw new Exception("Invalid date string for source format: $source_format");
|
||||
}
|
||||
return $date->format('Y-m-d'); // MySQL default format
|
||||
}
|
||||
|
||||
// Case 3: Source format is null, auto-detect format
|
||||
if ($source_format === null) {
|
||||
foreach ($allowed_formats as $format) {
|
||||
if (isValidDate($date_str, $format)) {
|
||||
$date = DateTime::createFromFormat($format, $date_str);
|
||||
return $date->format($output_format); // Default is MySQL format
|
||||
}
|
||||
}
|
||||
// If no format matches, throw an exception
|
||||
$allowed_placeholders = implode(', ', $allowed_formats);
|
||||
throw new Exception("Invalid date string format. Allowed formats: $allowed_placeholders");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return "Error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ class EmployeeModel extends Model
|
||||
{
|
||||
|
||||
return $this->db->table('employee_polices')
|
||||
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
|
||||
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.policy_status', 1)
|
||||
|
||||
@ -33,6 +33,7 @@ class EmployeePolicyModel extends Model
|
||||
"rand_string",
|
||||
"is_active",
|
||||
"claim_status",
|
||||
'ecard_sent_status'
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
@ -125,7 +126,6 @@ class EmployeePolicyModel extends Model
|
||||
->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
|
||||
->orderBy('emp.emp_code', 'ASC')
|
||||
->orderBy('employee_polices.employee_id', 'ASC');
|
||||
|
||||
// Conditionally add where clauses
|
||||
if ($client_id != 0 && !empty($client_id)) {
|
||||
$result->where('emp.client_id', $client_id);
|
||||
@ -194,6 +194,7 @@ class EmployeePolicyModel extends Model
|
||||
$result->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.tpa_id is not null')
|
||||
->where('employee_polices.ecard_sent_status',0)
|
||||
->where('emp.relationship','Self');
|
||||
|
||||
return $result->findAll();
|
||||
|
||||
11
app/Models/GmailSentHistoryModel.php
Normal file
11
app/Models/GmailSentHistoryModel.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class GmailSentHistoryModel extends Model{
|
||||
protected $table = 'gmail_sent_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ["id", "mail", "bcc", "cc", "message", "attachments", "client_id", "client_branch_id", "client_policy_id", "employee_policy_id", "employee_id", "mail_type", "gmail_api_status", "gmail_api_id", "created_by", "created_at", "updated_by", "updated_at", "isactive","received_message"];
|
||||
}
|
||||
56
phpqueue.sh
Executable file
56
phpqueue.sh
Executable file
@ -0,0 +1,56 @@
|
||||
!/bin/bash
|
||||
while true; do
|
||||
echo "Running job at $(date)"
|
||||
/usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
!/bin/bash
|
||||
!/bin/bash
|
||||
|
||||
# Read the Job_Queue variable from the temporary file
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Define the root directory for the project and PID file path
|
||||
#!/bin/bash
|
||||
|
||||
# Define paths
|
||||
# ROOT_DIR=$(dirname "$(realpath "$0")")
|
||||
# JOB_QUEUE_FILE="$ROOT_DIR/job_queue"
|
||||
# PID_FILE="$ROOT_DIR/phpqueue.pid"
|
||||
|
||||
|
||||
# # Check if the script is already running
|
||||
# if [[ -f "$PID_FILE" ]] && kill -0 "$(cat $PID_FILE)" 2>/dev/null; then
|
||||
# echo "phpqueue.sh is already running. Exiting."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Write the current process ID (PID) to the PID file
|
||||
# echo $$ > "$PID_FILE"
|
||||
|
||||
# # Ensure the PID file is removed on script exit
|
||||
# trap "rm -f $PID_FILE" EXIT
|
||||
|
||||
# # Main loop
|
||||
# while true; do
|
||||
# # Check if the Job_Queue file exists
|
||||
# if [[ ! -f "$JOB_QUEUE_FILE" ]]; then
|
||||
# echo "Job Queue file not found."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Read the value of Job_Queue from the file
|
||||
# Job_Queue=$(cat "$JOB_QUEUE_FILE")
|
||||
|
||||
# if [[ "$Job_Queue" -eq 1 ]]; then
|
||||
# /usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
# else
|
||||
# echo "No job to process."
|
||||
# fi
|
||||
|
||||
# # Sleep for 1 second before the next iteration
|
||||
# sleep 1
|
||||
# done
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user