Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Periods in GL Reports
03-10-2018, 11:00 PM, (This post was last modified: 03-11-2018, 01:20 AM by VortecCPI.)
#1
Periods in GL Reports
Now that we have pre-defined periods in Report Builder it would be nice to have them in the GL report areas as well:

   

Perhaps in other areas as well?

I am going to have a crack at this using MiscFunctions.php:

PHP Code:
    //Select the period
    
echo '<tr>
            <td>' 
_('Select Period') . '</td>
            <td>' 
ReportPeriodList() . '</td>
        </tr>'


PHP Code:
function ReportPeriodList(){
    
/* Used in report scripts for standard periods.
    */
    
$html '<select name="Period">
            <option value=""></option>
            <option value="' 
_('This Month') . '">' _('This Month') . '</option>
            <option value="' 
_('This Quarter') . '">' _('This Quarter') . '</option>
            <option value="' 
_('This Year') . '">' _('This Year') . '</option>
            <option value="' 
_('Last Month') . '">' _('Last Month') . '</option>
            <option value="' 
_('Last Quarter') . '">' _('Last Quarter') . '</option>
            <option value="' 
_('Last Year') . '">' _('Last Year') . '</option>
            <option value="' 
_('Next Month') . '">' _('Next Month') . '</option>
            <option value="' 
_('Next Quarter') . '">' _('Next Quarter') . '</option>
            <option value="' 
_('Next Year') . '">' _('Next Year') . '</option>
        </select>'
;

    return 
$html;


PHP Code:
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) {
        
        Case 
_('This Month'):
            
$ds date('Y-m-d'mktime(0,0,0$ThisMonth1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$ThisMonth$TotalDays$ThisYear));
            break;
        Case 
_('This Quarter'):
            
$QtrStrt intval(($ThisMonth-1)/3)*3+1;
            
$QtrEnd intval(($ThisMonth-1)/3)*3+3;
            if ( 
$QtrEnd == OR $QtrEnd == OR $QtrEnd == OR $QtrEnd == 11 ) { $TotalDays=30; }
            
$ds date('Y-m-d'mktime(0,0,0$QtrStrt1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$QtrEnd$TotalDays$ThisYear));
            break;
        Case 
_('This Year'):
            
$ds date('Y-m-d'mktime(0,0,011$ThisYear));
            
$de date('Y-m-d'mktime(0,0,01231$ThisYear));
            break;
        Case 
_('Last Month'):
            
$ds date('Y-m-d'mktime(0,0,0$LastMonth1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$LastMonth$TotalDaysLast$ThisYear));
            break;
        Case 
_('Last Quarter'):
            
$QtrStrt intval(($ThisMonth-1)/3)*3-2;
            
$QtrEnd intval(($ThisMonth-1)/3)*3+0;            
            if ( 
$QtrEnd == OR $QtrEnd == OR $QtrEnd == OR $QtrEnd == 11 ) { $TotalDays=30; }
            
$ds date('Y-m-d'mktime(0,0,0$QtrStrt1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$QtrEnd$TotalDays$ThisYear));
            break;
        Case 
_('Last Year'):
            
$ds date('Y-m-d'mktime(0,0,011$LastYear));
            
$de date('Y-m-d'mktime(0,0,01231$LastYear));
            break;
        Case 
_('Next Month'):
            
$ds date('Y-m-d'mktime(0,0,0$NextMonth1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$NextMonth$TotalDaysNext$ThisYear));
            break;
        Case 
_('Next Quarter'):
            
$QtrStrt intval(($ThisMonth-1)/3)*3+4;
            
$QtrEnd intval(($ThisMonth-1)/3)*3+6;
            if ( 
$QtrEnd == OR $QtrEnd == OR $QtrEnd == OR $QtrEnd == 11 ) { $TotalDays=30; }
            
$ds date('Y-m-d'mktime(0,0,0$QtrStrt1$ThisYear));
            
$de date('Y-m-d'mktime(0,0,0$QtrEnd$TotalDays$ThisYear));
            break;
        Case 
_('Next Year'):
            
$ds date('Y-m-d'mktime(0,0,011$NextYear));
            
$de date('Y-m-d'mktime(0,0,01231$NextYear));
            break;
    }    
    
    if (
$FromOrTo == 'From') {
        
$Period GetPeriod(ConvertSQLDate($ds));
    } else {
        
$Period GetPeriod(ConvertSQLDate($de));
    }
    return 
$Period;


Work in progress...
https://www.linkedin.com/in/eclipsepaulbecker
Reply


Messages In This Thread
Periods in GL Reports - by VortecCPI - 03-10-2018, 11:00 PM
RE: Periods in GL Reports - by VortecCPI - 03-11-2018, 02:12 AM
RE: Periods in GL Reports - by VortecCPI - 03-11-2018, 04:33 AM
RE: Periods in GL Reports - by TurboPT - 03-13-2018, 03:21 PM
RE: Periods in GL Reports - by VortecCPI - 03-13-2018, 09:51 PM
RE: Periods in GL Reports - by TurboPT - 03-16-2018, 04:32 PM
RE: Periods in GL Reports - by VortecCPI - 03-17-2018, 06:47 PM
RE: Periods in GL Reports - by TurboPT - 03-18-2018, 01:42 AM
RE: Periods in GL Reports - by VortecCPI - 03-18-2018, 10:46 PM
RE: Periods in GL Reports - by TimSchofield - 03-19-2018, 12:58 AM
RE: Periods in GL Reports - by VortecCPI - 03-19-2018, 05:22 AM
RE: Periods in GL Reports - by phil - 03-19-2018, 07:49 AM
RE: Periods in GL Reports - by TimSchofield - 03-19-2018, 08:07 AM
RE: Periods in GL Reports - by VortecCPI - 03-19-2018, 11:00 AM
RE: Periods in GL Reports - by TimSchofield - 03-19-2018, 06:33 PM
RE: Periods in GL Reports - by TimSchofield - 03-19-2018, 09:17 PM
RE: Periods in GL Reports - by VortecCPI - 03-19-2018, 10:38 PM
RE: Periods in GL Reports - by TimSchofield - 03-19-2018, 11:11 PM
RE: Periods in GL Reports - by TimSchofield - 03-20-2018, 07:19 PM
RE: Periods in GL Reports - by TurboPT - 03-22-2018, 10:22 AM
RE: Periods in GL Reports - by TimSchofield - 03-22-2018, 10:02 PM
RE: Periods in GL Reports - by TurboPT - 03-23-2018, 10:27 AM
RE: Periods in GL Reports - by TurboPT - 04-01-2018, 01:33 AM
RE: Periods in GL Reports - by TimSchofield - 04-01-2018, 01:47 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)