432 lines
21 KiB
PHP
Executable File
432 lines
21 KiB
PHP
Executable File
<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;
|
||
}
|
||
|
||
.emp_data_model {
|
||
font-size: 17px;
|
||
/* keep fixed size */
|
||
color: #555 !important;
|
||
cursor: pointer;
|
||
transition: transform 0.2s, color 0.2s;
|
||
/* smooth hover effect */
|
||
display: inline-block;
|
||
/* important for transform */
|
||
}
|
||
|
||
.emp_data_model:hover {
|
||
color: #00999E !important;
|
||
transform: scale(1.5);
|
||
}
|
||
.dataTables_length label {height: 21px !important;}
|
||
</style>
|
||
|
||
<div class="container-fluid-min">
|
||
<div class="row">
|
||
<div class="col-xl-12">
|
||
<div class="card-body">
|
||
<div id="accordion" class="mb-3">
|
||
<div class="card mb-1">
|
||
<h4>
|
||
Filter
|
||
<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>
|
||
</h4>
|
||
<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>
|
||
<?php foreach ($client as $key => $value) { ?>
|
||
<option value="<?= $value['id'] ?>" <?= (($getData['client_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
|
||
<?= $value['client_name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Insurer</label> <br />
|
||
<select class="form-control" id="insurer">
|
||
<option value="0">Select</option>
|
||
<?php foreach ($insurer as $key => $value) { ?>
|
||
<option value="<?= $value['id'] ?>" <?= (($getData['insurer_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
|
||
<?= $value['name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
|
||
</option>
|
||
<?php } ?>
|
||
</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 ?>" <?= (($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/retail-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>
|
||
|
||
<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</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">S.No </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 class="text-center"><b><?php echo ($key + 1) ?></b></td>
|
||
<td class="text-center"><?php echo $employee['policy_number'] ?></td>
|
||
<td class="text-center"><?php echo $employee['endorsement_no'] ?></td>
|
||
<td class="text-center"><?php echo $employee['endorsement_description'] ?></td>
|
||
<td class="text-center"><?php echo $employee['client_name'] ? $employee['client_name'] . ' ( ' . $employee['client_short_name'] . ' ) ' : 'N/A' ?></td>
|
||
<td class="text-center"><?php echo $employee['insurer_name'] ? $employee['insurer_name'] . ' ( ' . $employee['insurer_short_name'] . ' ) ' : 'N/A' ?></td>
|
||
<td class="text-center"><?php echo $employee['agent_name'] ?? 'N/A' ?></td>
|
||
<td class="text-center"><?php echo $employee['manager_name'] ?? 'N/A' ?></td>
|
||
<td class="text-center"><?php if (!empty($employee['created_at'])):
|
||
$cd = date("j F Y", strtotime($employee['created_at']));
|
||
$ct = date("h:i A", strtotime($employee['created_at']));
|
||
echo $cd . "<br><span class='time'> " . $ct . "</span>";
|
||
endif; ?></td>
|
||
<td class="text-center"><?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-pencil text-muted vertical-middle 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>
|
||
|
||
|
||
|
||
|
||
|
||
<div class="modal fade font-color-black " id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<form id="retailEndorsementForm">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title title-text" id="myCenterModalLabel" style="font-size:27px !important">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">
|
||
<div class="form-row">
|
||
<input type="hidden" id="edit_id" name="id">
|
||
<input type="hidden" id="updated_by" name="updated_by" value="<?= get_session_userid(); ?>">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="endorsement_no" class="sub-title-text ">Endorsement Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="endorsement_no" placeholder="Enter Endorsement Number" name="endorsement_no" required>
|
||
</div>
|
||
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="edit_status" class="sub-title-text ">Status<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="edit_status" name="status" required>
|
||
<option value="">Select Status</option>
|
||
<?php foreach ($status as $key => $value) { ?>
|
||
<option value="<?= $key ?>"><?= $value ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal-footer">
|
||
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit" onclick="submitRetailEndorsement(event)">Save</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
// Initialize select2
|
||
$("#clients").select2();
|
||
$("#insurer").select2();
|
||
});
|
||
|
||
var client_id = '<?= $getData['client_id'] ?? '' ?>';
|
||
var insurer_id = '<?= $getData['insurer_id'] ?? '' ?>';
|
||
var status_id = '<?= $getData['status'] ?? '' ?>';
|
||
|
||
$(window).on("load", function() {
|
||
console.log("window loaded");
|
||
});
|
||
|
||
|
||
// 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 insurer_id = $('#insurer').val();
|
||
var status = $('#status1').val();
|
||
|
||
var queryParams = {
|
||
client_id: client_id,
|
||
insurer_id: insurer_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);
|
||
fetchRetailEndorsementData(id, eno, status)
|
||
|
||
});
|
||
|
||
function submitRetailEndorsement(e) {
|
||
e.preventDefault(); // stop normal form submit
|
||
var form = document.getElementById("retailEndorsementForm");
|
||
var id = form.querySelector("[name='id']").value;
|
||
var formData = new FormData(form);
|
||
form.classList.remove('was-validated');
|
||
var btn = document.getElementById("btnSubmit");
|
||
btn.disabled = true;
|
||
btn.innerText = "Saving...";
|
||
|
||
var endorsement_no = document.getElementById('endorsement_no').value.trim();
|
||
var edit_status = document.getElementById('edit_status').value.trim();
|
||
|
||
if (endorsement_no === "" || edit_status === "") {
|
||
toastr.warning('Please fill all required fields.', 'Warning');
|
||
form.classList.add('was-validated');
|
||
return;
|
||
}
|
||
|
||
$.ajax({
|
||
url: "<?= base_url('/employee/retail-endorsement-save') ?>",
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
if (response.status === "success") {
|
||
toastr.success(response.message, 'Success');
|
||
$('.emp_data_model').modal('hide');
|
||
form.reset();
|
||
window.location.href = "<?= base_url('/employee/retail-endorsement-list') ?>";
|
||
} else {
|
||
toastr.error(response.message, 'Error');
|
||
}
|
||
},
|
||
error: function(xhr) {
|
||
toastr.error("Something went wrong!", 'Error');
|
||
console.error(xhr.responseText);
|
||
if (xhr.status === 400) {
|
||
let response = JSON.parse(xhr.responseText);
|
||
if (response.errors) {
|
||
$.each(response.errors, function (field, message) {
|
||
toastr.warning(message, 'Validation Error');
|
||
});
|
||
} else {
|
||
toastr.warning(response.message || 'Validation failed', 'Warning');
|
||
}
|
||
}
|
||
},
|
||
complete: function() {
|
||
btn.disabled = false;
|
||
btn.innerText = "Save";
|
||
}
|
||
});
|
||
}
|
||
|
||
function fetchRetailEndorsementData(id, eno, status) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var form = document.getElementById('retailEndorsementForm');
|
||
form.reset();
|
||
|
||
$("#edit_id").val(id);
|
||
$("#endorsement_no").val(eno);
|
||
$("#edit_status").val(status);
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 200);
|
||
}
|
||
|
||
|
||
$(document).ready(function() {
|
||
|
||
$('#tickets-table').DataTable({
|
||
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||
// "<'row'<'col-sm-12'tr>>" +
|
||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||
// buttons: [{
|
||
// extend: 'csv',
|
||
// text: 'CSV',
|
||
// title: 'Retail-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
|
||
// }
|
||
// }
|
||
// }
|
||
// }],
|
||
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||
"<'row'<'col-sm-12'tr>>" +
|
||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||
buttons: [{
|
||
extend: 'collection',
|
||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||
className: 'btn app-btn-secondary ',
|
||
buttons: [{
|
||
extend: 'csv',
|
||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||
className: 'app-btn-primary ',
|
||
title: 'Retail-Endorsement-List',
|
||
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": "15px"
|
||
});
|
||
},
|
||
language: {
|
||
search: `
|
||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||
_INPUT_
|
||
<i class="mdi mdi-magnify datatable-search-icon"
|
||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||
</div>`,
|
||
searchPlaceholder: "Search",
|
||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||
},
|
||
paging: true,
|
||
// pagingType: 'full_numbers'
|
||
columnDefs: [{
|
||
type: 'scientific',
|
||
targets: 0
|
||
} // Apply custom sorting type to the first column
|
||
],
|
||
});
|
||
|
||
|
||
|
||
});
|
||
</script>
|