From 0fede834ced0a39e35838962a147aff00b80b4f4 Mon Sep 17 00:00:00 2001 From: Terran McCanna Date: Mon, 29 Aug 2022 16:50:13 -0400 Subject: [PATCH] Online Renewal - Retrieve patron then update fields to push back Signed-off-by: Terran McCanna --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm index b51230f33f..215b31e8bb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm @@ -16,7 +16,6 @@ $Data::Dumper::Indent = 0; my $U = 'OpenILS::Application::AppUtils'; # Check URL to see if this is a new registration or a renewal -# Do the subroutines have access to this variable??? my $self = shift; my $path = $self->apache->path_info; my $update_type = 'register'; @@ -271,7 +270,7 @@ sub compile_response { return Apache2::Const::OK; } -# Create actor.usr perl object and populate column data +# Create actor.usr perl object and populate column data (for new registration) sub make_user { my $self = shift; my $ctx = $self->ctx; @@ -324,24 +323,32 @@ sub make_user { return $ctx->{user} = $au; } -# New sub to update a user +# If existing account, update instead of create sub update_user { my $self = shift; + my @extra_flesh = @_; + my $e = $self->editor; my $ctx = $self->ctx; my $cgi = $self->cgi; - my $au = Fieldmapper::actor::user->new; - - # Grab user id - is this how we match the right patron to update? - $au->id($cgi->param('patron_id')); + # Grab user id, retrieve patron info from db and create patron object + my $patron_id = $cgi->param('patron_id'); - # We need to figure out how to append this value rather than replace - $au->name_keywords('quipu_renew'); + my $au = $self->editor->retrieve_actor_user([$patron_id, + { + flesh => 1, + flesh_fields => { + au => ['billing_address', 'mailing_address', 'groups'] + } + } + ]); - my $home_ou = $cgi->param('home_ou'); + # Replace values in patron object with new data + # Need to append new keyword for use in reports later + $au->name_keywords($au->name_keywords + ' quipu_renew'); + # Temp renewal is only 30 days, otherwise use perm_interval - # Is using '30 days' the right syntax here? my $temp_renewal = $cgi->param('temp_renewal'); if ($temp_renewal == '1') { @@ -665,7 +672,7 @@ sub save_user { my $self = shift; my $ctx = $self->ctx; my $cgi = $self->cgi; - my $user = $ctx->{user}; #Do we need to change this for renew? + my $user = $ctx->{user}; my $resp = $U->simplereq( 'open-ils.actor', -- 2.11.0