Добавил фильтр по дате в таблицу сотрудников
This commit is contained in:
parent
87b38e0933
commit
3fd59c578f
@ -76,6 +76,14 @@
|
||||
<div class="tab-content" id="custom-tabs-three-tabContent">
|
||||
<div class="tab-pane fade show active" id="on-map" role="tabpanel"
|
||||
aria-labelledby="on-map-tab">
|
||||
<div class="mb-3">
|
||||
<label for="min-datetime">С:</label>
|
||||
<input type="datetime-local" id="min-datetime"
|
||||
class="form-control d-inline-block" style="width: auto;">
|
||||
<label for="max-datetime">По:</label>
|
||||
<input type="datetime-local" id="max-datetime"
|
||||
class="form-control d-inline-block" style="width: auto;">
|
||||
</div>
|
||||
<table class="table table-bordered table-hover table-head-fixed text-nowrap text-sm w-100"
|
||||
id="workersTable">
|
||||
<thead>
|
||||
@ -143,6 +151,7 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/plug-ins/1.13.6/sorting/datetime-moment.js"></script>
|
||||
<script src="https://cdn.datatables.net/plug-ins/1.13.6/sorting/custom-data-source/dom-text.js"></script>
|
||||
|
||||
<script>
|
||||
// Регистрация пользовательского сортировщика
|
||||
jQuery.extend(jQuery.fn.dataTable.ext.type.order, {
|
||||
@ -158,6 +167,25 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
|
||||
const minVal = document.getElementById('min-datetime').value;
|
||||
const maxVal = document.getElementById('max-datetime').value;
|
||||
const rowDateStr = data[1]; // Столбец с датой
|
||||
|
||||
if (!rowDateStr) return false;
|
||||
|
||||
const rowDate = moment(rowDateStr, 'DD.MM.YYYY HH:mm:ss');
|
||||
const min = minVal ? moment(minVal) : null;
|
||||
const max = maxVal ? moment(maxVal) : null;
|
||||
|
||||
if ((min === null || rowDate.isSameOrAfter(min)) &&
|
||||
(max === null || rowDate.isSameOrBefore(max))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
const lang = {
|
||||
"decimal": "",
|
||||
@ -258,6 +286,11 @@
|
||||
]
|
||||
});
|
||||
|
||||
$('#min-datetime, #max-datetime').on('change', function () {
|
||||
$('#workersTable').DataTable().draw(); // Замените id таблицы на свой
|
||||
});
|
||||
|
||||
|
||||
allWorkersTable = $('#allWorkersTable').DataTable({
|
||||
order: [[0, 'asc']],
|
||||
dom: '<"top"f>rt<"bottom d-flex justify-content-between align-items-center"ip><"clear">',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user