EPSCoR / ERCore

ERcore content management system to assist with NSF EPSCoR reporting
4 stars 7 forks source link

Error with current reporting range #30

Closed aturling closed 8 years ago

aturling commented 8 years ago

Now that we're a few days into our next reporting period, I noticed that the range on the admin tables wasn't updating. For example: http://dev-ercore.nmepscor.net/reporting/outputs Scroll down and you'll see "Reporting Period - [Jun 1, 2014 - May 31, 2015]" but we're past that; now it should say Jun 1, 2015 - May 31, 2016. I traced the error to this function in er.module:

function er_get_reporting_range($use_default = true)

specifically this line:

$adjusted_date = mktime(0, 0, 0, $cur_month-$reporting_month-5);//+half a year into the past (6) + 1 offset

From the documentation on mktime(), if the year isn't given, it seems like it goes with the current year if the month is positive (e.g., month = 1 -> Jan current_day 2015) and last year if the month is zero or negative (e.g., month = 0 -> Dec current_day 2014, month = -1 -> Nov current_day 2014). So I think that line should instead be:

$adjusted_date = mktime(0, 0, 0, $cur_month-$reporting_month+1); since the next two lines are:

$year = date('Y', $adjusted_date); return _generate_reporting_range($year);

so all you need from $adjusted_date is whether the reporting period should start with this year or last year (in other words, adjust your range to a regular calendar year so that $reporting_month -> Jan, $reporting_month+1 -> Feb, and so on, and then grab the year from that.)

iserna commented 8 years ago

@aturling I usually adjust the reporting year here, http://dev-ercore.nmepscor.net/reporting, in the drop down titled Reporting Year. Then all my views and template downloads will/should reflect that year. Is this what you are referring to?

aturling commented 8 years ago

Oh I see, that must be what that first bit of code does in the er_get_reporting_range function. If you don't first go to /reporting and select the desired reporting year from the drop-down, it defaults to trying to guess the current reporting year using the current date and the $adjusted_date calculation. I usually don't go to /reporting first and just go directly to the admin views.

khuffman commented 8 years ago

@aturling we in RI do just like NM, we first go to the /reporting set the date range there and from there we go to the various views.

iserna commented 8 years ago

@aturling I am closing this question.