Adds advanced view
This commit is contained in:
@@ -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
Reference in New Issue
Block a user