function ReportPeriod($PeriodName, $FromOrTo){ /* Used in report scripts to determine period. */ $ThisMonth = date('m'); $ThisYear = date('Y'); $LastMonth = $ThisMonth-1; $LastYear = $ThisYear-1; $NextMonth = $ThisMonth+1; $NextYear = $ThisYear+1; // Find total number of days in this month: $TotalDays = cal_days_in_month(CAL_GREGORIAN, $ThisMonth, $ThisYear); // Find total number of days in last month: $TotalDaysLast = cal_days_in_month(CAL_GREGORIAN, $LastMonth, $ThisYear); // Find total number of days in next month: $TotalDaysNext = cal_days_in_month(CAL_GREGORIAN, $NextMonth, $ThisYear); switch ($PeriodName) {
The minor change allows the user's selected period to keep the setting if they choose to "Select a Different Period" (the non-PDF route)
Also, in your original GLTrialBalance.php file, I contemplated moving lines 409-412 to just after the include at line 402 so that I could keep all the hidden inputs together.
However, if that block of code is moved, and the period sets the from/to dates will also make the form have the from/to date ranges set, as well as the period upon return to the form, and I wasn't sure that would be desired behavior if only the period was selected?
Anyway, give the files a diff. In MiscFunctions.php, the ReportPeriodList() function has entirely new handling to work with the change.
You can also preview the current changes at this git branch. Note that the diff will show removal of a few unused $j variables in GLTrialBalance, but this was not applied to the MOD file.
Paul... Are you (and others) okay with the abstraction of the code to MiscFunctions? In my opinion it makes it easy to extend and maintain the new feature but it also means it would be more difficult to customize for a specific script.
As a long time OO guy (even brute-force inheritance in VBA and VB6) I try to share as many objects and/or attributes and behaviors as possible for the sake of extensibility and maintainability.
I ask because it seems to me we could also move other Period-related or GLAccount-related dropdowns/selectors to the MiscFunctions script as well, thus unifying the code.
Is there any penalty to having code outside of the page as in this case?
The policy has always been to avoid "unnecessary abstractions" which is vague and in the past it has been looked at on a case by case basis. This is to make each script as much as possible a self contained readable document.
In this case I think it's a good thing. I like your functions and have included them in my code (though my liking it may be more of a hindrance).
I have some observations on them but I will write them later when I am at a computer rather than try to tap them out on my phone.