Adds advanced view

This commit is contained in:
2024-11-13 20:03:04 -08:00
parent 6291a6c8cd
commit d119e01857
9 changed files with 553 additions and 60 deletions

View File

@@ -232,6 +232,40 @@ const calendarYearPeriod = (date) => {
return {end: formatDateMMDDYYYY(end), start: formatDateMMDDYYYY(start)};
}
const getLastMonthPeriods = (date) => {
if (!date) {
date = new Date();
} else {
date = parseMMDDYYYY(date);
}
// Get the first day of the current month
const firstDayOfCurrentMonth = new Date(date.getFullYear(), date.getMonth(), 1);
// Get the last day of the previous month
const lastDayOfPreviousMonth = dateFns.subDays(firstDayOfCurrentMonth, 1);
// Get the first day of the previous month
const firstDayOfPreviousMonth = new Date(lastDayOfPreviousMonth.getFullYear(), lastDayOfPreviousMonth.getMonth(), 1);
// Get the same period for the previous year
const firstDayOfPreviousYearMonth = new Date(firstDayOfPreviousMonth.getFullYear() - 1, firstDayOfPreviousMonth.getMonth(), 1);
const lastDayOfPreviousYearMonth = dateFns.lastDayOfMonth(firstDayOfPreviousYearMonth);
// Create period objects
const currentPeriod = {
start: formatDateMMDDYYYY(firstDayOfPreviousMonth),
end: formatDateMMDDYYYY(lastDayOfPreviousMonth)
};
const previousYearPeriod = {
start: formatDateMMDDYYYY(firstDayOfPreviousYearMonth),
end: formatDateMMDDYYYY(lastDayOfPreviousYearMonth)
};
return [currentPeriod, previousYearPeriod];
};
initMultiDatepicker = function(elem, startingValue) {
const modalParent = elem.closest('#modal-content');
if (modalParent) {

File diff suppressed because one or more lines are too long