#!/usr/local/bin/perl5_8 #Campus Main Menu use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); #remove for PRD use HTML::Template; my $CGI = CGI->new; #clear buffers and set up web page (required) $|=1; print $CGI->header; #get the main menu, and pass $CGI variables to template(s) as needed my $template = HTML::Template->new( filename => 'nc_mainmenu.tmpl', associate => $CGI, loop_context_vars => 1, global_vars => 1, ); ############################### Begin Section ####################################### #Set up and generate drop down list for report dates variable ($rpt_asofdt) my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; my $mo = $mon + 1; my $dy = $mday; my $yr = $year + 1900; #Set array to look up month text and last day of month (add dummy to index item 0) my @lkup_mon_text = ( 'DUMMY000','JAN','FEB','MAR','APR','MAY', 'JUN','JUL','AUG','SEP','OCT','NOV','DEC'); my @lkup_mon_long = ( 'DUMMY000','January','February','March','April','May', 'June', 'July','August','September','October','November','December'); my @lkup_last_day = ( 'DUMMY000','31','28','31','30','31', '30','31','31','30','31','30','31'); #loop through to generate rolling drop down list of months ('25' is arbitrary) my ( $i, $next_mmyyyy, @rollingmonth, @dt_loop ); for ( $i=1; $i<=25; $i++ ) { $next_mmyyyy = "Month Ending $lkup_mon_long[$mo] $yr"; push(@rollingmonth, $next_mmyyyy); #pad months 1-9 with a leading zero if ( length($mo) == 1 ) { $mo = "0$mo"; } #set up hash for TMPL_LOOP params my %dt_data; $dt_data{dt_value} = "$yr~$mo~$dy~$lkup_mon_long[$mo] $dy, $yr"; $dt_data{dt_display} = "$next_mmyyyy"; push(@dt_loop, \%dt_data); #determine if rolling back to previous calendar year $mo = $mo - 1; if ( $mo eq 0 ) { $mo = 12; $yr = $yr - 1; } $dy = $lkup_last_day[$mo]; #determine if February and a Leap Year; if so, last day = 29 if ( ( $mo eq 2 ) && ( $yr % 4 eq 0 ) ) { $dy = 29; } } #+++++++++++++++++++++++++++++++ End Section ++++++++++++++++++++++++++++++++++++++++ ############################### Begin Section ####################################### #Control table used to generate report radio buttons, rpt titles... #template vars: key->Rpt no. (rpt_no); value->Rpt Descr (rpt_descr) my %rpt_tbl = ( '1' => 'Fiscal Year-to-Date Financial Information' ,'2' => 'QTD/PTD Financial Information' ,'3' => 'Cash Balance' ,'4' => 'Financial Status' ,'5' => 'Financial Summary Status' ,'6' => 'Summary by Phase' ,'7' => 'Summary by Segment' ); my (@radio_loop, $key); foreach $key ( sort keys %rpt_tbl ) { push(@radio_loop, {rpt_no => $key, rpt_descr => $rpt_tbl{$key}}); } #+++++++++++++++++++++++++++++++ End Section ++++++++++++++++++++++++++++++++++++++++ #pass the date loop info to the template, along with other params, and print web page $template->param(dt_select=>\@dt_loop); $template->param(radio =>\@radio_loop); $template->param(title_bar=>"Main Menu"); print $template->output();