303 lines
12 KiB
PHP
303 lines
12 KiB
PHP
<style>
|
||
.bg-staff {
|
||
background-color: #FFF5E5;
|
||
}
|
||
</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">
|
||
<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="fas fa-arrow-left" style="font-size: 17px;"></i>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Navigation Tabs -->
|
||
<ul class="nav nav-pills navtab-bg">
|
||
<li class="nav-item">
|
||
<a href="#general-tab" data-toggle="tab" class="nav-link px-2 py-1 active" id="general_tab"
|
||
aria-expanded="true">
|
||
<i class="mdi mdi-ticket-account"></i>
|
||
<span class="d-none d-sm-inline-block">General</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#reply-tab" data-toggle="tab" class="nav-link px-2 py-1" id="reply_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-message-processing"></i>
|
||
<span class="d-none d-sm-inline-block">Reply</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#note-tab" data-toggle="tab" class="nav-link px-2 py-1" id="note_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-note-text"></i>
|
||
<span class="d-none d-sm-inline-block">Notes</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#history-tab" data-toggle="tab" class="nav-link px-2 py-1" id="history_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-history"></i>
|
||
<span class="d-none d-sm-inline-block">History</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#autoQuery-tab" data-toggle="tab" class="nav-link px-2 py-1" id="auto_query_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-robot mr-1"></i>
|
||
<span class="d-none d-sm-inline-block">Auto Query Content</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#uploads-tab" data-toggle="tab" class="nav-link px-2 py-1" id="uploads_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-file mr-1"></i>
|
||
<span class="d-none d-sm-inline-block">Claim Files</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#viewpolicyterms-tab" data-toggle="tab" class="nav-link px-2 py-1" id="viewpolicyterms_tab"
|
||
aria-expanded="false">
|
||
<i class="mdi mdi-eye mr-1"></i>
|
||
<span class="d-none d-sm-inline-block">View Policy Terms</span>
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
|
||
<!-- Tab Content -->
|
||
<div class="tab-content">
|
||
<div class="tab-pane fade show active" id="general-tab">
|
||
<?php
|
||
|
||
if ($ticket_data['ticket_type_id'] == 1) {
|
||
include('ticket_form_gmc.php');
|
||
} else {
|
||
include('ticket_form_gpa.php');
|
||
}
|
||
?>
|
||
</div>
|
||
<div class="tab-pane fade" id="reply-tab">
|
||
<?php include('ticket_reply.php'); ?>
|
||
</div>
|
||
<div class="tab-pane fade" id="note-tab">
|
||
<?php include('ticket_note.php'); ?>
|
||
</div>
|
||
<div class="tab-pane fade" id="history-tab">
|
||
<?php include('ticket_history.php'); ?>
|
||
</div>
|
||
<div class="tab-pane fade" id="autoQuery-tab">
|
||
<?php include('ticket_auto_query.php'); ?>
|
||
</div>
|
||
<div class="tab-pane fade" id="uploads-tab">
|
||
<?php include('claim_files_upload.php'); ?>
|
||
</div>
|
||
<div class="tab-pane fade" id="viewpolicyterms-tab">
|
||
<?php include('view_policy_terms.php'); ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal fade" id="member_data_modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel"></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="acm_id">Insured Member<span class="text-danger"></span></label>
|
||
<select class="form-control" onchange="setMemberData(this)">
|
||
<option value="0">Select Insured Member</option>
|
||
<?php if (!empty($member_data)) : ?>
|
||
<?php foreach ($member_data as $value) : ?>
|
||
<option value="<?= isset($value['emp_code']) ? $value['emp_code'] : '' ?>"
|
||
data-empID="<?= isset($value['emp_id']) ? $value['emp_id'] : '' ?>"
|
||
data-empName="<?= isset($value['emp_name']) ? htmlspecialchars($value['emp_name'], ENT_QUOTES, 'UTF-8') : '' ?>"
|
||
data-policyNo="<?= isset($value['policy_no']) ? $value['policy_no'] : '' ?>"
|
||
data-tpaNo="<?= isset($value['tpa_no']) ? $value['tpa_no'] : '' ?>"
|
||
data-relationship="<?= isset($value['emp_relationship']) ? htmlspecialchars($value['emp_relationship'], ENT_QUOTES, 'UTF-8') : '' ?>">
|
||
<?= isset($value['emp_name']) && isset($value['emp_relationship'])
|
||
? htmlspecialchars($value['emp_name'] . ' - ' . $value['emp_relationship'], ENT_QUOTES, 'UTF-8')
|
||
: 'Unknown Member' ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
<?php endif; ?>
|
||
</select>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<a class="btn btn-primary close" data-dismiss="modal" aria-label="Close">Submit</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="ticket_conversation_div">
|
||
<?php include("ticket_conversation.php") ?>
|
||
</div>
|
||
|
||
<?php //include("ticket_form_handler.php") ?>
|
||
|
||
<script>
|
||
|
||
function submitClaimForm(event, form) {
|
||
|
||
event.preventDefault();
|
||
|
||
var isValid = $('#ticket_form_data').parsley().validate();
|
||
|
||
if (!isValid) {
|
||
toastr.warning('Form validation failed. Please check the required fields.', 'WARNING');
|
||
return false;
|
||
}
|
||
|
||
const formAction = '<?= base_url("ticket/update"); ?>';
|
||
|
||
// Show loader
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
// Collect IDs and form data
|
||
const formData = new FormData(form);
|
||
|
||
// AJAX request
|
||
$.ajax({
|
||
data: formData,
|
||
url: formAction,
|
||
type: "POST",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(response) {
|
||
// Hide loader
|
||
|
||
console.log('Form submitted response:', response);
|
||
|
||
if (response.status === true) {
|
||
location.reload();
|
||
toastr.success(response.message, 'SUCCESS');
|
||
} else {
|
||
toastr.error(response.message, 'ERROR');
|
||
}
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
|
||
// Hide loader
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
function openFetchEmpDataodal() {
|
||
var myModal = new bootstrap.Modal(document.getElementById('member_data_modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
function setMemberData(input) {is_head_approved
|
||
|
||
var selectedOption = $(input).find(':selected');
|
||
|
||
// Retrieve the data-* attributes
|
||
var empId = selectedOption.data('empid');
|
||
var empName = selectedOption.data('empname');
|
||
var policyNo = selectedOption.data('policyno');
|
||
var tpaNo = selectedOption.data('tpano');
|
||
var relationship = selectedOption.data('relationship');
|
||
|
||
$('#tpa_no').val(tpaNo);
|
||
$('#insured_emp_id').val(empId);
|
||
$('#insured_name').val(empName);
|
||
$('#policy_no').val(policyNo);
|
||
|
||
$('#relationship option').each(function() {
|
||
if ($(this).text() === relationship) {
|
||
$(this).prop('selected', true);
|
||
}
|
||
});
|
||
}
|
||
|
||
function showConfirmationModal(event) {
|
||
Swal.fire({
|
||
title: "Approve Claim Rejection",
|
||
// text: "Do you want to save this?",
|
||
icon: "warning",
|
||
showCancelButton: true,
|
||
showDenyButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#6c757d",
|
||
denyButtonColor: "#d33",
|
||
confirmButtonText: "Approve",
|
||
denyButtonText: "Reject",
|
||
cancelButtonText: "Cancel"
|
||
}).then((result) => {
|
||
if (result.isConfirmed) {
|
||
$('#is_head_approved').val(1);
|
||
console.log($('#ticket_form_data')[0])
|
||
submitClaimForm(event, $('#ticket_form_data')[0]); // Fixed selector
|
||
} else if (result.isDenied) {
|
||
// Show second Swal for rejection reason
|
||
Swal.fire({
|
||
title: "Rejection Reason",
|
||
text: "Please provide a reason for rejection",
|
||
input: "textarea",
|
||
inputPlaceholder: "Enter your reason here...",
|
||
icon: "info",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
cancelButtonColor: "#6c757d",
|
||
confirmButtonText: "Submit",
|
||
cancelButtonText: "Back"
|
||
}).then((reasonResult) => {
|
||
if (reasonResult.isConfirmed) {
|
||
// Check if reason is not empty
|
||
if (reasonResult.value && reasonResult.value.trim() !== "") {
|
||
$('#is_head_approved').val(2);
|
||
$('#rejection_reason').val(reasonResult.value.trim());
|
||
console.log($('#ticket_form_data')[0]);
|
||
$('#head_rejection_reason').val(reasonResult.value.trim());
|
||
submitClaimForm(event, $('#ticket_form_data')[0]);
|
||
} else {
|
||
// Alert if reason is empty
|
||
Swal.fire({
|
||
title: "Error",
|
||
text: "Rejection reason cannot be empty",
|
||
icon: "error",
|
||
confirmButtonColor: "#3085d6"
|
||
}).then(() => {
|
||
// Go back to the rejection reason dialog
|
||
showConfirmationModal(event);
|
||
});
|
||
}
|
||
} else {
|
||
// If canceled, go back to first Swal
|
||
showConfirmationModal(event);
|
||
}
|
||
});
|
||
} else {
|
||
$('#is_head_approved').val(0);
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
|
||
</script>
|