'FEAT_EMP_MODULE_EXCEL_ERROR_DOWNLOAD_FULL_FILE_RV'
This commit is contained in:
parent
c14541e3d3
commit
b6f3d97608
@ -216,6 +216,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){
|
|||||||
$routes->get("view-success-emp-list", "EmployeeController::viewUploadedEmployeeList/$1");
|
$routes->get("view-success-emp-list", "EmployeeController::viewUploadedEmployeeList/$1");
|
||||||
$routes->get("fetch-policy-for-policy-type", "ClientController::fetchPolicyDataForPolicyType/$1");
|
$routes->get("fetch-policy-for-policy-type", "ClientController::fetchPolicyDataForPolicyType/$1");
|
||||||
$routes->get("fetch-emp-count/(:any)", "EmployeeController::getEmpCount/$1");
|
$routes->get("fetch-emp-count/(:any)", "EmployeeController::getEmpCount/$1");
|
||||||
|
$routes->get("init-Emp-onboard/(:any)", "EmployeeController::initiateManualEmployeesOnboardProcess/$1");
|
||||||
|
$routes->get("full-excel-error-file/(:any)", "EmployeeController::downloadFullExcelErrorFile/$1");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -490,7 +490,7 @@ class EmpDataServiceController extends BaseController
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($value[15] === null) {
|
if ($value[15] === null || $value[16] === null) {
|
||||||
$missing_id[] = $key + 1;
|
$missing_id[] = $key + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,8 @@ use App\Controllers\EmpDataServiceController;
|
|||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
|
|
||||||
class EmployeeController extends AdminController
|
class EmployeeController extends AdminController
|
||||||
{
|
{
|
||||||
@ -248,6 +250,7 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
// Render views and capture output
|
// Render views and capture output
|
||||||
$result = $empServiceController->getExcelErrorData($file_id);
|
$result = $empServiceController->getExcelErrorData($file_id);
|
||||||
|
$result['file_id'] = $file_id;
|
||||||
|
|
||||||
// echo '<pre>';
|
// echo '<pre>';
|
||||||
// print_r($result); die;
|
// print_r($result); die;
|
||||||
@ -565,9 +568,20 @@ class EmployeeController extends AdminController
|
|||||||
// client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB
|
// client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB
|
||||||
public function initiateManualEmployeesOnboardProcess($client_policy_id)
|
public function initiateManualEmployeesOnboardProcess($client_policy_id)
|
||||||
{
|
{
|
||||||
|
$client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name')
|
||||||
|
->join('clients', 'clients.id = client_policy.client_id')
|
||||||
|
->join('policies', 'policies.id = client_policy.policy_id')
|
||||||
|
->where('client_policy.id', $client_policy_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
$empServiceController = new EmployeeServiceController();
|
$empServiceController = new EmployeeServiceController();
|
||||||
$res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
|
$res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
|
||||||
dd($res);
|
// dd($res);
|
||||||
|
|
||||||
|
$count = count($res);
|
||||||
|
$message = $count . ' Employees are Initiate Onboard Process againts Client '. $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name'] ;
|
||||||
|
session()->setFlashdata('success1', $message);
|
||||||
|
return redirect()->to(base_url('/employee/upload'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -665,9 +679,9 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
public function getEmpCount($id = null){
|
public function getEmpCount($id = null){
|
||||||
|
|
||||||
$data = $this->employeeModel->select('employees.id')
|
$data = $this->employeePolicyModel->select('employee_polices.id')
|
||||||
->join('clients', 'clients.id = employees.client_id')
|
->where('employee_polices.is_active', 1)
|
||||||
->where('employees.client_id', $id)
|
->where('employee_polices.client_policy_id', $id)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$emp_count = count($data);
|
$emp_count = count($data);
|
||||||
@ -684,4 +698,119 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadFullExcelErrorFile($file_id = 137, $rowIndex = 1, $colIndex = 1)
|
||||||
|
{
|
||||||
|
// Get file data from the database
|
||||||
|
$file_data = $this->fileModel->find($file_id);
|
||||||
|
|
||||||
|
$error = json_decode($file_data['reason']);
|
||||||
|
// echo '<pre>';
|
||||||
|
// print_r($error); die;
|
||||||
|
// dd($error);
|
||||||
|
|
||||||
|
// Check if the file exists
|
||||||
|
if (!$file_data) {
|
||||||
|
$error_message = "File not found";
|
||||||
|
$this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
|
||||||
|
return $error_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = $file_data['file_name'];
|
||||||
|
$filePath = WRITEPATH . '/uploads/excel/' . $fileName;
|
||||||
|
|
||||||
|
// Check if the file exists
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
$error_message = "File not found";
|
||||||
|
$this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
|
||||||
|
return $error_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Excel file
|
||||||
|
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
|
||||||
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// echo '<pre>';
|
||||||
|
|
||||||
|
foreach ($error->error_data as $index => $error_data) {
|
||||||
|
|
||||||
|
$rowIndex = $index+1;
|
||||||
|
|
||||||
|
if( $error->error_type == 1 ){
|
||||||
|
|
||||||
|
foreach ($error_data as $key => $value) {
|
||||||
|
|
||||||
|
$colIndex = $value->col_idx+1;
|
||||||
|
|
||||||
|
$originalValue = $sheet->getCell([$colIndex, $rowIndex])->getValue();
|
||||||
|
|
||||||
|
$newValue = implode(', ',$value->error);
|
||||||
|
$val = $originalValue . ' ( ' . $newValue . ' )';
|
||||||
|
$sheet->setCellValue([$colIndex, $rowIndex], $val);
|
||||||
|
|
||||||
|
$style = [
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => ['rgb' => 'ffad99'] // Red color
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
|
||||||
|
|
||||||
|
}
|
||||||
|
}else if( $error->error_type == 2){
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($error_data as $key => $value) {
|
||||||
|
|
||||||
|
|
||||||
|
$originalValue = $sheet->getCell([1, $rowIndex])->getValue();
|
||||||
|
|
||||||
|
$newValue = implode(', ',$value->error);
|
||||||
|
$val = $originalValue . ' ( ' . $newValue . ' )';
|
||||||
|
$sheet->setCellValue([$colIndex, $rowIndex], $val);
|
||||||
|
|
||||||
|
$style = [
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||||
|
'startColor' => ['rgb' => 'ffad99'] // Red color
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create a new filename for the modified Excel file
|
||||||
|
$newFileName = 'modified_' . $fileName;
|
||||||
|
|
||||||
|
// Save the modified Excel file to a new location
|
||||||
|
$newFilePath = WRITEPATH . '/uploads/excel/' . $newFileName;
|
||||||
|
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
|
||||||
|
$writer->save($newFilePath);
|
||||||
|
|
||||||
|
// Set headers to force download
|
||||||
|
$response = service('response');
|
||||||
|
$response->setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
|
$response->setHeader('Content-Disposition', 'attachment;filename="' . $newFileName . '"');
|
||||||
|
$response->setHeader('Cache-Control', 'max-age=0');
|
||||||
|
$response->setHeader('Content-Length', filesize($newFilePath));
|
||||||
|
$response->setBody(file_get_contents($newFilePath));
|
||||||
|
|
||||||
|
// Delete the temporary file
|
||||||
|
unlink($newFilePath);
|
||||||
|
|
||||||
|
// Return the response
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -568,7 +568,8 @@ class EmployeeServiceController extends AdminController
|
|||||||
|
|
||||||
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
|
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
|
||||||
|
|
||||||
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
|
// $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
|
||||||
|
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid()];
|
||||||
// dd($this->employeeModel->getLastQuery());
|
// dd($this->employeeModel->getLastQuery());
|
||||||
// Kint::dump($existing_famility_details);die();
|
// Kint::dump($existing_famility_details);die();
|
||||||
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
|
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
|
||||||
|
|||||||
@ -659,6 +659,7 @@ class EmployeePolicyModel extends Model
|
|||||||
->where('employee_polices.client_policy_id',$policy_id);
|
->where('employee_polices.client_policy_id',$policy_id);
|
||||||
|
|
||||||
$result->whereIn('employee_polices.status', ['draft', 'enrolled']);
|
$result->whereIn('employee_polices.status', ['draft', 'enrolled']);
|
||||||
|
$result->whereIn('emp.emp_status', ['draft', 'enrolled']);
|
||||||
$result = $result->findAll();
|
$result = $result->findAll();
|
||||||
return ($result);
|
return ($result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
<style>
|
||||||
|
|
||||||
|
option:disabled {
|
||||||
|
color: gray !important; /* Set text color to gray */
|
||||||
|
background-color: lightgray !important;}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<div class="tab-pane fade active show" id="general-q-tab">
|
<div class="tab-pane fade active show" id="general-q-tab">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -124,7 +131,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-primary">Save changes</button>
|
<a id="fetch_btn" class="btn btn-primary">Initiate Emp Onboard</a>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
@ -152,6 +159,10 @@
|
|||||||
$('#file_upload').hide();
|
$('#file_upload').hide();
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
<?php if (session()->has('success1')): ?>
|
||||||
|
toastr.success('<?= session()->getFlashdata('success1') ?>', 'success');
|
||||||
|
<?php endif; ?>
|
||||||
// Initialize select2
|
// Initialize select2
|
||||||
$("#client_id").select2();
|
$("#client_id").select2();
|
||||||
$("#policy_id").select2();
|
$("#policy_id").select2();
|
||||||
@ -478,10 +489,10 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('#client_id').on('change', function() {
|
$('#client_id').on('change', function() {
|
||||||
var selectedClient = $(this).val();
|
var selectedClient = $(this).val();
|
||||||
|
|
||||||
console.log('selectedClient', selectedClient);
|
console.log('selectedClient', selectedClient);
|
||||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||||||
|
|
||||||
|
|
||||||
// Check if the selected option exists in apiData
|
// Check if the selected option exists in apiData
|
||||||
var foundPolicies = clientPolicies.find(function(item) {
|
var foundPolicies = clientPolicies.find(function(item) {
|
||||||
return item.id === selectedClient;
|
return item.id === selectedClient;
|
||||||
@ -489,64 +500,6 @@ $(document).ready(function() {
|
|||||||
console.log(foundPolicies.policies);
|
console.log(foundPolicies.policies);
|
||||||
appendPolicies(foundPolicies.policies);
|
appendPolicies(foundPolicies.policies);
|
||||||
|
|
||||||
var apiURL = '<?php echo base_url();?>' + 'util/fetch-emp-count/' + selectedClient;
|
|
||||||
console.log(apiURL);
|
|
||||||
$.ajax({
|
|
||||||
url: apiURL,
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
|
|
||||||
console.log('responce data emp_count', response);
|
|
||||||
|
|
||||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
|
||||||
try {
|
|
||||||
console.log(response.emp_count.length)
|
|
||||||
if(response.emp_count > 0){
|
|
||||||
|
|
||||||
var select = document.getElementById("upload-action-type");
|
|
||||||
for (var i = 0; i < select.options.length; i++) {
|
|
||||||
if (select.options[i].value === "inception") {
|
|
||||||
select.options[i].disabled = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
|
|
||||||
var select = document.getElementById("upload-action-type");
|
|
||||||
for (var i = 0; i < select.options.length; i++) {
|
|
||||||
if (select.options[i].value === "inception") {
|
|
||||||
select.options[i].disabled = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} 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);
|
|
||||||
var select = document.getElementById("upload-action-type");
|
|
||||||
for (var i = 0; i < select.options.length; i++) {
|
|
||||||
if (select.options[i].value === "inception") {
|
|
||||||
select.options[i].disabled = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -637,6 +590,12 @@ document.getElementById('toggleIcon1').addEventListener('click', function() {
|
|||||||
$('#fetch_enrolled_data').click(function()
|
$('#fetch_enrolled_data').click(function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var policy_id = $('#policy_id').val();
|
||||||
|
var uri = '<?= base_url('util/init-Emp-onboard/') ?>' + policy_id;
|
||||||
|
console.log(policy_id);
|
||||||
|
console.log(uri);
|
||||||
|
$('#fetch_btn').attr('href', uri);
|
||||||
|
|
||||||
$('#emp_data').empty();
|
$('#emp_data').empty();
|
||||||
var client_id = $('#client_id').val();
|
var client_id = $('#client_id').val();
|
||||||
var policy_id = $('#policy_id').val();
|
var policy_id = $('#policy_id').val();
|
||||||
@ -700,5 +659,75 @@ $('#fetch_enrolled_data').click(function()
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$('#policy_id').change(function(){
|
||||||
|
|
||||||
|
var selectedpolicy = $(this).val();
|
||||||
|
console.log('selectedpolicy',selectedpolicy)
|
||||||
|
|
||||||
|
var apiURL = '<?php echo base_url();?>' + 'util/fetch-emp-count/' + selectedpolicy;
|
||||||
|
console.log(apiURL);
|
||||||
|
$.ajax({
|
||||||
|
url: apiURL,
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
|
||||||
|
console.log('responce data emp_count', response);
|
||||||
|
|
||||||
|
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||||
|
try {
|
||||||
|
console.log(response.emp_count.length)
|
||||||
|
if(response.emp_count > 0){
|
||||||
|
|
||||||
|
var select = document.getElementById("upload-action-type");
|
||||||
|
for (var i = 0; i < select.options.length; i++) {
|
||||||
|
if (select.options[i].value === "inception") {
|
||||||
|
select.options[i].disabled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
var select = document.getElementById("upload-action-type");
|
||||||
|
for (var i = 0; i < select.options.length; i++) {
|
||||||
|
if (select.options[i].value === "inception") {
|
||||||
|
select.options[i].disabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} 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);
|
||||||
|
var select = document.getElementById("upload-action-type");
|
||||||
|
for (var i = 0; i < select.options.length; i++) {
|
||||||
|
if (select.options[i].value === "inception") {
|
||||||
|
select.options[i].disabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
</script>
|
</script>
|
||||||
@ -66,6 +66,7 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- <button><a href="">download full file</a></button> -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
|
<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">
|
<thead class="bg-light">
|
||||||
@ -118,6 +119,12 @@ $(document).ready(function() {
|
|||||||
extend: 'excel',
|
extend: 'excel',
|
||||||
text: 'Excel', // Set the title for the Excel button
|
text: 'Excel', // Set the title for the Excel button
|
||||||
title: 'ExcelErrorData', // Set your custom title here
|
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
|
paging: false, // Disable pagination
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user