FEAT_FETCH_CLAIM_STATS_AND _REQUIRED_IR_DOCS

This commit is contained in:
VENKATESHWARAN 2025-12-10 11:44:55 +05:30
parent 0ed060a523
commit dc60635076
5 changed files with 630 additions and 263 deletions

View File

@ -712,7 +712,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->post('getUrlDataByTicketId',"TicketController::getUrlDataByTicketId");
$routes->get('remove_url',"TicketController::remove_url");
$routes->get('fetchVehiclePolicy/(:any)','TicketController::fetchVehiclePolicy/$1');
$routes->post('saveIRDocsJson',"TicketController::saveIRDocsJson");
$routes->get('getTpaClaimStatus',"ApiServiceController::getClaimStatus");
});
$routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){

View File

@ -237,6 +237,8 @@ class ApiServiceController extends BaseController
return $mediAssistController->ClaimDetail($claimId);
}else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
$message = "This TPA has no API service enabled";
return $this->response->setJSON(['status' => false,'message' => $message ]);
}
}

View File

@ -2838,5 +2838,31 @@ class TicketController extends BaseController
}
}
// -------- END CLAIM DUMP UPLOAD ----------------------------------------------------------------------------------------------
public function saveIRDocsJson()
{
$ticket_id = $this->request->getPost('ticket_id');
$required_docs = $this->request->getPost('required_docs');
if(empty($ticket_id)){
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to save Docs'], 200);
}
if(empty($required_docs)){
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to save Docs'], 200);
}
db_connect()->query(
"UPDATE ticket_master SET required_docs = ? WHERE id = ?",
[$required_docs, $ticket_id]
);
$required_docs = $this->ticketMasterModel->select('required_docs')->where('id', $ticket_id)->first();
$required_docs = json_decode($required_docs['required_docs'] ?? '{}', true) ?? [];
return $this->respond(['status' => true, 'code' => 200, 'message' => 'IR docs saved successfully', 'data' => $required_docs], 200);
}
}

View File

@ -1,9 +1,68 @@
<div class="tab-pane" id="fileupload">
<div id="required_id_docs_div" class="card">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 0px 4px 4px 0px #00000040;">
<div class="form-group">
<!-- Header Row: Title + Switch + Save -->
<div class="row mb-3 align-items-center">
<div class="col-md-6">
<h5 class="mb-0"><strong>IR Documents</strong></h5>
</div>
<div class="col-md-6 text-right">
<div class="d-inline-block mr-3">
<div class="custom-control custom-switch d-inline-block">
<input type="checkbox" class="custom-control-input"
id="action_freeze_switch"
onchange="toggleActionFreeze()">
<label class="custom-control-label" for="action_freeze_switch">
<strong>Freeze User Actions</strong>
</label>
</div>
</div>
<button type="button"
class="btn btn-success waves-effect waves-light"
onclick="saveConfiguration()"> Save
</button>
</div>
</div>
<!-- Document List Container -->
<div class="row mb-3">
<div class="col-md-12">
<!-- Header Row -->
<div class="form-row mb-2">
<div class="col-md-7"><strong>Document Name</strong></div>
<div class="col-md-3"><strong>Status</strong></div>
<div class="col-md-2 text-center"><strong>Action</strong></div>
</div>
<!-- Dynamic Document Rows -->
<div id="document-list-container"></div>
<!-- Add Button -->
<!-- <div class="row mt-3">
<div class="col-md-12 text-right">
<button type="button"
class="btn btn-primary waves-effect waves-light"
onclick="addDocument()">
<i class="mdi mdi-plus"></i> Add Document
</button>
</div>
</div> -->
</div>
</div>
</div>
<!-- Hidden field to store JSON data for form submission -->
<input type="hidden" id="document_config_json" name="document_config">
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<div class="card mb-1" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 0px 4px 4px 0px #00000040;">
<h5 class="m-1">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
@ -45,7 +104,7 @@
</div>
<div id="file_table" class="card">
<div class="card-body">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 0px 4px 4px 0px #00000040;">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">File List</h4>
@ -72,7 +131,6 @@
</div>
</div>
<!-- edit modal -->
<div class="modal fade" id="edit_url_modal" tabindex="-1" role="dialog" aria-labelledby="editUrlModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
@ -108,24 +166,12 @@
</div>
</div>
<script>
$(document).ready(function(){
let ticket_id = $('#ticket_master_id').val();
$('#ticket_id_url').val(ticket_id);
let urlData = getUrlDataByTicketId(ticket_id);
})
$("#drive_file_upload_form").submit(function(event) {
@ -394,5 +440,257 @@ function toggleUploadType(btn) {
}
}
</script>
<script>
let documentConfig = {
is_action_freeze: false,
docs: []
};
$(document).ready(function(){
let jsonDocumentConfig = <?= isset($ticket_data['required_docs']) && !empty($ticket_data['required_docs'])
? $ticket_data['required_docs']
: '{"is_action_freeze": false, "docs": [{"document_name":"","document_received":false}]}' ?>;
console.log('loadConfiguration pre', jsonDocumentConfig);
loadConfiguration(jsonDocumentConfig);
})
// Initialize the form with JSON data
function initializeForm(jsonData) {
documentConfig = jsonData;
// Set the freeze switch
const freezeSwitch = document.getElementById('action_freeze_switch');
if (freezeSwitch) {
freezeSwitch.checked = documentConfig.is_action_freeze;
}
// Render document list
renderDocumentList();
}
// Render the document input list
function renderDocumentList() {
const container = document.getElementById('document-list-container');
if (!container) return;
container.innerHTML = '';
documentConfig.docs.forEach((doc, index) => {
const docRow = createDocumentRow(doc, index);
container.appendChild(docRow);
});
}
// Create a single document row
function createDocumentRowOld(doc, index) {
const row = document.createElement('div');
row.className = 'form-row align-items-center mb-2';
row.dataset.index = index;
row.innerHTML = `
<div class="col-md-7">
<input type="text" class="form-control"
placeholder="Document Name"
value="${doc.document_name}"
onchange="updateDocumentName(${index}, this.value)"
${documentConfig.is_action_freeze ? 'disabled' : ''}>
</div>
<div class="col-md-3">
<span class="badge ${doc.document_received ? 'badge-success' : 'badge-danger'} text-center d-block"
style="cursor:pointer; font-size:14px; padding:13px 12px; font-weight:600; border-radius:9px;"
onclick="${documentConfig.is_action_freeze ? '' : `updateDocumentReceived(${index}, ${!doc.document_received})`}">
${doc.document_received ? 'Received' : 'Not Received'}
</span>
</div>
<div class="col-md-2">
<button type="button" class="btn btn-sm btn-danger"
onclick="removeDocument(${index})"
${documentConfig.is_action_freeze ? 'disabled' : ''}>
<i class="mdi mdi-delete"></i> Remove
</button>
</div>
`;
return row;
}
function createDocumentRow(doc, index) {
const row = document.createElement('div');
row.className = 'form-row align-items-center mb-2';
row.dataset.index = index;
const isLastRow = index === documentConfig.docs.length - 1; // 👉 Check last item
row.innerHTML = `
<div class="col-md-7">
<input type="text" class="form-control"
placeholder="Document Name"
value="${doc.document_name}"
onchange="updateDocumentName(${index}, this.value)"
${documentConfig.is_action_freeze ? 'disabled' : ''}>
</div>
<div class="col-md-3">
<span class="badge ${doc.document_received ? 'badge-success' : 'badge-danger'} text-center d-block"
style="cursor:pointer; font-size:14px; padding:13px 12px; font-weight:600; border-radius:9px;"
onclick="${documentConfig.is_action_freeze ? '' : `updateDocumentReceived(${index}, ${!doc.document_received})`}">
${doc.document_received ? 'Received' : 'Not Received'}
</span>
</div>
<div class="col-md-2 text-center">
<button type="button" class="btn btn-sm btn-danger"
onclick="removeDocument(${index})"
${documentConfig.is_action_freeze ? 'disabled' : ''}>
<i class="mdi mdi-delete"></i>
</button>
${isLastRow && !documentConfig.is_action_freeze ? `
<button type="button" class="btn btn-sm btn-primary ml-1"
onclick="addDocument()">
<i class="mdi mdi-plus"></i>
</button>` : ''}
</div>
`;
return row;
}
// Add new document
function addDocument() {
if (documentConfig.is_action_freeze) {
toastr.warning('Cannot add documents when action is frozen', 'WARNING');
return;
}
documentConfig.docs.push({
document_name: '',
document_received: false
});
renderDocumentList();
}
// Remove document
function removeDocumentold(index) {
if (documentConfig.is_action_freeze) {
alert('Cannot remove documents when action is frozen');
return;
}
documentConfig.docs.splice(index, 1);
renderDocumentList();
}
function removeDocument(index) {
if (documentConfig.is_action_freeze) {
toastr.warning('Cannot remove documents when action is frozen', 'WARNING');
return;
}
const doc = documentConfig.docs[index];
// ❗ If document is already received, do not remove
if (doc.document_received === true) {
toastr.warning('Cannot remove a received document', 'WARNING');
return;
}
// 👉 First row cannot be removed
if (index === 0) {
documentConfig.docs[0].document_name = '';
documentConfig.docs[0].document_received = false;
renderDocumentList();
return;
}
// 👉 Other rows can be removed
documentConfig.docs.splice(index, 1);
renderDocumentList();
}
// Update document name
function updateDocumentName(index, value) {
documentConfig.docs[index].document_name = value;
}
// Update document received status
function updateDocumentReceived(index, value) {
documentConfig.docs[index].document_received = value === 'true';
}
// Toggle freeze state
function toggleActionFreeze() {
const freezeSwitch = document.getElementById('action_freeze_switch');
documentConfig.is_action_freeze = freezeSwitch.checked;
// Re-render to update disabled states
renderDocumentList();
}
// Save configuration
function saveConfiguration() {
const hasEmptyNames = documentConfig.docs.some(doc => !doc.document_name.trim());
if (hasEmptyNames) {
toastr.warning('Please fill in all document names', 'WARNING');
return false;
}
let ticket_id = $('#ticket_id_url').val();
let required_docs = JSON.stringify(documentConfig);
console.log('Saving configuration:', JSON.stringify(documentConfig, null, 2));
console.log('ticket_id', ticket_id);
// Data to send in the AJAX request
let requestData = {
ticket_id: ticket_id,
required_docs: required_docs
};
let url = '<?= base_url('ticket/saveIRDocsJson') ?>';
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
loadConfiguration(response.data);
toastr.success(response.message, 'SUCCESS');
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while saving docs.', 'ERROR');
});
}
// Get current configuration as JSON
function getConfiguration() {
return documentConfig;
}
// Edit mode - load existing configuration
function loadConfiguration(jsonString) {
try {
const data = typeof jsonString === 'string' ? JSON.parse(jsonString) : jsonString;
initializeForm(data);
} catch (e) {
console.error('Invalid JSON:', e);
}
}
</script>

View File

@ -33,19 +33,29 @@
}
</style>
<div class="row">
<div class="col-12">
<div class="card" style="margin-right: 23px;">
<div class="card-body">
<!-- Header Section -->
<div class="row mb-3">
<div class="col-6 d-flex align-items-center">
<div class="row mb-3 align-items-center justify-content-between">
<div class="col-auto">
<h4 class="mb-0">Claims</h4>
</div>
<div class="col-6 text-right">
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
<i class="mdi mdi-arrow-left" style="font-size: 17px;"></i>
<div class="col-auto d-flex align-items-center">
<?php if(isset($ticket_data['tpa_claim_push_reference_no']) && !empty($ticket_data['tpa_claim_push_reference_no'])) : ?>
<a href="#" class="btn btn-success mr-2" onclick="fetchTpaClaimStatus()">
Fetch Claim Status
</a>
<?php endif; ?>
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
<i class="mdi mdi-arrow-left" style="font-size: 24px;"></i>
</a>
</div>
</div>
@ -350,4 +360,34 @@
}
});
}
function fetchTpaClaimStatus(){
let ticket_master_id = $('#ticket_master_id').val();
console.log({ticket_master_id});
let requestData = {
claim_id: ticket_master_id,
};
let url = '<?= base_url('ticket/getTpaClaimStatus') ?>';
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
toastr.success(response.message || 'Status updated successfully', 'SUCCESS');
window.location.reload(true);
} else {
toastr.warning(response.message || 'Failed to update status', 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while saving docs.', 'ERROR');
});
}
</script>