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
|
||||
public function ecardRequest()
|
||||
public function ecardRequest($params = [], $return_type = 'api')
|
||||
{
|
||||
try{
|
||||
|
||||
$payload = $this->request->getJSON(true);
|
||||
$id = $payload['id'] ?? null;
|
||||
$emp_code = $payload['emp_code'] ?? null;
|
||||
$client_policy_id = $payload['client_policy_id'] ?? null;
|
||||
$policy_no = $payload['policy_no'] ?? null;
|
||||
if(empty($params) && $this->response){
|
||||
|
||||
$payload = $this->request->getJSON(true);
|
||||
$id = $payload['id'] ?? null;
|
||||
$emp_code = $payload['emp_code'] ?? null;
|
||||
$client_policy_id = $payload['client_policy_id'] ?? 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
|
||||
->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();
|
||||
|
||||
|
||||
|
||||
if(count($employee_policy) > 0)
|
||||
{
|
||||
if($employee_policy[0]['tpa_id'] != null)
|
||||
@ -81,21 +95,33 @@ class ApiServiceController extends BaseController
|
||||
$mediAssistController = new MediAssistApiController();
|
||||
$data['eCardDownload'] = $mediAssistController->EcardRequest( $emp_code, $policy_no );
|
||||
}else{
|
||||
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
|
||||
|
||||
if($type == "download"){
|
||||
// direct download
|
||||
$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";
|
||||
|
||||
} else {
|
||||
$data['eCardDownload'] = null;
|
||||
$data['message'] = "E-card not generated";
|
||||
log_message('error', 'TPA number is null');
|
||||
}
|
||||
}else{
|
||||
$data['eCardDownload'] = null;
|
||||
$data['message'] = "E-card not generated";
|
||||
log_message('error', 'Employee not found');
|
||||
}
|
||||
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => '', 'data' => $data]);
|
||||
if($return_type == 'api'){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => '', 'data' => $data]);
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
|
||||
} catch(\Exception $e){
|
||||
|
||||
@ -136,7 +162,7 @@ class ApiServiceController extends BaseController
|
||||
'created_by'=> get_session_userid(),
|
||||
];
|
||||
|
||||
if ($tpa_id == 1) // MediAssist
|
||||
if ($tpa_id == 2) // MediAssist
|
||||
{
|
||||
$file_id = $fileModel->insert($data);
|
||||
log_message('error', "Files table inserted successfully, File id : {$file_id}");
|
||||
|
||||
@ -4934,6 +4934,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
cp.policy_type_id,
|
||||
cp.is_addon,
|
||||
cp.policy_no,
|
||||
|
||||
employee_polices.id as emp_policy_id,
|
||||
employee_polices.client_policy_id,
|
||||
@ -4960,6 +4961,11 @@ class EmpDataServiceController extends BaseController
|
||||
'notification' => $notification,
|
||||
'client_data' => $client_data,
|
||||
'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'] = [
|
||||
|
||||
@ -126,7 +126,8 @@ class sendMailNotification
|
||||
|
||||
$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'];
|
||||
$name = $get_emp_email_and_other_details['name'];
|
||||
|
||||
@ -5,6 +5,7 @@ use App\Models\FileModel;
|
||||
use App\Models\BatchFileModelFileModel;
|
||||
use App\Controllers\GoogleDriveController;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Controllers\ApiServiceController;
|
||||
|
||||
// File: app/Helpers/Uuid_helper.php
|
||||
|
||||
@ -926,3 +927,20 @@ if (!function_exists('getMimeTypeByFileName')) {
|
||||
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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,81 +1,81 @@
|
||||
<style>
|
||||
.badge2 {
|
||||
box-shadow: none;
|
||||
}
|
||||
.badge2 {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.badge2-secondary2 {
|
||||
color: #fff;
|
||||
background-color: #187607;
|
||||
}
|
||||
.badge2-secondary2 {
|
||||
color: #fff;
|
||||
background-color: #187607;
|
||||
}
|
||||
|
||||
.badge2 {
|
||||
display: inline-block;
|
||||
padding: .25em .4em;
|
||||
font-size: 75%;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
border-radius: .25rem;
|
||||
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
||||
}
|
||||
.badge2 {
|
||||
display: inline-block;
|
||||
padding: .25em .4em;
|
||||
font-size: 75%;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
border-radius: .25rem;
|
||||
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.word-wrap {
|
||||
word-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
.word-wrap {
|
||||
word-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.dataTables_filter{
|
||||
position: absolute;
|
||||
}
|
||||
.dataTables_filter{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.readonly-select {
|
||||
pointer-events: none;
|
||||
background-color: #f0f0f0;
|
||||
color: #666;
|
||||
}
|
||||
.readonly-select {
|
||||
pointer-events: none;
|
||||
background-color: #f0f0f0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
/* Timeline Design */
|
||||
.timeline {
|
||||
position: relative;
|
||||
padding-left: 30px;
|
||||
border-left: 3px solid #007bff;
|
||||
}
|
||||
/* Timeline Design */
|
||||
.timeline {
|
||||
position: relative;
|
||||
padding-left: 30px;
|
||||
border-left: 3px solid #007bff;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
.timeline-item {
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.timeline-dot {
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: 5px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: #007bff;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.timeline-dot {
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: 5px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: #007bff;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.timeline-content {
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php $pro_rata_total = 0; $gst_total = 0 ?>
|
||||
@ -195,7 +195,8 @@
|
||||
<?php } ?>
|
||||
|
||||
<?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 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) {
|
||||
|
||||
let emp_code = $('#emp_code_for_edit').val();
|
||||
@ -739,12 +721,51 @@
|
||||
});
|
||||
}
|
||||
|
||||
// function closeModal(){
|
||||
// var myModalEl = document.getElementById('emp_history_modal');
|
||||
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
|
||||
// if (modalInstance) {
|
||||
// modalInstance.hide();
|
||||
// }
|
||||
// }
|
||||
function viewEcard(emp_id, emp_code, policy_id, policy_no){
|
||||
|
||||
console.log({emp_id, emp_code, policy_id, policy_no});
|
||||
|
||||
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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user