FIX_IMPORT_EXPORT_FILE_VALIDATION : RV
This commit is contained in:
parent
1dac89b628
commit
cf0b9525d3
@ -220,6 +220,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("full-excel-error-file/(:any)", "EmployeeController::downloadFullExcelErrorFile/$1");
|
||||
$routes->get("id-card", "EmployeeController::viewECard/$1");
|
||||
$routes->get("preview-card/(:any)", "EmployeeController::previewTemplate/$1");
|
||||
$routes->get("export-import-error-list/(:any)", "EmployeeController::errorListExportImport/$1");
|
||||
});
|
||||
|
||||
$routes->cli('cli/processjob', 'JobWorker::processJob');
|
||||
|
||||
@ -22,8 +22,10 @@ use App\Models\EmpEndorsementModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
use App\Controllers\JobWorker;
|
||||
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
// use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as SpreadsheetReaderException;
|
||||
@ -93,6 +95,19 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
public function insertBatchList($params){
|
||||
|
||||
foreach ($params['batch_list_data'] as $value) {
|
||||
|
||||
$batch_list_data['batch_code'] = $params['batch_code'];
|
||||
$batch_list_data['emp_policy_id'] = $value['primaryKey'];
|
||||
$batch_list_data['created_by'] = get_session_userid();
|
||||
$this->batchListModel->insert($batch_list_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates an Excel file for Inception_Addititon_DependentAddititon, Correction, SI_Enhancement and Deletion events based on given export data.
|
||||
*
|
||||
@ -107,23 +122,31 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
public function generateExcelForAdditionandInception($export_data)
|
||||
{
|
||||
|
||||
$return = $this->removeOldExportInfoFromBatchFile($export_data);
|
||||
|
||||
// Fetch employee data for export from the database
|
||||
$objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
|
||||
|
||||
|
||||
$insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
|
||||
|
||||
$cash_balance = $this->clientDepositModel->where('client_id',$export_data['client_id'] )->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
|
||||
|
||||
|
||||
$cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
|
||||
|
||||
|
||||
$totals = 0;
|
||||
foreach ($objects as $key => $value) {
|
||||
|
||||
|
||||
$totals += $value->total;
|
||||
}
|
||||
|
||||
if((int) $cash_balance['balance'] < (int) $totals){
|
||||
if (!empty($cash_balance)) {
|
||||
|
||||
return 0;
|
||||
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -131,6 +154,7 @@ class EmpDataServiceController extends BaseController
|
||||
$count = count($objects);
|
||||
$export_data['count'] = $count;
|
||||
$export_data['amount'] = $totals;
|
||||
$export_data['status'] = 'success';
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Inception export data count : {data}', ['data' => $count]);
|
||||
@ -177,11 +201,27 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// If Excel generation is successful
|
||||
if ($success) {
|
||||
|
||||
|
||||
// Batch files and list entry
|
||||
$return = $this->batchFilesAndBatchListEntry($export_data, $objects);
|
||||
// $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
|
||||
|
||||
$random_number_count = 4;
|
||||
$export_data['batch_code'] = generate_random_string($random_number_count);
|
||||
$export_data['created_by'] = get_session_userid();
|
||||
|
||||
$insert = $this->batchFileModel->insert($export_data);
|
||||
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
|
||||
$batch_code = $batch_file_batch_code['batch_code'];
|
||||
|
||||
// $this->insertBatchList(['batch_code' => $batch_code, 'batch_list_data' => $objects ]);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'insertBatchList','payload' => ['batch_code' => $batch_code, 'batch_list_data' => $objects ]]);
|
||||
|
||||
|
||||
// If batch operation is successful
|
||||
if ($return) {
|
||||
if (true) {
|
||||
// Set headers for Excel file download
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
|
||||
@ -195,7 +235,9 @@ class EmpDataServiceController extends BaseController
|
||||
fclose($tempFile);
|
||||
|
||||
return true; // Excel file successfully generated and exported
|
||||
|
||||
} else {
|
||||
|
||||
return false; // Batch operation failed
|
||||
}
|
||||
}
|
||||
@ -289,7 +331,7 @@ class EmpDataServiceController extends BaseController
|
||||
$ids = [];
|
||||
$objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
|
||||
|
||||
|
||||
|
||||
$totals = 0;
|
||||
foreach ($objects as $obj) {
|
||||
$ids[] = $obj->endorsement_primarykey;
|
||||
@ -395,7 +437,7 @@ class EmpDataServiceController extends BaseController
|
||||
$count = count($objects);
|
||||
$export_data['count'] = $count;
|
||||
$export_data['amount'] = $rounded_totals;
|
||||
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Deletion export data count : {data}', ['data' => $count]);
|
||||
|
||||
@ -490,181 +532,467 @@ class EmpDataServiceController extends BaseController
|
||||
public function importExcelDataForInception($import_data)
|
||||
{
|
||||
|
||||
$client_id = $import_data['client_id'];
|
||||
$client_policy_id = $import_data['client_policy_id'];
|
||||
$file = $import_data['file'];
|
||||
|
||||
$data = $this->readExcelToArray($file);
|
||||
|
||||
if (!$data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unset($data[0]);
|
||||
array_pop($data);
|
||||
$count = count($data);
|
||||
|
||||
$missing_id = [];
|
||||
$empty_emp_tpa_uh_ids = [];
|
||||
$totals = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if ($import_data['insurer_or_tpa'] == 'tpa') {
|
||||
|
||||
if ($value[15] === null) {
|
||||
$missing_id[] = $key + 1;
|
||||
}
|
||||
} else if ($import_data['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
if ($value[16] === null) {
|
||||
$missing_id[] = $key + 1;
|
||||
}
|
||||
}
|
||||
|
||||
$emp_code = $value[2];
|
||||
$name = $value[1];
|
||||
$totals += $value[20];
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// Execute the query
|
||||
$query = $db->table('employee_polices');
|
||||
$query->select('employee_polices.id');
|
||||
$query->join('employees', 'employees.id = employee_polices.employee_id');
|
||||
$query->where('employee_polices.client_policy_id', $client_policy_id);
|
||||
$query->where('employees.client_id', $client_id);
|
||||
$query->where('employees.name', $name);
|
||||
$query->where('employees.emp_code', $emp_code);
|
||||
if ($import_data['insurer_or_tpa'] == 'tpa') {
|
||||
|
||||
$query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")');
|
||||
} else if ($import_data['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
$query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")');
|
||||
}
|
||||
$query->where('employee_polices.is_active', 1);
|
||||
$query->limit(1);
|
||||
|
||||
// Get the result
|
||||
$result = $query->get()->getRowArray();
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
$empty_emp_tpa_uh_ids[] = $result['id'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$missing_id_count = count($missing_id);
|
||||
$empty_id_count = count($empty_emp_tpa_uh_ids);
|
||||
|
||||
|
||||
if ($import_data['insurer_or_tpa'] == 'tpa') {
|
||||
|
||||
if ($empty_id_count == 0) {
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ($missing_id_count != 0) {
|
||||
|
||||
return 2;
|
||||
}
|
||||
} else if ($import_data['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
if ($empty_id_count == 0) {
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
if ($missing_id_count != 0) {
|
||||
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
// if ($missing_id_count != $count) {
|
||||
|
||||
// return 2;
|
||||
// }
|
||||
|
||||
|
||||
// if ($empty_emp_tpa_uh_ids != $count) {
|
||||
|
||||
// return 3;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// dd($empty_emp_tpa_uh_ids);
|
||||
|
||||
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
|
||||
$filename = $file->getName();
|
||||
$this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
|
||||
|
||||
$import_data['count'] = $count;
|
||||
|
||||
$random_number_count = 4;
|
||||
$import_data['batch_code'] = generate_random_string($random_number_count);
|
||||
$import_data['created_by'] = get_session_userid();
|
||||
$import_data['status'] = 'pending';
|
||||
$import_data['file_name'] = $filename;
|
||||
$import_data['amount'] = $totals;
|
||||
|
||||
$insert = $this->batchFileModel->insert($import_data);
|
||||
|
||||
$this->insertBatchFileAndBatchListForImportExcel($import_data, $empty_emp_tpa_uh_ids);
|
||||
|
||||
// dd($import_data, $empty_emp_tpa_uh_ids);
|
||||
|
||||
|
||||
$tpa_id = [];
|
||||
$uhid = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$tpa_id[] = $value[15];
|
||||
$uhid[] = $value[16];
|
||||
}
|
||||
|
||||
foreach ($empty_emp_tpa_uh_ids as $key => $id) {
|
||||
|
||||
$dataToUpdateTPAID = ['tpa_id' => $tpa_id[$key]];
|
||||
$dataToUpdateUHID = ['uhid' => $uhid[$key]];
|
||||
|
||||
$this->employeePolicyModel->where('id', $id)
|
||||
->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")')
|
||||
->set($dataToUpdateTPAID)->update();
|
||||
|
||||
$this->employeePolicyModel->where('id', $id)
|
||||
->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")')
|
||||
->set($dataToUpdateUHID)->update();
|
||||
}
|
||||
|
||||
|
||||
if($import_data['insurer_or_tpa'] == 'tpa'){
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
$depositeData = [
|
||||
'employeeIds' => $empty_emp_tpa_uh_ids,
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'count' => $count,
|
||||
'event' => $import_data['event_type'],
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
];
|
||||
|
||||
$this->cashDepositCalculationForInception($depositeData);
|
||||
|
||||
|
||||
$this->sendMailForDownloadingECard($empty_emp_tpa_uh_ids);
|
||||
|
||||
}
|
||||
$file_id['file_id'] = $insert;
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importInceptionFileValidation','payload' => ['file_id' => $insert]]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public function importInceptionFileValidation($params)
|
||||
{
|
||||
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->batchFileModel->where('id', $file_id)->first();
|
||||
$client_id = $file['client_id'];
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$batch_code = $file['batch_code'];
|
||||
|
||||
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
$id = 'tpa_id';
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
$id = 'uhid';
|
||||
}
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
$excel_data = $this->readExcelFileToArray($file_name_with_path);
|
||||
unset($excel_data[0]);
|
||||
array_pop($excel_data);
|
||||
|
||||
$emp_count = count($excel_data);
|
||||
|
||||
$employee_data = $this->employeePolicyModel
|
||||
->select('
|
||||
|
||||
employee_polices.id as emp_policy_id,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
"Has Define" as emp_type,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.date_coverage,
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.change_event AS change_event,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.days,
|
||||
employee_polices.tpa_id,
|
||||
employee_polices.uhid,
|
||||
employee_polices.premium,
|
||||
employee_polices.rata_premimum,
|
||||
employee_polices.gst,
|
||||
(employee_polices.rata_premimum + employee_polices.gst) AS total
|
||||
')
|
||||
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employees.client_id', $client_id)
|
||||
->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''")
|
||||
->findAll();
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($employee_data); die;
|
||||
|
||||
|
||||
if ($employee_data == null || empty($employee_data)) {
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
$data = [
|
||||
'status' => 'failed-1',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
|
||||
return 3;
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
$data = [
|
||||
'status' => 'failed-2',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
$excel_data_count = count($excel_data);
|
||||
$emp_data_count = count($employee_data);
|
||||
|
||||
// dd($excel_data_count, $emp_data_count);
|
||||
$difference = $emp_data_count - $excel_data_count;
|
||||
|
||||
$status = 'in-progress';
|
||||
if ($excel_data_count < $emp_data_count) {
|
||||
|
||||
$status = 'in-progress-partially';
|
||||
$partially_updated_data = 'Expected : ' . $emp_data_count . ', ' . 'Updated : ' . $excel_data_count . ', ' . 'difference : ' . $difference;
|
||||
}
|
||||
|
||||
|
||||
if ($emp_data_count < $excel_data_count) {
|
||||
|
||||
$data = [
|
||||
'status' => 'failed-3',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
return 6;
|
||||
}
|
||||
|
||||
|
||||
$errors = []; // Initialize an array to store errors
|
||||
$missing_id = [];
|
||||
$batch_list_id = [];
|
||||
|
||||
foreach ($employee_data as $key => $emp_value) {
|
||||
|
||||
$key = $key + 1;
|
||||
|
||||
if(!isset($excel_data[$key])){
|
||||
break;
|
||||
}
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
if ($excel_data[$key][15] === null) {
|
||||
$missing_id[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 15,
|
||||
];
|
||||
}
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
if ($excel_data[$key][16] === null) {
|
||||
$missing_id[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 16,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($emp_value['emp_name'] != $excel_data[$key][1]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 1,
|
||||
'db_data' => $emp_value['emp_name'],
|
||||
'excel_data' => $excel_data[$key][1]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['emp_code'] != $excel_data[$key][2]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 2,
|
||||
'db_data' => $emp_value['emp_code'],
|
||||
'excel_data' => $excel_data[$key][2]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['emp_dob'] != $excel_data[$key][5]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 5,
|
||||
'db_data' => $emp_value['emp_dob'],
|
||||
'excel_data' => $excel_data[$key][5]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['emp_gender'] != $excel_data[$key][6]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 6,
|
||||
'db_data' => $emp_value['emp_gender'],
|
||||
'excel_data' => $excel_data[$key][6]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['pre_existing_alignments'] != $excel_data[$key][7]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 7,
|
||||
'db_data' => $emp_value['pre_existing_alignments'],
|
||||
'excel_data' => $excel_data[$key][7]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['basic_cover_si'] != $excel_data[$key][8]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 8,
|
||||
'db_data' => $emp_value['basic_cover_si'],
|
||||
'excel_data' => $excel_data[$key][8]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['emp_relationship'] != $excel_data[$key][11]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 11,
|
||||
'db_data' => $emp_value['emp_relationship'],
|
||||
'excel_data' => $excel_data[$key][11]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['policy_end_date'] != $excel_data[$key][13]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 13,
|
||||
'db_data' => $emp_value['policy_end_date'],
|
||||
'excel_data' => $excel_data[$key][13]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['days'] != $excel_data[$key][14]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 14,
|
||||
'db_data' => $emp_value['days'],
|
||||
'excel_data' => $excel_data[$key][14]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['premium'] != $excel_data[$key][17]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 17,
|
||||
'db_data' => $emp_value['premium'],
|
||||
'excel_data' => $excel_data[$key][17]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['rata_premimum'] != $excel_data[$key][18]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 18,
|
||||
'db_data' => $emp_value['rata_premimum'],
|
||||
'excel_data' => $excel_data[$key][18]
|
||||
];
|
||||
}
|
||||
|
||||
if ($emp_value['gst'] != $excel_data[$key][19]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 19,
|
||||
'db_data' => $emp_value['gst'],
|
||||
'excel_data' => $excel_data[$key][19]
|
||||
];
|
||||
}
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
if ($emp_value['uhid'] != $excel_data[$key][16]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 16,
|
||||
'db_data' => $emp_value['uhid'],
|
||||
'excel_data' => $excel_data[$key][16]
|
||||
];
|
||||
}
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
if ($emp_value['tpa_id'] != $excel_data[$key][15]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 15,
|
||||
'db_data' => $emp_value['tpa_id'],
|
||||
'excel_data' => $excel_data[$key][15]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$batch_list_id[] = $emp_value['emp_policy_id'];
|
||||
}
|
||||
|
||||
|
||||
$error_count = count($errors);
|
||||
$json_errors = json_encode($errors);
|
||||
|
||||
// echo $json_errors; die;
|
||||
|
||||
$missing_id_count = count($missing_id);
|
||||
$json_missing_id = json_encode($missing_id);
|
||||
|
||||
// dd($error_count, $missing_id_count, $json_errors, $json_missing_id);
|
||||
|
||||
// dd($batch_list_id);
|
||||
|
||||
if ($missing_id_count > 0) {
|
||||
|
||||
$data = [
|
||||
'error_data' => $json_missing_id,
|
||||
'status' => 'failed',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
return 2;
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($error_count > 0) {
|
||||
|
||||
$data = [
|
||||
'error_data' => $json_errors,
|
||||
'status' => 'failed',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
|
||||
$data = [
|
||||
'count' => $emp_count,
|
||||
'status' => $status,
|
||||
'error_data' => $partially_updated_data ?? null,
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
|
||||
|
||||
foreach ($batch_list_id as $key => $value) {
|
||||
|
||||
$data = [
|
||||
'emp_policy_id' => $value,
|
||||
'batch_code' => $batch_code,
|
||||
];
|
||||
|
||||
$insert = $this->batchListModel->insert($data);
|
||||
}
|
||||
|
||||
|
||||
$parameters['file_id'] = $file_id;
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importInceptionUpdateTPAandUHID','payload' => ['file_id' => $file_id]]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function importInceptionUpdateTPAandUHID($params)
|
||||
{
|
||||
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->batchFileModel->find($file_id);
|
||||
if (!$file) {
|
||||
$data = [
|
||||
'status' => 'failed-4',
|
||||
];
|
||||
|
||||
$this->batchFileModel->where('id', $file_id)->set($data)->update();
|
||||
return 0; // Return error code if file not found
|
||||
}
|
||||
|
||||
$client_id = $file['client_id'];
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
$status = $file['status'];
|
||||
$batch_code = $file['batch_code'];
|
||||
|
||||
$status_val = 'success';
|
||||
if($status == 'in-progress-partially'){
|
||||
|
||||
$status_val = 'partially success';
|
||||
}
|
||||
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
$excel_data = $this->readExcelFileToArray($file_name_with_path);
|
||||
unset($excel_data[0]); // Remove header row
|
||||
array_pop($excel_data); // Remove footer row
|
||||
|
||||
$totals = 0;
|
||||
$emp_count = count($excel_data);
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
foreach ($excel_data as $key => $value) {
|
||||
|
||||
$name = $value[1];
|
||||
$emp_code = $value[2];
|
||||
$tpa_id = $value[15];
|
||||
$uhid = $value[16];
|
||||
$amount = $value[20];
|
||||
|
||||
$totals += $amount;
|
||||
|
||||
$sql = "
|
||||
UPDATE employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id
|
||||
SET tpa_id = ?
|
||||
WHERE employees.name = ?
|
||||
AND employees.emp_code = ?
|
||||
AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = '')";
|
||||
|
||||
$params = [$tpa_id, $name, $emp_code];
|
||||
$db->query($sql, $params);
|
||||
|
||||
|
||||
|
||||
$sql = "
|
||||
UPDATE employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id
|
||||
SET employee_polices.uhid = ?
|
||||
WHERE employees.name = ?
|
||||
AND employees.emp_code = ?
|
||||
AND (employee_polices.uhid IS NULL OR employee_polices.uhid = '')";
|
||||
|
||||
$params = [$uhid, $name, $emp_code];
|
||||
$db->query($sql, $params);
|
||||
}
|
||||
|
||||
// Update batch file status and amount
|
||||
$this->batchFileModel->update($file_id, [
|
||||
'count' => $emp_count,
|
||||
'status' => $status_val,
|
||||
'amount' => $totals,
|
||||
]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function importExcelDataForCorrection($import_data)
|
||||
{
|
||||
|
||||
@ -1046,7 +1374,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$missing_id = [];
|
||||
$empty_emp_tpa_uh_ids = [];
|
||||
$totals = 0 ;
|
||||
$totals = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
try {
|
||||
@ -1545,15 +1873,15 @@ class EmpDataServiceController extends BaseController
|
||||
{
|
||||
if ($file->isValid() && !$file->hasMoved()) {
|
||||
$file = $file;
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$reader = IOFactory::createReaderForFile($file->getPathname());
|
||||
$spreadsheet = $reader->load($file->getPathname());
|
||||
|
||||
|
||||
// Get the active sheet
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
|
||||
// Iterate through rows to read data
|
||||
$data = [];
|
||||
foreach ($sheet->getRowIterator() as $row) {
|
||||
@ -1563,9 +1891,8 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
$data[] = $rowData;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
return $data;
|
||||
} catch (SpreadsheetReaderException $e) {
|
||||
|
||||
error_log('PhpSpreadsheet reader exception: ' . $e->getMessage());
|
||||
@ -1575,7 +1902,7 @@ class EmpDataServiceController extends BaseController
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function insertBatchFileAndBatchListForImportExcel($data, $ids)
|
||||
@ -1605,7 +1932,7 @@ class EmpDataServiceController extends BaseController
|
||||
{
|
||||
try {
|
||||
foreach ($ids as $key => $id) {
|
||||
|
||||
|
||||
$get_emp_email_and_other_details = $this->employeePolicyModel
|
||||
->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate, employees.name, employees.id as employee_id, employees.emp_code employee_polices.rand_string, employee_polices.tpa_id')
|
||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
@ -1614,9 +1941,9 @@ class EmpDataServiceController extends BaseController
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.is_active', '1')
|
||||
->where('employee_polices.id', $id)->first();
|
||||
|
||||
|
||||
if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "") {
|
||||
|
||||
|
||||
$employee_id = $get_emp_email_and_other_details['employee_id'];
|
||||
$name = $get_emp_email_and_other_details['name'];
|
||||
$emp_code = $get_emp_email_and_other_details['name'];
|
||||
@ -1625,18 +1952,18 @@ class EmpDataServiceController extends BaseController
|
||||
$tpa_id = $get_emp_email_and_other_details['tpa_id'];
|
||||
$link = generate_download_link($rand_string);
|
||||
$subject = 'Download E-Card';
|
||||
|
||||
|
||||
$html = '<body>
|
||||
<p>Dear ' .$name .',</p>
|
||||
<p>Your Policy( ' .$tpa_id .' ) has been successfully created. Please click the link below to download the insurance card:</p>
|
||||
<p><a href="'.$link.'">Download Insurance Card</a></p>
|
||||
<p>Dear ' . $name . ',</p>
|
||||
<p>Your Policy( ' . $tpa_id . ' ) has been successfully created. Please click the link below to download the insurance card:</p>
|
||||
<p><a href="' . $link . '">Download Insurance Card</a></p>
|
||||
<p>Thank you,</p>
|
||||
</body>';
|
||||
|
||||
|
||||
|
||||
|
||||
if ($email != null && $email != "") {
|
||||
|
||||
|
||||
$mail_data = [
|
||||
'mail' => $email,
|
||||
'subject' => $subject,
|
||||
@ -1644,29 +1971,25 @@ class EmpDataServiceController extends BaseController
|
||||
];
|
||||
|
||||
// dd($mail_data);
|
||||
|
||||
|
||||
$result = Mailhelper::send_email($mail_data);
|
||||
$decoded_result = (array) json_decode($result);
|
||||
|
||||
$data = [
|
||||
'status' => $decoded_result['status'],
|
||||
'message'=>$decoded_result['message'] ?? 'Internal Server Error',
|
||||
'status' => $decoded_result['status'],
|
||||
'message' => $decoded_result['message'] ?? 'Internal Server Error',
|
||||
'email' => $decoded_result['data']
|
||||
];
|
||||
|
||||
|
||||
// dd($data);
|
||||
$this->myLogger->logme('error', 'status : {status}, message : {message}, email : {email}', $data);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$this->myLogger->log('error', 'The employee (primaryKey : {id}, Name : {name}, Emp Code : {emp_code} ) has no corporate email.', ['id' => $employee_id, 'name' => $name, 'emp_code' => $emp_code]);
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$this->myLogger->log('error', 'The employee policy ID ( {id} ) has no active policy or the employee is not active.', ['id' => $id]);
|
||||
|
||||
}
|
||||
}
|
||||
return true; // Email(s) sent successfully
|
||||
@ -1677,4 +2000,48 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function readExcelFileToArray($path)
|
||||
{
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
|
||||
return $excel_data;
|
||||
}
|
||||
|
||||
|
||||
public function removeOldExportInfoFromBatchFile($params){
|
||||
|
||||
$client_id = $params['client_id'];
|
||||
$client_policy_id = $params['client_policy_id'];
|
||||
$insurer_or_tpa = $params['insurer_or_tpa'];
|
||||
$event_type = $params['event_type'];
|
||||
$actions = $params['actions'];
|
||||
|
||||
|
||||
$batch_data = $this->batchFileModel
|
||||
->where('client_id', $client_id)
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('insurer_or_tpa', $insurer_or_tpa)
|
||||
->where('event_type', $event_type)
|
||||
->where('actions', $actions)
|
||||
->first();
|
||||
|
||||
if(!empty($batch_data)){
|
||||
|
||||
$id = $batch_data['id'];
|
||||
$batch_code = $batch_data['batch_code'];
|
||||
|
||||
$this->batchFileModel->where('id', $id)->delete();
|
||||
$this->batchListModel->where('batch_code', $batch_code)->delete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ class EmployeeController extends AdminController
|
||||
|
||||
if($return == 0){
|
||||
|
||||
session()->setFlashdata('error', "The insurer has an insufficient deposit amount.");
|
||||
session()->setFlashdata('error', "Insufficient deposit amount.");
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
@ -396,12 +396,35 @@ class EmployeeController extends AdminController
|
||||
} else if ($actions == 'import') {
|
||||
|
||||
$batch_data['file'] = $this->request->getFile('import_file_data');
|
||||
|
||||
|
||||
if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') {
|
||||
|
||||
$return = $empDataServiceController->importExcelDataForInception($batch_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;
|
||||
|
||||
$file_id = $this->batchFileModel->insert($batch_data);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'importInceptionFileValidation','payload' => ['file_id' => $file_id]]);
|
||||
|
||||
$return = 1;
|
||||
|
||||
// $return = $empDataServiceController->importExcelDataForInception($batch_data);
|
||||
|
||||
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 TPA ID column is either partially or entirely empty.');
|
||||
@ -418,6 +441,9 @@ class EmployeeController extends AdminController
|
||||
} 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.');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
} else if ($event_type == 'correction') {
|
||||
|
||||
@ -714,7 +740,8 @@ class EmployeeController extends AdminController
|
||||
if (!file_exists($filePath)) {
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
|
||||
return $error_message;
|
||||
$data['message'] = 'Physical File Not Found';
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
|
||||
// Load the Excel file
|
||||
@ -1037,4 +1064,81 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function errorListExportImport($file_id)
|
||||
{
|
||||
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
|
||||
$file = $this->batchFileModel->where('id', $file_id)->first();
|
||||
$client_id = $file['client_id'];
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
|
||||
$error_data = json_decode($file['error_data']);
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error', ($error_message . ' for file id ' . $file_id));
|
||||
$data['message'] = 'Physical File Not Found';
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
|
||||
$excel_data = $empDataServiceController->readExcelFileToArray($file_name_with_path);
|
||||
$excelErrorData['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
array_pop($excel_data);
|
||||
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data as $key => $values) {
|
||||
|
||||
foreach ($values as $key2 => $value) {
|
||||
|
||||
$row = $value->row;
|
||||
$column = $value->column;
|
||||
|
||||
if(property_exists($value, 'db_data')){
|
||||
|
||||
$error = 'Expected value: ' . ($value->db_data == null || $value->db_data == "" ? 'NULL' : $value->db_data);
|
||||
|
||||
}else{
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
|
||||
$error = 'Expected value : TPA ID';
|
||||
|
||||
} else if ($insurer_or_tpa == 'insurer') {
|
||||
|
||||
$error = 'Expected value : UHID';
|
||||
}
|
||||
|
||||
}
|
||||
$data = ['value' => $excel_data[$row][$column], 'error' => $error,];
|
||||
$excel_data[$row][$column] = $data;
|
||||
}
|
||||
|
||||
array_push($finalArray, $excel_data[$key]);
|
||||
}
|
||||
|
||||
|
||||
foreach ($finalArray as $fkey => $value) {
|
||||
foreach ($value as $vkey => $arrayData) {
|
||||
if (!is_array($arrayData)) {
|
||||
$data = ['value' => $arrayData];
|
||||
$finalArray[$fkey][$vkey] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $finalArray;
|
||||
$excelErrorData['file_id'] = $file_id;
|
||||
|
||||
// dd($finalArray);
|
||||
|
||||
echo view('export_import_error_list', $excelErrorData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,7 +14,11 @@ 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'],'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']];
|
||||
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'],
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
// echo 'HiC';//die();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<style>
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
@ -27,29 +27,51 @@
|
||||
<th class="font-weight-medium">Action</th>
|
||||
<th class="font-weight-medium">Count</th>
|
||||
<th class="font-weight-medium">Amount</th>
|
||||
<th class="font-weight-medium">status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if(isset($batch_list))
|
||||
{
|
||||
foreach ($batch_list as $key => $file) {
|
||||
<?php
|
||||
if (isset($batch_list)) {
|
||||
foreach ($batch_list as $key => $file) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><b><?php echo ($key + 1)?></b></td>
|
||||
<td><?php echo $file['batch_code']?></td>
|
||||
<td data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>" ><?php echo strlen($file['file_name']) > 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?></td>
|
||||
<td><?php echo $file['client_short_name']?></td>
|
||||
<td><?php echo $file['policy_name']?></td>
|
||||
<td><?php echo $file['event_type']?></td>
|
||||
<td><?php echo $file['insurer_or_tpa']?></td>
|
||||
<td><?php echo $file['actions']?></td>
|
||||
<td><?php echo $file['count']?></td>
|
||||
<td><?php echo $file['amount']?></td>
|
||||
</tr>
|
||||
<?php }}?>
|
||||
<tr>
|
||||
<td><b><?php echo ($key + 1) ?></b></td>
|
||||
<td><?php echo $file['batch_code'] ?></td>
|
||||
<td data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>"><?php echo strlen($file['file_name']) > 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?></td>
|
||||
<td><?php echo $file['client_short_name'] ?></td>
|
||||
<td><?php echo $file['policy_name'] ?></td>
|
||||
<td><?php echo $file['event_type'] ?></td>
|
||||
<td><?php echo $file['insurer_or_tpa'] ?></td>
|
||||
<td><?php echo $file['actions'] ?></td>
|
||||
<td><?php echo $file['count'] ?></td>
|
||||
<td><?php echo intval($file['amount']) ?></td>
|
||||
<td>
|
||||
<?php if ($file['status'] == 'failed') { ?>
|
||||
<?php echo $file['status']; ?> <a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>" class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank" data-toggle="tooltip" data-placement="top" title="Click to show the error"></a>
|
||||
<?php } else if ($file['status'] == 'partially success') { ?>
|
||||
<?php echo $file['status']; ?>
|
||||
<?php if ($file['error_data'] != 0) { ?>
|
||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||
<?php } ?>
|
||||
<?php } else if ($file['status'] == 'failed-1') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="The list of employees provided has already been updated with the TPA ID."></a>
|
||||
<?php } else if ($file['status'] == 'failed-2') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="The list of employees provided has already been updated with the UHID."></a>
|
||||
<?php } else if ($file['status'] == 'failed-3') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="The Excel record count exceeds the DB record count."></a>
|
||||
<?php } else if ($file['status'] == 'failed-4') { ?>
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="Physical File Not Found."></a>
|
||||
<?php } else { ?>
|
||||
<?php echo $file['status']; ?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -59,31 +81,31 @@
|
||||
</div><!-- end col -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#datatable-buttons').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Batch List',
|
||||
className: 'my_class',
|
||||
}],
|
||||
initComplete: function(settings, json) {
|
||||
$('.my_class').css({
|
||||
position: "relative",
|
||||
left: "50px"
|
||||
});
|
||||
},
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true
|
||||
});
|
||||
|
||||
|
||||
$('#datatable-buttons').DataTable({
|
||||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Batch List',
|
||||
className: 'my_class',
|
||||
}],
|
||||
initComplete: function(settings, json) {
|
||||
$('.my_class').css({
|
||||
position: "relative",
|
||||
left: "50px"
|
||||
});
|
||||
},
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search..."
|
||||
},
|
||||
paging: true
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
134
app/Views/export_import_error_list.php
Normal file
134
app/Views/export_import_error_list.php
Normal file
@ -0,0 +1,134 @@
|
||||
<link rel="shortcut icon" href="<?= base_url()."public"; ?>/assets/images/Nhance_Favi.svg">
|
||||
<title>Excel Error Report</title>
|
||||
<!-- Include DataTables CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
|
||||
<!-- Include DataTables Buttons CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.3.0/css/buttons.dataTables.min.css">
|
||||
<!-- Include Font Awesome CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
|
||||
<style>
|
||||
/* Table styles */
|
||||
.table {
|
||||
width: 100%;
|
||||
border: 2px solid #ddd;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table th, .table td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background-color: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.table tr:nth-child(even) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.error-tooltip {
|
||||
display: none;
|
||||
/* Hide error message by default */
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.error-icon {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.error-icon:hover+.error-tooltip {
|
||||
display: block;
|
||||
/* Show error message when hovering over the icon */
|
||||
}
|
||||
|
||||
/* .error-cell {
|
||||
border: 2px solid red !important;
|
||||
} */
|
||||
|
||||
/* .container{
|
||||
position: relative;
|
||||
bottom: 150px;
|
||||
} */
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- <button><a href="">download full file</a></button> -->
|
||||
<div class="container">
|
||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<?php foreach ($excel_header as $header): ?>
|
||||
<th><?php echo $header; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($i = 0; $i < count($excel_data); $i++): ?>
|
||||
<tr>
|
||||
<?php foreach ($excel_data[$i] as $data): ?>
|
||||
<td <?php if (isset($data['error'])) echo 'class="error-cell"'; ?>>
|
||||
<?php
|
||||
if (isset($data['value'])) {
|
||||
echo $data['value'];
|
||||
}
|
||||
if (isset($data['error'])) {
|
||||
echo '<span class="error-icon"> <i class="fas fa-exclamation-circle" style="color: red;"></i></span>';
|
||||
echo '<span class="error-tooltip">' . $data['error'] . '</span>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Include jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<!-- Include DataTables JavaScript -->
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<!-- Include DataTables Buttons JavaScript -->
|
||||
<script src="https://cdn.datatables.net/buttons/2.3.0/js/dataTables.buttons.min.js"></script>
|
||||
<!-- Include DataTables JSZip library -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<!-- Include DataTables Buttons HTML5 export extension -->
|
||||
<script src="https://cdn.datatables.net/buttons/2.3.0/js/buttons.html5.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tickets-table').DataTable({
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel', // Set the title for the Excel button
|
||||
title: 'ExcelErrorData', // Set your custom title here
|
||||
},
|
||||
// {
|
||||
// text: 'Excel Error', // Set the text for the custom button
|
||||
// action: function (e, dt, node, config) {
|
||||
// window.location.href = '<?= base_url("util/full-excel-error-file/") . $file_id ?>';
|
||||
// }
|
||||
// }
|
||||
],
|
||||
paging: false, // Disable pagination
|
||||
lengthMenu: [[-1], ["All"]] // Display all rows
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user