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

This commit is contained in:
vadivelJ96 2025-08-22 15:06:27 +05:30
commit a0fd40d917
11 changed files with 828 additions and 67 deletions

View File

@ -183,6 +183,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->post('get_emp_history','EmployeeController::getEmpHistory');
});
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {
$routes->group("insurer", ["filter" => "authMVC"], function ($routes) {
@ -561,7 +563,15 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
$routes->get("ticketConversationList", "ThzController::ticketConversationList");
$routes->get("hrFileList", "EmployeeRestController::hrFileList");
$routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters");
$routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload");
$routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload");
$routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData");
});
$routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters");
$routes->post("hrFileList", "EmployeeRestController::hrFileList");
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -34,6 +34,7 @@ use App\Models\TicketMasterModel;
use App\Models\TicketMessageModel;
use App\Models\HRAccessControlModel;
use App\Models\InsurerModel;
use App\Models\HrFileUploadModel;
@ -87,6 +88,7 @@ class EmployeeRestController extends AdminController
protected $ticketController;
protected $hrAccessControlModel;
protected $insurerModel;
protected $hrFileUploadModel;
public function __construct()
@ -118,6 +120,7 @@ class EmployeeRestController extends AdminController
$this->ticketController = new TicketController();
$this->hrAccessControlModel = new HRAccessControlModel();
$this->insurerModel = new InsurerModel();
$this->hrFileUploadModel = new HrFileUploadModel();
}
@ -3781,4 +3784,232 @@ class EmployeeRestController extends AdminController
return $response->getBody();
}
//--------------------------------------------------------------------------------------------
public function hrFileUpload()
{
try {
// Check file
$file = $this->request->getFile('file_name');
if (!$file) {
return $this->response->setJSON([
'status' => false,
'message' => "Invalid file or file not uploaded.",
'data' => "No Data"
]);
}
// Upload folder path
$uploadPath = WRITEPATH . 'uploads/hr_files/';
// If directory not exists, create it
if (!is_dir($uploadPath)) {
mkdir($uploadPath, 0777, true);
}
// New file name with timestamp
$newFileName = time() . '_' . $file->getRandomName();
// Move file
$file->move($uploadPath, $newFileName);
// Prepare data
$data = [
'client_id' => $this->request->getPost('client_id'),
'client_branch_id' => $this->request->getPost('client_branch_id'),
'policy_no' => $this->request->getPost('policy_no'),
'file_name' => $newFileName,
'file_action' => $this->request->getPost('file_action'),
'status' => 'Yet to start',
'created_by' => $this->request->getPost('created_by'),
'updated_by' => $this->request->getPost('created_by'),
];
// Save into DB
$this->hrFileUploadModel->insert($data);
return $this->respondCreated([
'status' => true,
'message' => 'File uploaded successfully',
'data' => $data
]);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
}
public function updateHrFileUploadData()
{
try {
$id = $this->request->getPost('id');
if (!$id) {
return $this->failValidationErrors('ID is required for update.');
}
// Prepare data
$data = [
'client_id' => $this->request->getPost('client_id'),
'client_branch_id' => $this->request->getPost('client_branch_id'),
'policy_no' => $this->request->getPost('policy_no'),
'file_action' => $this->request->getPost('file_action'),
'status' => $this->request->getPost('status'),
'updated_by' => $this->request->getPost('updated_by'),
];
// Check if record exists
$record = $this->hrFileUploadModel->find($id);
if (!$record) {
return $this->failNotFound("Record with ID {$id} not found.");
}
// Update record
$this->hrFileUploadModel->update($id, $data);
return $this->respond([
'status' => true,
'message' => 'File record updated successfully',
'data' => $data
], 200);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
}
public function hrFileDownload($id = null)
{
try {
$file_id = $this->request->getGet('id') ?? $id;
// Find record
$record = $this->hrFileUploadModel->where('id',$file_id)->find();
// print_rr( $record);die;
if (!$record) {
return $this->failNotFound("File record not found");
}
$uploadPath = WRITEPATH . 'uploads/hr_files/';
$filePath = $uploadPath . $record[0]['file_name'];
if (!file_exists($filePath)) {
return $this->failNotFound("File not found on server");
}
// Force file download
return $this->response->download($filePath, null)
->setFileName($record[0]['file_name']);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
}
// public function hrFileList()
// {
// try {
// $request = service('request');
// $builder = $this->hrFileUploadModel
// ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name ');
// // Allowed filter keys
// $filters = [
// 'client_id',
// 'client_branch_id',
// 'policy_no',
// 'file_action',
// 'status',
// 'created_by'
// ];
// // Apply filters dynamically
// foreach ($filters as $key) {
// $value = $request->getGetPost($key); // supports both GET and POST
// if (!empty($value)) {
// $builder->where($key, $value);
// }
// }
// // Fetch results
// $builder->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left');
// $builder->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left');
// $builder->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
// $data = $builder->findAll();
// return $this->respond([
// 'status' => true,
// 'message' => 'File list fetched successfully',
// 'data' => $data
// ]);
// } catch (\Exception $e) {
// return $this->failServerError($e->getMessage());
// }
// }
public function hrFileList()
{
try {
$request = service('request');
// Start builder from model
$builder = $this->hrFileUploadModel
->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name')
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
// Allowed filter keys
$filters = [
'client_id',
'client_branch_id',
'policy_no',
'file_action',
'status',
'created_by'
];
// Apply filters dynamically
foreach ($filters as $key) {
$value = $request->getGetPost($key); // supports both GET and POST
if (!empty($value)) {
$builder->where("hr_file_upload.$key", $value);
}
}
// Execute query
$data = $builder->get()->getResultArray();
return $this->respond([
'status' => "success",
'message' => 'File list fetched successfully',
'data' => $data
]);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
}
public function hrFileUploadMasters()
{
try {
//for inception upload
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
return $this->respond([
'status' => true,
'message' => 'File inception upload masters',
'data' => $data
]);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
}
}

View File

@ -96,6 +96,7 @@ class ThzController extends BaseController
$data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu
// 2,3,4 remain person varannum.
$data['client_list'] = $this->clientModel->getCreatedByUserName();
return $this->loadLayout('thz_list', $data);
}
@ -149,7 +150,7 @@ class ThzController extends BaseController
$policyIds = array_column($details, 'policy_id');
$policyIds = array_filter($policyIds);
$clientPolicy = $this->clientPolicyModel->whereIn('policy_id', $policyIds)->where('is_active', 1)->get()->getResultArray();
$clientPolicy = $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray();
$result['client_details'] = $details;
$result['policy_details'] = empty($clientPolicy) ? [] : $clientPolicy ;
@ -195,14 +196,19 @@ class ThzController extends BaseController
if ($returnType === 'api') {
return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200);
}else{
$toGetRelated = $result['master'][0]['created_by'];
$toGetCreatedBy = $result['master'][0]['created_by'];
$toGetPolicyId = (!empty($result['master'][0]['policy_id']) && strtolower($result['master'][0]['policy_id']) !== 'null')
? $result['master'][0]['policy_id']
: '';
$result['related_tickets'] = $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.created_by', $toGetRelated)
->where('thz_master.created_by', $toGetCreatedBy)
->findAll();
$result['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu
// 2,3,4 remain person varannum.
$result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : '';
return $this->loadLayout('thz_notes', $result);
}
@ -449,6 +455,23 @@ class ThzController extends BaseController
}
public function getPolicyTerms($client_policy_id)
{
$policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $client_policy_id)->first();
$policy_terms = [];
if(isset($policy_data['policy_terms']) && !empty($policy_data['policy_terms'])){
$raw_terms = json_decode($policy_data['policy_terms'] ?? [] , true) ?? [];
$ticketController = new TicketController();
$policy_terms = $ticketController->convertTermsToDisplay($raw_terms);
}
$data['policy_terms'] = $policy_terms;
return view('view_policy_terms', $data);
}
}

View File

@ -2386,17 +2386,20 @@ class TicketController extends BaseController
}
// 5. Merge the Sum Insured value if the multiple sum insured exists
if(isset($data['multiple_sum_insured'])){
if(isset($data['sumInsured2'])){
$data['sumInsured2'] = $data['sumInsured2'] . ", " . implode(", ", $data['multiple_sum_insured']);
}else{
$data['sum_insured'] = $data['sum_insured'] . ", " . implode(", ", $data['multiple_sum_insured']);
if (isset($data['multiple_sum_insured'])) {
$multipleSumInsured = is_array($data['multiple_sum_insured']) ? $data['multiple_sum_insured'] : [$data['multiple_sum_insured']]; // force into array if string
if (isset($data['sumInsured2'])) {
$data['sumInsured2'] .= ", " . implode(", ", $multipleSumInsured);
} else {
$data['sum_insured'] .= ", " . implode(", ", $multipleSumInsured);
}
unset($data['multiple_sum_insured']);
}
// 6. Add the special condition to key value pair
if(!empty($data['special_condition_label'])){
foreach ($data['special_condition_label'] as $key => $value) {
if($value != "" && $value != null) {

View File

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class HrFileUploadModel extends Model
{
protected $table = 'hr_file_upload';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
// Allowed fields
protected $allowedFields = [
'client_id',
'client_branch_id',
'policy_no',
'file_name',
'file_action',
'status',
'created_by',
'created_at',
'updated_by',
'updated_at'
];
// Automatically set timestamps
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
// Return type
protected $returnType = 'array';
}

View File

@ -105,7 +105,7 @@ class ThzMasterNotesModel extends Model
AND LOWER(thz_master_notes.notes_by) = 'user'
WHERE thz_master_notes.thz_id = ". $integer_ticket_id ."
$ticketTypeFilter
ORDER BY thz_master_notes.created_at ASC";
ORDER BY thz_master_notes.created_at DESC";
$result = $this->db->query($notes_sql)->getResultArray();

View File

@ -0,0 +1,383 @@
<style>
.select2-container .select2-selection--multiple .select2-selection__choice {
padding: 5px 7px 5px 0 !important;
color: #000000;
}
</style>
<div class="tab-pane fade" id="HR-DOC-tab">
<div class="row">
<div class="col-xl-12">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h5 class="m-1">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h5>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<form class="parsley-examples" id="hr_file_upload_search" >
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select name="client_id" class="form-control" id="client2" >
<option value="">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Branch</label> <br />
<select name="client_branch_id" class="form-control" id="client_branch_id2" >
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select name="client_policy_id" class="form-control" id="policy2" >
<option value="">Select</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Event<span class="text-danger">*</span></label> <br />
<select name="file_action" class="form-control" id="event_type" required>
<option value="">Select</option>
<?php
if (isset($events) && count($events)) {
foreach ($events as $key => $action) {
echo "<option value='$key'" . ($key == "si_enhancement" ? " class='si-enhancement-option'" : "") . ">$action</option>";
}
}
?>
</select>
</div>
</div>
<div class="form-row" id="">
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
<div class="form-group col-md-3">
<button type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Search</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row" id="hr_file_list">
<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;">Files</h4>
</div>
</div>
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0"
id="hr_tickets_table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">File name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">Client Branch</th>
<th class="font-weight-medium">Policy</th>
<th class="font-weight-medium">Event</th>
<th class="font-weight-medium">User/Time</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody class="font-12">
<?php
if (isset($HRfileList)) { foreach ($fileList as $key => $file) { ?>
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name']?>
</td>
<td><?php echo $file['short_name'] ?></td>
<td><?php echo $file['branch_name'] ?></td>
<td><?php echo $file['policy_no'] ?></td>
<td><?php echo $file['file_action'] ?></td>
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['first_name'] . '</strong>' ?></td>
<td><?php echo $file['status']; ?> </td>
<td> </td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
</div>
<script>
var client_list = ''; // local variable for storing the client branch list
var branch_list = ''; // local variable for storing the client branch list
var policy_list = ''; // local variable for storing the client policy list
var branch_policy = '';
$(document).ready(function(){
//initialize the get client, branch, and policy
getClientAndBranchAndPolicy();
//client change to get the Client Branch
$('#client2').change(function(){
let client_id = $(this).val();
console.log('client_id', client_id);
if(branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch3(data);
}
})
//change the client branch than change the client policy
$('#client_branch_id2').change(function(){
let branch_id = $(this).val();
console.log("branch_id", branch_id);
if(policy_list != '' && branch_id != '') {
let data = policy_list[branch_id];
appendPolicy3(data);
}
});
})
$(document).ready(function() {
// Initialize select2
$("#client2").select2();
$("#policy2").select2();
$("#client_branch_id2").select2();
// Form submit event
$("#hr_file_upload_search").on("submit", function (e) {
e.preventDefault(); // stop normal form submit
let formData = $(this).serialize(); // serialize form with csrf
$.ajax({
url: "<?= base_url('hrFileList') ?>",
type: "POST",
data: formData,
dataType: "json",
beforeSend: function () {
// optional loader
$("#hr_tickets_table tbody").html(
"<tr><td colspan='9' class='text-center'>Loading...</td></tr>"
);
},
success: function (res) {
let tbody = "";
if (res.status === "success" && res.data.length > 0) {
$.each(res.data, function (index, file) {
tbody += `
<tr>
<td><b>${index + 1}</b></td>
<td id="${file.id}" class="reload truncate" title="${file.file_name}">${file.file_name}</td>
<td>${file.short_name ?? ""}</td>
<td>${file.branch_name ?? ""}</td>
<td>${file.policy_no ?? ""}</td>
<td>${file.file_action ?? ""}</td>
<td>${file.created_at} by <strong>${file.first_name ?? ""}</strong></td>
<td>${file.status}</td>
<td>
</td>
</tr>
`;
});
} else {
tbody = `<tr><td colspan="9" class="text-center">No records found</td></tr>`;
}
$("#hr_tickets_table tbody").html(tbody);
},
error: function (xhr, status, error) {
console.error("Error:", error);
$("#hr_tickets_table tbody").html(
`<tr><td colspan="9" class="text-center text-danger">Something went wrong</td></tr>`
);
},
});
});
});
// <div class="btn-group dropdown">
// <a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
// data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
// <div class="dropdown-menu dropdown-menu-right">
// <a href="${baseUrl}/hrFileUploadMasters?id=${file.id}" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
// </div>
// </div>
//featch client and branch and policy
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
vehicle_list = res.vehicle_data;
unit_list = res.unit_data;
appendClients3(res.client_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
// ------------ Append Functions are Below ----------------------------------------------------------------------------------
function appendClients3(data)
{
$('#client2').empty();
$('#client2').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
let client_show_name = item.client_name;
if (item.client_type == 2) {
client_show_name = item.client_name + (item.dob ? ('- (' + item.dob + ' )' ) : '') + (item.pan ? ('- ' + item.pan ) : '');
// console.log(client_show_name);
}
var option = $('<option>', {
value: item.id,
text: client_show_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
});
$('#client2').append(option);
});
}
function appendBranch3(data)
{
$('#client_branch_id2').empty();
$('#client_branch_id2').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#client_branch_id2').append(option);
});
}
function appendPolicy3(data)
{
console.log('policy2', data);
console.log('policy2', $('#policy2'));
$('#policy2').empty();
$('#policy2').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.policy_no,
text: item.policy_type + '-' + item.policy_no,
});
$('#policy2').append(option);
});
}
// ----------------------------------------------------------------------------------------------
$(document).ready(function() {
$('#hr_tickets_table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{
"extend": 'csv',
"text": 'CSV',
"title": 'Employee-Upload-List',
"className": 'my_class',
"exportOptions": {
"columns": ':not(:last-child)'
},
}],
"initComplete": function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
});
},
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
});
});
</script>

View File

@ -25,10 +25,17 @@
<span class="d-none d-sm-inline-block">Insurer or TPA Data</span>
</a>
</li>
<li class="nav-item">
<a href="#HR-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="hr_tab">
<span class="mr-1"><i class="fa fa-file"></i></span>
<span class="d-none d-sm-inline-block">HR Uploaded Files</span>
</a>
</li>
</ul>
<div class="tab-content">
<?php include('employee_upload.php'); ?>
<?php include('insurer_or_tpa_data.php'); ?>
<?php include('hr_file_upload.php'); ?>
</div>
</div>
</div>
@ -45,6 +52,11 @@
$('#kyc_tab').click();
}
if (window.location.hash === '#HR-DOC-tab') {
console.log('url hash :', window.location.hash)
$('#hr_tab').click();
}
})

View File

@ -537,7 +537,7 @@
.show > .btn-ternary:dropdown-toggle:focus {
box-shadow: 0 0 0 0.15rem rgba(226, 103, 40, 0.5); }
.btn-border-radius{ .border-radius: 10px !important; }
.btn-border-radius{ border-radius: 10px !important; }

View File

@ -80,6 +80,11 @@ tbody tr td:last-child {
white-space: nowrap !important;
}
.maincard{
margin-top:0 !important;
padding-top: 0 !important;
}
.col-12 {
max-width: 98% !important;
@ -122,8 +127,8 @@ td .text-muted {
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="card-body maincard">
<div class="row" style="padding-bottom: 10px;" >
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Ticket List </h4>
</div>
@ -155,7 +160,10 @@ td .text-muted {
<span class="text-muted"><?php if (!empty($row['empcode'])): echo '('.$row['empcode'].')'; endif; ?></span><br>
<span class="text-muted"><?php if (!empty($row['mobile'])): echo $row['mobile']; endif; ?></span>
</td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo (!empty($row['policy_no']) && strtolower($row['policy_no']) !== 'null')
? $row['policy_no']
: 'N/A'; ?>
</td>
<td><?php echo $row['ticket_type']; ?></td>
<td><?php echo $row['subject']; ?></td>
<td><?php echo $row['status']; ?></td>
@ -259,22 +267,23 @@ td .text-muted {
<input type="text" class="form-control" id="empcode" name="empcode" placeholder="Enter Employee code">
</div>
<div class="form-group col-md-4">
<label for="ticket_type">Ticket Type<span class="text-danger">*</span></label>
<select class="form-control" id="ticket_type" name="ticket_type" required onchange="hideandshowpolicy()">
<option value="">Select Ticket Type</option>
<option value="Sales" selected >Sales</option>
<option value="Service">Service</option>
</select>
</div>
<div class="form-group col-md-4" id="policy_container">
<label for="policy_no">Policy Number</label>
<select class="form-control" id="policy_no" name="policy_no" onchange="changevalue()">
<option value="" selected data-id="">Select Policy</option>
</select>
</div>
<div class="form-group col-md-4">
<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="status">Status</label>
@ -287,9 +296,9 @@ td .text-muted {
</select>
</div> -->
<!-- // enga 5-"head" and 1-"admin" assign pannvaga dropdown-data la varakudhathu
// 2,3,4 dropdown data'va varannum but those role means hide it -->
<?php if(in_array(get_role_id(), [2,3,4]) ) { ?>
<!-- // enga 5-"head" and 1-"admin" assign pannvaga dropdown-data la varakudhathu. but dropdown display aganum
// 2,3,4 dropdown data'va varannum but dropdown hide pannanum -->
<?php if(in_array(get_role_id(), [1,5]) ) { ?>
<div class="form-group col-md-4">
<label for="assign_to">Assign To</label>
<select class="form-control" id="assign_to" name="assign_to">
@ -304,19 +313,20 @@ td .text-muted {
<?php } ?>
<div class="form-group col-md-12">
<label for="subject">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Enter Subject">
<label for="subject">Subject<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Enter Subject" required>
</div>
<div class="form-group col-md-12">
<label for="message">Message</label>
<label for="message">Message<span class="text-danger">*</span></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>
<textarea class="form-control" id="message" name="message" placeholder="Enter Message" rows="4" required></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-border-radius mr-2 text-white" onclick="resetTicket()">Reset</button>
<button type="button" class="btn btn-ternary btn-border-radius" onclick="submitTicket()">Save</button>
</div>
</form>
@ -368,6 +378,11 @@ td .text-muted {
myModal.show();
}
function resetTicket(){
var form = document.getElementById('ticketForm');
form.reset();
}
function submitTicket() {
var form = document.getElementById('ticketForm');
@ -483,14 +498,14 @@ td .text-muted {
let opt = document.createElement("option");
opt.value = p.policy_no;
opt.text = p.policy_no;
opt.setAttribute("data-id", p.policy_id);
opt.setAttribute("data-id", p.id);
policySelect.appendChild(opt);
});
// If you want to auto-select the first real policy instead of "Select Policy"
policySelect.value = policies[0].policy_no;
document.getElementById('policy_no').value = policies[0].policy_no || "";
document.getElementById('policy_id').value = policies[0].policy_id;
document.getElementById('policy_id').value = policies[0].id;
}
} else {
toastr.warning(response.message || "No details found.", 'warning');
@ -512,6 +527,19 @@ td .text-muted {
var policyId = selectedOption.getAttribute("data-id");
document.getElementById('policy_id').value = policyId || "";
}
function hideandshowpolicy() {
var select = document.getElementById('ticket_type').value;
var policyContainer = document.getElementById('policy_container');
if (select === 'Service') {
policyContainer.style.display = "block"; // show
} else {
policyContainer.style.display = "none"; // hide
document.getElementById('policy_no').value = "";
document.getElementById('policy_id').value = "";
}
}
</script>
<script>
@ -536,10 +564,7 @@ $(document).ready(function() {
$("#assign_to").select2();
$("#policy_no").select2();
$("#modal_assignee").select2();
});
// Datatable document ready
$(document).ready(function() {
hideandshowpolicy();
var ticketsTable = $('#scroll-horizontal-datatable');
$('#scroll-horizontal-datatable_filter').prepend('<i class="mdi mdi-magnify"></i>');
@ -554,7 +579,7 @@ $(document).ready(function() {
buttons: [
{
text: '<i class="mdi mdi-plus"></i> Create New Ticket',
className: 'btn btn-ternary btn-border-radius text-white mr-2',
className: 'btn btn-primary btn-border-radius text-white mr-2',
attr: { style: "color:#fff !important;" },
action: function(e, dt, node, config) {
openTicket();
@ -563,6 +588,7 @@ $(document).ready(function() {
{
extend: 'collection',
text: ' Export <i class="mdi mdi-menu-down"></i>',
className: 'btn btn-ternary btn-border-radius text-white',
buttons: [
{
extend: 'csv',

View File

@ -26,7 +26,6 @@
.btn-icon {
background: #008b8b;
border: none;
color: white;
border-radius: 50%;
width: 32px;
height: 32px;
@ -37,6 +36,7 @@
}
.btn-icon i {
color: #ffffff !important;
font-size: 18px;
}
@ -88,9 +88,15 @@
<!-- Title -->
<div class="row" id="notes-title" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Ticket ID-<?php echo $master[0]['thz_id']; ?></h4>
</div>
<!-- <div class="col-6" style="align-self: center;">
<h4 style="position: relative;"><span onclick="history.back()"><i class="mdi mdi-chevron-left" style="font-size: 24px;"></i></span> Ticket ID-<?php echo $master[0]['thz_id']; ?></h4>
</div> -->
<h4 class="d-flex align-items-center" style="gap: 8px;">
<span onclick="history.back()" style="cursor: pointer;">
<i class="mdi mdi-chevron-left" style="font-size: 43px;"></i>
</span>
Ticket ID-<?= $master[0]['thz_id']; ?>
</h4>
</div>
<!-- Body -->
@ -126,7 +132,19 @@
</div>
<div class="row mb-2">
<div class="col-5">Policy Number</div>
<div class="col-7 text-end"><?= $master[0]['policy_no'];?></div>
<div class="col-7 text-end">
<?= (!empty($master[0]['policy_no']) && strtolower($master[0]['policy_no']) !== 'null')
? '<u class="text-warning">
<a href="javascript:void(0);"
class="text-warning"
data-toggle="modal"
data-target="#PolicyModal"
data-id="'.$master[0]['policy_id'].'">'
.$master[0]['policy_no'].'
</a>
</u>'
: 'N/A'; ?>
</div>
</div>
<div class="row mb-2">
<div class="col-5">Assigned To</div>
@ -204,7 +222,7 @@
<?php endforeach; ?>
<?php else: ?>
<div class="d-flex justify-content-center align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
<p class="text-center"><i>No Data Found</i></p>
</div>
<?php endif; ?>
@ -248,8 +266,8 @@
<div class="modal-body">
<div class="form-row">
<input type="text" id="edit_thz_id" name="thz_id">
<input type="text" id="updated_by" name="updated_by" value="<?= get_session_userid(); ?>">
<input type="hidden" id="edit_thz_id" name="thz_id">
<input type="hidden" id="updated_by" name="updated_by" value="<?= get_session_userid(); ?>">
<div class="form-group col-md-12">
<label for="ticket_type">Ticket Type<span class="text-danger">*</span></label>
@ -272,9 +290,9 @@
</select>
</div>
<!-- // enga 5-"head" and 1-"admin" assign pannvaga dropdown-data la varakudhathu
// 2,3,4 dropdown data'va varannum but those role means hide it -->
<?php if(in_array(get_role_id(), [2,3,4]) ) { ?>
<!-- // enga 5-"head" and 1-"admin" assign pannvaga dropdown-data la varakudhathu. but dropdown display aganum
// 2,3,4 dropdown data'va varannum but dropdown hide pannanum -->
<?php if(in_array(get_role_id(), [1,5]) ) { ?>
<div class="form-group col-md-12">
<label for="assign_to">Assign To</label>
<select class="form-control" id="assign_to" name="assign_to">
@ -314,11 +332,11 @@
<div class="card related-ticket-card mb-3">
<div class="card-body" style="border-radius: 20px; padding:27px !important;">
<div class="d-flex justify-content-between align-items-start">
<h5 class="mb-1"><?php echo $rt['ticket_type']; ?></h5>
<h5 class="mb-1"><?php echo '# '.$rt['thz_id']." / ".$rt['ticket_type']; ?></h5>
<small>
<?php if (!empty($rt['created_at'])):
$cdt = new DateTime($rt['created_at']);
echo $cdt->format('d/m/Y') . "<span class='time'>" . $cdt->format('h:i a') . "</span>";
echo $cdt->format('d/m/Y') . "<span class='time'> " . $cdt->format('h:i a') . "</span>";
endif;
?></small>
</div>
@ -333,6 +351,29 @@
</div>
</div>
<div class="modal fade" id="PolicyModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content" style="border-radius:15px;">
<div class="modal-header" style="border-bottom-width:0;">
<h4 class="modal-title">Policy Terms</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body card-scroll" style="padding-top:5px!important;">
<?php if(!empty($policy_terms)):
echo $policy_terms;
else: ?>
<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
<p class="text-center"><i>No Data Found</i></p>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script>
@ -342,32 +383,30 @@
$("#ticket_type").select2();
$("#status").select2();
$("#assign_to").select2();
var form = document.getElementById('ticketForm');
form.reset();
var masterData = <?= json_encode($master[0]); ?>;
document.getElementById('edit_thz_id').value = masterData.thz_id;
document.getElementById('assign_to').value = masterData.assign_to;
document.getElementById('status').value = masterData.status;
document.getElementById('ticket_type').value = masterData.ticket_type;
document.getElementById('EditModalLabel').innerText = "Update Ticket: " + masterData.thz_id ;
});
function openEditTicket() {
var masterData = <?= json_encode($master[0]); ?>;
console.log(masterData);
var form = document.getElementById('ticketForm');
form.reset();
document.getElementById('EditModalLabel').innerText = "Update Ticket: " + masterData.thz_id ;
var masterData = <?= json_encode($master[0]); ?>;
console.log(masterData);
var myModal = new bootstrap.Modal(document.getElementById('EditModal'));
myModal.show();
$("#edit_thz_id").val(masterData.thz_id);
$("#ticket_type").val(masterData.ticket_type).trigger("change");
$("#status").val(masterData.status).trigger("change");
$("#assign_to").val(masterData.assign_to).trigger("change");
$("#EditModalLabel").text("Update #" + masterData.thz_id);
var myModal = new bootstrap.Modal(document.getElementById('EditModal'));
myModal.show();
}
function submitTicket() {
var form = document.getElementById("ticketForm");