FEAT_ECARD_FROM_TPA_INTEGRATION
This commit is contained in:
parent
3067ce676f
commit
2a352ef945
@ -51,16 +51,31 @@ class ApiServiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// E-Card Request
|
// E-Card Request
|
||||||
public function ecardRequest()
|
public function ecardRequest($params = [], $return_type = 'api')
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
if(empty($params) && $this->response){
|
||||||
|
|
||||||
$payload = $this->request->getJSON(true);
|
$payload = $this->request->getJSON(true);
|
||||||
$id = $payload['id'] ?? null;
|
$id = $payload['id'] ?? null;
|
||||||
$emp_code = $payload['emp_code'] ?? null;
|
$emp_code = $payload['emp_code'] ?? null;
|
||||||
$client_policy_id = $payload['client_policy_id'] ?? null;
|
$client_policy_id = $payload['client_policy_id'] ?? null;
|
||||||
$policy_no = $payload['policy_no'] ?? null;
|
$policy_no = $payload['policy_no'] ?? null;
|
||||||
|
$type = $payload['type'] ?? 'download';
|
||||||
|
log_message('error', 'Received Payload API : '. json_encode($payload ?? ""));
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$id = $params['id'] ?? null;
|
||||||
|
$emp_code = $params['emp_code'] ?? null;
|
||||||
|
$client_policy_id = $params['client_policy_id'] ?? null;
|
||||||
|
$policy_no = $params['policy_no'] ?? null;
|
||||||
|
$type = $params['type'] ?? 'download';
|
||||||
|
|
||||||
|
log_message('error', 'Received Payload INTERNAL : '. json_encode($params ?? ""));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$employee_policy = $this->employeePolicyModel
|
$employee_policy = $this->employeePolicyModel
|
||||||
->select('employees.*, employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid , client_policy.tpa_id as tpa_primary_id ')
|
->select('employees.*, employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid , client_policy.tpa_id as tpa_primary_id ')
|
||||||
@ -71,7 +86,6 @@ class ApiServiceController extends BaseController
|
|||||||
->where('employee_polices.is_active', 1 )->findAll();
|
->where('employee_polices.is_active', 1 )->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(count($employee_policy) > 0)
|
if(count($employee_policy) > 0)
|
||||||
{
|
{
|
||||||
if($employee_policy[0]['tpa_id'] != null)
|
if($employee_policy[0]['tpa_id'] != null)
|
||||||
@ -81,21 +95,33 @@ class ApiServiceController extends BaseController
|
|||||||
$mediAssistController = new MediAssistApiController();
|
$mediAssistController = new MediAssistApiController();
|
||||||
$data['eCardDownload'] = $mediAssistController->EcardRequest( $emp_code, $policy_no );
|
$data['eCardDownload'] = $mediAssistController->EcardRequest( $emp_code, $policy_no );
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
if($type == "download"){
|
||||||
|
// direct download
|
||||||
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
|
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
|
||||||
|
}else{
|
||||||
|
// view and download
|
||||||
|
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$data['message'] = "E-card generated";
|
$data['message'] = "E-card generated";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$data['eCardDownload'] = null;
|
$data['eCardDownload'] = null;
|
||||||
$data['message'] = "E-card not generated";
|
$data['message'] = "E-card not generated";
|
||||||
|
log_message('error', 'TPA number is null');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$data['eCardDownload'] = null;
|
$data['eCardDownload'] = null;
|
||||||
$data['message'] = "E-card not generated";
|
$data['message'] = "E-card not generated";
|
||||||
|
log_message('error', 'Employee not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($return_type == 'api'){
|
||||||
return $this->respond(['status' => true, 'code' => 200, 'message' => '', 'data' => $data]);
|
return $this->respond(['status' => true, 'code' => 200, 'message' => '', 'data' => $data]);
|
||||||
|
}else{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
} catch(\Exception $e){
|
} catch(\Exception $e){
|
||||||
|
|
||||||
@ -136,7 +162,7 @@ class ApiServiceController extends BaseController
|
|||||||
'created_by'=> get_session_userid(),
|
'created_by'=> get_session_userid(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($tpa_id == 1) // MediAssist
|
if ($tpa_id == 2) // MediAssist
|
||||||
{
|
{
|
||||||
$file_id = $fileModel->insert($data);
|
$file_id = $fileModel->insert($data);
|
||||||
log_message('error', "Files table inserted successfully, File id : {$file_id}");
|
log_message('error', "Files table inserted successfully, File id : {$file_id}");
|
||||||
|
|||||||
@ -4934,6 +4934,7 @@ class EmpDataServiceController extends BaseController
|
|||||||
|
|
||||||
cp.policy_type_id,
|
cp.policy_type_id,
|
||||||
cp.is_addon,
|
cp.is_addon,
|
||||||
|
cp.policy_no,
|
||||||
|
|
||||||
employee_polices.id as emp_policy_id,
|
employee_polices.id as emp_policy_id,
|
||||||
employee_polices.client_policy_id,
|
employee_polices.client_policy_id,
|
||||||
@ -4960,6 +4961,11 @@ class EmpDataServiceController extends BaseController
|
|||||||
'notification' => $notification,
|
'notification' => $notification,
|
||||||
'client_data' => $client_data,
|
'client_data' => $client_data,
|
||||||
'get_emp_email_and_other_details' => $emp_details,
|
'get_emp_email_and_other_details' => $emp_details,
|
||||||
|
|
||||||
|
'id' => $emp_details['emp_id'],
|
||||||
|
'emp_code' => $emp_details['emp_code'],
|
||||||
|
'policy_no' => $emp_details['policy_no'],
|
||||||
|
'client_policy_id' => $emp_details['client_policy_id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$params['common'] = [
|
$params['common'] = [
|
||||||
|
|||||||
@ -126,7 +126,8 @@ class sendMailNotification
|
|||||||
|
|
||||||
$subject = $cleanedText;
|
$subject = $cleanedText;
|
||||||
|
|
||||||
$link = generate_download_link($rand_string).'/1';
|
// $link = generate_download_link($rand_string).'/1';
|
||||||
|
$link = generate_ecard_download_link_based_on_tpa($params);
|
||||||
|
|
||||||
$app_link = $_ENV['App_Url'];
|
$app_link = $_ENV['App_Url'];
|
||||||
$name = $get_emp_email_and_other_details['name'];
|
$name = $get_emp_email_and_other_details['name'];
|
||||||
|
|||||||
@ -5,6 +5,7 @@ use App\Models\FileModel;
|
|||||||
use App\Models\BatchFileModelFileModel;
|
use App\Models\BatchFileModelFileModel;
|
||||||
use App\Controllers\GoogleDriveController;
|
use App\Controllers\GoogleDriveController;
|
||||||
use App\Models\BatchFileModel;
|
use App\Models\BatchFileModel;
|
||||||
|
use App\Controllers\ApiServiceController;
|
||||||
|
|
||||||
// File: app/Helpers/Uuid_helper.php
|
// File: app/Helpers/Uuid_helper.php
|
||||||
|
|
||||||
@ -926,3 +927,20 @@ if (!function_exists('getMimeTypeByFileName')) {
|
|||||||
return $mime_types[$ext] ?? 'application/octet-stream'; // default fallback
|
return $mime_types[$ext] ?? 'application/octet-stream'; // default fallback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('generate_ecard_download_link_based_on_tpa')) {
|
||||||
|
|
||||||
|
function generate_ecard_download_link_based_on_tpa($params) {
|
||||||
|
|
||||||
|
$apiServiceController = new ApiServiceController();
|
||||||
|
$data = $apiServiceController->ecardRequest($params, $return_type = 'internal');
|
||||||
|
log_message('error', 'E-card request call from the helper for mail send');
|
||||||
|
|
||||||
|
if(isset($data['eCardDownload']) && !empty($data['eCardDownload'])){
|
||||||
|
return $data['eCardDownload'];
|
||||||
|
}else{
|
||||||
|
return $data['message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -195,7 +195,8 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] . "/0/1" ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
<!-- <a href="<?= base_url('download-e-card/'). $employee['rand_string'] . "/0/1" ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a> -->
|
||||||
|
<a class="dropdown-item" onclick="viewEcard(<?= $employee['employee_id'] ?>, '<?= $employee['emp_code'] ?>', <?= $employee['client_policy_id'] ?>, '<?= $employee['policy_no'] ?>')"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if($employee['relationship'] == 'Self' && in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php if($employee['relationship'] == 'Self' && in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
@ -586,25 +587,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// function validateInput(input, table, field){
|
|
||||||
|
|
||||||
// let value = $(input).val();
|
|
||||||
// let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
|
||||||
|
|
||||||
// let message = "Value is duplicate!";
|
|
||||||
// if(label){
|
|
||||||
// message = label + " already exists!";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
|
||||||
// if (isDuplicate) {
|
|
||||||
// toastr.warning(message, 'WARNING');
|
|
||||||
// $(input).val('')
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
function validateInput(input, table, field) {
|
function validateInput(input, table, field) {
|
||||||
|
|
||||||
let emp_code = $('#emp_code_for_edit').val();
|
let emp_code = $('#emp_code_for_edit').val();
|
||||||
@ -739,12 +721,51 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// function closeModal(){
|
function viewEcard(emp_id, emp_code, policy_id, policy_no){
|
||||||
// var myModalEl = document.getElementById('emp_history_modal');
|
|
||||||
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
|
console.log({emp_id, emp_code, policy_id, policy_no});
|
||||||
// if (modalInstance) {
|
|
||||||
// modalInstance.hide();
|
let url_type = 'view';
|
||||||
// }
|
let url = '<?= base_url('ecardRequest') ?>';
|
||||||
// }
|
|
||||||
|
// Data to send in the AJAX request
|
||||||
|
let requestData = {
|
||||||
|
id: emp_id,
|
||||||
|
emp_code: emp_code,
|
||||||
|
client_policy_id: policy_id,
|
||||||
|
policy_no: policy_no,
|
||||||
|
type: url_type,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert to JSON
|
||||||
|
let jsonData = JSON.stringify(requestData);
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
// Send AJAX request
|
||||||
|
sendAjaxRequestForGlobal(url, 'POST', jsonData, function(response) {
|
||||||
|
|
||||||
|
console.log('Data fetched successfully:', response);
|
||||||
|
|
||||||
|
if (response.status == true && response.data.eCardDownload) {
|
||||||
|
console.log(response.data.message || 'Initiating successafully', 'SUCCESS');
|
||||||
|
const newTab = window.open(response.data.eCardDownload, '_blank');
|
||||||
|
if (newTab) newTab.focus();
|
||||||
|
} else {
|
||||||
|
toastr.error(response.data.message || 'Unable to fetch e-card', 'ERROR');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
}, function(xhr, status, error) {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user