CHANGE_ALL_IMPORT_EXPORT_FUNCTION_TO_CHECK_VALIDATION_AND_CONVERT_TO_JOB : RV
This commit is contained in:
parent
19c25711d2
commit
d9c9209286
@ -586,11 +586,11 @@ class ClientController extends AdminController
|
||||
|
||||
$this->myLogger->logme('error','Client policy CREATE function called');
|
||||
|
||||
$policy_id = $this->request->getPost('policy_id');
|
||||
$policy_type_id = $this->request->getPost('policy_type_id');
|
||||
$client_branch_id = $this->request->getPost('client_branch_id');
|
||||
|
||||
$policyCount = $this->clientPolicyModel
|
||||
->where('policy_id', $policy_id)
|
||||
->where('policy_type_id', $policy_type_id)
|
||||
->where('client_branch_id', $client_branch_id)
|
||||
->countAllResults();
|
||||
|
||||
@ -816,7 +816,6 @@ class ClientController extends AdminController
|
||||
|
||||
$jsonDataForRelation = json_encode($relation_data);
|
||||
|
||||
|
||||
// if($policy_grid_id == 10 || $policy_grid_id == 11){
|
||||
// $premium_type = 1;
|
||||
// }else{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -358,7 +358,7 @@ class EmployeeController extends AdminController
|
||||
public function importExport()
|
||||
{
|
||||
|
||||
$this->myLogger->logme('error', 'importExport function called');
|
||||
$this->myLogger->logme('error', 'Import Export -- Function called');
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
@ -370,10 +370,10 @@ class EmployeeController extends AdminController
|
||||
|
||||
$client_data = $this->clientModel->where('id', $client_id)->first();
|
||||
$policy_name_and_branch_name = $this->clientPolicyModel->select('policies.name, client_branch.branch_code')
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
->first();
|
||||
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
->first();
|
||||
$file_name = generate_filename($client_data['short_name'], $event_type, $actions, $insurer_or_tpa, $policy_name_and_branch_name['name'], $policy_name_and_branch_name['branch_code']);
|
||||
|
||||
$batch_data = [
|
||||
@ -386,20 +386,19 @@ class EmployeeController extends AdminController
|
||||
'file_name' => $file_name,
|
||||
];
|
||||
|
||||
// $event_type = 'si_enhancement';
|
||||
|
||||
if ($actions == 'export') {
|
||||
|
||||
if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') {
|
||||
|
||||
$return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
|
||||
|
||||
if($return == 0){
|
||||
|
||||
if ($return == 0) {
|
||||
|
||||
session()->setFlashdata('error', "Insufficient deposit amount.");
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!$return) {
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
@ -409,7 +408,6 @@ class EmployeeController extends AdminController
|
||||
session()->setFlashdata('error', "No data was found for this action. The UHID has already been updated.");
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'Successfully exported Excel file in {data}.', ['data' => $event_type]);
|
||||
}
|
||||
@ -425,6 +423,13 @@ class EmployeeController extends AdminController
|
||||
} else if ($event_type == 'si_enhancement') {
|
||||
|
||||
$return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
|
||||
|
||||
if ($return == 0) {
|
||||
|
||||
session()->setFlashdata('error', "Insufficient deposit amount.");
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
if (!$return) {
|
||||
session()->setFlashdata('error', 'No data found about this action');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
@ -444,29 +449,25 @@ class EmployeeController extends AdminController
|
||||
} else if ($actions == 'import') {
|
||||
|
||||
$batch_data['file'] = $this->request->getFile('import_file_data');
|
||||
|
||||
$file = $this->request->getFile('import_file_data');
|
||||
|
||||
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
|
||||
$filename = $file->getName();
|
||||
$this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
|
||||
|
||||
$random_number_count = 4;
|
||||
$batch_data['batch_code'] = generate_random_string($random_number_count);
|
||||
$batch_data['created_by'] = get_session_userid();
|
||||
$batch_data['status'] = 'pending';
|
||||
$batch_data['file_name'] = $filename;
|
||||
|
||||
if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') {
|
||||
|
||||
|
||||
$file = $this->request->getFile('import_file_data');
|
||||
|
||||
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
|
||||
$filename = $file->getName();
|
||||
$this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
|
||||
|
||||
|
||||
$random_number_count = 4;
|
||||
$batch_data['batch_code'] = generate_random_string($random_number_count);
|
||||
$batch_data['created_by'] = get_session_userid();
|
||||
$batch_data['status'] = 'pending';
|
||||
$batch_data['file_name'] = $filename;
|
||||
|
||||
$file_id = $this->batchFileModel->insert($batch_data);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importInceptionFileValidation','payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importInceptionFileValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$return = 1;
|
||||
|
||||
// $return = $empDataServiceController->importInceptionFileValidation(['file_id' => $file_id]);
|
||||
@ -474,71 +475,64 @@ class EmployeeController extends AdminController
|
||||
if ($return == 1) {
|
||||
session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 2) {
|
||||
session()->setFlashdata('error', 'The TPA ID column is either partially or entirely empty.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 0) {
|
||||
session()->setFlashdata('error', 'Please upload the correct file.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 3) {
|
||||
session()->setFlashdata('error', 'The list of employees provided has already been updated with the TPA ID, or this is not the correct file');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 4) {
|
||||
session()->setFlashdata('error', 'The UHID column is either partially or entirely empty.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 5) {
|
||||
session()->setFlashdata('error', 'The list of employees provided has already been updated with the UHID, or this is not the correct file');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 6) {
|
||||
session()->setFlashdata('error', 'The Excel record count exceeds the DB record count.');
|
||||
} else {
|
||||
session()->setFlashdata($return['status'], $return['message']);
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
} else if ($event_type == 'correction') {
|
||||
|
||||
$return = $empDataServiceController->importExcelDataForCorrection($batch_data);
|
||||
$file_id = $this->batchFileModel->insert($batch_data);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importCorrectionValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$return = 1;
|
||||
|
||||
// $return = $empDataServiceController->importCorrectionValidation(['file_id' => $file_id]);
|
||||
|
||||
if ($return == 1) {
|
||||
session()->setFlashdata('success', 'Data updated successfully');
|
||||
session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 2) {
|
||||
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 0) {
|
||||
session()->setFlashdata('error', 'Please upload the correct file');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 3) {
|
||||
session()->setFlashdata('error', 'File already uploaded');
|
||||
} else {
|
||||
session()->setFlashdata('error', $return);
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
} else if ($event_type == 'si_enhancement') {
|
||||
|
||||
$return = $empDataServiceController->importExcelDataForSIEnhancement($batch_data);
|
||||
|
||||
$file_id = $this->batchFileModel->insert($batch_data);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importSIEnhancementValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$return = 1;
|
||||
|
||||
// $return = $empDataServiceController->importSIEnhancementValidation(['file_id' => $file_id]);
|
||||
|
||||
if ($return == 1) {
|
||||
session()->setFlashdata('success', 'Data updated successfully');
|
||||
session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 2) {
|
||||
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 0) {
|
||||
session()->setFlashdata('error', 'Please upload the correct file');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 3) {
|
||||
session()->setFlashdata('error', 'File already uploaded');
|
||||
} else {
|
||||
session()->setFlashdata('error', $return);
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
} else if ($event_type == 'deletion') {
|
||||
|
||||
$return = $empDataServiceController->importExcelDataForDeletion($batch_data);
|
||||
$file_id = $this->batchFileModel->insert($batch_data);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importDeletionValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$return = 1;
|
||||
|
||||
// $return = $empDataServiceController->importDeletionValidation(['file_id' => $file_id]);
|
||||
|
||||
|
||||
if ($return == 1) {
|
||||
session()->setFlashdata('success', 'Data updated successfully');
|
||||
session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 2) {
|
||||
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 0) {
|
||||
session()->setFlashdata('error', 'Please upload the correct file');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
} else if ($return == 3) {
|
||||
session()->setFlashdata('error', 'File already uploaded');
|
||||
} else {
|
||||
session()->setFlashdata('error', $return);
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
}
|
||||
@ -707,6 +701,9 @@ class EmployeeController extends AdminController
|
||||
|
||||
public function viewUploadedEmployeeList()
|
||||
{
|
||||
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
|
||||
$file_id = $this->request->getGet('file_id');
|
||||
// $emp_data['employees'] = $this->employeePolicyModel->getViewEmpSuccessList($file_id);
|
||||
// $html = view('view_file_upload_emp_list', $emp_data);
|
||||
@ -718,20 +715,21 @@ class EmployeeController extends AdminController
|
||||
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
->where('files.id', $file_id)->first();
|
||||
|
||||
// dd($file_name);
|
||||
|
||||
try {
|
||||
|
||||
$filePath = WRITEPATH . '/uploads/excel/' . $file_name['file_name'];
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
// dd($excel_data);
|
||||
|
||||
$excel_data = $empDataServiceController->readExcelFileToArray($filePath);
|
||||
$emp_data['thead'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
$emp_data['tbody'] = $excel_data;
|
||||
$emp_data['count'] = count($excel_data);
|
||||
|
||||
// dd($emp_data);
|
||||
|
||||
$html = view('view_file_upload_emp_list', $emp_data);
|
||||
} else {
|
||||
@ -1210,6 +1208,7 @@ class EmployeeController extends AdminController
|
||||
$client_id = $file['client_id'];
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
$event_type = $file['event_type'];
|
||||
|
||||
$error_data = json_decode($file['error_data']);
|
||||
|
||||
@ -1225,8 +1224,10 @@ class EmployeeController extends AdminController
|
||||
$excel_data = $empDataServiceController->readExcelFileToArray($file_name_with_path);
|
||||
$excelErrorData['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
array_pop($excel_data);
|
||||
|
||||
if($event_type == 'inception' || $event_type == 'deletion'){
|
||||
array_pop($excel_data);
|
||||
}
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data as $key => $values) {
|
||||
@ -1242,15 +1243,22 @@ class EmployeeController extends AdminController
|
||||
|
||||
}else{
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
if($event_type == 'inception'){
|
||||
|
||||
$error = 'Expected value : TPA ID';
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
$error = 'Expected value : UHID';
|
||||
$error = 'Expected value : TPA ID';
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
$error = 'Expected value : UHID';
|
||||
}
|
||||
|
||||
}else{
|
||||
$error = 'Expected value : ENDORSEMENT ID';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$data = ['value' => $excel_data[$row][$column], 'error' => $error,];
|
||||
$excel_data[$row][$column] = $data;
|
||||
|
||||
@ -16,10 +16,22 @@ class JobWorker extends AdminController
|
||||
|
||||
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'], 'employeesOnboardPreprocess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeeDisembark' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesSIEnhanceProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesCorrectionProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'send_email' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'bulk_mail' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'insertBatchList' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'importInceptionFileValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importInceptionUpdateTPAandUHID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'cashDepositCalculationForInception' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'sendMailForDownloadingECard' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'importCorrectionValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importCorrectionUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'cashDepositCalculationForSIEnhancement' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importSIEnhancementValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importSIEnhancementUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
|
||||
'cashDepositCalculationForDeletion' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importDeletionValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
'importDeletionUpdateEndorsementID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -143,7 +143,7 @@ class EmployeePolicyModel extends Model
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
'Has Define' as emp_type,
|
||||
employees.emp_type as emp_type,
|
||||
|
||||
employee_polices.id as primaryKey,
|
||||
employee_polices.tpa_id,
|
||||
@ -175,8 +175,13 @@ class EmployeePolicyModel extends Model
|
||||
) as batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '')
|
||||
AND employees.client_branch_id = '{$client_branch_id}'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employees.client_branch_id = '{$client_branch_id}'";
|
||||
AND employee_polices.status = 'active'
|
||||
AND employees.is_active = 1
|
||||
AND employees.emp_status = 'active'
|
||||
|
||||
";
|
||||
|
||||
// Get the result set
|
||||
$query = $this->db->query($sql);
|
||||
@ -209,7 +214,7 @@ class EmployeePolicyModel extends Model
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.client_id AS emp_client_id,
|
||||
'Has Define' AS emp_type,
|
||||
employees.emp_type as emp_type,
|
||||
employee_polices.uhid,
|
||||
employees.relationship_code,
|
||||
batch_data.emp_policy_id,
|
||||
@ -235,12 +240,16 @@ class EmployeePolicyModel extends Model
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON emp_endorsement.pk = batch_data.emp_policy_id
|
||||
|
||||
WHERE batch_data.bf IS NULL
|
||||
AND batch_data.bl IS NULL
|
||||
AND employees.client_id = '{$client_id}'
|
||||
WHERE employees.client_id = '{$client_id}'
|
||||
AND employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
AND employees.client_branch_id = '{$client_branch_id}'
|
||||
AND emp_endorsement.actions = 'c'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employee_polices.status = 'active'
|
||||
AND employees.is_active = 1
|
||||
AND employees.emp_status = 'active'
|
||||
AND (employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id != '')
|
||||
AND (employee_polices.uhid IS NOT NULL AND employee_polices.uhid != '')
|
||||
AND (emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')";
|
||||
|
||||
// Execute the raw query
|
||||
@ -265,13 +274,14 @@ class EmployeePolicyModel extends Model
|
||||
$query = $this->db->query("
|
||||
SELECT
|
||||
a.id as endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id AS primaryKey,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
'Has Define' AS emp_type,
|
||||
employees.emp_type as emp_type,
|
||||
employee_polices.uhid AS risk_id,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.policy_end_date,
|
||||
@ -283,10 +293,15 @@ class EmployeePolicyModel extends Model
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_si_premium,
|
||||
sidata.date_of_coverage,
|
||||
|
||||
DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
|
||||
sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium,
|
||||
|
||||
ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum,
|
||||
|
||||
ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
|
||||
((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total
|
||||
|
||||
FROM
|
||||
@ -346,14 +361,16 @@ class EmployeePolicyModel extends Model
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
WHERE
|
||||
batch_data.bf IS NULL
|
||||
AND batch_data.bl IS NULL
|
||||
AND employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
AND employees.client_branch_id = '{$client_policy_id}'
|
||||
AND employee_polices.is_active = '1'
|
||||
|
||||
WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
AND employees.client_branch_id = '{$client_branch_id}'
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
AND a.field_name = 'si_enhancement_date'
|
||||
AND a.actions = 'si'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employee_polices.status = 'active'
|
||||
AND employees.is_active = 1
|
||||
AND employees.emp_status = 'active'
|
||||
group by group_key
|
||||
");
|
||||
|
||||
// Get the result set
|
||||
@ -374,13 +391,14 @@ class EmployeePolicyModel extends Model
|
||||
$query = $this->db->query("
|
||||
SELECT DISTINCT
|
||||
a.id as endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id as primaryKey,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship AS emp_relationship,
|
||||
'Has Define' as emp_type,
|
||||
employees.emp_type as emp_type,
|
||||
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.uhid as risk_id,
|
||||
@ -404,7 +422,7 @@ class EmployeePolicyModel extends Model
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
employees ON a.emp_code = employees.emp_code
|
||||
employees ON a.emp_code = employees.emp_code and a.pk = employees.id
|
||||
LEFT JOIN
|
||||
employee_polices ON employees.id = employee_polices.employee_id
|
||||
|
||||
@ -439,16 +457,20 @@ class EmployeePolicyModel extends Model
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
WHERE
|
||||
batch_data.bf IS NULL
|
||||
AND batch_data.bl IS NULL
|
||||
AND employee_polices.client_policy_id = {$client_policy_id}
|
||||
|
||||
WHERE employee_polices.client_policy_id = {$client_policy_id}
|
||||
AND employees.client_branch_id = {$client_branch_id}
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
AND a.actions = 'd'
|
||||
AND employee_polices.is_active = 1
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '') AND a.field_name = 'status'
|
||||
AND employee_polices.status = 'active'
|
||||
AND employees.is_active = 1
|
||||
AND employees.emp_status = 'active'
|
||||
group by group_key
|
||||
");
|
||||
|
||||
$result = $query->getResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
@ -547,34 +569,62 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
public function fetchEmpEndorsementData($fetch_data)
|
||||
{
|
||||
// dd($fetch_data);
|
||||
|
||||
$client_policy_id = $fetch_data['client_policy_id'];
|
||||
$client_branch_id = $fetch_data['client_branch_id'];
|
||||
$emp_name = $fetch_data['emp_name'];
|
||||
$emp_code = $fetch_data['emp_code'];
|
||||
|
||||
// Your raw SQL query
|
||||
$sql = "
|
||||
SELECT
|
||||
ep.id,
|
||||
MAX(CASE WHEN ee.field_name = 'date_of_exit' THEN ee.new_value END) AS date_of_exit,
|
||||
MAX(CASE WHEN ee.field_name = 'reason_for_exit' THEN ee.new_value END) AS reason_for_exit,
|
||||
MAX(CASE WHEN ee.field_name = 'status' THEN ee.new_value END) AS status
|
||||
FROM
|
||||
emp_endorsement AS ee
|
||||
JOIN
|
||||
employee_polices AS ep ON ep.id = ee.pk
|
||||
WHERE
|
||||
ee.emp_code = '$emp_code'
|
||||
AND ep.client_policy_id = $client_policy_id
|
||||
AND ee.name = '$emp_name'
|
||||
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status')
|
||||
GROUP BY
|
||||
ee.emp_code, ee.name, ep.id";
|
||||
SELECT
|
||||
ee.id as emp_endorsement_primarykey,
|
||||
ep.id as emp_policy_primarykey,
|
||||
e.id as employees_primarykey,
|
||||
ee.group_key,
|
||||
MAX(
|
||||
CASE
|
||||
WHEN ee.field_name = 'date_of_exit' THEN ee.new_value
|
||||
END
|
||||
) AS date_of_exit,
|
||||
MAX(
|
||||
CASE
|
||||
WHEN ee.field_name = 'reason_for_exit' THEN ee.new_value
|
||||
END
|
||||
) AS reason_for_exit,
|
||||
MAX(
|
||||
CASE
|
||||
WHEN ee.field_name = 'status' THEN ee.new_value
|
||||
END
|
||||
) AS status
|
||||
FROM
|
||||
emp_endorsement AS ee
|
||||
JOIN employee_polices AS ep ON ep.id = ee.pk
|
||||
JOIN employees AS e ON e.emp_code = ee.emp_code
|
||||
WHERE
|
||||
ee.emp_code = '$emp_code'
|
||||
AND ep.client_policy_id = '$client_policy_id'
|
||||
AND e.client_branch_id = '$client_branch_id'
|
||||
AND ee.name = '$emp_name'
|
||||
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status')
|
||||
AND ep.is_active = 1
|
||||
AND ep.status = 'active'
|
||||
AND e.is_active = 1
|
||||
AND e.emp_status = 'active'
|
||||
GROUP BY
|
||||
ee.group_key
|
||||
";
|
||||
|
||||
// dd($sql);
|
||||
|
||||
// Execute the raw SQL query
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
// Fetch and return results
|
||||
return $row = $query->getRowArray();
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
@ -659,7 +709,7 @@ class EmployeePolicyModel extends Model
|
||||
$query2->join('insurers', 'insurers.id = policies.insurer_id');
|
||||
$query2->whereIn('e.actions', ['si', 'd']);
|
||||
$query2->where('ep.client_policy_id', $policy_id);
|
||||
$query2->where('employees.client_id', $policy_id);
|
||||
$query2->where('employees.client_id', $client_id);
|
||||
$query1->where('employees.client_branch_id', $branch_id);
|
||||
if($status != 0 && !empty($status)){
|
||||
|
||||
@ -931,7 +981,132 @@ class EmployeePolicyModel extends Model
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function bulkUpdateForEndorsement($endorsement_details)
|
||||
{
|
||||
|
||||
// Extract IDs, endorsement_ids, and statuses
|
||||
$ids = array_column($endorsement_details, 'group_key');
|
||||
$endorsement_ids = array_column($endorsement_details, 'endorsement_id');
|
||||
$statuses = array_column($endorsement_details, 'status');
|
||||
|
||||
// Escape values for SQL
|
||||
$escapedIds = array_map([$this->db, 'escape'], $ids);
|
||||
$escapedEndorsementIds = array_map([$this->db, 'escape'], $endorsement_ids);
|
||||
$escapedStatuses = array_map([$this->db, 'escape'], $statuses);
|
||||
|
||||
// Construct the CASE statements
|
||||
$caseEndorsementId = array_map(function ($id, $endorsement_id) {
|
||||
return "WHEN group_key = $id THEN $endorsement_id";
|
||||
}, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
$caseStatus = array_map(function ($id, $status) {
|
||||
return "WHEN status = $id THEN $status";
|
||||
}, $escapedIds, $escapedStatuses);
|
||||
|
||||
// Convert cases to a string
|
||||
$caseEndorsementIdString = implode(' ', $caseEndorsementId);
|
||||
$caseStatusString = implode(' ', $caseStatus);
|
||||
|
||||
// Convert ids to a string
|
||||
$idsString = implode(', ', $escapedIds);
|
||||
|
||||
// Construct the SQL query
|
||||
$sql = "
|
||||
UPDATE emp_endorsement
|
||||
SET
|
||||
endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
status = CASE {$caseStatusString} END
|
||||
WHERE group_key IN ({$idsString})
|
||||
";
|
||||
|
||||
// Begin a transaction
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
// Execute the query
|
||||
$this->db->query($sql);
|
||||
|
||||
// Commit the transaction
|
||||
if ($this->db->transStatus() === FALSE) {
|
||||
// If something went wrong, rollback
|
||||
$this->db->transRollback();
|
||||
throw new \Exception('Bulk update failed.');
|
||||
} else {
|
||||
// Otherwise, commit
|
||||
$this->db->transCommit();
|
||||
}
|
||||
|
||||
return $this->db->getLastQuery();
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction on error
|
||||
$this->db->transRollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function bulkUpdateForCorrection($emp_details){
|
||||
|
||||
foreach ($emp_details as $employee) {
|
||||
$id = $this->db->escape($employee['id']);
|
||||
$ids[] = $id;
|
||||
|
||||
foreach ($employee as $field => $value) {
|
||||
if ($field === 'id') continue;
|
||||
$escapedValue = $this->db->escape($value);
|
||||
|
||||
if (!isset($caseStatements[$field])) {
|
||||
$caseStatements[$field] = [];
|
||||
}
|
||||
|
||||
$caseStatements[$field][] = "WHEN id = $id THEN $escapedValue";
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the CASE strings
|
||||
$caseStrings = [];
|
||||
foreach ($caseStatements as $field => $cases) {
|
||||
$caseStrings[] = "$field = CASE " . implode(' ', $cases) . " END";
|
||||
}
|
||||
|
||||
// Convert ids to a string
|
||||
$idsString = implode(', ', $ids);
|
||||
|
||||
// Construct the SQL query
|
||||
$sql = "
|
||||
UPDATE employees
|
||||
SET " . implode(', ', $caseStrings) . "
|
||||
WHERE id IN ($idsString)
|
||||
";
|
||||
|
||||
// Begin a transaction
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
// Execute the query
|
||||
$this->db->query($sql);
|
||||
|
||||
// Commit the transaction
|
||||
if ($this->db->transStatus() === FALSE) {
|
||||
// If something went wrong, rollback
|
||||
$this->db->transRollback();
|
||||
throw new \Exception('Bulk update failed.');
|
||||
} else {
|
||||
// Otherwise, commit
|
||||
$this->db->transCommit();
|
||||
}
|
||||
|
||||
return $this->db->getLastQuery();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction on error
|
||||
$this->db->transRollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -14,7 +14,7 @@
|
||||
<th>Policy</th>
|
||||
<th>TPA</th>
|
||||
<th>Date</th>
|
||||
<th>Enrollment Status</th>
|
||||
<th>Enrollment <br> Status</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
@ -252,7 +252,7 @@
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${item.policy_name} (${item.policy_type_name})</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td>${(item.policy_start_date)} / <br> ${(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
@ -474,7 +474,7 @@
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${item.policy_name} (${item.policy_type_name})</td>
|
||||
<td>${tpaValue}</td>
|
||||
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
|
||||
<td>${rearrangeDateFormat(item.policy_start_date)} / <br> ${rearrangeDateFormat(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
|
||||
@ -20,8 +20,8 @@ option:disabled {
|
||||
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion1">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<form class="parsley-examples" id="emp-upload-form"
|
||||
action="<?php echo base_url().'employee/upload'?>" method="post">
|
||||
<form class="parsley-examples" id="emp-upload-form" action="<?php echo base_url().'employee/upload'?>" method="post" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>"
|
||||
id="csrf_token">
|
||||
|
||||
@ -38,14 +38,14 @@ option:disabled {
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Branch</label> <br />
|
||||
<select name="branch_id" class="form-control" id="branch_id">
|
||||
<select name="branch_id" class="form-control" id="branch_id" required>
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy</label> <br />
|
||||
<select name="policy_id" class="form-control" id="policy_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)">
|
||||
<select name="policy_id" class="form-control" id="policy_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)" required>
|
||||
<option value="0">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -214,7 +214,21 @@ $(document).ready(function() {
|
||||
// console.log('submit called');
|
||||
|
||||
|
||||
if(!checkValues()){
|
||||
|
||||
toastr.warning('Form is Empty', 'warning')
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$('#client_id').val()
|
||||
$('#policy_id').val()
|
||||
$('#branch_id').val()
|
||||
$('#upload-action-type').val()
|
||||
|
||||
var isValid = $('#emp-upload-form').parsley().validate();
|
||||
|
||||
console.log('isValid', isValid)
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return;
|
||||
@ -933,7 +947,7 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 300);
|
||||
|
||||
console.log('check policy responce', response);
|
||||
|
||||
@ -965,7 +979,7 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 300);
|
||||
// toastr.error('Something went wrong! Try Later', 'Error');
|
||||
console.error('Error fetching data from checkPolicyTermsAndRackRatesHasDefiend API:', error);
|
||||
return false;
|
||||
@ -976,5 +990,36 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
|
||||
}
|
||||
|
||||
|
||||
function checkValues() {
|
||||
|
||||
var clientId = $('#client_id').val();
|
||||
var policyId = $('#policy_id').val();
|
||||
var branchId = $('#branch_id').val();
|
||||
var uploadActionType = $('#upload-action-type').val();
|
||||
|
||||
if (!clientId || clientId == '0') {
|
||||
// alert('Client ID is empty or zero');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!policyId || policyId == '0') {
|
||||
// alert('Policy ID is empty or zero');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!branchId || branchId == '0') {
|
||||
// alert('Branch ID is empty or zero');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!uploadActionType || uploadActionType == '0') {
|
||||
// alert('Upload action type is empty or zero');
|
||||
return false;
|
||||
}
|
||||
|
||||
// If all values are valid, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
</script>
|
||||
@ -81,7 +81,7 @@
|
||||
class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<?php if($file['status'] == 'failed') { ?>
|
||||
<a data-id="<?= htmlspecialchars(json_encode($file)) ?>" data-toggle="modal"
|
||||
<a data-id="<?= htmlspecialchars(json_encode(['client_id' => $file['client_id'], 'client_policy_id' => $file['client_policy_id'], 'action' => $file['action']])) ?>" data-toggle="modal"
|
||||
data-target="#file-upload-modal" class="dropdown-item upload_button" href="#"><i
|
||||
class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
|
||||
<?php } ?>
|
||||
@ -136,7 +136,7 @@
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Reupload the file</h4>
|
||||
<h4 class="modal-title" id="myCenterModalLabel">ReUpload the file</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -158,7 +158,7 @@
|
||||
<script>
|
||||
$('body').on('click', '.view_emp_list', function() {
|
||||
|
||||
console.log('file_id');
|
||||
console.log('file_id', 'file_id');
|
||||
$('#emp_data_success').empty();
|
||||
$('#title').html(' ');
|
||||
var file_id = $(this).attr('data-id');
|
||||
|
||||
@ -902,6 +902,7 @@ $("#AdditionalGridForm").submit(function(event) {
|
||||
|
||||
if (!checkCheckboxes()) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
var isValid = $('#AdditionalGridForm').parsley().validate();
|
||||
@ -2648,12 +2649,11 @@ function createCheckboxes(obj, additional_relationship) {
|
||||
$.each(obj, function(key, value) {
|
||||
if (value > 0 && key != 'either-parents-pil') {
|
||||
const isChecked = additional_relationship && typeof additional_relationship === 'object' && additional_relationship[key] == 1 ? 'checked' : '';
|
||||
key = formatString(key);
|
||||
console.log('isChecked', isChecked);
|
||||
html += `
|
||||
<div class="col-2">
|
||||
<input class="relation_checkbox" type="checkbox" name="${key}" ${isChecked}>
|
||||
<label style="position: relative;left: 18px;bottom: 30px;">${key}</label>
|
||||
<label style="position: relative;left: 18px;bottom: 30px;">${formatString(key)}</label>
|
||||
</div>`;
|
||||
// console.log(html);
|
||||
}
|
||||
@ -2743,6 +2743,7 @@ $('#del_btn').click(function() {
|
||||
|
||||
|
||||
function checkCheckboxes() {
|
||||
|
||||
var checkboxes = $('input.relation_checkbox');
|
||||
var checkedCount = checkboxes.filter(':checked').length;
|
||||
var uncheckedCount = checkboxes.not(':checked').length;
|
||||
@ -2753,7 +2754,7 @@ function checkCheckboxes() {
|
||||
if (checkedCount < 1) {
|
||||
toastr.warning('You must select at least one checkbox.', 'Warning');
|
||||
return false;
|
||||
} else if (checkedCount != uncheckedCount) {
|
||||
} else if (checkedCount == uncheckedCount) {
|
||||
toastr.warning('You can not select all of the checkboxes', 'Waraning');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ table.dataTable tbody td {
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php for ($i = 1; $i <= count($tbody); $i++): ?>
|
||||
<?php for ($i = 1; $i <= $count; $i++): ?>
|
||||
<tr>
|
||||
<?php foreach ($tbody[$i] as $data): ?>
|
||||
<td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user