CHANGE_CLAIM_PUSH_CLAIM_FILE_UPLOAD

This commit is contained in:
VENKATESHWARAN 2025-11-06 18:33:16 +05:30
parent 54fb5576a1
commit ea7b5e807c
4 changed files with 270 additions and 165 deletions

View File

@ -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,

View File

@ -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
];
}
}

View File

@ -19,16 +19,17 @@
<div class="form-group">
<div id="dynamic-form-container">
<div align="right">
<a class="btn btn-primary waves-effect waves-light mr-1"
onclick="addHTMLInput(this)">
+ Add
<div id="dynamic-form-container">
<div align="right">
<a id="toggle-upload-btn" class="btn btn-info waves-effect waves-light mr-1" onclick="toggleUploadType(this)">
File Upload
</a>
<a class="btn btn-primary waves-effect waves-light" id="add_btn_for_claim_file_upload" onclick="addHTMLInput(this)">+ Add</a>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="g_drive_file_upload_sbt_btn">Submit</button>
@ -39,7 +40,6 @@
</div>
</div>
</div>
</div>
</div>
</div>
@ -112,6 +112,7 @@
<script>
$(document).ready(function(){
@ -180,8 +181,7 @@ $("#drive_file_upload_form").submit(function(event) {
});
});
function addHTMLInput()
{
function addHTMLInput() {
const container = document.getElementById('dynamic-form-container');
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
@ -208,8 +208,7 @@ function addHTMLInput()
}
function removeHTMLInput(element)
{
function removeHTMLInput(element) {
const container = document.getElementById('dynamic-form-container');
const rows = container.querySelectorAll('.dynamic-form-row');
@ -219,7 +218,7 @@ function removeHTMLInput(element)
}
}
function getUrlDataByTicketId(ticket_id) {
function getUrlDataByTicketId(ticket_id) {
// Show loader
$('.loader').fadeIn();
@ -262,7 +261,6 @@ function openEditModal(id, docName, url) {
$('#edit_url_modal').modal('show'); // Bootstrap modal
}
function create_url_list(data) {
$('#table_bd').empty(); // clear existing rows
@ -276,7 +274,7 @@ function create_url_list(data) {
<tr>
<td class="text-center">${index + 1}</td>
<td>${item.doc_name}</td>
<td><a href="${item.url}" target="_blank">${item.url}</a></td>
<td><a href="${item.url}" target="_blank">${item.file_type == 1 ? item.url : item.doc_name}</a></td>
<td>
<a href="javascript:void(0);" class="delete-url"
style="bacolor:black;"
@ -293,6 +291,7 @@ function create_url_list(data) {
$('#table_bd').html('<tr><td colspan="4">No Data Found</td></tr>');
}
}
$(document).on('click', '.delete-url', function (e) {
e.preventDefault();
const url = $(this).data('href');
@ -332,7 +331,68 @@ $(document).on('click', '.delete-url', function (e) {
});
});
function addFileUploadHtml() {
const container = document.getElementById('dynamic-form-container');
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="docs_name" name="docs_name[]" placeholder="Enter file name" required>
</div>
<div class="form-group col-md-5">
<label for="file">Choose File <span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_upload" name="file_upload[]" accept=".pdf,.jpg,.jpeg,.png" required>
</div>
<div class="form-group col-md-2" style="position: relative; top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)" style="background-color: #BD0707;">
<i class="mdi mdi-delete"></i>
</a>
</div>
`;
container.appendChild(newRow);
}
function toggleUploadType(btn) {
const $btn = $(btn);
const $addBtn = $('#add_btn_for_claim_file_upload');
console.log('addBtn', $addBtn);
const $container = $('#dynamic-form-container');
const currentType = $btn.text().trim();
console.log('currentType', currentType);
// Remove all existing dynamic rows when mode changes
$container.find('.dynamic-form-row').remove();
if (currentType === 'URL Upload') {
$btn.text('File Upload').removeClass('btn-success').addClass('btn-info');
// Change the Add button action
$addBtn.attr('onclick', 'addHTMLInput(this)');
// Handle switching to file upload mode here
console.log('Switched to File Upload mode');
// call the function
addHTMLInput();
} else {
$btn.text('URL Upload').removeClass('btn-info').addClass('btn-success');
// Change the Add button action
$addBtn.attr('onclick', 'addFileUploadHtml(this)');
// Handle switching to URL upload mode here
console.log('Switched to URL Upload mode');
// call the function
addFileUploadHtml();
}
}
</script>

View File

@ -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 = '<?= base_url("util/download_import_excel/"); ?>' + 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 = '<?= base_url("util/download_import_excel/"); ?>' + selectedValue;
$('#import_excel_download').attr('href', fullURL);
} else {
$('#import_excel_download').hide();
$('#import_excel_download').removeAttr('href');
}
});
});
// Function to convert object to query parameters