Online Renewal - Retrieve patron then update fields to push back
authorTerran McCanna <tmccanna@georgialibraries.org>
Mon, 29 Aug 2022 20:50:13 +0000 (16:50 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Sun, 30 Oct 2022 17:12:36 +0000 (13:12 -0400)
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm

index b51230f..215b31e 100644 (file)
@@ -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',