})
);
- # PINES - need to make sure we're retrieving current info or else changed expire date won't show up
+ # PINES - need to make sure we're retrieving current info
$self->prepare_extended_user_info;
# PINES - check whether or not to provide account renewal link
if ($self->ctx->{user}->billing_address) {
});
#check for PATRON_TEMP_RENEWAL
+ my $findpenalty = new_editor()->search_config_standing_penalty({name => 'PATRON_TEMP_RENEWAL'})->[0];
+ my $penaltyid = $findpenalty->id;
my $searchpenalty_temp = new_editor()->search_actor_user_standing_penalty({
usr => $user->id,
- standing_penalty => 90,
+ standing_penalty => $penaltyid,
'-or' => [
{stop_date => undef},
{stop_date => {'>' => 'now'}}
#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.';
+ $ctx->{account_renew_message} = '<div style="border:2px solid green;padding:5px;">Your account could only be temporarily renewed because your
+ address changed. Please visit your nearest PINES library with your current proof of address
+ to complete your account renewal.</div>';
} 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} = '';
{name => 'mailing_county', class => 'aua'},
{name => 'mailing_state', class => 'aua'},
{name => 'mailing_country', class => 'aua'},
- {name => 'voter_registration', class => 'asvr'},
+ {name => 'voter_registration', class => 'asvr'}
);
my @api_fields_register = (
$update_type = 'register';
}
- #TERRAN TEST ECARD CONNECTION
- $logger->error("TERRAN ACTION TYPE: $update_type");
-
$self->log_params;
my $testmode = $cgi->param('testmode') || '';
} else {
return $self->compile_response unless $self->update_user;
return $self->compile_response unless $self->update_addresses;
- return $self->compile_response unless $self->add_survey_responses;
+# TERRAN - Survey is broken right now
+ #return $self->compile_response unless $self->add_survey_responses;
return $self->compile_response unless $self->save_user;
return $self->compile_response if $ctx->{response}->{status};
}
$logger->info("ECARD responding with " . $ctx->{response});
#TERRAN TEST
- $logger->error("TERRAN - compiled response is " . $ctx->{response});
+ $logger->error("TERRAN - response being sent to Quipu is: " . $ctx->{response});
return Apache2::Const::OK;
}
my $home_ou = $cgi->param('home_ou');
$au->name_keywords($in_house ? 'quipu_inhouse' : 'quipu_remote');
-
-# TERRAN - for testing purposes, hardcoding the home_ou temporarily
-# my $home_ou = $cgi->param('home_ou');
- my $home_ou = '4';
-
-# TERRAN - for testing purposes, hardcoding perm_grp temporarily
-# my $perm_grp = $U->ou_ancestor_setting_value(
-# $home_ou,
-# 'lib.ecard_patron_profile'
-# );
- my $perm_grp = '2';
+ my $perm_grp = $U->ou_ancestor_setting_value(
+ $home_ou,
+ 'lib.ecard_patron_profile'
+ );
$au->profile($perm_grp);
my $grp = new_editor()->retrieve_permission_grp_tree($perm_grp);
DateTime->now(time_zone => 'local')->add(
seconds => interval_to_seconds('30 days'))->iso8601()
);
+ # Add standing penalty to account
+ $self->apply_temp_renewal_penalty;
} else {
my $grp = new_editor()->retrieve_permission_grp_tree($perm_grp);
$au->expire_date(
my $answer = $cgi->param('voter_registration');
my $survey_response = Fieldmapper::action::survey_response->new;
+
$survey_response->id(-1);
$survey_response->isnew(1);
- $survey_response->survey(1); # voter registration survey
+ $survey_response->survey(1);
$survey_response->question(1);
$survey_response->answer($answer);
} else {
$msg = "Error updating user account: " . $resp->{textcode};
$logger->error("E-RENEW: $msg");
- $ctx->{response}->{status} = 'UPDATE_ERR'; # Does this work?
+ $ctx->{response}->{status} = 'UPDATE_ERR';
}
$ctx->{response}->{messages} = [{msg => $msg, pid => $$}];
return 1;
}
+sub apply_temp_renewal_penalty {
+
+ my $self = shift;
+ my $ctx = $self->ctx;
+ my $cgi = $self->cgi;
+ my $patron_id = $cgi->param('patron_id');
+
+ my $e = new_editor(xact => 1);
+ my $ptype = $e->search_config_standing_penalty({name => 'PATRON_TEMP_RENEWAL'})->[0];
+
+ my $penalty = Fieldmapper::actor::user_standing_penalty->new;
+ $penalty->usr($patron_id);
+ $penalty->org_unit(1);
+ $penalty->standing_penalty($ptype->id);
+
+ my $aum = Fieldmapper::actor::usr_message->new;
+ $aum->create_date('now');
+ $aum->sending_lib(1);
+ $aum->title('Temporary Account Renewal');
+ $aum->usr($penalty->usr);
+ $aum->message('Patron renewed online with an address change so was given a 30-day
+ temporary account renewal. Please archive this message after the address is
+ verified and the renewal date extended.');
+ $aum->pub(0);
+
+ $aum = $e->create_actor_usr_message($aum);
+ unless($aum) {
+ $e->rollback;
+ return 0;
+ }
+
+ $penalty->usr_message($aum->id);
+
+ unless($e->create_actor_user_standing_penalty($penalty)) {
+ $e->rollback;
+ return 0;
+ }
+
+ $e->commit;
+ return 1;
+}
+
+
1;