mfss-positioning/static/eps/report/daterange_picker.js

66 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(function () {
const shiftStartHour = 8;
const nowMoment = moment();
let shiftStartMoment = moment();
if (nowMoment.hours() < shiftStartHour) {
shiftStartMoment = moment().add(-1, 'days').set({hour: 20, minute: 0, second: 0});
} else {
shiftStartMoment = moment().set({hour: 8, minute: 0, second: 0});
}
$('#daterange').daterangepicker({
timePicker: true,
timePicker24Hour: true,
timePickerSeconds: false,
alwaysShowCalendars: false,
locale: {
format: 'DD.MM.YYYY HH:mm',
separator: " - ",
applyLabel: "Выбрать",
cancelLabel: "Отмена",
fromLabel: "С",
toLabel: "До",
customRangeLabel: "Другая дата",
weekLabel: "W",
daysOfWeek: ["ВС", "ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ"],
monthNames: [
"Январь", "Февраль", "Март", "Апрель",
"Май", "Июнь", "Июль", "Август",
"Сентябрь", "Октябрь", "Ноябрь", "Декабрь"
],
firstDay: 1
},
maxSpan: {
hours: 48
},
ranges: {
"Текущая смена": [shiftStartMoment.clone(), moment()],
'Предыдущая смена': [shiftStartMoment.clone().subtract(12, 'hours'), shiftStartMoment.clone()],
},
startDate: moment().startOf('day').add(8, 'hours'),
minDate: moment('2024-12-05'),
maxDate: moment(),
buttonClasses: "btn btn-sm",
applyButtonClasses: "btn-primary",
cancelButtonClasses: "btn-default",
}, function (start, end) {
});
});
$('#daterange').on('show.daterangepicker', function (event, picker) {
const customRangeButton = $('.ranges ul li:contains("Другая дата")');
$('.ranges ul li').on('click', function () {
$('.ranges ul li').removeClass('active');
$(this).addClass('active');
});
customRangeButton.trigger('click');
});
$('.input-group-append').on('click', function () {
$('#daterange').focus(); // Программно открываем календарь
});