Rev 138 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perl# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";close STDERR;open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";#warn "Redirecting errors to ${error_log_path}vorc_error.log";#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }use strict;use cPanelUserConfig;use CGI qw/param cookie header start_html url/;use HTML::Tiny;use tableViewer;use RollerCon;our $h = HTML::Tiny->new( mode => 'html' );my $cookie_string = authenticate (3) || die;our ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");my $pageTitle = "Volunteer Hours Summary";our $DBTABLE = 'v_volhours';my %COLUMNS = (# colname => [qw(DisplayName N type status)], status -> static | default | <blank>RCid => [qw(RCid 15 number )],derby_name => [qw(DerbyName 25 select static )],full_name => [qw(FullName 27 select )],dept => [qw(Department 30 select static )],hours => [qw(Hours 40 number static )]);# Set any custom "where" DB filters here...my @whereClause;# Users should only be able to see the hours report for the departments in which they're a managerif ($LVL < 5) {my $string = "dept in (".join ",", map { '"'.$_.'"' } grep { $ORCUSER->{department}->{$_} >= 3 } keys %{$ORCUSER->{department}};$string .= ")";push @whereClause, $string;}push @whereClause, "dept != 'PER'";# If we need to modify line item values, create a subroutine named "modify_$columnname"# It will receive a hashref to the object lineitemsub modify_derby_name {my $li = shift;return $h->a ({ href=>"view_user.pl?RCid=".getRCid ($li->{derby_name}) }, $li->{derby_name});}my $DEPTS = getDepartments ();sub modify_dept {my $hr = shift;return $DEPTS->{$hr->{dept}};}# If we need to modify how a filter works, create a subroutine named "filter_$columnname"# It will receive two fields, the field name and the current filter value (if any)sub filter_dept {my $colName = shift;my $filter = shift;if (defined $filter) {if ($filter eq "-blank-") {return "($colName = '' or isNull($colName) = 1)";}return "$colName = \"$filter\"";} else {my $tmpFormValue = param ("filter-${colName}");my $categories = join "", map { $tmpFormValue eq $_ ? $h->option ({ value=>$_, selected=>[] }, $DEPTS->{$_}) : $h->option ({ value=>$_ }, $DEPTS->{$_}) } grep { $LVL > 4 or $ORCUSER->{department}->{$_} >= 3 } sort keys %{$DEPTS};my $Options = "<OPTION></OPTION>".$categories;$Options =~ s/>($tmpFormValue)/ selected>$1/;my $onChange = param ("autoload") ? "onChange='page.value = 1; submit();'" : "";return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";}}# Uncomment and update if we want to enable clicking on a row to open a new page.##sub addRowClick {# my $t = shift;# return "location.href='view_thing.pl?field=$t->{field}&choice=View'";#}# Call the function to print the table view page (with available options)printTablePage ({ Title => $pageTitle,Table => $DBTABLE,Columns => \%COLUMNS,RCAuth => $RCAUTH_cookie,Where => join(" and ", @whereClause),DisplayYearSelect => 1,});