436 lines
21 KiB
PHP
436 lines
21 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">Ticket</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="#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>
|
||
</ul>
|
||
|
||
<!-- Tab Content -->
|
||
<div class="tab-content">
|
||
<div class="tab-pane fade show active" id="general-tab">
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card-body">
|
||
<form role="form" class="parsley-examples" method="post" id="thz_form_data" onsubmit="submitTicket(event, this)" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
|
||
<h5>Ticket Master Details</h5>
|
||
<hr>
|
||
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="name">Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile" name="mobile" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="email">Email Id<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="email" placeholder="Enter Email" name="Email" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="empcode">Employee code<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="empcode" placeholder="Enter Employee code" name="empcode" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="policy_no">Policy Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="policy_no" placeholder="Enter Policy Number" name="policy_no" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="ticket_type">Ticket Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="ticket_type" name="ticket_type" required>
|
||
<option value="">Select Ticket Type</option>
|
||
<option value="Sales">Sales</option>
|
||
<option value="Service">Service</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="modal_vehicle_no">Subject<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="subject" placeholder="Enter Subject" name="subject" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="message">Message<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="message" placeholder="Enter Message" name="message" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="status">Status<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="status" name="status" required>
|
||
<option value="">Select Status</option>
|
||
<option value="Open">Open</option>
|
||
<option value="In Progress">In Progress</option>
|
||
<option value="Resolved">Resolved</option>
|
||
<option value="Closed">Closed</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="assign_to">Assign To<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="Assign_to" name="assign_to" required>
|
||
<option value="">Select Assignee</option>
|
||
<?php if(isset($assignee)) { ?>
|
||
<?php foreach ($assignee as $value) { ?>
|
||
<option value="<?= $a['id']?>"><?= $a['emp_code'] ?> - <?= $a['first_name'] ?> <?= $a['last_name'] ?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
<input type="hidden" id="thz_id" name="thz_id">
|
||
|
||
</div>
|
||
|
||
<br><br>
|
||
</div>
|
||
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="tab-pane fade" id="note-tab">
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card-body">
|
||
<form role="form" class="parsley-examples" method="post" id="thz_note_form"
|
||
enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="ticket_note">Add Notes</label>
|
||
<textarea class="form-control" id="thz_notes" name="notes" rows="3"
|
||
placeholder="Enter Text"><?= isset($thz_note['notes']) ? $thz_note['notes'] : '' ?></textarea>
|
||
</div>
|
||
</div>
|
||
</div><input type="hidden" id="thz_notes_id">
|
||
<input type="hidden" id="thz_master_id">
|
||
<div class="form-group text-right m-b-0">
|
||
<button type="submit" class="btn btn-primary" id="thz_note_submit">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div> <!-- end col-->
|
||
</div>
|
||
</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>
|
||
<script>
|
||
$(document).ready(function() {
|
||
// Initialize select2
|
||
$("#ticket_type").select2();
|
||
$("#status").select2();
|
||
$("#assign_to").select2();
|
||
|
||
url = '<?= base_url('ThzControllernote/1'); ?>';
|
||
data = { id : $('#thz_master_id').val(), is_auto_query : 0};
|
||
$.ajax({
|
||
url:url,
|
||
data:data,
|
||
type:'POST',
|
||
success: function(res) {
|
||
if (res.status == true){
|
||
$('#thz_master_id').val(res.data.thz_id);
|
||
$('#thz_notes').val(res.data.notes);
|
||
$('#thz_notes_id').val(res.data.id);
|
||
$('#thz_notes_by').val('Staff');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Went Wrong!', 'warning');
|
||
}, 1000);
|
||
}
|
||
})
|
||
|
||
$("#ticket_note_form").submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var url = '<?= base_url("/ThzControllernote/2"); ?>';
|
||
var formData = $(this).serializeArray();
|
||
var ticket_id = $('#thz_master_id').val();
|
||
if (ticket_id != null && ticket_id != ''){
|
||
formData.push({ name: 'thz_id', value: ticket_id});
|
||
}
|
||
var primary_key = $('#thz_note_id').val();
|
||
if (primary_key != null && primary_key != ''){
|
||
formData.push({ name: 'id', value: primary_key});
|
||
}
|
||
console.log(formData);
|
||
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
|
||
if (response.status == true) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.success('Note Added Successfully','Success');
|
||
// console.log("Respone id is ")
|
||
// console.log(response.id);
|
||
$('#note_id').val(response.id);
|
||
// console.log($('#'))
|
||
|
||
|
||
} else {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
let message = response.message;
|
||
toastr.error(message, 'ERROR');
|
||
}
|
||
|
||
|
||
}, function(xhr, status, error) {
|
||
console.error('Error fetching data:', error);
|
||
console.error(xhr.responseText);
|
||
toastr.error('An error occurred while fetching the report page.', 'ERROR');
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
});
|
||
});
|
||
|
||
});
|
||
|
||
</script>
|