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

This commit is contained in:
VENKATESHWARAN 2025-08-05 10:44:10 +05:30
commit f30ca93c5e
17 changed files with 670 additions and 11 deletions

View File

@ -592,7 +592,9 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
$routes->post("getMoreInfo","TicketController::getMoreInfo");
$routes->get("getMoreInfo","TicketController::getMoreInfo");
// $routes->post('ticket_messages','TicketController::getTicketMessage');
$routes->post('upload_url',"TicketController::upload_url");
$routes->post('getUrlDataByTicketId',"TicketController::getUrlDataByTicketId");
$routes->get('remove_url',"TicketController::remove_url");
});
$routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){

View File

@ -20,6 +20,7 @@ use App\Models\EmployeePolicyModel;
use App\Models\InsurerModel;
use App\Models\EmployeeModel;
use App\Models\TPAModel;
use App\Models\ClaimFilesModel;
use DOMDocument;
use Psr\Log\LoggerInterface;
@ -58,6 +59,7 @@ class TicketController extends BaseController
protected $extraFieldsDisplayForFrontend;
protected $insurerModel;
protected $TPAModel;
protected $claimFilesModel;
public function __construct()
{
@ -341,6 +343,7 @@ class TicketController extends BaseController
$this->employeePolicyModel = new EmployeePolicyModel();
$this->insurerModel = new InsurerModel();
$this->TPAModel = new TPAModel();
$this->claimFilesModel = new ClaimFilesModel();
}
public function ticketList()
@ -825,8 +828,12 @@ class TicketController extends BaseController
// dd($data);
$data['ticket_data'] = $ticket_data;
$data['acms'] = $this->employeeModel->getAcmUsingClientID($ticket_data['client_id']);
$raw_json = $this->ticketMasterModel->getPolicyTermsJson($ticket_id) ;
$decoded_top = json_decode($raw_json ?? "", true) ?? [];
$data['policy_terms'] = $this->recursive_json_decode($decoded_top);
// dd($data);
return $this->loadLayout('ticket_edit_onbording', $data);
}
@ -2135,7 +2142,117 @@ class TicketController extends BaseController
$date = \DateTime::createFromFormat($format, $value);
return $date && $date->format($format) === $value;
}
public function upload_url(){
$data = $this->request->getPost();
$insertArr = [];
foreach ($data['docs_name'] as $key => $eachData) {
if (!empty($eachData) ) {
$insertData = [
'doc_name' => $data['docs_name'][$key]??'',
'url' => $data['url'][$key]??'',
'ticket_id'=> $data['ticket_id_url']??'',
'created_by' => get_session_userid(),
'is_active' => 1
];
$insertArr[] = $insertData;
}
}
if(!empty($insertArr)){
// Insert into database
$insert = $this->claimFilesModel->insertBatch($insertArr);
}
if (isset($insert) && !empty($insert)) {
return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']);
} else {
return $this->respond(['status' => false, 'message' => 'Failed to upload file ']);
}
}
public function getUrlDataByTicketId()
{
$ticket_id = $this->request->getPost('ticket_id');
if (!$ticket_id) {
return $this->response->setJSON([
'status' => false,
'message' => 'Ticket ID is required',
'data' => []
]);
}
$urlData = $this->claimFilesModel
->where('ticket_id', $ticket_id)
->where('is_active',1)
->findAll();
return $this->response->setJSON([
'status' => true,
'data' => $urlData
]);
}
public function remove_url()
{
$id = $this->request->getGet('id');
if (empty(trim($id))) {
return $this->response->setJSON([
'status' => false,
'message' => 'Invalid ID'
]);
}
$updated = $this->claimFilesModel
->where('id', $id)
->set(['is_active' => 0])
->update();
if ($updated) {
return $this->response->setJSON([
'status' => true,
'message' => 'URL successfully marked inactive.'
]);
} else {
return $this->response->setJSON([
'status' => false,
'message' => 'Failed to update record.'
]);
}
}
public function recursive_json_decode($input) {
if (is_string($input)) {
$decoded = json_decode($input, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $this->recursive_json_decode($decoded); // continue decoding recursively
} else {
return $input;
}
}
if (is_array($input)) {
foreach ($input as $key => $value) {
$input[$key] = $this->recursive_json_decode($value);
}
}
return $input;
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ClaimFilesModel extends Model
{
protected $table = 'claim_files';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'ticket_id',
'doc_name',
'url',
'created_by',
'updated_by',
'created_at',
'updated_at',
'is_active'
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}
}

View File

@ -953,4 +953,29 @@ class TicketMasterModel extends Model
'ticket_ids' => $ticketIdsString
];
}
public function getPolicyTermsJson($ticket_id)
{
$sql = " SELECT cp.policy_terms
FROM ticket_master tm
JOIN client_policy cp ON cp.id = tm.client_policy_id
WHERE tm.id = ?
AND tm.is_active = 1
AND cp.is_active = 1
";
$binds = [$ticket_id];
$query = $this->db->query($sql, $binds);
if ($query && $query->getNumRows() > 0) {
$row = $query->getRowArray();
return json_encode(['policy_terms' => $row['policy_terms']]);
}
return json_encode(['policy_terms' => null]);
}
}

View File

@ -0,0 +1,329 @@
<div class="tab-pane" id="fileupload">
<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;color:black;"></i>
</a>
</h5>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<form class="parsley-examples" id="drive_file_upload_form" method="post"
enctype="multipart/form-data">
<input type="hidden" id="ticket_id_url" name="ticket_id_url">
<div class="form-group">
<div id="dynamic-form-container"></div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="g_drive_file_upload_sbt_btn">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="file_table" 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;">File List</h4>
</div>
</div>
<div class="table-responsive" style="overflow-x: auto;">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No</th>
<th>Docs Name</th>
<th>File Name</th>
<th>Action</th>
</tr>
</thead>
<tbody id="table_bd">
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-- edit modal -->
<div class="modal fade" id="edit_url_modal" tabindex="-1" role="dialog" aria-labelledby="editUrlModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<form id="edit_url_form">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit URL</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<input type="hidden" id="edit_url_id" name="id">
<div class="form-group">
<label for="edit_doc_name">Document Name</label>
<input type="text" class="form-control" id="edit_doc_name" name="doc_name">
</div>
<div class="form-group">
<label for="edit_url_link">URL</label>
<input type="text" class="form-control" id="edit_url_link" name="url">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save Changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</form>
</div>
</div>
<script>
$(document).ready(function(){
let ticket_id = $('#ticket_master_id').val();
$('#ticket_id_url').val(ticket_id);
let urlData = getUrlDataByTicketId(ticket_id);
})
$("#drive_file_upload_form").submit(function(event) {
event.preventDefault();
var isValid = $('#drive_file_upload_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return ;
}
form_action = '<?php echo base_url() . 'ticket/upload_url' ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#drive_file_upload_form')[0]);
$.ajax({
data:formData,
url: form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
toastr.success(res.message, 'Success');
window.location.reload();
}else{
toastr.error(res.message, 'Error');
}
},
error: function (xhr, status, error) {
console.log("error in submission of url data");
console.error(xhr.responseText);
console.error(status, error);
},
complete : function(){
console.log("ajax call is completed for submission of url data..!!");
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
function addHTMLInput()
{
const container = document.getElementById('dynamic-form-container');
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="docs_name" name="docs_name[]" placeholder="Enter file name" required
value=""
>
</div>
<div class="form-group col-md-5">
<label for="file">URL<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="url_name" name="url[]" required
value=""
>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
</div>
`;
container.appendChild(newRow);
}
function removeHTMLInput(element)
{
const container = document.getElementById('dynamic-form-container');
const rows = container.querySelectorAll('.dynamic-form-row');
if (rows.length > 1) {
const row = element.closest('.dynamic-form-row');
row.remove();
}
}
function getUrlDataByTicketId(ticket_id) {
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: "<?= base_url('ticket/getUrlDataByTicketId')?>", // base_url must be defined in JS
type: "POST",
data: { ticket_id: ticket_id },
dataType: 'json',
success: function(response) {
console.log('Form submitted response:', response);
if (response.status === true) {
create_url_list(response.data);
addHTMLInput();
return ;
} else {
addHTMLInput();
console.warn("No Data");
}
},
error: function(xhr, status, error) {
console.log("error in get urldata api");
console.error("AJAX Error:", error);
},
complete: function() {
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log("Ajax is completed for get url data..!!");
}
});
}
function openEditModal(id, docName, url) {
$('#edit_url_id').val(id);
$('#edit_doc_name').val(docName);
$('#edit_url_link').val(url);
$('#edit_url_modal').modal('show'); // Bootstrap modal
}
function create_url_list(data) {
$('#table_bd').empty(); // clear existing rows
let base_url = "<?php echo base_url() ?>";
if (data && data.length > 0) {
let html = "";
data.forEach((item, index) => {
html += `
<tr>
<td>${index + 1}</td>
<td>${item.doc_name}</td>
<td><a href="${item.url}" target="_blank">${item.url}</a></td>
<td>
<a href="javascript:void(0);" class="delete-url"
style="bacolor:black;"
data-href="${base_url}/ticket/remove_url?id=${item.id}">
<i class="mdi mdi-delete mr-1"></i>
</a>
</td>
</tr>
`;
});
$('#table_bd').append(html);
} else {
$('#table_bd').html('<tr><td colspan="4">No Data Found</td></tr>');
}
}
$(document).on('click', '.delete-url', function (e) {
e.preventDefault();
const url = $(this).data('href');
const $row = $(this).closest('tr'); // capture the row before async execution
confirmActionSweertAlert("Do you want to delete?", "Yes, Proceed!", "No, Cancel")
.then((confirmed) => {
if (confirmed) {
$.ajax({
url: url,
type: "GET",
dataType: "json",
beforeSend: function () {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
},
success: function (response) {
if (response.status === true) {
toastr.success('Removed Successfully');
$row.remove();
} else {
toastr.error(response.message || 'Deletion failed');
}
},
error: function (xhr, status, error) {
console.log("error ");
console.error("AJAX Error:", error);
toastr.error('AJAX request failed');
},
complete: function () {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log("Ajax is completed for get url data..!!");
}
});
}
});
});
</script>

View File

@ -106,6 +106,8 @@
<th class="font-weight-medium">EMP Code</th>
<th class="font-weight-medium">Relationship</th>
<th class="font-weight-medium">Gender</th>
<th class="font-weight-medium">Email</th>
<th class="font-weight-medium">Mobile</th>
<th class="font-weight-medium">Date of Birth</th>
<th class="font-weight-medium">Policy name</th>
<th class="font-weight-medium">Insurer name</th>
@ -141,6 +143,8 @@
<td><?php echo $employee['emp_code']; ?></td>
<td><?php echo $employee['relationship']; ?></td>
<td><?php echo $employee['gender']; ?></td>
<td><?php echo $employee['email_corporate']; ?></td>
<td><?php echo $employee['mobile']; ?></td>
<td><?php echo date('d/m/Y', strtotime($employee['dob'])); ?></td>
<td><?php echo isset($employee['policy_type']) ? $employee['policy_type'] : ''; ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : ''; ?></td>
<td><?php echo $employee['insurer_short_name']; ?></td>

View File

@ -56,6 +56,20 @@
<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 -->
@ -82,6 +96,12 @@
<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>

View File

@ -109,7 +109,12 @@ table.dataTable tbody td {
<th>TAT</th>
<!-- role based delete option -->
<?php if(in_array(get_role_id(), [1,2,5]) ) { ?>
<th>ACTION</th>
<?php } ?>
</tr>
</thead>
<tbody>
@ -217,16 +222,21 @@ table.dataTable tbody td {
<td><?php echo $row['tat']; ?></td>
<td>
<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 class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removeClaim(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<!-- role based delete option -->
<?php if(in_array(get_role_id(), [1,2,5]) ) { ?>
<td>
<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 class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removeClaim(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
</div>
</div>
</td>
</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>

View File

@ -0,0 +1,97 @@
<br>
<p style="color:black;">
<b>Policy Terms</b>
</p>
<br>
<?php
// ✅ Format keys: underscores to spaces, each word capitalized
function readable_key($key) {
$key = str_replace('_', ' ', $key);
return ucwords($key);
}
// ✅ Format values: 0 = NO, 1 = YES, >1 = number as-is
function format_value($value) {
if (is_numeric($value)) {
if ($value == 0) return 'No';
if ($value == 1) return 'Yes';
}
return $value;
}
// ✅ Recursively render nested keyvalue pairs
function nestedKeyValuePair($data) {
$output = '';
foreach ($data as $key => $value) {
$label = readable_key($key);
$output .= "<span style='color:black;'> : <b>$label</b>";
if (is_array($value)) {
$output .= "<span style='margin-left: 10px;'>" . nestedKeyValuePair($value) . "</span>";
} else {
$formattedValue = format_value($value);
$output .= " : " . htmlspecialchars($formattedValue) ;
}
$output .= "</span>";
}
return $output;
}
if (isset($policy_terms['policy_terms']) && is_array($policy_terms['policy_terms'])) {
// ✅ Merge multiple_sum_insured with sum_insured
if (
isset($policy_terms['policy_terms']['multiple_sum_insured']) &&
is_array($policy_terms['policy_terms']['multiple_sum_insured'])
) {
$sum_insured_values = implode(' , ', $policy_terms['policy_terms']['multiple_sum_insured']);
$original_sum = isset($policy_terms['policy_terms']['sum_insured'])
? $policy_terms['policy_terms']['sum_insured']
: '';
$policy_terms['policy_terms']['sum_insured'] = $original_sum . " , " . $sum_insured_values;
unset($policy_terms['policy_terms']['multiple_sum_insured']);
}
// ✅ Display each policy term
foreach ($policy_terms['policy_terms'] as $key => $value) {
if ($key === "age_ratio" || $key === "enrollment_display_key") {
continue; // Skip excluded keys
}
// Normalize specific raw keys (if needed)
if ($key === 'waiverof30dayswaitingperiod') {
$key = 'Waiver_of_30_days_waiting_period';
}
if ($key === 'suminsuredenhancement') {
$key = 'sum_insured_enhancement';
}
// Readable label
$label = readable_key($key);
$nesetedValues = "";
?>
<div class="row">
<div class="form-group col-3">
<p style="color:black;"><b><?php echo htmlspecialchars($label); ?>:</b></p>
</div>
<div class="form-group col-6">
<?php
if (is_array($value)) {
$nesetedValues .= nestedKeyValuePair($value) .",";
echo "$nesetedValues";
} else {
$formattedValue = format_value($value);
echo "<p style='color:black;'>: " . htmlspecialchars($formattedValue) . "</p>";
}
?>
</div>
</div>
<?php
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB