Rev 6 | 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/;use DateTime;my $dt = DateTime->today;$dt =~ s/T00\:00\:00$//;my $cookie_string = authenticate (1) || die;my ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $user = $ORCUSER;#my $activated = $ORCUSER->{access};my %LOOKUP = (# colname => [qw(DisplayName N type status)], status -> static | default | <blank>person_id => [qw(MemberID 5 number id )],policy_id => [qw(PolicyID 10 number policy_id )],first_name => [qw(FirstName 15 text name_first )],last_name => [qw(LastName 20 text name_last )],skater_name => [qw(SkaterName 25 text derby_name )],);my %NAME = map { $_ => $LOOKUP{$_}->[0] } keys %LOOKUP;my %colOrderHash = map { $_ => $LOOKUP{$_}->[1] } keys %LOOKUP;sub byfield { $colOrderHash{$a} <=> $colOrderHash{$b}; }my %colFilterTypeHash = map { $_ => $LOOKUP{$_}->[2] } keys %LOOKUP;my %field_name = map { $_ => $LOOKUP{$_}->[3] } keys %LOOKUP;print header (-cookie=>CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string"));printRCHeader("Insurance Verification");# 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}) ]);my ($EARCH, @ERRORS, $count);foreach (keys %LOOKUP) {$EARCH->{$_} = WebDB::trim scalar param $_;if ($colFilterTypeHash{$_} eq "number" and $EARCH->{$_} !~ /^\d*$/) {push @ERRORS, "$NAME{$_} should be a number (and you entered '$EARCH->{$_}').";$EARCH->{$_} = "";}if ($colFilterTypeHash{$_} eq "text" and $EARCH->{$_} !~ qr/^[\p{L}\p{M}\p{P}\s\'-]*$/u) {push @ERRORS, "$NAME{$_} should be text (and you entered '$EARCH->{$_}').";$EARCH->{$_} = "";}$count++ unless !$EARCH->{$_};}push @ERRORS, "At least two fields must be included to search (you entered $count)." unless $count != 1;print $h->form ( { name => "insuranceVerification", method => "post", action => url }, [$h->div ({class=>"hint"}, "At least two fields are required. If more than two are entered, they will all need to match."),scalar @ERRORS ? $h->div ({class=>"error"}, @ERRORS) : [],$h->div ({ class => "rTableRow" },map { $h->div ({class=>"rTableCellr"}, $NAME{$_}).$h->div ({class=>"rTableCellr"}, $h->input ({name => "$_", value => $EARCH->{$_}})) } sort byfield keys %LOOKUP),# "Member ID: ", $h->input ({name => "person_id"}), $h->br,# "Policy ID: ", $h->input ({name => "policy_id"}), $h->br,# "First Name: ", $h->input ({name => "first_name"}), $h->br,# "Last Name: ", $h->input ({name => "last_name"}), $h->br,# "Skater Name: ", $h->input ({name => "skater_name"}), $h->br,$h->button ("Verify Insurance")#, $h->button ("Reset")]);if ($count and !scalar @ERRORS) {my $where = join " and ", map { "$field_name{$_} = ?" } grep { $EARCH->{$_} } sort byfield keys %LOOKUP;my ($person_id, $first, $last, $derby_name, $policy_id, $league) = $dbh->selectrow_array ("select id, name_first, name_last, derby_name, policy_id, group_concat(distinct league_name SEPARATOR ', ') from v_person where ".$where, undef, map { $EARCH->{$_} } grep { $EARCH->{$_} } sort byfield keys %LOOKUP);if ($policy_id) {$first =~ s/(.).+(..)/$1 . '*' x (length($&)-3) . $2/e;$last =~ s/(.).+(..)/$1 . '*' x (length($&)-3) . $2/e;my $policy = getCoverageByID ($policy_id, $person_id);print $h->div ({class => "rTableRow"}, "Results:", [$h->div ({class=>"rTableCell"}, "$first $last", $derby_name." [".$league."]", "Insured Through: $policy->{end}")]);# logit ($user->{id}, "Successfull Insurance Lookup: $derby_name [$league] Through: $policy->{end}");logit ($user->{id}, "Successfull Insurance Lookup: ".join (": ", map { "$field_name{$_} = $EARCH->{$_}" } grep { $EARCH->{$_} } sort byfield keys %LOOKUP));} else {print $h->div ({class => "rTableRow"}, "No Matching Results Found.");logit ($user->{id}, "Failed Insurance Lookup: ".join (": ", map { "$field_name{$_} = $EARCH->{$_}" } grep { $EARCH->{$_} } sort byfield keys %LOOKUP));}}print $h->close ("body", "html");