Page 1 of 1

Change setting for Default Last Week in Reporting

Posted: Tue Apr 11, 2017 12:07 pm
by nthaler
HI!

Is there a way to change the default of 'Last Week' reporting time period? The default is Sunday to Monday. We run our week from Monday to Sunday. How can I change this? I want to automatically run a report every Monday for the last week.

Thank you!

Re: Change setting for Default Last Week in Reporting

Posted: Tue Apr 11, 2017 1:47 pm
by tgriep
To change the This week and Last week to start on Monday instead of Sunday, edit the following file

Code: Select all

/usr/local/nagiosxi/html/includes/utils-reports.inc.php
Go to this section on line 750 (or close to it) and change it from

Code: Select all

        case "thisweek":  
            if (date('D', $now) == 'Sun') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last sunday");
            }
            $end = $now;
            break;
to

Code: Select all

       case "thisweek":  
            if (date('D', $now) == 'Mon') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last monday");
            }
            $end = $now;
            break;
Then go to this section on line 787 (or close to it) and change it from

Code: Select all

        case "lastweek":
            //$start=strtotime("first day of last week");
            //$end=strtotime("first day of this week");
            $start = strtotime("last sunday -7 days");
            $end = strtotime("last sunday");
            break;
to

Code: Select all

        case "lastweek":
            //$start=strtotime("first day of last week");
            //$end=strtotime("first day of this week");
            $start = strtotime("last monday -7 days");
            $end = strtotime("last monday");
            break;
Save the file and that should make the start day Monday instead of Sunday.
FYI, if you upgrade the Nagios XI server, you will have to re-edit the file and put the changes in as the upgrade will over write this file.

Re: Change setting for Default Last Week in Reporting

Posted: Tue Apr 11, 2017 6:04 pm
by nthaler
tgriep wrote:To change the This week and Last week to start on Monday instead of Sunday, edit the following file

Code: Select all

/usr/local/nagiosxi/html/includes/utils-reports.inc.php
Go to this section on line 750 (or close to it) and change it from

Code: Select all

  case "thisweek":  
            if (date('D', $now) == 'Sun') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last sunday");
            }
            $end = $now;
            break;
to

Code: Select all

       case "thisweek":  
            if (date('D', $now) == 'Mon') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last monday");
            }
            $end = $now;
            break;
.
At line 753 I see this instead of the above. Do I just need to change sunday to monday? I see no if statements.

Code: Select all

    753         case "thisweek":
    754             //$start=strtotime("first day of this week");
    755             $start = strtotime("last sunday");
    756             $end = $now;
    757             break;

Re: Change setting for Default Last Week in Reporting

Posted: Wed Apr 12, 2017 10:08 am
by tgriep
Yes, you would just have to change sunday to monday and it should work for you.

Re: Change setting for Default Last Week in Reporting

Posted: Wed Apr 12, 2017 4:04 pm
by nthaler
Working as expected. Thank you!

Re: Change setting for Default Last Week in Reporting

Posted: Wed Apr 12, 2017 4:22 pm
by cdienger
Glad to hear! Are we okay locking the thread at this point?

Re: Change setting for Default Last Week in Reporting

Posted: Wed Apr 12, 2017 4:23 pm
by nthaler
Yes :)