# phone number (or staff manually delete the penalty).
my $contact_type = ($self->api_name =~ /invalidate.(\w+)(\.|$)/)[0];
-
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
);
}
+__PACKAGE__->register_method(
+ method => "generate_patron_barcode",
+ api_name => "open-ils.actor.generate_patron_barcode",
+ signature => {
+ desc => "Generates a new patron barcode. If a user ID is supplied," .
+ "that user's card will be updated to point at the new barcode." ,
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'User ID', type => 'number'},
+ ],
+ return => {desc => 'Generated barcode on success'}
+ }
+);
+
+# evergreen.lu_update_barcode(user-id) generates a barcode, creates an actor.card
+# object, and points actor.usr.card to the new actor.card.id
+#
+# evergreen.lu_generate_barcode() just generates a barcode
+sub generate_patron_barcode {
+
+ my( $self, $client, $auth, $user_id ) = @_;
+
+ my $e = new_editor( authtoken=>$auth );
+ return $e->die_event unless $e->checkauth;
+
+ my $barcode;
+ if ($user_id) {
+ return $e->die_event unless $e->allowed('UPDATE_USER');
+ $barcode = $e->json_query(
+ {from => ['evergreen.lu_update_barcode', $user_id]})->[0]
+ or return $e->die_event;
+ } else {
+ $barcode = $e->json_query(
+ {from => ['evergreen.lu_generate_barcode']})->[0]
+ or return $e->die_event;
+ }
+
+ return $barcode;
+}
+
+
# Putting the following method in open-ils.actor is a bad fit, except in that
# it serves an interface that lives under 'actor' in the templates directory,
# and in that there's nowhere else obvious to put it (open-ils.trigger is