Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2024-04-05 18:09:08 +05:30
commit b30e8723b9
24 changed files with 1841 additions and 425 deletions

View File

@ -112,6 +112,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function($routes){
$routes->get("upload", "EmployeeController::employeesUplodWithEvents");
$routes->post("upload", "EmployeeController::employeesUplodWithEvents");
$routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1");
$routes->get("endorsement-list", "EmployeeController::endorsementList");
});
@ -206,6 +207,7 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){
$routes->get("policy-premium", "ClientController::getpolicyGridData/$1");
$routes->get("update-policy-status", "ClientController::updateClientPolicyStatus/$1");
$routes->get("download-excel/(:any)", "EmployeeController::downloadSampleExcelFile/$1");
$routes->get("get-emp-endorsement/(:any)", "EmployeeController::getEmpEndoresmentEntry/$1");
$routes->post("import-export", "EmployeeController::importExport");
});
@ -230,9 +232,6 @@ $routes->group("/api", ["filter" => "authJWT"], function($routes){
$routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/$1");
$routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile");
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->get("relationshipList", "EmployeeRestController::relationshipList");
@ -245,6 +244,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
$routes->get("getClientDetails", "EmployeeRestController::getClientDetails");
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
$routes->get("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -307,6 +307,8 @@ class ClientController extends AdminController
} elseif ($data['is_download_btn']) {
$data['is_download_btn'] = 1;
}
// print_r($data);die;
$update = $this->clientModel->update($id,$data);
@ -1311,7 +1313,7 @@ class ClientController extends AdminController
$termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first();
if(empty($termsData['policy_terms'])){
return $this->respond(['status' => false,'code' => 200,'message' => 'This Policy does not Create Terms'], 200);
return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy terms '], 200);
}
@ -1338,11 +1340,21 @@ class ClientController extends AdminController
if($racRate == 0){
return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy has no Data for Rac Rate'], 200);
return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy premium'], 200);
}
$policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update();
return $this->respond(['status' => true,'code' => 200, 'message' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate], 200);
$json_data ='';
$open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id )->set('open_for_enrollment', 1)->update();
if ($open_for_enrollment) {
$open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id )->find();
$open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment'];
$client_policy_id_value = $client_policy_id;
$json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]);
}
return $this->respond(['status' => true,'code' => 200, 'message' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200);

View File

@ -162,9 +162,17 @@ class EmpDataServiceController extends BaseController
public function generateExcelForCorrection($export_data)
{
$ids = [];
$objects = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data);
// dd($objects);
foreach ($objects as $obj) {
$ids[] = $obj->id;
}
// echo '<pre>';
// print_r($objects); die;
$count = count($objects);
$export_data['count'] = $count;
$this->myLogger->logme('error','Correction export data count : {data}', ['data'=> $count ]);
@ -201,6 +209,14 @@ class EmpDataServiceController extends BaseController
$return = $this->batchFilesAndBatchListEntry($export_data, $objects);
if($return){
foreach ($ids as $key => $id) {
$group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
if ($group_key) {
$this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
}
}
// Set the appropriate headers for Excel file download
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
@ -228,9 +244,15 @@ class EmpDataServiceController extends BaseController
public function generateExcelForSIEnhancement($export_data)
{
$ids = [];
$objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
foreach ($objects as $obj) {
$ids[] = $obj->endorsement_primarykey;
}
// echo '<pre>';
// print_r($ids); die;
// dd($objects);
$count = count($objects);
@ -279,6 +301,13 @@ class EmpDataServiceController extends BaseController
if($value){
$return = $this->batchFilesAndBatchListEntry($export_data, $objects);
if($return){
foreach ($ids as $key => $id) {
$group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
if ($group_key) {
$this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
}
}
// Set the appropriate headers for Excel file download
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
@ -306,8 +335,18 @@ class EmpDataServiceController extends BaseController
public function generateExcelForDeletion($export_data)
{
// dd($export_data['client_id']);
$ids = [];
$objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($export_data);
foreach ($objects as $obj) {
$ids[] = $obj->endorsement_primarykey;
}
// echo '<pre>';
// print_r($ids);
// print_r($objects); die;
$count = count($objects);
$export_data['count'] = $count;
@ -350,6 +389,13 @@ class EmpDataServiceController extends BaseController
if($value){
$return = $this->batchFilesAndBatchListEntry($export_data, $objects);
if( $return){
foreach ($ids as $key => $id) {
$group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
if ($group_key) {
$this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
}
}
// Set the appropriate headers for Excel file download
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
@ -560,7 +606,7 @@ class EmpDataServiceController extends BaseController
// $this->employeePolicyModel->updateCorrectionData($emp_code, $uhid, $endorsement_id);
$queryData = $this->empEndorsementModel->select('emp_endorsement.*')
$queryData = $this->empEndorsementModel->select('emp_endorsement.*, employees.id as emp_id')
->join('employees', 'employees.id = emp_endorsement.pk')
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->where('employees.emp_code', $emp_code)
@ -578,7 +624,11 @@ class EmpDataServiceController extends BaseController
$emp_id = $endorsementData['emp_id'];
$field_name = $endorsementData['field_name'];
$new_value = $endorsementData['new_value'];
$this->empEndorsementModel->where('id', $emp_endoresment_id)->set('endorsement_id', $endorsement_id)->update();
$endoresment_udate_data = [
'endorsement_id' => $endorsement_id,
'status' => 'complete',
];
$this->empEndorsementModel->where('id', $emp_endoresment_id)->set($endoresment_udate_data)->update();
$this->employeeModel->where('id', $emp_id)->set($field_name, $new_value)->update();
}
@ -617,7 +667,7 @@ class EmpDataServiceController extends BaseController
$import_data['created_by'] = get_session_userid();
$import_data['file_name'] = $filename;
$insert = $this->batchFileModel->insert($import_data);
$batch_file_batch_code = $this->batchFileModel->where('id', 2)->first();
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
$batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
$batch_code_for_batch_list['created_by'] = get_session_userid();
@ -725,8 +775,6 @@ class EmpDataServiceController extends BaseController
$this->cashDepositCalculationForSIEnhancement($depositeData);
return 1;
}
@ -801,18 +849,18 @@ class EmpDataServiceController extends BaseController
array_push($employeeIds, $id);
}
$updateData = [
'emp_code' =>$emp_code,
'client_id' =>$client_id,
'client_policy_id' =>$client_policy_id,
'emp_name' =>$emp_name,
'endorsement_id' =>$endorsement_id,
];
// $updateData = [
// 'emp_code' =>$emp_code,
// 'client_id' =>$client_id,
// 'client_policy_id' =>$client_policy_id,
// 'emp_name' =>$emp_name,
// 'endorsement_id' =>$endorsement_id,
// ];
$this->employeePolicyModel->updateEndoresmentIdForDeletion($updateData);
// $this->employeePolicyModel->updateEndoresmentIdForDeletion($updateData);
$deletionDataForEmployee = $this->empEndorsementModel
->select('emp_endorsement.new_value, employees.id')
->select('emp_endorsement.new_value, emp_endorsement.id as ee_id, employees.id')
->join('employees', 'emp_endorsement.emp_code = employees.emp_code')
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->where('emp_endorsement.emp_code', $emp_code)
@ -824,6 +872,13 @@ class EmpDataServiceController extends BaseController
$deletionDataForEmployee['updated_by'] = get_session_userid();
$this->employeeModel->save($deletionDataForEmployee);
$e_Data = [
'endorsement_id'=> $endorsement_id,
'status'=> 'complete',
];
$group_key = $this->empEndorsementModel->select('group_key')->where('id', $deletionDataForEmployee['ee_id'])->first();
$this->empEndorsementModel->where('group_key', $group_key)->set($e_Data)->update();
$fetchData = [
'emp_code'=> $emp_code,
@ -834,11 +889,6 @@ class EmpDataServiceController extends BaseController
$deletionDataForEmployeePolicy = $this->employeePolicyModel->fetchEmpEndorsementData($fetchData);
$deletionDataForEmployeePolicy['updated_by'] = get_session_userid();
$this->employeePolicyModel->save($deletionDataForEmployeePolicy);
// echo '<pre>';
// print_r($deletionDataForEmployeePolicy); die;
$this->employeePolicyModel->save($deletionDataForEmployeePolicy);
// $query = $this->employeePolicyModel->getLastQuery();
// echo $query . "<br>";
@ -918,6 +968,7 @@ class EmpDataServiceController extends BaseController
}
public function cashDepositCalculationForSIEnhancement($arrayData)
{
if (!empty($arrayData)) {
@ -954,13 +1005,14 @@ class EmpDataServiceController extends BaseController
}
}
public function cashDepositCalculationForDeletion($arrayData)
{
// print_r($arrayData);
if (!empty($arrayData)) {
echo '<pre>';
print_r($arrayData); die;
// echo '<pre>';
// print_r($arrayData); die;
$amount = $this->employeePolicyModel->query("
SELECT
SUM(ROUND((employee_polices.premium * DATEDIFF(employee_polices.policy_end_date, employee_polices.date_of_exit)) / 365, 2) +
@ -968,7 +1020,7 @@ class EmpDataServiceController extends BaseController
FROM employee_polices
WHERE id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
print_r($amount);die;
$insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
$description = 'The following amount of ' . $amount->total_sum . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
@ -996,11 +1048,175 @@ class EmpDataServiceController extends BaseController
}
public function getPolicyNameUsingClientPolicyId($client_policy_id){
/**
* Below function retrieves the policy name associated with a given client policy ID.
*
* @param int $client_policy_id The ID of the client policy.
* @return mixed Returns the policy name if found, otherwise null.
*/
public function getPolicyNameUsingClientPolicyId($client_policy_id)
{
return $this->clientPolicyModel->select('policies.name as policy_name')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.id', $client_policy_id)
->first();
}
/**
* Below function converts row data into column data format for SI enhancement.
*
* This function takes an array of data containing information about SI enhancement
* and calculates additional fields such as pro rata premium, GST, and total.
*
* @param array $data The array of data containing SI enhancement information.
* @return array Returns the converted data in column format.
*/
public function convertRowTColumnForSIEnhancement($data)
{
$result = array();
foreach ($data as $obj) {
$pro_rata_premium = round(($obj->difference_premium * $obj->no_of_days / 365), 2);
$gst = round(($pro_rata_premium * 18 / 100), 2);
$total = round(($pro_rata_premium + $gst), 2);
$old_total = round(($obj->old_rata + $obj->old_gst), 2);
$result[] = array(
"field_name" => 'Basic Cover SI',
"old_value" => $obj->old_basic_cover_si,
"new_value" => $obj->new_basic_cover_si
);
$result[] = array(
"field_name" => 'Premium',
"old_value" => $obj->old_si_premium,
"new_value" => $obj->new_si_premium
);
$result[] = array(
"field_name" => 'SI Enhancement Date',
"old_value" => change_date_format($obj->old_date, 'Y-m-d', 'd-M-Y'),
"new_value" => change_date_format($obj->date_of_coverage, 'Y-m-d', 'd-M-Y')
);
$result[] = array(
"field_name" => 'Difference Premium',
"old_value" => ' --- ',
"new_value" => $obj->difference_premium
);
$result[] = array(
"field_name" => 'No of Days',
"old_value" => $obj->old_days,
"new_value" => $obj->no_of_days
);
$result[] = array(
"field_name" => 'Pro Rata Premium',
"old_value" => $obj->old_rata,
"new_value" => $pro_rata_premium
);
$result[] = array(
"field_name" => 'GST(18%)',
"old_value" => $obj->old_gst,
"new_value" => $gst
);
$result[] = array(
"field_name" => 'Total',
"old_value" => $old_total,
"new_value" => $total
);
}
return $result;
}
/**
* Below function converts row data into column data format for deletion records.
*
* This function takes an array of data containing information about deletion records
* and converts it into a column format. It also calculates additional fields such as
* period of non-coverage, premium for non-coverage period, GST, total amount, and
* claim status based on the exist_reason field.
*
* @param array $data The array of data containing deletion records information.
* @return array Returns the converted data in column format.
*/
public function convertRowTColumnForDeletion($data)
{
$result = array();
foreach ($data as $obj) {
$old_total = round(($obj->old_rata + $obj->old_gst), 2);
$result[] = array(
"field_name" => 'Policy Period',
"data" => change_date_format($obj->start_date, 'Y-m-d', 'd-M-Y') . ' - <br> ' . change_date_format($obj->end_date, 'Y-m-d', 'd-M-Y'),
);
$result[] = array(
"field_name" => 'Exit on',
"data" => change_date_format($obj->date_of_leaving, 'Y-m-d', 'd-M-Y'),
);
$result[] = array(
"field_name" => 'Reason',
"data" => $obj->exist_reason,
);
if($obj->exist_reason != 'death'){
$result[] = array(
"field_name" => 'Period of non coverage',
"data" => $obj->no_of_days
);
$result[] = array(
"field_name" => 'Premium for non coverage period',
"data" => $obj->pro_rata_premium
);
$result[] = array(
"field_name" => 'GST(18%)',
"data" => $obj->gst
);
$result[] = array(
"field_name" => 'Total Amount',
"data" => $obj->total
);
$result[] = array(
"field_name" => 'Claim',
"data" => '---',
);
}
}
return $result;
}
// -----------------------------------------------------------------------------------
}

View File

@ -61,10 +61,12 @@ class EmployeeController extends AdminController
{
// $model = new UserModel();
$data = [];
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'expired' => 'Expired'];
if(count($this->request->getGet()))
{
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'],policy_id: $filterData['policy_id']);
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
}
$this->myLogger->logme('error','list called');
@ -451,4 +453,92 @@ class EmployeeController extends AdminController
}
// -------------------------------------------------------------------------------------------
/**
* Below function displays the endorsement list page.
*
* This method retrieves filter data from the request and fetches the endorsement list
* based on the provided filters such as client ID, policy ID, and status.
*/
public function endorsementList()
{
$data = [];
$data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete'=>'Complete'];
if(count($this->request->getGet()))
{
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
// echo "<pre>";
// print_r($data); die;
}
$this->myLogger->logme('error','list called');
$this->loadLayout('endorsement_list',$data);
}
/**
* Beleo function retrieves employee endorsement (emp_endorsement table) data.
*
* This method fetches endorsement data based on the provided ID.
* It determines the type of endorsement action (SI enhancement, deletion, or other),
* formats the data accordingly, and returns it as a response.
*
* @param int|null $id The ID of the endorsement entry to retrieve.
* @return \CodeIgniter\HTTP\Response Returns a JSON response containing the endorsement entry data.
*/
public function getEmpEndoresmentEntry($id = null)
{
// Create instance of EmpDataServiceController
$empDataServiceController = new EmpDataServiceController();
// Check if $id is provided
if ($id) {
// Retrieve group key and actions based on $id
$group_key_actions = $this->empEndorsementModel->select('group_key, actions')->where('id', $id)->first();
$groupedData = $this->empEndorsementModel->where('group_key', $group_key_actions['group_key'])->findAll();
// If group key and actions are found
if ($group_key_actions) {
// Retrieve endorsement data based on actions
switch ($group_key_actions['actions']) {
case 'si':
$data = $this->empEndorsementModel->getDataForEnodrsementListinSIEnhancement($group_key_actions['group_key']);
$formatedData = $empDataServiceController->convertRowTColumnForSIEnhancement($data);
break;
case 'd':
$data = $this->empEndorsementModel->getDataForEnodrsementListinDeletion($group_key_actions['group_key']);
$formatedData = $empDataServiceController->convertRowTColumnForDeletion($data);
break;
default:
$formatedData = $groupedData;
$formatedData[0]['field_name'] = remove_underscore_capitalize_first_letter($formatedData[0]['field_name']);
$formatedData[0]['old_value'] = formatDateOrReturn($formatedData[0]['old_value']);
$formatedData[0]['new_value'] = formatDateOrReturn($formatedData[0]['new_value']);
break;
}
// Return response with data
return $this->respond([
'dataStatus' => true,
'code' => 200,
'data' => $formatedData,
'data2' => $groupedData
], 200);
} else {
// Return response if group key and actions are not found
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
}
} else {
// Return response if $id is not provided
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
}
}
}

View File

@ -145,7 +145,7 @@ class EmployeeRestController extends AdminController
foreach ($data as $item) {
$id = $item->id;
$item->dob = $this->convertDateFormat($item->dob);
$item->dob = $this->convertDateFormatYMD($item->dob);
$employee = $this->employeeModel->update($id, (array)$item);
if ($employee) {
$updatedCount++;
@ -179,7 +179,7 @@ class EmployeeRestController extends AdminController
//update old data
$id = $item->id;
$item->family_floater_key = $this->RelationshipMap($item->relationship);
$item->dob = $this->convertDateFormat($item->dob);
$item->dob = $this->convertDateFormatYMD($item->dob);
$employee = $this->employeeModel->update($id, (array)$item);
if ($employee) {
$Count++;
@ -187,7 +187,7 @@ class EmployeeRestController extends AdminController
}else{
//create new data
$item->family_floater_key = $this->RelationshipMap($item->relationship);
$item->dob = $this->convertDateFormat($item->dob);
$item->dob = $this->convertDateFormatYMD($item->dob);
$employee = $this->employeeModel->insert($item);
if ($employee) {
$Count++;
@ -224,24 +224,32 @@ class EmployeeRestController extends AdminController
}
}
private function convertDateFormat($dateString)
private function convertDateFormatYMD($dateString)
{
// Attempt to create a DateTime object from the provided date string
$dateTime = \DateTime::createFromFormat('d-m-Y', $dateString);
// Check if the conversion was successful and the date string is in the format dd-mm-yyyy
if ($dateTime instanceof \DateTime) {
// Format the date to yyyy-mm-dd
return $dateTime->format('Y-m-d');
} else {
// If the date string is not in the format dd-mm-yyyy, return null
return null;
}
}
private function convertDateFormatDMY($dateString)
{
// Attempt to create a DateTime object from the provided date string
$dateTime = \DateTime::createFromFormat('Y-m-d', $dateString);
if ($dateTime instanceof \DateTime) {
return $dateTime->format('d-m-Y');
} else {
return null;
}
}
public function deleteDependence()
{
try {
print_r($this->rquest);die;
if($this->request->getGet('id'))
{
$delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete();
@ -286,14 +294,23 @@ class EmployeeRestController extends AdminController
public function getClientPolicy()
{
try {
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->findAll();
$result[] = $ClientPolicyData[0];
$result[] = $ClientPolicyData[2];
// You probably meant to check $result, not $data
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->findAll();
$result = [];
foreach ($ClientPolicyData as $key => $value) {
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
if($value['is_addon'] == 1){
$value['type'] = 'Add-On';
}else{
$value['type'] = $getSlabAndGridData['grid_master']['policy_type'];
}
array_push($result,$value);
}
if ($ClientPolicyData) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
@ -308,134 +325,134 @@ class EmployeeRestController extends AdminController
}
public function getEmployeePolicy()
{
try {
$id = $this->request->getGet('id');
$emp_code = $this->request->getGet('emp_code');
// public function getEmployeePolicy()
// {
// try {
// $id = $this->request->getGet('id');
// $emp_code = $this->request->getGet('emp_code');
$keysToRemove = ["removable_keys"];
// $keysToRemove = ["removable_keys"];
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
// $empPolicy = $this->employeeModel->getEmployeePolicy($id);
$empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
if ($empPolicy) {
// $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
// if ($empPolicy) {
$result = [];
foreach ($empPolicy as $array) {
// $result = [];
// foreach ($empPolicy as $array) {
$decodedArray = json_decode($array->Policy_Terms);
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
// $decodedArray = json_decode($array->Policy_Terms);
// $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
$array->Policy_Terms = $refusingData;
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
$array->SlabRates = $getSlabAndGridData['slab_rates'];
$array->GridMaster = $getSlabAndGridData['grid_master'];
// $array->Policy_Terms = $refusingData;
// $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
// $array->SlabRates = $getSlabAndGridData['slab_rates'];
// $array->GridMaster = $getSlabAndGridData['grid_master'];
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
$default_si = $array->Policy_Terms->sumInsured2;
$index = -1;
foreach ($array->SlabRates as $key => $value) {
if ($value['si'] == $default_si) {
$index = $key;
break;
}
}
if ($index >= 0) {
$element =$array->SlabRates[$index];
array_splice($array->SlabRates, $index, 1);
array_unshift($array->SlabRates, $element);
}
// if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
// $default_si = $array->Policy_Terms->sumInsured2;
// $index = -1;
// foreach ($array->SlabRates as $key => $value) {
// if ($value['si'] == $default_si) {
// $index = $key;
// break;
// }
// }
// if ($index >= 0) {
// $element =$array->SlabRates[$index];
// array_splice($array->SlabRates, $index, 1);
// array_unshift($array->SlabRates, $element);
// }
$employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
if($employee_policy){
$gpaSI['family_floater_key'] = 'self';
$gpaSI['label'] = 'Self';
$gpaSI['employee_id'] = $employee_policy->employee_id;
$gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
$gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
$gpaSI['client_policy_id'] = $array->ClientPolicyId;
// $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
// if($employee_policy){
// $gpaSI['family_floater_key'] = 'self';
// $gpaSI['label'] = 'Self';
// $gpaSI['employee_id'] = $employee_policy->employee_id;
// $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
// $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
$array->mapped_family_floaters = $gpaSI;
}else{
$gpaSI['family_floater_key'] = 'self';
$gpaSI['label'] = 'Self';
$gpaSI['employee_id'] = $id;
$gpaSI['basic_cover_si'] = null;
$gpaSI['premium'] = null;
$gpaSI['client_policy_id'] = $array->ClientPolicyId;
// $array->mapped_family_floaters = $gpaSI;
// }else{
// $gpaSI['family_floater_key'] = 'self';
// $gpaSI['label'] = 'Self';
// $gpaSI['employee_id'] = $id;
// $gpaSI['basic_cover_si'] = null;
// $gpaSI['premium'] = null;
// $gpaSI['client_policy_id'] = $array->ClientPolicyId;
$array->mapped_family_floaters = $gpaSI;
}
// $array->mapped_family_floaters = $gpaSI;
// }
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
// }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
// re-arranging order of si
$default_si = $array->Policy_Terms->sum_insured;
// Filter the array using the callback function
$getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
$default_premium = $getPremium[0]['premium'];
// // re-arranging order of si
// $default_si = $array->Policy_Terms->sum_insured;
// // Filter the array using the callback function
// $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
// $default_premium = $getPremium[0]['premium'];
$index = -1;
foreach ($array->SlabRates as $key => $value) {
if ($value['si'] == $default_si) {
$index = $key;
break;
}
}
if ($index >= 0) {
$element =$array->SlabRates[$index];
array_splice($array->SlabRates, $index, 1);
array_unshift($array->SlabRates, $element);
}
// $index = -1;
// foreach ($array->SlabRates as $key => $value) {
// if ($value['si'] == $default_si) {
// $index = $key;
// break;
// }
// }
// if ($index >= 0) {
// $element =$array->SlabRates[$index];
// array_splice($array->SlabRates, $index, 1);
// array_unshift($array->SlabRates, $element);
// }
//map family floates array to employee and dependent
$familyFloates = $array->Policy_Terms->family_floaters;
$data = [];
foreach ($familyFloates as $familyFloatesValue) {
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
if(count($empData)){
foreach ($empData as $key => $value) {
if ($value['family_floater_key'] === $dependent) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
$temp['family_floater_key'] = $familyFloatesValue;
$temp['label'] = $value['relationship'];
$temp['name'] = $value['name'];
$temp['employee_id'] = $value['id'];
$temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
$temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
$temp['client_policy_id'] = $array->ClientPolicyId;
array_push($data,$temp);
unset($empData[$key]);
break;
}
}
}
}
$array->mapped_family_floaters = $data;
// //map family floates array to employee and dependent
// $familyFloates = $array->Policy_Terms->family_floaters;
// $data = [];
// foreach ($familyFloates as $familyFloatesValue) {
// $dependent = preg_replace('/\d/', '', $familyFloatesValue);
// if(count($empData)){
// foreach ($empData as $key => $value) {
// if ($value['family_floater_key'] === $dependent) {
// $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
// $temp['family_floater_key'] = $familyFloatesValue;
// $temp['label'] = $value['relationship'];
// $temp['name'] = $value['name'];
// $temp['employee_id'] = $value['id'];
// $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
// $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
// $temp['client_policy_id'] = $array->ClientPolicyId;
// array_push($data,$temp);
// unset($empData[$key]);
// break;
// }
// }
// }
// }
// $array->mapped_family_floaters = $data;
$temp2=[];
foreach ($array->SlabRates as $key => $value) {
$value['additional_premium'] = $value['premium'] - $default_premium;
array_push($temp2,$value);
}
$array->SlabRates = $temp2;
// $temp2=[];
// foreach ($array->SlabRates as $key => $value) {
// $value['additional_premium'] = $value['premium'] - $default_premium;
// array_push($temp2,$value);
// }
// $array->SlabRates = $temp2;
}
// }
$result[] = $array;
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
// $result[] = $array;
// }
// return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
// }else{
// return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
// }
// } catch (\Exception $e) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
// }
// }
// Get the RelationShip list
@ -451,17 +468,21 @@ class EmployeeRestController extends AdminController
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
->where('client_policy_id', $value->client_policy_id)
->findAll();
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($value->client_policy_id,$value->client_id);
$SlabRatesArray = $getSlabAndGridData['slab_rates'];
$premium = $this->findPremiumAmount($SlabRatesArray, $value->basic_cover_si);
// dd($checkIfExist);
if ($checkIfExist) {
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$value->premium);
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$premium);
}else{
$data['employee_id']= $value->employee_id;
$data['client_policy_id']= $value->client_policy_id;
$data['basic_cover_si']= $value->basic_cover_si;
$data['premium']= $value->premium;
$data['premium']= $premium;
$this->employeePolicyModel->insert($data);
}
@ -473,7 +494,15 @@ class EmployeeRestController extends AdminController
}
}
public function findPremiumAmount($slabArray,$siAmount)
{
foreach ($slabArray as $key => $value) {
if($value['si'] == $siAmount){
return $value['premium'];
break;
}
}
}
public function relationshipList()
{
try {
@ -499,12 +528,17 @@ class EmployeeRestController extends AdminController
$client_id = $this->request->getPost('client_id');
$policy_id = $this->request->getPost('policy_id');
$token = $this->request->headers()['Auth']->getValue();
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
$jwt = $this->request->getHeader('Authorization');
$jwtParts = explode(' ', $jwt);
$token = $jwtParts[1];
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
// get the employee id from token
$employee_id = $decodedPayload['id'];
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first();
if ($client_policy) {
@ -677,6 +711,7 @@ class EmployeeRestController extends AdminController
$basic_cover_si[]= $basic_cover_si_value;
}
}
$count = 0;
for ($a=0; $a <count($dataToInsert) ; $a++)
{
$employee = $this->employeeModel->checkExistingEmployee($dataToInsert[$a]);
@ -753,10 +788,23 @@ class EmployeeRestController extends AdminController
$data['policy_name']=$policy['name'];
$message = view('mail_welcome', $data);
if ($dataToInsert[$a]['relationship'] == 'Self' && $mail != null || $mail != '') {
$count++;
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $message];
}
// print_r($wholeData);
// if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'send_email','payload' => ['mail' => $mail, 'subject' => $subject,'message'=> $message]]);
// }
if($count == 20 || $a == count($dataToInsert)-1){
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
// $wholeData[]= $r;
// Mailhelper::bulk_mail($wholeData);
$wholeData = [];
$count = 0;
}
// print_r($r);//die();
// $jobWorker = new JobWorker();
@ -778,6 +826,397 @@ class EmployeeRestController extends AdminController
}
//-------------------------------------
public function getEmployeePolicy()
{
try {
$id = $this->request->getGet('id');
$emp_code = $this->request->getGet('emp_code');
// This is an array containing keys to be removed from the terms and conditions array
$keysToRemove = ["removable_keys"];
// Retrieve employee policy data by passing the employee primary key
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
// Retrieve employee and dependents data by passing the employee code
$employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('is_addon_value',0)->findAll();
if ($empPolicy) {
$result = [];
foreach ($empPolicy as $array) {
// Reset employee array
$empData = $employeeData;
// Removes specific keys from the decoded array and assigns the result to $refusingData
$decodedArray = json_decode($array->Policy_Terms);
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
$array->Policy_Terms = $refusingData;
// Retrieve slab rate and grid master data by passing the ClientPolicyId and ClientId
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
$array->SlabRates = $getSlabAndGridData['slab_rates'];
$array->GridMaster = $getSlabAndGridData['grid_master'];
// Construct value for policy type GPA
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
// Filter employee data where the family_floater_key is 'self'
$selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self');
$self['is_value_exist'] = true;
$self['data']['family_floater_key'] = 'self';
$self['data']['employee_id'] = $id;
$self['data']['relationship'] = 'Self';
$self['data']['name'] = $selfData[0]['name'];
$self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']);
$self['data']['mobile'] = $selfData[0]['mobile'];
$self['data']['client_policy_id'] = $array->ClientPolicyId;
$array->mapped_family_floaters = $self;
// Return result
if($this->request->getGet('policy') == 'GPA')
{
return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
}
// Construct value for policy type GMC
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
// Map family floaters that already exist in the employee table
$familyFloates = $array->Policy_Terms->family_floaters;
// Generate Notes string based on familyFloates terms
$array->notes = $this->FloterNotesConvertion($familyFloates);
// Convert familyFloaters terms data to plain array
$floters = $this->FloterConvertion($familyFloates);
$data = [];
foreach ($floters as $familyFloatesValue) {
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
if(count($empData)){
foreach ($empData as $key => $value) {
if ($value['family_floater_key'] === $dependent) {
$temp['is_value_exist'] = true;
$temp['data']['family_floater_key'] = $familyFloatesValue;
$temp['data']['employee_id'] = $value['id'];
$temp['data']['relationship'] = $value['relationship'];
$temp['data']['name'] = $value['name'];
$temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
$temp['data']['form_type'] = $dependent;
array_push($data,$temp);
unset($empData[$key]);
$floters = array_diff($floters, [$familyFloatesValue]);
break;
}
}
}
}
// Remove Unwanted floter key from floters array based on either-parents-pil term value
if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
{
$count_parent = 0;
$count_parent_in_law = 0;
foreach ($floters as $value) {
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
}
if($count_parent != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
}
if($count_parent_in_law != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
}
}
// Add family floter buttons placement data for FE validation
if(count($floters)){
foreach ($floters as $familyFloatesValue) {
$temp2['is_value_exist'] = false;
$temp2['data']['family_floater_key'] = $familyFloatesValue;
$temp2['data']['client_policy_id'] = $array->ClientPolicyId;
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
array_push($data,$temp2);
}
}
$array->mapped_family_floaters = $data;
if($this->request->getGet('policy') == 'GMC'){
return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
}
}
$result[] = $array;
}
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
public function FloterConvertion($array){
$result = [];
foreach ($array as $key => $value) {
if ($value > 0) {
if ($value != 0 && $key === 'childrens') {
for ($i = 1; $i <= $value; $i++) {
$result[] = "child" . $i;
}
} else if($value != 0 && $key ==='parents') {
for ($i = 1; $i <= $value; $i++) {
$result[] = "parent" . $i;
}
}else if($value != 0 && $key ==='parents-in-law') {
for ($i = 1; $i <= $value; $i++) {
$result[] = "parent_in_law" . $i;
}
}else if($value != 0 && $key ==='either-parents-pil') {
for ($i = 1; $i <= 2; $i++) {
$result[] = "parent" . $i;
$result[] = "parent_in_law" . $i;
}
}else {
$result[] = $key;
}
}
}
return $result;
}
public function FloterNotesConvertion($array){
$result = 'Can Add Self ';
foreach ($array as $key => $value) {
if ($value > 0) {
if($value != 0 && $key ==='either-parents-pil') {
$result .= ' + Either 2 Parents or 2 Parents in law';
}else if($value != 0 && $key ==='spouse') {
$string = str_replace('-', ' ', $key);
$string = ucwords($string);
$result .= ' + '.$string;
}else if($value != 0 && $key ==='self') {
}else{
$string = str_replace('-', ' ', $key);
$string = ucwords($string);
$result .= ' + '.$value.' '.$string;
}
}
}
return $result;
}
public function getClientDetails()
{
try {
$client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first();
if($client) {
$client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo'];
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
return $this->respond(['status' => 'success','code' => 200,'data' => ['client'=>$client,'client_policy'=>$clientPolicy]], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
public function getAddOnPolicy()
{
try {
$addOnEmployeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))->where('is_addon_value',1)->findAll();
$GMCEmployeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))->where('is_addon_value',0)->findAll();
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
// dd($clientPolicy);
if(count($clientPolicy))
{
$PolicyData = [];
foreach ($clientPolicy as $key => $array) {
$decodedArray = json_decode($array['policy_terms']);
$policy_terms = $decodedArray;
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array['id'],$array['client_id']);
if($array['is_addon'] == 1)
{
$responce['policy_name'] = $this->policesModel->where('id',$array['policy_id'])->get()->getRow()->name;
$responce['SlabRates'] = $getSlabAndGridData['slab_rates'];
$responce['GridMaster'] = $getSlabAndGridData['grid_master'];
$responce['client_id'] = $array['client_id'];
$responce['client_policy_id'] = $array['id'];
$responce['is_addon'] = $array['is_addon'];
$responce['open_for_enrollment'] = $array['open_for_enrollment'];
$responce['policy_terms'] = $decodedArray;
// Map family floaters that already exist in the employee table
$familyFloates = $policy_terms->family_floaters;
// Convert familyFloaters terms data to plain array
$floters = $this->FloterConvertion($familyFloates);
$data = [];
$dependent_and_si_value = null;
$dependent_and_si_premium_value = null;
foreach ($floters as $familyFloatesValue) {
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
if(count($addOnEmployeeData)){
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'])->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = $employee_policy->basic_cover_si; }
if(isset($employee_policy->premium)){ $dependent_and_si_premium_value = $employee_policy->premium;}
$temp['is_value_exist'] = true;
$temp['data']['family_floater_key'] = $familyFloatesValue;
$temp['data']['employee_id'] = $value['id'];
$temp['data']['relationship'] = $value['relationship'];
$temp['data']['name'] = $value['name'];
$temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
$temp['data']['client_policy_id'] = $array['id'];
$temp['data']['form_type'] = $dependent;
$temp['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
$temp['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
array_push($data,$temp);
unset($addOnEmployeeData[$key]);
$floters = array_diff($floters, [$familyFloatesValue]);
break;
}
}
}
}
//Remove Unwanted floter key from floters array based on either-parents-pil term value
if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
{
if(count($addOnEmployeeData) == 0)
{
$GMCEmpData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('is_addon_value',0)
->where('family_floater_key','parent')
->findAll();
if(count($GMCEmpData) > 0){
$floters = array_diff($floters, ["parent1","parent2"]);
}else{
$floters = array_diff($floters, ["parent_in_law1","parent_in_law2"]);
}
}else{
$count_parent = 0;
$count_parent_in_law = 0;
foreach ($floters as $value) {
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
}
if($count_parent != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
}
if($count_parent_in_law != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
}
}
}
// Add family floter buttons placement data for FE validation
if(count($floters)){
foreach ($floters as $familyFloatesValue) {
$temp2['is_value_exist'] = false;
$temp2['data']['family_floater_key'] = $familyFloatesValue;
$temp2['data']['client_policy_id'] = $array['id'];
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
array_push($data,$temp2);
}
}
$responce['family_floaters_of_dependent_and_si_array'] = $data;
$responce['family_floaters_of_dependent_and_si_value'] = $dependent_and_si_value;
$responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value;
$only_si_array = [];
$only_si_value = null;
$only_si_premium_value = null;
foreach ($GMCEmployeeData as $key => $value) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
if(isset($employee_policy->premium)){ $only_si_premium_value = $employee_policy->premium;}
$temp3['is_value_exist'] = true;
$temp3['data']['employee_id'] = $value['id'];
$temp3['data']['relationship'] = $value['relationship'];
$temp3['data']['name'] = $value['name'];
$temp3['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
$temp3['data']['client_policy_id'] = $array['id'];
$temp3['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
$temp3['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
array_push($only_si_array,$temp3);
}
$responce['family_floaters_of_only_si_array'] = $only_si_array;
$responce['family_floaters_of_only_si_value'] = $only_si_value;
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
array_push($PolicyData, $responce);
}
}
return $this->respond(['status' => 'success','code' => 200,'data' => ['addon_policy'=>$responce]], 200);
}else{
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
public function iAgreeForAddOn()
{
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
}
}

View File

@ -14,7 +14,7 @@ class JobWorker extends AdminController
* Constructs the class
*/
private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']];
private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper'],'bulk_mail' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']];
public function __construct()
{
// echo 'HiC';//die();
@ -199,4 +199,7 @@ class JobWorker extends AdminController
}
}
}

View File

@ -18,15 +18,7 @@ class AuthJWT implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$jwt ='';
if($request->headers()['Auth']){
$jwt = $request->headers()['Auth'];
}else{
$jwt = $request->getHeader('Authorization');
}
$jwt = $request->getHeader('Authorization');
if ($jwt) {
if (JWTToken::validateJWT($jwt)) {

View File

@ -9,6 +9,8 @@ use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use App\Models\JobModel;
class MailHelper
{
@ -18,6 +20,7 @@ class MailHelper
$subject = $params['subject'];
$message = $params['message'];
try {
$email = \Config\Services::email();
$email->setMailType('html');
$email->setFrom('bbone@venbait.in', 'Nhance');
@ -37,5 +40,26 @@ class MailHelper
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
}
}
public static function bulk_mail(array $mails = [])
{
$model = new JobModel();
$start = microtime(true);
$runtime= 0;
try {
foreach ( $mails as $index=>$mail) {
$runtime = microtime(true) - $start;
$send_mail = self::send_email($mail);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
} catch (\Throwable $th) {
return json_encode(['status' => 'failed','code' => 500],500);
}
}
}
?>

View File

@ -394,7 +394,27 @@ if (! function_exists('generate_filename')) {
if (!function_exists('remove_underscore_capitalize_first_letter')) {
function remove_underscore_capitalize_first_letter($word) {
// Remove underscore and capitalize first letter of each word
$pattern = '/dob/i';
if (preg_match($pattern, $word)) {
$formattedEvent = 'DOB';
return $formattedEvent;
}
$formattedEvent = ucwords(str_replace('_', ' ', $word));
return $formattedEvent;
}
}
if (!function_exists('formatDateOrReturn')) {
function formatDateOrReturn($value)
{
// Check if the value is a valid date
$timestamp = strtotime($value);
if ($timestamp !== false) {
// Format the date
return date('d-M-Y', $timestamp);
} else {
// Return the original value
return $value;
}
}
}

View File

@ -86,31 +86,34 @@ if (!function_exists('compressImage')) {
if (!function_exists('fancy_date_time_format'))
{
function fancy_date_time_format($datetime,$return_type = 'fancy') {
date_default_timezone_set('Asia/Kolkata');
$currentDateTime = new DateTime();
$passedDateTime = new DateTime($datetime);
// Calculate the interval between the current time and the passed datetime
$interval = $currentDateTime->diff($passedDateTime);
// return change_date_format($datetime,'Y-m-d H:i:s','d M Y h:i a');
// If the interval is more than 1 month, return the original datetime
if ($interval->m > 1 || $interval->y > 0) {
if($return_type = 'fancy'){ return change_date_format($datetime,'Y-m-d H:i:s','d M Y h:i a'); }
return $datetime;
} elseif ($interval->m == 1 && $interval->y == 0) {
return "1 month ago";
} elseif ($interval->d >= 7) {
$weeks = floor($interval->d / 7);
return $weeks == 1 ? "1 week ago" : "$weeks weeks ago";
} elseif ($interval->d >= 1) {
return $interval->d == 1 ? "1 day ago" : $interval->d . " days ago";
} elseif ($interval->h >= 1) {
return $interval->h == 1 ? "1 hour ago" : $interval->h . " hours ago";
} elseif ($interval->i >= 1) {
return $interval->i == 1 ? "1 minute ago" : $interval->i . " minutes ago";
} else {
return "Just now";
// Calculate the interval between the current time and the passed datetime
$interval = $currentDateTime->diff($passedDateTime);
// If the interval is more than 1 month or the year is different, return the original datetime
if ($interval->m > 1 || $interval->y != 0) {
if ($return_type == 'fancy') {
return change_date_format($datetime, 'Y-m-d H:i:s', 'd M Y h:i a');
}
return $datetime;
} elseif ($interval->m == 1 && $interval->y == 0) {
return "1 month ago";
} elseif ($interval->d >= 7) {
$weeks = floor($interval->d / 7);
return $weeks == 1 ? "1 week ago" : "$weeks weeks ago";
} elseif ($interval->d >= 1) {
return $interval->d == 1 ? "1 day ago" : $interval->d . " days ago";
} elseif ($interval->h >= 1) {
return $interval->h == 1 ? "1 hour ago" : $interval->h . " hours ago";
} elseif ($interval->i >= 1) {
return $interval->i == 1 ? "1 minute ago" : $interval->i . " minutes ago";
} else {
return "Just now";
}
}
}
@ -129,3 +132,5 @@ if(!function_exists('check_string_date'))

View File

@ -71,12 +71,13 @@ class ClientPolicyModel extends Model
->select('policy_type.policy_type as policy_type_name')
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->select('policy_type.policy_type as policy_type_name')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('client_policy.client_id', $client_id)
->get()
->getResult();

View File

@ -11,6 +11,7 @@ class EmpEndorsementModel extends Model
protected $allowedFields = [
'id',
'pk',
'group_key',
'endorsement_id',
'emp_code',
'table_name',
@ -27,4 +28,173 @@ class EmpEndorsementModel extends Model
"remarks"
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
// protected function afterFind(array $data)
// {
// foreach ($data as &$row) {
// // Format date_of_coverage field to Indian date format
// if (isset($row['field_name'])) {
// $row['field_name'] = remove_underscore_capitalize_first_letter($row['field_name']);
// }
// }
// return $data;
// }
public function getDataForEnodrsementListinSIEnhancement($group_key){
$query = "
SELECT
employee_polices.days as old_days,
employee_polices.rata_premimum as old_rata,
employee_polices.gst as old_gst,
client_policy.policy_start_date as old_date,
MAX(CASE WHEN emp_endorsement.field_name = 'basic_cover_si' THEN emp_endorsement.new_value ELSE NULL END) AS new_basic_cover_si,
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) AS new_si_premium,
MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END) AS date_of_coverage,
MAX(CASE WHEN emp_endorsement.field_name = 'basic_cover_si' THEN emp_endorsement.old_value ELSE NULL END) AS old_basic_cover_si,
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END) AS old_si_premium,
(MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) AS difference_premium,
DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value END)) + 1 AS no_of_days,
ROUND(
(
(
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value END) -
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value END)
) *
DATEDIFF(
employee_polices.policy_end_date,
MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value END)
) / 365
),
2
) AS pro_rata_premimum,
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365) * 0.18, 2) AS gst,
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365), 2) +
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365) * 0.18, 2) AS total
FROM emp_endorsement
JOIN employee_polices ON employee_polices.id = emp_endorsement.pk
JOIN client_policy ON client_policy.id = employee_polices.client_policy_id
WHERE group_key = '{$group_key}'
";
$results = $this->db->query($query)->getResult();
return $results;
}
public function getDataForEnodrsementListinDeletion($group_key){
$query = "
SELECT
employee_polices.days as old_days,
employee_polices.rata_premimum as old_rata,
employee_polices.gst as old_gst,
employee_polices.policy_end_date as end_date,
client_policy.policy_start_date as start_date,
MAX(CASE WHEN a.field_name = 'date_of_exit' THEN a.new_value ELSE NULL END) AS date_of_leaving,
MAX(CASE WHEN a.field_name = 'reason_for_exit' THEN a.new_value ELSE NULL END) AS exist_reason,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) AS no_of_days,
ROUND((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365, 2) AS pro_rata_premium,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18, 2) AS gst,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) + (((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18), 2) AS total
FROM
emp_endorsement a
LEFT JOIN
employees ON a.emp_code = employees.emp_code
LEFT JOIN
employee_polices ON employees.id = employee_polices.employee_id
LEFT JOIN
client_policy ON client_policy.id = employee_polices.client_policy_id
LEFT JOIN (
SELECT
aa.emp_code,
aa.new_value AS 'empstatus',
bb.new_value AS 'changeevent',
cc.new_value AS 'dateofexit',
dd.new_value AS 'reasonforexit',
ee.new_value AS 'status'
FROM
(
SELECT
a1.emp_code,
a1.field_name,
a1.new_value
FROM
emp_endorsement AS a1
WHERE
a1.field_name = 'emp_status'
) aa
LEFT JOIN
(
SELECT
b1.emp_code,
b1.field_name,
b1.new_value
FROM
emp_endorsement AS b1
WHERE
b1.field_name = 'change_event'
) bb ON aa.emp_code = bb.emp_code
LEFT JOIN
(
SELECT
c1.emp_code,
c1.field_name,
c1.new_value
FROM
emp_endorsement AS c1
WHERE
c1.field_name = 'date_of_exit'
) cc ON aa.emp_code = cc.emp_code
LEFT JOIN
(
SELECT
d1.emp_code,
d1.field_name,
d1.new_value
FROM
emp_endorsement AS d1
WHERE
d1.field_name = 'reason_for_exit'
) dd ON aa.emp_code = dd.emp_code
LEFT JOIN
(
SELECT
e1.emp_code,
e1.field_name,
e1.new_value
FROM
emp_endorsement AS e1
WHERE
e1.field_name = 'status'
) ee ON aa.emp_code = ee.emp_code
) AS deletiondata ON a.emp_code = deletiondata.emp_code
WHERE group_key = '{$group_key}';
";
$results = $this->db->query($query)->getResult();
return $results;
}
}

View File

@ -35,7 +35,8 @@ class EmployeeModel extends Model
"updated_by",
"updated_at",
"is_active",
"file_id"
"file_id",
"is_addon_value"
];
// Callbacks

View File

@ -67,7 +67,7 @@ class EmployeePolicyModel extends Model
}
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id)
public function getEmployeePolicy($client_id,$policy_id,$status)
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
@ -79,8 +79,13 @@ class EmployeePolicyModel extends Model
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('employee_polices.client_policy_id',$policy_id)
->findAll();
->where('employee_polices.client_policy_id',$policy_id);
if($status != 0 && !empty($status)){
$result->where('employee_polices.status', $status);
}
$result = $result->findAll();
return ($result);
}
@ -230,6 +235,7 @@ class EmployeePolicyModel extends Model
$query = $this->db->query("
SELECT
a.id as endorsement_primarykey,
employee_polices.id AS primaryKey,
employees.name AS emp_name,
employees.emp_code AS emp_code,
@ -336,6 +342,7 @@ class EmployeePolicyModel extends Model
$query = $this->db->query("
SELECT
a.id as endorsement_primarykey,
employee_polices.id as primaryKey,
employees.name AS emp_name,
employees.emp_code AS emp_code,
@ -451,7 +458,7 @@ class EmployeePolicyModel extends Model
UPDATE emp_endorsement
JOIN employees ON employees.id = emp_endorsement.pk
JOIN employee_polices ON employees.id = employee_polices.employee_id
SET emp_endorsement.endorsement_id = '$endorsement_id'
SET emp_endorsement.endorsement_id = '$endorsement_id', emp_endorsement.status = 'complete'
WHERE employees.emp_code = '$emp_code'
AND employee_polices.uhid = '$uhid'
";
@ -463,15 +470,15 @@ class EmployeePolicyModel extends Model
$client_id = $update_data['client_id'];
$client_policy_id = $update_data['client_policy_id'];
$emp_name = $update_data['name'];
$emp_name = $update_data['emp_name'];
$emp_code = $update_data['emp_code'];
$endorsement_id = $update_data['uhid'];
$endorsement_id = $update_data['endorsement_id'];
$sql = "
UPDATE emp_endorsement
JOIN employee_polices ON employee_polices.id = emp_endorsement.pk
JOIN employees ON employee_polices.employee_id = employees.id
SET emp_endorsement.endorsement_id = '$endorsement_id'
SET emp_endorsement.endorsement_id = '$endorsement_id', emp_endorsement.status = 'complete'
WHERE emp_endorsement.emp_code = '$emp_code'
AND employees.client_id = '$client_id'
AND employee_polices.client_policy_id = '$client_policy_id'
@ -483,19 +490,20 @@ class EmployeePolicyModel extends Model
}
public function updateEndoresmentIdForDeletion($update_data){
public function updateEndoresmentIdForDeletion($update_data)
{
$client_id = $update_data['client_id'];
$client_policy_id = $update_data['client_policy_id'];
$emp_name = $update_data['name'];
$emp_name = $update_data['emp_name'];
$emp_code = $update_data['emp_code'];
$endorsement_id = $update_data['uhid'];
$endorsement_id = $update_data['endorsement_id'];
$sql = "
UPDATE emp_endorsement
JOIN employee_polices ON employee_polices.id = emp_endorsement.pk
JOIN employees ON employee_polices.employee_id = employees.id
SET emp_endorsement.endorsement_id = '$endorsement_id'
SET emp_endorsement.endorsement_id = '$endorsement_id', emp_endorsement.status = 'complete'
WHERE employees.emp_code = '$emp_code'
AND employees.client_id = '$client_id'
AND employee_polices.client_policy_id = '$client_policy_id'
@ -508,7 +516,7 @@ class EmployeePolicyModel extends Model
public function fetchEmpEndorsementData($fetch_data)
{
$client_policy_id = $fetch_data['client_policy_id'];
$emp_name = $fetch_data['name'];
$emp_name = $fetch_data['emp_name'];
$emp_code = $fetch_data['emp_code'];
// Your raw SQL query
@ -560,6 +568,79 @@ class EmployeePolicyModel extends Model
$this->query($query);
}
//------------------------------------------------------------------
}
public function getEmployeeEndorsementList($client_id, $policy_id, $status)
{
$query1 = $this->db->table('emp_endorsement e');
$query1->select('
e.id,
e.pk,
e.emp_code,
e.name,
e.actions,
e.status,
e.remarks,
e.endorsement_id,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
');
$query1->distinct();
$query1->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query1->join('employees', 'employees.id = ep.employee_id', 'left');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query1->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query1->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $client_id);
$query1->where('employees.client_id', $policy_id);
if($status != 0 && !empty($status)){
$query1->where('e.status', $status);
}
$query1->orderBy('e.id', 'desc');
$results1 = $query1->get()->getResultArray();
$query2 = $this->db->table('emp_endorsement e');
$query2->select('
e.id,
e.pk,
e.emp_code,
e.name,
e.actions,
e.status,
e.endorsement_id,
e.remarks,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
');
$query2->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query2->join('employees', 'employees.id = ep.employee_id', 'left');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query2->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query2->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query2->whereIn('e.actions', ['si', 'd']);
$query2->where('ep.client_policy_id', $client_id);
$query2->where('employees.client_id', $policy_id);
if($status != 0 && !empty($status)){
$query2->where('e.status', $status);
}
$query2->groupBy('e.emp_code, e.name, e.actions');
$query2->orderBy('e.id', 'desc');
$results2 = $query2->get()->getResultArray();
$results = array_merge($results1, $results2);
return $results;
}
//----------------------------------------------------------------------------------------------
}

View File

@ -1,5 +1,4 @@
<style>
body {
.multiselect-native-select {
position: relative;
@ -25,7 +24,15 @@ body {
.multiselect-selected-text{
float: left !important;
}
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style>
<!-- End ADD and EDIT Page HTML -->

View File

@ -36,8 +36,8 @@
<form role="form" class="parsley-examples" method="post" id="policy_form"
enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" id="policy_form_action" />
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey"/>
<input type="hidden" id="policy_form_action"/>
<input type="hidden" name="policy_type_id" id="policy_type_id"/>
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<div class="form-group">
@ -94,12 +94,10 @@
</div>
</div>
<!-- <hr> -->
<div id="policy_fields"></div>
<div id="policy_fields"></div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
@ -159,6 +157,7 @@
$('.btnAdd').click(function(){
$('#policy_form')[0].reset();
$('#add_form').show();
$('#table_list').hide();
$('.btnBack').show();
@ -170,14 +169,13 @@
$('#policy').html('<option value="" selected>Select Policy</option>');
$('#is_addon').prop('checked', false);
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
$('#policy_status_field').hide()
})
$('.btnBack').click(function(){
$('#GMC').remove();
$('#GPA').remove();
$('#policy_form')[0].reset();
$('#add_form').hide();
$('#table_list').show();
$('.btnBack').hide();
@ -194,10 +192,22 @@
if (policy_PrimaryKey !== '') {
var policyTable = '';
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
// console.log('client_policy_data',data)
data.forEach(function(item) {
// console.log("----------------------------");
console.log(item.open_for_enrollment);
var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
var subject = item.policy_type_name;
// console.log(item);
if (patternGMC.test(subject)) {
search_term = 'GMC';
} else if (patternGPA.test(subject)) {
search_term = 'GPA';
} else {
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
console.log('search_term :', search_term)
policyTable += `
<tr>
@ -211,10 +221,15 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal" id="${item.policy_type_id}"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a>
</div>
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
`;
if (item.open_for_enrollment == 0) {
policyTable +=`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a> `;
}else{
policyTable +=`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll" style="pointer-events:none; background-color: lightgrey;"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle" ></i>Open Enrollment</a> `;
}
policyTable += ` </div>
</div>
</td>
</tr>
@ -271,7 +286,7 @@
success: function(res) {
console.log(res);
$('#policy_form')[0].reset();
if (res.status === false) {
toastr.error('Policy Dose Not Create', 'Error');
return;
@ -295,10 +310,25 @@
$('#policy_table tr').remove();
var policyTable = '';
$.each(res.data, function(index, item) {
var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
var subject = item.policy_type_name;
if (patternGMC.test(subject)) {
search_term = 'GMC';
} else if (patternGPA.test(subject)) {
search_term = 'GPA';
} else {
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
console.log('search_term :', search_term)
policyTable += `
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name}</td>
<td>${item.policy_name} (${item.policy_type_name})</td>
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
@ -307,8 +337,8 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyMaster" data-toggle="modal" id="${item.policy_type_id}"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a>
</div>
</div>
@ -482,13 +512,28 @@
client_policy_id : client_policy_id,
},
success: function(res) {
// console.log(res);
console.log(res);
if(res) {
if (res.open_for_enrollment) {
var json_decode=JSON.parse(res.open_for_enrollment);
var open_for_enrollment=json_decode.open_for_enrollment;
var client_policy_id=json_decode.client_policy_id;
if (open_for_enrollment == 1) {
// console.log($('[data-id="' + client_policy_id + '"]');
$('.btnOpenEnroll').each(function(index, element) {
if ($(element).data('id') == client_policy_id) {
$(element).css({'background-color': 'lightgrey', 'pointer-events': 'none'});
}
});
}
}
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status === true){
toastr.success(res.message, 'Success');
}else if(res.status === false){
toastr.warning(res.message, 'Warning');
}

View File

@ -22,23 +22,34 @@ table.dataTable tbody td {
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="row">
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Status</label> <br />
<select class="form-control" id="status2">
<option value="0">Select</option>
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -98,7 +109,19 @@ table.dataTable tbody td {
<td><?php echo $employee['insurer_short_name']?></td>
<td><?php echo $employee['tpa_id']?></td>
<td><?php echo $employee['uhid']?></td>
<td><span class="badge badge-success">active</span></td>
<td>
<?php
if ($employee['status'] == 'draft') {
echo '<span class="badge badge-secondary">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'active') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inactive') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
}elseif ($employee['status'] == 'expired') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
}
?>
</td>
<td><?php echo $employee['premium']?></td>
<td>
<div class="btn-group dropdown">
@ -134,6 +157,8 @@ table.dataTable tbody td {
<script>
// Declare a global variable to store API response data
var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
$(document).ready(function() {
console.log("document loaded");
@ -144,7 +169,6 @@ $(document).ready(function() {
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
@ -167,8 +191,21 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
// console.log(clientPolicies);
console.log('1',clientPolicies);
appendClients(clientPolicies);
//this function for reselect the policy
setTimeout(function() {
if (client_id != 0 ) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
});
appendPolicies(foundPolicies.policies);
}
}, 500);
//end
} catch (error) {
console.error('Error parsing API response data:', error);
}
@ -188,29 +225,43 @@ function fetchClientPolicies() {
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
$('#clients').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.client_name
}));
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>;
console.log(PolicyID)
$.each(data, function(index, item) {
$('#policies').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.name
}));
});
if (PolicyID == item.id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
$('#clients').on('change', function() {
var selectedClient = $(this).val();
console.log(selectedClient);
@ -224,16 +275,20 @@ $('#clients').on('change', function() {
appendPolicies(foundPolicies.policies);
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status2').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
@ -241,8 +296,10 @@ function fetchEmpolyeeList(event) {
}
var queryParams = {
client_id: client_id,
policy_id: policy_id
policy_id: policy_id,
status : status,
};
const queryString = objectToQueryString(queryParams);
@ -268,9 +325,11 @@ function fetchEmpolyeeList(event) {
// });
}
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
</script>

View File

@ -1,12 +1,12 @@
<style>
.table th,
.table td {
padding: 8px;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style>
<div class="row">
@ -22,23 +22,34 @@
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="row">
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Status</label> <br />
<select class="form-control" id="status1">
<option value="0">Select</option>
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -74,11 +85,11 @@
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Name/code</th>
<th class="font-weight-medium">Policy name</th>
<th class="font-weight-medium">Insurar name</th>
<th class="font-weight-medium">TPA ID</th>
<th class="font-weight-medium">UHID ID</th>
<th class="font-weight-medium">Policy status</th>
<th class="font-weight-medium">Premium</th>
<th class="font-weight-medium">Endorsement ID</th>
<th class="font-weight-medium">Insurer name</th>
<th class="font-weight-medium">Remarks</th>
<th class="font-weight-medium">Endorsement Type</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
@ -91,32 +102,37 @@
<tr>
<td><b><?php echo ($key + 1)?></b></td>
<!-- <td><?php echo $employee['emp_code']?></td> -->
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> )</td>
<td><?php echo $employee['policy_name']?></td>
<td><?php echo $employee['insurer_short_name']?></td>
<td><?php echo $employee['tpa_id']?></td>
<td><?php echo $employee['uhid']?></td>
<td><span class="badge badge-success">active</span></td>
<td><?php echo $employee['premium']?></td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo $employee['endorsement_id']?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td>
<td><?php echo $employee['remarks']?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"><i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
Ticket</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-check-all mr-2 text-muted font-18 vertical-middle"></i>Close</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Remove</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>Mark as
Unread</a>
</div>
</div>
<?php
if ($employee['actions'] == 'c') {
echo 'Correction';
} elseif ($employee['actions'] == 'si') {
echo 'SI Enhancement';
} elseif ($employee['actions'] == 'd') {
echo 'Deletion';
}
?>
</td>
<td>
<?php
if ($employee['status'] == 'pending') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'complete') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
}
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id']?>"
class="fa fa-eye emp_data_model" aria-hidden="true" data-toggle="modal"
data-target="#centermodal"></a>
</td>
</tr>
<?php }}?>
@ -127,27 +143,48 @@
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<div id="loader" class="loader" style="display:none;">SPINNER</div>
<!-- Center modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Endorsement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead id="table_head_data">
</thead>
<tbody id="table_data">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
// Declare a global variable to store API response data
var clientPolicies = [];
$(document).ready(function() {
console.log("document loaded");
//fetchClientPolicies();
});
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
@ -166,8 +203,21 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
// console.log(clientPolicies);
console.log(clientPolicies);
appendClients(clientPolicies);
//this function for reselect policy
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
});
appendPolicies(foundPolicies.policies);
}
}, 500);
//end
} catch (error) {
console.error('Error parsing API response data:', error);
}
@ -187,26 +237,40 @@ function fetchClientPolicies() {
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
$('#clients').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.client_name
}));
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>;
console.log(PolicyID)
$.each(data, function(index, item) {
$('#policies').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.name
}));
});
if (PolicyID == item.id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
@ -233,6 +297,7 @@ function fetchEmpolyeeList(event) {
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status1').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
@ -241,7 +306,8 @@ function fetchEmpolyeeList(event) {
var queryParams = {
client_id: client_id,
policy_id: policy_id
policy_id: policy_id,
status: status,
};
const queryString = objectToQueryString(queryParams);
@ -256,4 +322,160 @@ document.getElementById('toggleIcon').addEventListener('click', function() {
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
$('.emp_data_model').click(function() {
var myVal = $(this).data('id');
console.log(myVal);
fetchEmpEndorsementData(myVal)
});
function fetchEmpEndorsementData(id) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = '<?php echo base_url();?>' + 'util/get-emp-endorsement/' + id;
console.log('fetchEmpEndorsementData');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
if (response.code === 200 && response.dataStatus === true) {
try {
endorsementData = (response.data);
endorsementData2 = (response.data2);
e_actions = endorsementData2[0]['actions'];
var heading = "";
if (endorsementData2[0]['actions'] == 'si') {
heading = ' - ' + 'SI Enhancement';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'd') {
heading = ' - ' + 'Deletion';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'c') {
heading = ' - ' + 'Correction';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
}
$('#heading').html(heading);
$('#table_data').empty();
$('#table_head_data').empty();
if(e_actions == 'd'){
$.each(endorsementData, function(index, item) {
var tableHtml = `
<tr>
<td>${item.field_name}</td>
<td>${formatNumberToIndianLocale(item.data, item.field_name, e_actions)}</td>
</tr>
`;
$('#table_data').append(tableHtml);
});
} else {
var table_head = `
<tr>
<th class="font-weight-medium"></th>
<th class="font-weight-medium">Old Value</th>
<th class="font-weight-medium">New Value</th>
</tr>
`;
$('#table_head_data').append(table_head);
$.each(endorsementData, function(index, item) {
var tableHtml = `
<tr>
<td>${item.field_name}</td>
<td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
<td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
</tr>
`;
$('#table_data').append(tableHtml);
});
}
} catch (error) {
console.error('Error parsing API response data:', error);
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 200);
}
function formatNumberToIndianLocale(value, field_name, action) {
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
if(field_name == 'Period of non coverage'){
return value + ' days';
}
if(field_name == 'Total Amount'){
return '₹ ' + return_val + ' ( To be Refunded )';
}
if(field_name == 'Total'){
if(action == 'd'){
return '₹ ' + return_val + ' ( To be Refunded )';
}else if(action == 'si'){
return '₹ ' + return_val + ' ( To be paid )';
}
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
}
}
$('.close').click(function(){
$('#table_data').empty();
})
</script>

View File

@ -14,6 +14,7 @@
<th class="font-weight-medium">File name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">policy</th>
<th class="font-weight-medium">Event</th>
<th class="font-weight-medium">User/Time</th>
<th class="font-weight-medium">Status</th>
</tr>
@ -34,6 +35,7 @@
<td><?php echo $file['file_name']?></td>
<td><?php echo $file['short_name']?></td>
<td><?php echo $file['policy_name']?></td>
<td><?php echo $file['action']?></td>
<td><?php echo fancy_date_time_format($file['created_at']).' by <strong>'.$file['first_name'].'</strong>'?></td>
<td><?php echo $file['status']; if($file['status'] == 'failed')
{

View File

@ -5,8 +5,8 @@
<meta charset="utf-8" />
<title>nHANCE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta content="A fully featured CRM" name="description" />
<meta content="Venba info tech" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url()."public"; ?>/assets/images/favicon.ico">

View File

@ -643,9 +643,9 @@ var grid_html = '';
var gmc_policy_type_id = $(this).attr('id');
console.log(gmc_policy_type_id)
if(gmc_policy_type_id >= 2){
if(gmc_policy_type_id == 'GMC'){
$('#policyGMCTerms').css('display', '');
$('#police-tab').css('display', 'none');
@ -802,6 +802,8 @@ var grid_html = '';
}
});
}else if(gmc_policy_type_id != 'GPA' && gmc_policy_type_id != 'GMC'){
// toastr.warning('The terms has no data ', 'warning');
}
});

View File

@ -446,7 +446,7 @@
var gpa_policy_type_id = $(this).attr('id');
// console.log('gpa_policy_type_id', gpa_policy_type_id)
if(gpa_policy_type_id == '1'){
if(gpa_policy_type_id == 'GPA'){
$('#policyGPATermsForm').css('display', '');
$('#police-tab').css('display', 'none');
@ -548,6 +548,8 @@
}
});
}else if(gpa_policy_type_id != 'GPA' && gpa_policy_type_id != 'GMC'){
toastr.warning("This policy has no policy terms.", 'warning');
}
});

View File

@ -7,6 +7,9 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="text-center" id="no_data"></div>
<form role="form" class="parsley-examples" method="post" id="GridForm" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>"/>
<input type="hidden" name="client_id" id="Client_id" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
@ -14,7 +17,7 @@
<input type="hidden" id="grid_emp_count"/>
<div class="form-group">
<div class="form-row">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-6">
<label for="emp_code">Policy Premium Type<span class="text-danger">*</span></label>
<select class="form-control" id="grid" name="policy_grid_id" onchange="addGridHTML(event)" required>
@ -566,105 +569,123 @@
var client_policy_id = $(this).data('id');
$('#client_policy_id').val(client_policy_id);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var policy_type_string = $(this).attr('id');
console.log('policy_type_string', policy_type_string)
if(policy_type_string == 'GPA' || policy_type_string == 'GMC'){
$.ajax({
url: '<?= base_url("util/policy-premium") ?>' ,
type: "GET",
data: { client_policy_id: client_policy_id},
dataType: 'json',
success: function (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
console.log('res',res);
var temp_for_premiumData = JSON.parse(res.premiumData);
$('#GridForm').show();
$('#no_data').html('');
res.premiumData= JSON.parse(res.premiumData);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?= base_url("util/policy-premium") ?>' ,
type: "GET",
data: { client_policy_id: client_policy_id},
dataType: 'json',
success: function (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
console.log('res',res);
var temp_for_premiumData = JSON.parse(res.premiumData);
$('#nameOfThePolicy').html(' - ' + res.policy_name);
$('#grid_emp_count').val(res.count);
res.premiumData= JSON.parse(res.premiumData);
$('#nameOfThePolicy').html(' - ' + res.policy_name);
$('#grid_emp_count').val(res.count);
if (res.status === false) {
toastr.error(res.status);
return;
}
if (res.status === false) {
toastr.error(res.status);
return;
}
var policy_grid_id_value = '';
if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0].policy_grid_id) {
policy_grid_id_value = res.premiumData[0].policy_grid_id;
}
$('#grid_content_input').empty();
var policeGridOptionHTML = '';
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
$.each(res.data, function(index, item) {
policeGridOptionHTML += '<option data-id="'+ item.ui_type +'" value="' + item.id + '" ' + (policy_grid_id_value === item.id ? 'selected="selected"' : '') + '>' + item.policy_grid_type + '</option>';
});
$('#grid').html(policeGridOptionHTML);
var si_or_bp_value = '';
if (res.premiumData && res.premiumData.length > 0) {
if(res.premiumData[0].si_or_bp){
si_or_bp_value = res.premiumData[0].si_or_bp;
var policy_grid_id_value = '';
if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0].policy_grid_id) {
policy_grid_id_value = res.premiumData[0].policy_grid_id;
}
addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, si_or_bp_value);
$('#grid_content_input').empty();
var policeGridOptionHTML = '';
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
$.each(res.data, function(index, item) {
policeGridOptionHTML += '<option data-id="'+ item.ui_type +'" value="' + item.id + '" ' + (policy_grid_id_value === item.id ? 'selected="selected"' : '') + '>' + item.policy_grid_type + '</option>';
});
$('#grid').html(policeGridOptionHTML);
var si_or_bp_value = '';
if (res.premiumData && res.premiumData.length > 0) {
res.premiumData.shift();
$.each(res.premiumData, function(index, item){
if (item.si_or_bp == '1') {
appendGridtHtml('1', item);
}else{
appendGridtHtml(item.policy_grid_id, item);
if(res.premiumData[0].si_or_bp){
si_or_bp_value = res.premiumData[0].si_or_bp;
}
addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, si_or_bp_value);
res.premiumData.shift();
$.each(res.premiumData, function(index, item){
if (item.si_or_bp == '1') {
appendGridtHtml('1', item);
}else{
appendGridtHtml(item.policy_grid_id, item);
}
});
} else {
console.log("res.premiumData is undefined, null, or empty.");
}
$('#bs-example-modal-lg').modal('show');
$("#gpa_si").trigger("keyup");
$("#gpa_premium").trigger("keyup");
$('#basic_pay').trigger('keyup');
$('#4_si').trigger('keyup');
$('input[name="gpa_sum_si[]"]').each(function() {
$(this).trigger('keyup');
});
} else {
console.log("res.premiumData is undefined, null, or empty.");
}
$('input[name="gpa_sum_premium[]"]').each(function() {
$(this).trigger('keyup');
});
$('#bs-example-modal-lg').modal('show');
var id_for_trigger =temp_for_premiumData[0].policy_grid_id;
$(`input[name="${id_for_trigger}_si[]"]`).each(function() {
console.log($(this));
$(this).trigger('keyup');
});
$(`input[name="${id_for_trigger}_premium[]"]`).each(function() {
console.log($(this));
$(this).trigger('keyup');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
} else{
$('#grid').empty();
$('#nameOfThePolicy').html('');
$('#GridForm').hide();
$('#no_data').html('The policy has no Policy Rac Rate');
toastr.warning("The policy has no Policy Rac Rate", "Warning")
}
$("#gpa_si").trigger("keyup");
$("#gpa_premium").trigger("keyup");
$('#basic_pay').trigger('keyup');
$('#4_si').trigger('keyup');
$('input[name="gpa_sum_si[]"]').each(function() {
$(this).trigger('keyup');
});
$('input[name="gpa_sum_premium[]"]').each(function() {
$(this).trigger('keyup');
});
var id_for_trigger =temp_for_premiumData[0].policy_grid_id;
$(`input[name="${id_for_trigger}_si[]"]`).each(function() {
console.log($(this));
$(this).trigger('keyup');
});
$(`input[name="${id_for_trigger}_premium[]"]`).each(function() {
console.log($(this));
$(this).trigger('keyup');
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
});
@ -672,7 +693,6 @@
var grid_id=$(this)[0].value;
var client_policy_id =$('#client_policy_id')[0].value;
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@ -1042,6 +1062,7 @@
}
function removebutton(index, type) {
if(index == 0){

View File

@ -157,7 +157,7 @@ paths:
summary: 'Add a new EmployeeUpload to the store'
operationId: EmployeeUpload
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -317,7 +317,7 @@ paths:
summary: 'RelationshipList'
operationId: RelationshipList
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -340,7 +340,7 @@ paths:
summary: 'GetEmployeeAndDependence'
operationId: GetEmployeeAndDependence
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -368,7 +368,7 @@ paths:
summary: 'EditEmployeeAndDependence'
operationId: EditEmployeeAndDependence
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -461,7 +461,7 @@ paths:
summary: 'AddEmployeeAndDependence'
operationId: AddEmployeeAndDependence
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -551,7 +551,7 @@ paths:
summary: 'GetEmployeePolicy'
operationId: GetEmployeePolicy
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -584,7 +584,7 @@ paths:
summary: 'CreateOrUpdateEmployeePolicySiAmount'
operationId: CreateOrUpdateEmployeePolicySiAmount
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -627,7 +627,7 @@ paths:
summary: 'DeleteDependence'
operationId: DeleteDependence
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -655,7 +655,7 @@ paths:
summary: 'GetEmployeeAndDependenceByClientId'
operationId: GetEmployeeAndDependenceByClientId
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true
@ -688,7 +688,7 @@ paths:
summary: 'GetClientPolicy'
operationId: GetClientPolicy
parameters:
- name: auth
- name: Authorization
in: header
description: an authorization header
required: true