Subversion Repositories PEEPS

Rev

Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/usr/bin/perl
2
 
3
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
4
#my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
5
#close STDERR;
6
#open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
8
 
9
use strict;
10
use PEEPS;
11
use CGI qw/param header start_html url/;
12
use CGI::Cookie;
13
our $h = HTML::Tiny->new( mode => 'html' );
14
my $dbh = getRCDBH ();
15
 
16
my $cookie_string = authenticate (1) || die;
17
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
18
my $user = $ORCUSER;
19
#my $activated = $ORCUSER->{access};
20
 
21
print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));
22
 
23
#foreach (sort keys %ENV) {
24
#	print "$_: $ENV{$_}\n<br>";
25
#}
26
 
27
use DateTime;
28
my $dt = DateTime->today;
29
$dt =~ s/T00\:00\:00$//;
30
 
31
my @announcements;
32
my @everyone;
33
my @leads;
34
 
35
my @insurance;
36
$user->{policy} = isPersonCovered ($user->{id});
37
if ($user->{policy}) {
38
  my $daysremaining = remainingPolicyDays ($user->{id}, $user->{policy});
39
  push @insurance, $h->li ("You are currently covered by Policy ID: $user->{policy}");
40
  push @insurance, $h->li ("You have $daysremaining days remaining in coverage.");
41
  if ($daysremaining <= 90) {
42
    push @insurance, $h->li ($h->a ( { href=>"attestation" }, "You're eligible to renew." ));
43
  }
44
 
45
} else {
46
  push @insurance, $h->li ($h->a ( { href=>"attestation" }, "Purchase Insurance." ));
47
}
48
 
49
 
50
my @policyhistory = ($h->div ({ class=>"rTableRow" },[ $h->div ({ class=>"rTableHead", style=>"font-size: smaller;" }, qw(ID Policy Start End) ) ]));
51
my @policy_columns = qw(id person_id member_org_id policy_name fee created start end terminated active);
52
 
53
my @policies = @{ $dbh->selectall_arrayref ("select * from coverage where person_id = ? order by start desc, end", undef, $user->{id}) };
54
my $active_policy = isPersonCovered ($user->{id});
55
foreach (@policies) {
56
  my %policy;
57
  @policy{@policy_columns} = @{$_};
58
 
59
  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}) ]);
60
 
61
#  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}) ]);
62
}
63
 
64
my @managers;
65
 
66
my @sysadmins;
67
 
68
my @activity_log;
69
my $alog = $dbh->prepare("select timestamp, event from log where person_id = ? order by timestamp desc limit 10");
70
$alog->execute($user->{person_id});
71
while (my @logs = $alog->fetchrow_array) {
72
	my ($d, $t) = split /\s+/, $logs[0];
73
	push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
74
}
75
 
76
my @reference;
77
 
78
printRCHeader("Home");
79
print $h->close ("table");
80
 
81
print $h->form ({ name => "Req", action => url });
82
 
83
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Announcement:"), $h->ul ([ @announcements ]) ]) if (scalar @announcements);
84
 
85
#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;
86
 
87
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
88
 
89
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Personal Insurance:"), $h->ul ([ @insurance ]) ]);
90
 
91
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Personal Policy History:"), $h->ul ([ @policyhistory ]) ]) if (scalar @policyhistory);
92
 
93
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
94
 
95
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
96
 
97
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
98
 
99
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]")) ]);
100
 
101
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
102
 
103
print $h->close ("body"), $h->close ("html");
104
 
105