diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 84dfb6b3..c8adbcbb 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -2334,47 +2334,60 @@ class TicketController extends BaseController { $data = $this->request->getPost(); + $get_file_data = $this->request->getFiles('file_upload') ?? []; + $ticket_id = $data['ticket_id_url']; - $insertArr = []; + if(empty($get_file_data)){ - foreach ($data['docs_name'] as $key => $eachData) { + $insertArr = []; - if (!empty($eachData)) { + foreach ($data['docs_name'] as $key => $eachData) { - $insertData = [ - 'doc_name' => $data['docs_name'][$key] ?? '', - 'url' => $data['url'][$key] ?? '', - 'ticket_id' => $data['ticket_id_url'] ?? '', - 'created_by' => get_session_userid(), - 'is_active' => 1, - 'file_type' => 1 - ]; + if (!empty($eachData)) { - $insertArr[] = $insertData; + $insertData = [ + 'doc_name' => $data['docs_name'][$key] ?? '', + 'url' => $data['url'][$key] ?? '', + 'ticket_id' => $data['ticket_id_url'] ?? '', + 'created_by' => get_session_userid(), + 'is_active' => 1, + 'file_type' => 1 + ]; + + $insertArr[] = $insertData; + } } - } - if (!empty($insertArr)) { - // Insert into database - $insert = $this->claimFilesModel->insertBatch($insertArr); - } + if (!empty($insertArr)) { + // Insert into database + $insert = $this->claimFilesModel->insertBatch($insertArr); + } - - if (isset($insert) && !empty($insert)) { - - if (isset($data['ticket_id_url']) && !empty($data['ticket_id_url'])) { - // this call for TPA integration - $ticket_id = $data['ticket_id_url']; - $apiServiceController = new ApiServiceController(); - $apiServiceController->pushClaims($ticket_id); - log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Ticket Controller while claim file upload"); + if (isset($insert) && !empty($insert)) { + return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); } else { - log_message('error', "Failed to call the pushClaims function in TicketController during claim file upload because the ticket id was not found."); + return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); + } + }else{ + + $get_docs_name = $data['docs_name']; + $file_data = []; + if(isset($get_file_data) && !empty($get_file_data)){ + $file_path = WRITEPATH . 'uploads/claim_files/'; + $file_data = multi_file_Upload($get_file_data, $file_path, $get_docs_name); } - return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); - } else { - return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); + if(!empty($file_data)){ + $employeeRest = new EmployeeRestController(); + $result = $employeeRest->handleCliamFiles($file_data, $ticket_id); + if(!empty($result)){ + return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); + }else{ + return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); + } + }else{ + return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); + } } } @@ -2391,10 +2404,17 @@ class TicketController extends BaseController } $urlData = $this->claimFilesModel - ->where('ticket_id', $ticket_id) - ->where('is_active',1) - ->where('file_type',1) - ->findAll(); + ->select(" + *, + CASE + WHEN file_type = 2 AND url IS NOT NULL AND url != '' + THEN CONCAT('" . base_url('downloadClaimFile/') . "', id) + ELSE url + END AS url + ") + ->where('ticket_id', $ticket_id) + ->where('is_active', 1) + ->findAll(); return $this->response->setJSON([ 'status' => true, diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 04cc5ba5..dd4de7df 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -133,7 +133,8 @@ if (!function_exists('multi_file_Upload')) { $uploadedFiles[] = [ 'file_name' => $fileName, 'doc_name' => $docs_name[$index] ?? $fileName, - 'file_path' => $filepath . $fileRandomName + // 'file_path' => $filepath . $fileRandomName + 'file_path' => $fileRandomName ]; } } diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 0b5eab77..31888578 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -19,16 +19,17 @@
-
-
- - + Add + + +
@@ -39,7 +40,6 @@
-
@@ -112,6 +112,7 @@ diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index 2c9406cb..b3d0a502 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -484,13 +484,26 @@ if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){ $("#event_type").removeAttr("multiple"); $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } $("#event_type").select2('destroy'); } }) $('#event_type').on('change', function() { + var selectedVal = $(this).val(); - // console.log(selectedVal); + var insurer_or_tpa = $('#insurer_or_tpa').val() + var action_type = $('#action_type').val() + + console.log({tpa_api_sevice, selectedVal, insurer_or_tpa, action_type}); + + if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (selectedVal == 'correction' || selectedVal == 'deletion' || selectedVal == 'si_enhancement')) { + $('.fetch_tpa').hide(); + } else { + $('.fetch_tpa').show(); + } if (selectedVal === 'correction') { $('#policy').prop('required', false); @@ -502,12 +515,137 @@ console.log('tpa_api_sevice', tpa_api_sevice); console.log('tpa_api_sevice type', typeof tpa_api_sevice); + }); - if (tpa_api_sevice == 0 || (selectedVal == 'correction' || selectedVal == 'deletion' || selectedVal == 'si_enhancement')) { + $('#insurer_or_tpa').on('change', function() { + + var insurer_or_tpa = $(this).val() + var policy_value = $('#policy').val() + var event_type_data = $('#event_type_data').val(); + var action_type = $('#action_type').val() + var event_string = $('#event_type').val(); + + console.log({tpa_api_sevice, insurer_or_tpa, policy_value, event_type_data, action_type, event_string}); + + if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (event_string == 'correction' || event_string == 'deletion' || event_string == 'si_enhancement')) { $('.fetch_tpa').hide(); } else { $('.fetch_tpa').show(); } + + // if(insurer_or_tpa == 'tpa' || event_type_data == 0){ + if(insurer_or_tpa == 'tpa'){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + }else if(insurer_or_tpa == 'insurer' && action_type == 'import'){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + }else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){ + + $("#event_type").attr("multiple", "multiple"); + $("#event_type").attr("name", "event_type[]"); + $("#event_type").select2(); + + }else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + }else{ + if(policy_value != 0){ + $("#event_type").attr("multiple", "multiple"); + $("#event_type").attr("name", "event_type[]"); + $("#event_type").select2(); + } + } + }); + + $('#action_type').on('change', function() { + + var action_type = $(this).val() + var policy_value = $('#policy').val() + var insurer_or_tpa = $('#insurer_or_tpa').val() + var event_string = $('#event_type').val(); + var event_type_data = $('#event_type_data').val(); + + console.log({tpa_api_sevice, action_type, policy_value, insurer_or_tpa, event_string, event_type_data}) + + if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (event_string == 'correction' || event_string == 'deletion' || event_string == 'si_enhancement')) { + $('.fetch_tpa').hide(); + } else { + $('.fetch_tpa').show(); + } + + if(action_type == 'import'){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + } else if(action_type == 'export' && insurer_or_tpa == 'tpa'){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + }else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){ + + $("#event_type").attr("multiple", "multiple"); + $("#event_type").attr("name", "event_type[]"); + $("#event_type").select2(); + + }else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){ + + $("#event_type").removeAttr("multiple"); + $("#event_type").attr("name", "event_type"); + if ($.fn.select2 && $('#event_type').data('select2')) { + $('#event_type').select2('destroy'); + } + $("#event_type").select2('destroy'); + + }else{ + if(policy_value != 0){ + $("#event_type").attr("multiple", "multiple"); + $("#event_type").attr("name", "event_type[]"); + $("#event_type").select2(); + } + } + }); + + /**This function updates the download link based on the selected option in the dropdown menu. **/ + $('#event_type').on('change', function() { + + var selectedValue = $(this).val(); + if (selectedValue !== '') { + $('#import_excel_download').show(); + var fullURL = '' + selectedValue; + $('#import_excel_download').attr('href', fullURL); + } else { + $('#import_excel_download').hide(); + $('#import_excel_download').removeAttr('href'); + } }); $('#action_type').on('change', function() { @@ -538,120 +676,6 @@ } }); - $('#insurer_or_tpa').on('change', function() { - - var insurer_or_tpa = $(this).val() - var policy_value = $('#policy').val() - var event_type_data = $('#event_type_data').val(); - var action_type = $('#action_type').val() - var event_type_data = $('#event_type_data').val(); - - console.log('policy_value', policy_value) - - // if(insurer_or_tpa == 'tpa' || event_type_data == 0){ - if(insurer_or_tpa == 'tpa'){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - }else if(insurer_or_tpa == 'insurer' && action_type == 'import'){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - }else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){ - - $("#event_type").attr("multiple", "multiple"); - $("#event_type").attr("name", "event_type[]"); - $("#event_type").select2(); - - }else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - }else{ - if(policy_value != 0){ - $("#event_type").attr("multiple", "multiple"); - $("#event_type").attr("name", "event_type[]"); - $("#event_type").select2(); - } - } - - if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") { - $('.fetch_tpa').hide(); - } else { - $('.fetch_tpa').show(); - } - }); - - $('#action_type').on('change', function() { - - var action_type = $(this).val() - var policy_value = $('#policy').val() - var insurer_or_tpa = $('#insurer_or_tpa').val() - - var event_type_data = $('#event_type_data').val(); - - console.log('policy_value', policy_value) - // if(insurer_or_tpa == 'import' || event_type_data == 0){ - - if(action_type == 'import'){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - } else if(action_type == 'export' && insurer_or_tpa == 'tpa'){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - }else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){ - - $("#event_type").attr("multiple", "multiple"); - $("#event_type").attr("name", "event_type[]"); - $("#event_type").select2(); - - }else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){ - - $("#event_type").removeAttr("multiple"); - $("#event_type").attr("name", "event_type"); - $("#event_type").select2('destroy'); - - }else{ - if(policy_value != 0){ - $("#event_type").attr("multiple", "multiple"); - $("#event_type").attr("name", "event_type[]"); - $("#event_type").select2(); - } - } - - if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") { - $('.fetch_tpa').hide(); - } else { - $('.fetch_tpa').show(); - } - }); - - /**This function updates the download link based on the selected option in the dropdown menu. **/ - $('#event_type').on('change', function() { - - var selectedValue = $(this).val(); - if (selectedValue !== '') { - $('#import_excel_download').show(); - var fullURL = '' + selectedValue; - $('#import_excel_download').attr('href', fullURL); - } else { - $('#import_excel_download').hide(); - $('#import_excel_download').removeAttr('href'); - } - }); - }); // Function to convert object to query parameters