Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
vadivelJ96 2025-08-19 12:07:21 +05:30
commit f827b83e7c
7 changed files with 992 additions and 29 deletions

View File

@ -551,6 +551,13 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("claimView", "EmployeeRestController::claimView");
$routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData");
//thz_master's
$routes->post("ticketSave", "ThzController::ticketSave");
$routes->get("ticketList", "ThzController::ticketList");
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
$routes->get("ticketConversationList", "ThzController::ticketConversationList");
});
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");

View File

@ -8,7 +8,7 @@ use CodeIgniter\HTTP\ResponseInterface;
use App\Models\ThzMasterModel;
use App\Models\ThzMasterNotesModel;
use App\ControllerCleaners\ThzControllerCleaner;
use app\Models\UserModel;
use App\Models\UserModel;
class ThzController extends BaseController
{
@ -35,8 +35,9 @@ class ThzController extends BaseController
public function ticketSave(){
$data = $this->request->getJSON(true);
$data = $this->request->getPost();
// $data = $this->request->getJSON(true);
// $return_type = isset($data['return_type']) ? $data['return_type'] : 'api';
if (!empty($data['thz_id'])) {
$text = "update";
$result = $this->updateTicket($data);
@ -48,7 +49,7 @@ class ThzController extends BaseController
return $this->response->setJSON([
'status' => $result ? 'success' : 'error',
'message' => $result ? "Ticket {$text}d successfully" : "Unable to {$text} ticket. Please try again."
]);
])->setStatusCode($result ? 200 : 400);
}
public function ticketList()
@ -60,26 +61,22 @@ class ThzController extends BaseController
$tickets = $this->fetchTicketsBasedOnrole($data);
if ($returnType === 'api') {
if (empty($tickets)) {
return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found',])->setStatusCode(404);
return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found'])->setStatusCode(404);
}
}else{
$data['page_name'] = "Ticket List";
$data['ticket_data'] = $tickets;
$data['assigner'] = $this->userModel->where('is_active', 1)->findAll();
return $this->loadLayout('ticket_list_web', $data);
}
$data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['1', '5'])->findAll(); // enga 5-"head" and 1-"admin" role person thaan assignee..
return $this->loadLayout('thz_list', $data);
}
return $this->response->setJSON([
'status' => 'success',
'data' => $tickets,
]);
])->setStatusCode(200);
}
public function ticketConversationSave(){
@ -89,11 +86,14 @@ class ThzController extends BaseController
$result = $this->thzMasterNotesModel->insert($data);
if(empty($result)){
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
}
return $this->response->setJSON((['status' => 'success', 'data' => $result]));
return $this->response->setJSON([
'status' => $result ? 'success' : 'error',
'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again."
])->setStatusCode($result ? 200 : 400);
}
@ -103,13 +103,21 @@ class ThzController extends BaseController
$thz_id = $data['thz_id'] ?? null;
$result = $this->thzMasterNotesModel->ticketConversationList($thz_id);
if($thz_id){
$result['master'] = $this->thzMasterModel
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
->where('thz_master.thz_id', $thz_id)
->findAll();
if(empty($result)){
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
$notes = $this->thzMasterNotesModel->ticketConversationList($thz_id);
$result['notes'] = !empty($notes) ? $notes : [];
}else{
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
}
return $this->response->setJSON((['status' => 'success', 'data' => $result]));
return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(400);
}
@ -159,27 +167,35 @@ class ThzController extends BaseController
private function fetchTicketsBasedOnrole(array $data): array
{
$id = $data['thz_id'] ?? null;
// $id = $data['thz_id'] ?? null;
$assign_to = $data['assign_to'] ?? null;
$mobile = $data['mobile'] ?? null;
if (!empty($assign_to)) {
// Tickets assigned to a staff
return $this->thzMasterModel
->where('assign_to', $assign_to)
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
->where('thz_master.assign_to', $assign_to)
->findAll();
}
if (!empty($id) && !empty($mobile)) {
// if (!empty($id) && !empty($mobile)) {
if (!empty($mobile)) {
// Specific ticket by ID and mobile
return $this->thzMasterModel
->where('thz_id', $id)
->where('mobile', $mobile)
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
// ->where('thz_id', $id)
->where('thz_master.mobile', $mobile)
->findAll();
}
// All tickets (e.g., for managers)
return $this->thzMasterModel->findAll();
return $this->thzMasterModel
->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
->findAll();
}
private function notificationBasedOnRole($data){

View File

@ -12,7 +12,7 @@ class ThzMasterModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['name','mobile','email','empcode','policy_no','ticket_type','subject','message','status','assign_to','created_at','updated_at'];
protected $allowedFields = ['name','mobile','email','empcode','policy_no','ticket_type','subject','message','status','assign_to','created_at','updated_at','created_by','updated_by' ,'client_id' ,'policy_id' ,'branch_id'];
protected bool $allowEmptyInserts = false;

View File

@ -40,7 +40,7 @@ class ThzMasterNotesModel extends Model
protected $beforeDelete = [];
protected $afterDelete = [];
public function ticketConversationList($thz_id){
public function ticketConversationLists($thz_id){
if(empty($thz_id)){
@ -76,5 +76,33 @@ class ThzMasterNotesModel extends Model
}
public function ticketConversationList($thz_id)
{
$notes_sql = "SELECT
thz_master_notes.*,
CASE
WHEN LOWER(thz_master_notes.notes_by) = 'staff'
THEN CONCAT(user_profiles.first_name, ' ', user_profiles.last_name)
WHEN LOWER(thz_master_notes.notes_by) = 'user'
THEN thz_master.name
ELSE thz_master_notes.notes_by
END AS name
FROM thz_master_notes
LEFT JOIN user_profiles
ON user_profiles.id = thz_master_notes.created_by
AND LOWER(thz_master_notes.notes_by) = 'staff'
LEFT JOIN thz_master
ON thz_master.thz_id = thz_master_notes.thz_id
AND LOWER(thz_master_notes.notes_by) = 'user'
WHERE thz_master_notes.thz_id = " . (int)$thz_id . "
ORDER BY thz_master_notes.created_at ASC";
$result = $this->db->query($notes_sql)->getResultArray();
return $result;
}
}

View File

@ -676,6 +676,9 @@
<li>
<a href="<?= base_url('/ticket/feedback-list') ?>">Claim Feedback List</a>
</li>
<li>
<a href="<?= base_url('/ticketList?return_type=web') ?>">Ticket List</a>
</li>
</ul>
</div>
</li>

473
app/Views/thz_list.php Normal file
View File

@ -0,0 +1,473 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
.addbtnStyle {
margin-left: 20px !important;
}
</style>
<style>
.table th:nth-child(1),
.table td:nth-child(1) {
max-width: 200px !important;
min-width: 100px !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
white-space: nowrap !important;
}
#scroll-horizontal-datatable tbody tr:hover {
background-color: #e0e0e0;
}
</style>
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Ticket List </h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>Ticket Number</th>
<th>Name</th>
<th>Mobile Number</th>
<th>Email</th>
<th>Emp Code</th>
<th>Policy Number</th>
<th>Ticket Type</th>
<th>Subject</th>
<th>Message</th>
<th>Status</th>
<th>Assignee</th>
<?php if(in_array(get_role_id(), [1,2,3]) ) { ?> <!-- admin,manager,acc.m -->
<th>ACTION</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php if (isset($ticket_data)) { ?>
<?php foreach($ticket_data as $index => $row){ ?>
<tr data-id="<?= $row['thz_id']; ?>" style="cursor: pointer;">
<td><?php echo $row['thz_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['empcode']; ?></td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo $row['ticket_type']; ?></td>
<td><?php echo $row['subject']; ?></td>
<td><?php echo $row['message']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['assignee_name']; ?></td>
<?php if(in_array(get_role_id(), [1,2,3]) ) { ?> <!-- admin,manager,acc.m -->
<td>
<div class="btn-group dropdown">
<button type="button"
class="btn btn-sm btn-primary"
data-id="<?= $row['thz_id']; ?>"
data-assignee="<?= $row['assign_to']; ?>"
data-subject="<?= $row['subject']; ?>"
onclick="openAssignee(this)">
Assign
</button>
</div>
<!-- <a href="javascript:void(0);"
data-toggle="modal"
data-target="#AssignModal"
data-id="<?= $row['thz_id']; ?>"
data-subject="<?= $row['subject']; ?>">
<i class="fa fa-users"
title="Assign To"
style="font-size:15px; color:#555; cursor:pointer; transition:0.2s;"
onmouseover="this.style.color='#02a8b5'; this.style.fontSize='17px';"
onmouseout="this.style.color='#555'; this.style.fontSize='15px';">
</i>
</a> -->
</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<div class="modal fade" id="ticketModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form id="ticketForm">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">New Ticket</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-row">
<input type="hidden" id="thz_id" name="thz_id">
<input type="hidden" id="return_type" name="return_type">
<div class="form-group col-md-6">
<label for="name">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required>
</div>
<div class="form-group col-md-6">
<label for="mobile">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile"
name="mobile" placeholder="Enter Mobile"
pattern="^[0-9]{10}$" required
title="Please enter a valid 10-digit mobile number">
</div>
<div class="form-group col-md-6">
<label for="email">Email Id<span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email"
name="email" placeholder="Enter Email"
required
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
title="Please enter a valid email address">
</div>
<div class="form-group col-md-6">
<label for="empcode">Employee code</label>
<input type="text" class="form-control" id="empcode" name="empcode" placeholder="Enter Employee code">
</div>
<div class="form-group col-md-6">
<label for="policy_no">Policy Number</label>
<input type="text" class="form-control" id="policy_no" name="policy_no" placeholder="Enter Policy Number">
</div>
<div class="form-group col-md-6">
<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-6">
<label for="subject">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Enter Subject">
</div>
<div class="form-group col-md-6">
<label for="message">Message</label>
<!-- <input type="text" class="form-control" id="message" name="message" placeholder="Enter Message"> -->
<textarea class="form-control" id="message" name="message" placeholder="Enter Message" rows="4"></textarea>
</div>
<div class="form-group col-md-6">
<label for="status">Status</label>
<select class="form-control" id="status" name="status">
<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</label>
<select class="form-control" id="assign_to" name="assign_to">
<option value="">Select Assign To</option>
<?php if(isset($assignee)) { ?>
<?php foreach ($assignee as $a) { ?>
<option value="<?= $a['id']?>"><?= $a['emp_code'] ?> - <?= $a['first_name'] ?> <?= $a['last_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitTicket()">Submit</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="AssignModal" 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="assignModalLabel">Ticket</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-row">
<input type="hidden" id="hidden_thz_id" name="hidden_thz_id">
<div class="form-group col-md-12">
<label for="modal_assignee">Assign To<span class="text-danger">*</span></label>
<select class="form-control" id="modal_assignee" name="modal_assignee" required>
<option value="">Select Assign To</option>
<?php if(isset($assignee)) { ?>
<?php foreach ($assignee as $a) { ?>
<option value="<?= $a['id']?>"><?= $a['emp_code'] ?> - <?= $a['first_name'] ?> <?= $a['last_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="updateAssignTo()">Submit</button>
</div>
</div>
</div>
</div>
<script>
function openTicket(){
var form = document.getElementById('ticketForm');
form.reset();
document.getElementById('thz_id').value = '';
document.getElementById('modalLabel').innerText = "New Ticket";
document.getElementById('return_type').innerText = "WEB";
var myModal = new bootstrap.Modal(document.getElementById('ticketModal'));
myModal.show();
}
function submitTicket() {
var form = document.getElementById('ticketForm');
// reset any old error styles
form.classList.remove('was-validated');
var name = document.getElementById('name').value.trim();
var mobile = document.getElementById('mobile').value.trim();
var email = document.getElementById('email').value.trim();
var ticketType= document.getElementById('ticket_type').value.trim();
if (name === "" || mobile === "" || email === "" || ticketType === "") {
toastr.warning('Please fill all required fields.', 'warning');
form.classList.add('was-validated');
return;
}
var mobilePattern = /^[0-9]{10}$/;
if (!mobilePattern.test(mobile)) {
toastr.warning('Please enter a valid 10-digit mobile number.', 'warning');
document.getElementById('mobile').focus();
return;
}
var emailPattern = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
if (!emailPattern.test(email)) {
toastr.warning('Please enter a valid email address.', 'warning');
document.getElementById('email').focus();
return;
}
var form = document.getElementById("ticketForm"); // your form ID
var formData = new FormData(form);
let obj = {};
formData.forEach((value, key) => obj[key] = value);
// obj["return_type"] = "web";
$.ajax({
url: "<?= base_url('ticketSave') ?>",
type: "POST",
data: JSON.stringify(obj),
contentType: "application/json",
dataType: 'json',
success: function(response) {
if (response.status === "success") {
toastr.success(response.message, 'success');
$('#ticketModal').modal('hide');
form.reset();
window.location.href = "<?= base_url('ticketList?return_type=web') ?>";
} else {
toastr.error(response.message, 'error');
}
},
error: function(xhr) {
toastr.error("Something went wrong!", 'error');
console.error(xhr.responseText);
}
});
}
function openAssignee(button) {
document.getElementById('hidden_thz_id').value = "";
document.getElementById('modal_assignee').value = "";
document.getElementById('assignModalLabel').innerText = "Ticket";
var id = button.getAttribute('data-id');
var subject = button.getAttribute('data-subject');
var assignee = button.getAttribute('data-assignee');
document.getElementById('hidden_thz_id').value = id;
document.getElementById('modal_assignee').value = assignee;
document.getElementById('assignModalLabel').innerText = "Ticket: " + subject + " (" + id + ")";
var myModal = new bootstrap.Modal(document.getElementById('AssignModal'));
myModal.show();
}
function updateAssignTo(){
console.log('function called then call the api then refresh the updateAssignTo');
}
</script>
<!-------------------------------------------------------------------------------------------------->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
// Initialize select2
$("#ticket_type").select2();
$("#status").select2();
$("#assign_to").select2();
$("#modal_assignee").select2();
});
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'ticket-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'ticket-List',
exportOptions: {
orthogonal: 'sort'
},
},
{
text: 'New ticket',
className: 'buttons-html5 addbtnStyle',
action: function(e, dt, node, config) {
openTicket()
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table Not found.");
}
});
function viewTicket(ticket_id){
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
let url = '<?= base_url('ThzControllerview/'); ?>' + ticket_id;
window.location.href = url;
}
function removeticket(input, ticket_id) {
confirmActionSweertAlert("Do you want to delete this ticket?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
if (confirmed) {
let url = '<?= base_url('ticket/remove') ?>';
// Include `pt_id` in the AJAX request if necessary
let requestData = { ticket_id: ticket_id };
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
window.location.reload();
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
});
}
$(document).on('click', 'tbody tr', function (e) {
// Exclude clicks on any elements inside the last column (actions)
if ($(e.target).closest('td').index() !== $(this).children('td').length - 1) {
const id = $(this).data('id');
console.log('Ticket ID', id)
viewTicket(id);
}
});
</script>

436
app/Views/thz_notes.php Normal file
View File

@ -0,0 +1,436 @@
<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>