Subversion Repositories PEEPS

Rev

Rev 3 | Rev 5 | 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";

use strict;
use PEEPS;
use CGI qw/param header start_html url/;
use CGI::Cookie;
our $h = HTML::Tiny->new( mode => 'html' );
my $dbh = getRCDBH ();
$ENV{HTTPS} = 'ON' if $ENV{SERVER_NAME} =~ /^peeps/;

my $cookie_string = authenticate (1) || die;
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
my $user = $ORCUSER;
#my $activated = $ORCUSER->{access};

print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));

#foreach (sort keys %ENV) {
#       print "$_: $ENV{$_}\n<br>";
#}

use DateTime;
my $dt = DateTime->today;
$dt =~ s/T00\:00\:00$//;

my @announcements;
my @everyone;
my @leads;

my @insurance;
$user->{policy} = isPersonCovered ($user->{id});
if ($user->{policy}) {
  my $daysremaining = remainingPolicyDays ($user->{id}, $user->{policy});
  push @insurance, $h->li ("You are currently covered by Policy ID: $user->{policy}");
  push @insurance, $h->li ("You have $daysremaining days remaining in coverage.");
  if ($daysremaining <= 90) {
    push @insurance, $h->li ($h->a ( { href=>"attestation" }, "You're eligible to renew." ));
  }
  
} else {
  push @insurance, $h->li ($h->a ( { href=>"attestation" }, "Purchase Insurance." ));
}


my @policyhistory = ($h->div ({ class=>"rTableRow" },[ $h->div ({ class=>"rTableHead", style=>"font-size: smaller;" }, qw(ID Policy Start End) ) ]));
my @policy_columns = qw(id person_id member_org_id policy_name fee created start end terminated active);

my @policies = @{ $dbh->selectall_arrayref ("select * from coverage where person_id = ? order by start desc, end", undef, $user->{id}) };
my $active_policy = isPersonCovered ($user->{id});
foreach (@policies) {
  my %policy;
  @policy{@policy_columns} = @{$_};
  
  push @policyhistory, $h->div ({ class=>"rTableRow ".($policy{id} == $active_policy ? "highlighted" : "shaded"), onClick=>"window.location.href='view_policy?id=$policy{id}'" },[ $h->div ({ class=>"rTableCellr", style=>"font-size: smaller;" }, $policy{id}, $policy{policy_name}, $policy{start}, $policy{end}) ]);
  
#  push @classes, $h->div ({ class=>"rTableRow ".($classhash->{signedup} ? "highlighted" : "shaded"), onClick=>"window.location.href='view_class?id=$classid'" },[ $h->div ({ class=>"rTableCellr", style=>"font-size: smaller;" }, @{$class}) ]);  
}

my @managers;

my @sysadmins;

my @activity_log;
my $alog = $dbh->prepare("select timestamp, event from log where person_id = ? order by timestamp desc limit 10");
$alog->execute($user->{person_id});
while (my @logs = $alog->fetchrow_array) {
        my ($d, $t) = split /\s+/, $logs[0];
        push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
}

my @reference;

printRCHeader("Home");
print $h->close ("table");

print $h->form ({ name => "Req", action => url });

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Announcement:"), $h->ul ([ @announcements ]) ]) if (scalar @announcements);

#print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Note:"), "<b>Your account is being reviewed.</b>", $h->br, "You won't have access to view or sign-up for things until you've been approved / added to a department.", $h->br, "Please watch your email for notifications." ]) unless $activated;

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Personal Insurance:"), $h->ul ([ @insurance ]) ]);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Personal Policy History:"), $h->ul ([ @policyhistory ]) ]) if (scalar @policyhistory);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Your Latest Activity:"), $h->ul ([ @activity_log ]), $h->h5 ($h->a ({ href=>"log?excel=0&autoload=1&eventid=true&timestamp=true&event=true&RCid=true&derby_name=true&filter-timestamp=&filter-event=&filter-RCid=".$user->{RCid}."&filter-derby_name=&sortby=eventid&limit=25&page=1" }, "[Your entire log history]")) ]);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);

print $h->close ("body"), $h->close ("html");