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

This commit is contained in:
VENKATESHWARAN 2025-09-09 18:48:44 +05:30
commit 0d6db7c68f
10 changed files with 754 additions and 30 deletions

View File

@ -27,6 +27,7 @@ use App\Models\ClientDepositModel;
use App\Models\PolicyPremium2Model;
use App\Models\AuditHistoryModel;
use App\Models\UserModel;
use App\Models\PartnerEndorsementRequestModel;
use App\Controllers\Jobs;
@ -68,6 +69,7 @@ class EmployeeController extends AdminController
protected $PolicyPremium2Model;
protected $auditHistory;
protected $userModel;
protected $partnerEndorsementRequestModel;
public function __construct()
{
@ -90,6 +92,7 @@ class EmployeeController extends AdminController
$this->PolicyPremium2Model = new PolicyPremium2Model();
$this->auditHistory = new AuditHistoryModel();
$this->userModel = new userModel();
$this->partnerEndorsementRequestModel = new PartnerEndorsementRequestModel();
}
public function list()
@ -3007,11 +3010,31 @@ class EmployeeController extends AdminController
}
/**
* Below function displays the endorsement list page.
*
* This method retrieves filter data from the request and fetches the endorsement list
* based on the provided filters such as client ID, policy ID, and status.
*/
public function retailendorsementList()
{
$data['message'] = 'File Not Found';
echo view('errors/404', $data);
$data = [];
$data['status'] = ['open' => 'Open', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
if (count($this->request->getGet())) {
$filterData = $this->request->getGet();
$data['employees'] = $this->partnerEndorsementRequestModel->getRetailEndorsementList(
client_id: $filterData['client_id'],
insurer_id: $filterData['insurer_id'],
status: $filterData['status']
);
$data['getData'] = $filterData;
// echo "<pre>";
// print_r($data); die;
}
$this->myLogger->logme('error', 'list called');
$this->loadLayout('retail_endorsement_list', $data);
}
}

View File

@ -1702,6 +1702,15 @@ class EmployeeServiceController extends AdminController
$value['relationship'] = ucfirst(trim($value['relationship']));
if(count($employee))
{
if (isset($employee[0]['email_corporate']) && $employee[0]['email_corporate'] != '')
{
unset($value['email_corporate']);
}
if (isset($employee[0]['mobile']) && $employee[0]['mobile'] != '')
{
unset($value['mobile']);
}
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee[0]['id'];
$value['emp_status'] = 'active';

View File

@ -676,12 +676,17 @@ class UserController extends AdminController
$fileId = $this->request->getPost('id');
if ($file && $file->isValid() && !$file->hasMoved()) {
$fileName = $file->getName();
$path = WRITEPATH.'uploads/incentives';
$originalName = $file->getClientName();
$extension = $file->getExtension();
$fileName = pathinfo($originalName, PATHINFO_FILENAME) . '_' . date('Ymd_His') . '.' . $extension;
$path = WRITEPATH . 'uploads/incentives';
$file->move($path, $fileName);
$data = [
'manager_id' => $managerId,
'incentive_month' => date('Y-m-d', strtotime($month)),
'incentive_month' => date('M Y', strtotime($month)),
'incentive_file_name' => $fileName,
'created_by' => get_session_userid()
];
@ -757,23 +762,33 @@ class UserController extends AdminController
}
}
public function downloadIncentivesFile($file_name)
public function downloadIncentivesFile($file_id)
{
$file_name = basename($file_name);
$filePath = WRITEPATH . 'uploads/incentives/' . $file_name;
try {
$result = $this->partnerManagerIncentiveFileModel->where('id', $file_id)->first();
if (!$result || empty($result['incentive_file_name'])) {
throw new \Exception("File Name Not Found");
}
$incentive_file_name = $result['incentive_file_name'];
$file_name = basename($incentive_file_name);
$filePath = WRITEPATH . 'uploads/incentives/' . $file_name;
if (file_exists($filePath)) {
return $this->response->download($filePath, null);
} else {
$data['message'] = 'File Not Found';
echo view('errors/404', $data);
throw new \Exception("File Not Found");
}
} catch (\Exception $e) {
// Handle any exceptions
$errorMessage = $e->getMessage();
$this->myLogger->logme('error', $errorMessage);
// You can return an error response here
echo $errorMessage;
$this->myLogger->logme('error', $e->getMessage());
// Show 404 error view
$data['message'] = $e->getMessage();
return view('errors/404', $data);
}
}
}

View File

@ -73,7 +73,7 @@
body[data-sidebar-size=condensed]:not([data-layout=compact]):not(.auth-fluid-pages) {
min-height: 0;
max-height:100vh !important;
}
.navbar-custom {

View File

@ -37,4 +37,53 @@ class PartnerEndorsementRequestModel extends Model
'status',
];
public function getRetailEndorsementList($client_id, $insurers_id, $status)
{
$query = $this->db->table('partner_endorsement_request per')
->distinct()
->select('
per.id,
per.client_id,
per.client_policy_id,
per.insurer_id,
per.insurer_branch_id,
per.policy_number,
per.endorsement_no,
per.endorsement_type,
per.endorsement_description,
per.created_at,
per.updated_by,
per.updated_at,
per.is_active,
per.created_by,
per.manager_id,
per.agent_id,
per.status,
i.name as insurer_name,
i.short_name as insurer_short_name,
c.client_name,
c.short_name as client_short_name,
ps.name as manager_name,
pa.name as agent_name
')
->join('insurers as i', 'i.id = per.insurer_id', 'left')
->join('clients as c', 'c.id = per.client_id AND c.client_type = 2', 'left')
->join('partner_staff as ps', 'ps.id = per.manager_id AND ps.role_id = 1', 'left')
->join('partner_agent as pa', 'pa.id = per.agent_id', 'left');
if (!empty($status)) {
$query->where('per.status', $status);
}
if (!empty($client_id)) {
$query->where('per.client_id', $client_id);
}
if (!empty($insurers_id)) {
$query->where('per.insurer_id', $insurers_id);
}
$query->orderBy('per.id', 'desc');
return $query->get()->getResultArray();
}
}

View File

@ -167,10 +167,9 @@
}
}
.tab-content-styles{
#client_add .tab-content-styles{
background-color:#F4F4F4;
margin-right:20px;
margin-left:20px;
margin-top:0px !important;
border-radius:25px!important;
min-height: 70vh !important;
@ -183,7 +182,7 @@
</style>
<p style="color:black;font-size:x-large;margin-left:50px;margin-bottom:20px;"><b>Dashboard</b></p>
<p style="color:black;font-size:x-large;margin-left:20px !important;margin-bottom:20px;"><b>Dashboard</b></p>
<?php if(in_array(get_role_id(), [1,2,3,4,5]) || (in_array(ENROLLMENT_TEAM_ID, user_team()) || in_array(CLAIMS_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>

View File

@ -542,7 +542,7 @@ table.dataTable tbody td {
</div>
</div>
</div><!-- /.modal -->
<div id="nhance-partner-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div id="nhance-partner-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
@ -594,7 +594,7 @@ table.dataTable tbody td {
</div>
</div>
</div><!-- /.modal -->
<div id="upload-incentive-file-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div id="upload-incentive-file-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
@ -797,7 +797,7 @@ table.dataTable tbody td {
var incentiveMonthPicker = flatpickr("#incentive_month", {
dateFormat: "Y-m-d", // real value stored (hidden)
altInput: true, // show a user-friendly display
altFormat: "M-Y", // what you want to display (Aug-2025)
altFormat: "M Y", // what you want to display (Aug 2025)
allowInput: false,
});
@ -1413,7 +1413,10 @@ table.dataTable tbody td {
// let container = modal.find(".container");
let container = $("#container");
container.html(`<div class="text-muted small">Loading...</div>`); // temporary loading msg
container.html(`<div class="col-md-12 mt-2">
<div class="d-flex align-items-center justify-content-center p-2 bg-white">
<div class="text-muted small">Loading...</div>
</div></div>`);
$.ajax({
@ -1436,7 +1439,8 @@ table.dataTable tbody td {
};
let uploaded = date.toLocaleString('en-GB', options).replace(',', '');
let color = file.incentive_file_name ? "app-text-success" : "app-text-black";
let download_url = "<?= base_url('user/download-incentive-file/') ?>" + encodeURIComponent(file.incentive_file_name);
let download_url = "<?= base_url('user/download-incentive-file/') ?>" + encodeURIComponent(file.id);
let im = file.incentive_month;
let card = `<div class="col-md-6 mt-2 file-card"
@ -1448,8 +1452,12 @@ table.dataTable tbody td {
<i class="mdi mdi-file-document-outline app-text-black" style="font-size: 24px;"></i>
</div>
<div class="ml-2">
<div class="font-weight-bold app-text-black small">${file.incentive_file_name}</div>
<div class="text-muted small">Uploaded ${uploaded}</div>
<div class="font-weight-bold app-text-black small text-truncate"
title="${file.incentive_file_name}"
style="max-width: 265px;">
${file.incentive_file_name}
</div>
<div class="text-muted small">Uploaded : ${im}</div>
</div>
</div>
<div>

View File

@ -3,6 +3,11 @@
border-collapse: separate; /* important */
border-spacing: 20px 0; /* 20px horizontal, 0 vertical */
}
#client_info_modal .modal-body{
padding:20px 0px 10px 40px !important;
}
</style>
@ -109,7 +114,7 @@
<?php foreach ($client_policy as $key => $value) { ?>
<tr class="policy_terms"
data-id="<?= htmlspecialchars($value['policy_terms']) ?>"
data-toggle="modal" data-target="#bs-example-modal-lg">
data-toggle="modal" data-target="#client_info_modal">
<td><?= $value['branch_name'] ?></td>
<td><?= $value['policy_type'] ?></td>
<td><?= $value['insurer_short_name'] ?></td>
@ -214,7 +219,7 @@
<!-- Modal content for the Large example -->
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
<div class="modal fade" id="client_info_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right: 15px">
<div class="modal-dialog modal-full-width">
<div class="modal-content">

View File

@ -131,6 +131,12 @@
.container-fluid {
padding: 0px 40px 0px 40px !important;
}
body[data-sidebar-size=condensed]:not([data-layout=compact]):not(.auth-fluid-pages)
{
min-height: 100vh !important;
}
</style>
<!-- navbar -->
@ -182,14 +188,14 @@
background-color: #D4F5F6;
z-index: 700;
padding: 0px !important;
height: 90%;
height: 90% !important;
}
</style>
<!-- rightbar -->
<style>
.right-bar {
width: 300px;
width: 300px !important;
/* Adjust as needed */
overflow: hidden;
}

View File

@ -0,0 +1,610 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
position: relative;
left: 79px;
}
</style>
<div class="container-fluid">
<h2>Retail Endorsement</h2>
<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"> -->
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Insurer</label> <br />
<select class="form-control" id="insurer">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Status</label> <br />
<select class="form-control" id="status1">
<option value="0">Select</option>
<?php foreach ($status as $key => $value) { ?>
<option value="<?= $key ?>" <?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div>
</div>
<!-- </div> -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="client_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;">Endorsement List</h4>
</div>
</div>
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Policy number</th>
<th class="font-weight-medium">Endorsement Number</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">Insurer name</th>
<th class="font-weight-medium">Agent</th>
<th class="font-weight-medium">Mananger</th>
<th class="font-weight-medium">Created At</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody class="font-12">
<?php
if (isset($employees)) {
foreach ($employees as $key => $employee) { ?>
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $employee['policy_number'] ?></td>
<td><?php echo $employee['endorsement_no'] ?></td>
<td><?php echo $employee['endorsement_description'] ?></td>
<td><?php echo $employee['insurer_name'] .' ( '. $employee['insurer_short_name'] .' ) ' ?></td>
<td><?php echo $employee['client_name'] .' ( '. $employee['client_short_name'] .' ) ' ?></td>
<td><?php echo $employee['agent_name'] ?></td>
<td><?php echo $employee['manager_name'] ?></td>
<td><?php echo $employee['created_at'] ?></td>
<td><?php if ($employee['status'] == 'open') {
echo '<span class="badge badge-primary">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'complete') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
}
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id'] ?>" data-eno="<?php echo $employee['endorsement_no'] ?>" data-status="<?php echo $employee['status'] ?>"
class="mdi mdi-eye emp_data_model" aria-hidden="true" data-toggle="modal" data-target="#centermodal"></a>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-- Center modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Edit Endorsement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(document).ready(function() {
// Initialize select2
$("#clients").select2();
$("#insurer").select2();
});
// Declare a global variable to store API response data
var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var insurer_id = '<?= isset($getData) ? $getData['insurer_id'] : '0' ?>';
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log(response.code);
// console.log(response.dataStatus);
// console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
response.data.forEach(policy => {
// console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
});
// console.log(clientPolicies);
appendClients(clientPolicies);
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
// console.log(typeof item.id)
return item.id == client_id;
});
appendBranch(foundPolicies.branchs);
}
}, 500);
setTimeout(function() {
if (client_branch_id) {
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
// console.log('item', item);
return item.branch_id === client_branch_id;
});
if (foundPolicies) {
// console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
}
}, 500);
} catch (error) {
console.error('Error parsing API response data:', error);
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
$('#loader').hide();
}
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendBranch(data) {
$('#branch_id').empty();
$('#branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
if (client_branch_id == item.id) {
option.attr('selected', true);
}
$('#branch_id').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
// console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
// text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
$(document).ready(function() {
$('#clients').on('change', function() {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val();
// console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
// Check if the selected option exists in apiData
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
// console.log(foundPolicies.branchs);
appendBranch(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
// console.log('selectedBranch', selectedClient);
// console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
// console.log('item', item);
return item.branch_id === selectedClient;
});
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
appendPolicies(foundPolicies);
toastr.warning('No policies found for the selected client branch.');
} else {
// console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
}
});
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status1').val();
var branch_id = $('#branch_id').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
status: status,
};
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
// console.log(apiURL);
window.location.href = apiURL;
}
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
$('.emp_data_model').click(function() {
var id = $(this).data('id');
var eno = $(this).data('eno');
var status = $(this).data('status');
// console.log(val);
fetchEmpEndorsementData(id,eno,status)
});
function fetchEmpEndorsementData(id,eno,status) {
alert("id");
alert(id);
alert(eno);
alert(status);
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// var apiURL = '<?php echo base_url(); ?>' + 'util/get-emp-endorsement/' + id;
// console.log('fetchEmpEndorsementData');
// // console.log(apiURL);
// $.ajax({
// url: apiURL,
// method: 'GET',
// headers: {
// "Content-Type": "application/json",
// "X-Requested-With": "XMLHttpRequest"
// },
// success: function(response) {
// // console.log(response);
// if (response.code === 200 && response.dataStatus === true) {
// try {
// endorsementData = (response.data);
// endorsementData2 = (response.data2);
// e_actions = endorsementData2[0]['actions'];
// var heading = "";
// if (endorsementData2[0]['actions'] == 'si') {
// heading = ' - ' + 'SI Enhancement';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// } else if (endorsementData2[0]['actions'] == 'd') {
// heading = ' - ' + 'Deletion';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// } else if (endorsementData2[0]['actions'] == 'c') {
// heading = ' - ' + 'Correction';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// }
// $('#heading').html(heading);
// $('#table_data').empty();
// $('#table_head_data').empty();
// if (e_actions == 'd') {
// $.each(endorsementData, function(index, item) {
// var tableHtml = `
// <tr>
// <td>${item.field_name}</td>
// <td>${formatNumberToIndianLocale(item.data, item.field_name, e_actions)}</td>
// </tr>
// `;
// $('#table_data').append(tableHtml);
// });
// } else {
// var table_head = `
// <tr>
// <th class="font-weight-medium"></th>
// <th class="font-weight-medium">Old Value</th>
// <th class="font-weight-medium">New Value</th>
// </tr>
// `;
// $('#table_head_data').append(table_head);
// $.each(endorsementData, function(index, item) {
// var tableHtml = `
// <tr>
// <td>${item.field_name}</td>
// <td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
// <td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
// </tr>
// `;
// $('#table_data').append(tableHtml);
// });
// }
// } catch (error) {
// console.error('Error parsing API response data:', error);
// }
// } else if (response.code === 404 && response.dataStatus === false) {
// console.error('no data found', response);
// } else {
// console.error('Something went wrong!');
// }
// },
// error: function(xhr, status, error) {
// console.error('Error fetching data from API:', error);
// }
// });
// setTimeout(function() {
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, 200);
}
function formatNumberToIndianLocale(value, field_name, action) {
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
if (field_name == 'Period of non coverage') {
return value + ' days';
}
if (field_name == 'Total Amount') {
return '₹ ' + return_val + ' ( To be Refunded )';
}
if (field_name == 'Total') {
if (action == 'd') {
return '₹ ' + return_val + ' ( To be Refunded )';
} else if (action == 'si') {
return '₹ ' + return_val + ' ( To be paid )';
}
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
}
}
$('.close').click(function() {
$('#table_data').empty();
})
$(document).ready(function() {
$('#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: 'Endorsement-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)',
format: {
body: function (data, row, column, node) {
// Convert data to string to avoid scientific notation in CSV
if (!isNaN(data) && parseFloat(data) > 1e20) {
return `'${data}`;
}
return data.toString();// Ensures all data is treated as strings
}
}
}
}],
initComplete: function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
});
},
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
// pagingType: 'full_numbers'
columnDefs: [
{ type: 'scientific', targets: 0 } // Apply custom sorting type to the first column
],
});
});
</script>