| 29 |
- |
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 |
my %FIELDS = (
|
|
|
22 |
id => 5,
|
|
|
23 |
policy_name => 10,
|
|
|
24 |
fee => 15,
|
|
|
25 |
person_id => 20,
|
|
|
26 |
created => 25,
|
|
|
27 |
start => 30,
|
|
|
28 |
end => 35,
|
|
|
29 |
active => 40,
|
|
|
30 |
terminated => 45,
|
|
|
31 |
policy_id => 50,
|
|
|
32 |
square_id => 55
|
|
|
33 |
);
|
|
|
34 |
sub byfield { $FIELDS{$a} <=> $FIELDS{$b}; }
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
#foreach (sort keys %ENV) {
|
|
|
38 |
# warn "$_: $ENV{$_}";
|
|
|
39 |
#}
|
|
|
40 |
|
|
|
41 |
use DateTime;
|
|
|
42 |
my $dt = DateTime->today;
|
|
|
43 |
$dt =~ s/T00\:00\:00$//;
|
|
|
44 |
|
|
|
45 |
my $coverage_id = WebDB::trim scalar param ("id") // ERROR ("Missing PolicyID", "Can't view a policy without an ID to look for.", "No PolicyID provided to View Policy");
|
|
|
46 |
my $userid = WebDB::trim scalar param ("userid") // $user->{id};
|
|
|
47 |
|
|
|
48 |
my $coverage = getCoverageByID ($coverage_id, $userid) // ERROR ("PolicyID Not Found", "Can't find a policy (that belongs to this user) with that ID.", "PolicyID provided to View Policy not found");
|
|
|
49 |
|
|
|
50 |
$coverage->{active} = $coverage->{active} ? "True" : "False";
|
|
|
51 |
$coverage->{terminated} = $coverage->{terminated} ? "True" : "False";
|
|
|
52 |
$coverage->{created} .= " UTC";
|
|
|
53 |
|
|
|
54 |
print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));
|
|
|
55 |
printRCHeader("View Policy: ".$coverage_id);
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Policy Details:"),
|
|
|
59 |
$h->div ({ class=>"rTable", style=>"min-width: 0%;" }, [
|
|
|
60 |
$h->div ({ class=>"rTableRow" }, map { [$h->div ({ class=>"rTableCellr", style=>"font-size: unset;" }, ucfirst ($_).": ", $coverage->{$_})] } sort byfield grep { exists $FIELDS{$_} } keys %{$coverage})])]);
|
|
|
61 |
|
|
|
62 |
print $h->close ("body"), $h->close ("html");
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
sub ERROR {
|
|
|
72 |
my $header = shift // "Unknown Error";
|
|
|
73 |
my $text = shift // "Something unexpectedly bad happened.";
|
|
|
74 |
my $logmsg = shift // "Unknown Error happened while viewing the Attestation page";
|
|
|
75 |
|
|
|
76 |
print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));
|
|
|
77 |
printRCHeader("Atttestation");
|
|
|
78 |
print $h->close ("table");
|
|
|
79 |
print $h->h2 ($header);
|
|
|
80 |
print $h->div ({ style=>"max-width:450px;" }, $text, " ");
|
|
|
81 |
print $h->button ({onclick => "window.location.href='/';"}, "Home");
|
|
|
82 |
print $h->close ("BODY", "HTML");
|
|
|
83 |
logit ($user->{id}, $logmsg);
|
|
|
84 |
exit;
|
|
|
85 |
}
|
|
|
86 |
|