$self->prepare_extended_user_info;
my $user = $self->ctx->{user};
+ # PINES - check whether or not to provide account renewal link
+ if ($self->ctx->{user}->billing_address) {
+ $self->ctx->{valid_billing_address} = $self->ctx->{user}->billing_address->valid;
+ } else {
+ $self->ctx->{valid_billing_address} = 0;
+ }
+ $self->check_account_exp();
+
my $lock_usernames = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.lock_usernames');
if(defined($lock_usernames) and $lock_usernames == 1) {
# Policy says no username changes
pub => 't'
})
);
+
+ # PINES - check whether or not to provide account renewal link
+ if ($self->ctx->{user}->billing_address) {
+ $self->ctx->{valid_billing_address} = $self->editor->retrieve_actor_user_address($self->ctx->{user}->billing_address)->valid;
+ } else {
+ $self->ctx->{valid_billing_address} = 0;
+ }
+ $self->check_account_exp();
+
return $self->prepare_fines($limit, $offset) || Apache2::Const::OK;
}
return Apache2::Const::OK;
}
+# PINES - check whether patron has standing penalties that should block
+# online account renewal
+sub has_penalties {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ my $user = $self->ctx->{user};
+
+ #check for INVALID_PATRON_ADDRESS
+ my $searchpenalty_address = new_editor()->search_actor_user_standing_penalty({
+ usr => $user->id,
+ standing_penalty => 29,
+ '-or' => [
+ {stop_date => undef},
+ {stop_date => {'>' => 'now'}}
+ ]
+ });
+
+ #check for INVALID_PATRON_DAY_PHONE
+ my $searchpenalty_phone = new_editor()->search_actor_user_standing_penalty({
+ usr => $user->id,
+ standing_penalty => 32,
+ '-or' => [
+ {stop_date => undef},
+ {stop_date => {'>' => 'now'}}
+ ]
+ });
+
+ #check for PATRON_IN_COLLECTIONS
+ my $searchpenalty_coll = new_editor()->search_actor_user_standing_penalty({
+ usr => $user->id,
+ standing_penalty => 30,
+ '-or' => [
+ {stop_date => undef},
+ {stop_date => {'>' => 'now'}}
+ ]
+ });
+
+ #check for alerting block
+ my $searchpenalty_alertblock = new_editor()->search_actor_user_standing_penalty({
+ usr => $user->id,
+ standing_penalty => 25,
+ '-or' => [
+ {stop_date => undef},
+ {stop_date => {'>' => 'now'}}
+ ]
+ });
+
+ #check for PATRON_TEMP_RENEWAL
+ ##### THIS WILL BE A DIFFERENT NUMBER ON PRODUCTION #####
+ my $searchpenalty_temp = new_editor()->search_actor_user_standing_penalty({
+ usr => $user->id,
+ standing_penalty => 101,
+ '-or' => [
+ {stop_date => undef},
+ {stop_date => {'>' => 'now'}}
+ ]
+ });
+
+ if (@$searchpenalty_address || @$searchpenalty_coll || @$searchpenalty_phone || @$searchpenalty_alertblock) {
+ $ctx->{haspenalty} = 1;
+ } else {
+ $ctx->{haspenalty} = 0;
+ }
+
+ if (@$searchpenalty_temp) {
+ $ctx->{hastemprenew} = 1;
+ } else {
+ $ctx->{hastemprenew} = 0;
+ }
+
+ return;
+}
+
+# PINES - check whether or not to show account renewal link
+sub check_account_exp {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ $self->update_dashboard_stats();
+
+ #make sure patron is in an eligible perm group for renewal
+ if ($ctx->{user}->profile eq '2' || $ctx->{user}->profile eq '14' || $ctx->{user}->profile eq '56' || $ctx->{user}->profile eq '53' || $ctx->{user}->profile eq '22' || $ctx->{user}->profile eq '64' || $ctx->{user}->profile eq '60') {
+ $ctx->{eligible_permgroup} = 1;
+ } else {
+ $ctx->{eligible_permgroup} = 0;
+ }
+
+ #check for various standing penalties that would block an online renewal
+ $self->has_penalties();
+
+ #check for other problems that would block an online renewal
+ if ($ctx->{user}->active ne 't') { #user is no longer active
+ $ctx->{hasproblem} = 1;
+ } elsif ($ctx->{haspenalty} eq 1) { #user has a standing penalty block
+ $ctx->{hasproblem} = 1;
+ } elsif ($ctx->{user}->barred eq 't') { #user is barred
+ $ctx->{hasproblem} = 1;
+ } elsif ($ctx->{valid_billing_address} ne 't') { #user has invalid address
+ $ctx->{hasproblem} = 1;
+ } else {
+ $ctx->{hasproblem} = 0;
+ }
+
+ #determine which message to show (if any)
+ if ($ctx->{hastemprenew} eq 1) { #user already has active temp renewal
+ $ctx->{account_renew_message} = 'Your account was renewed for 30 days. Please visit your nearest PINES library with your current ID and proof of address to complete your account renewal.';
+ } elsif (DateTime->today->add(days=>30) lt $ctx->{user}->expire_date) {
+ #expiration date is too far in future - don't show message
+ $ctx->{account_renew_message} = '';
+ } elsif ($ctx->{hasproblem} eq 1 or $ctx->{eligible_permgroup} eq 0) { #see other problems above
+ $ctx->{account_renew_message} = 'Your account is due for renewal, but it is not eligible for online renewal. Please visit your nearest PINES library with your current ID and proof of address to renew your account.';
+ } elsif ($ctx->{user_stats}->{fines}->{balance_owed} gt 0) { #user has fines
+ $ctx->{account_renew_message} = 'Your account expiration date is coming up soon. Please pay your outstanding fines in order to renew your account.';
+ } else {
+ $ctx->{account_renew_message} = '<span class="light_border"><a class="btn btn-sm btn-action" href="/eg/opac/renew-account"><i class="fas fa-user-cog"></i>Click here to renew your account</a></span>';
+ }
+
+ return;
+}
+
+# PINES - if account is eligible to renew, pass patron data to vendor to populate form
+sub load_renew_account {
+ return;
+}
+
1;