<event code='2003' textcode='INTERNAL_SERVER_ERROR'>
<desc xml:lang="en-US">There was an internal server error</desc>
</event>
+ <event code='2004' textcode='ACTOR_USER_DELETE_OPEN_XACTS'>
+ <desc xml:lang="en-US">The user you have attempted to delete cannot be deleted because it has open circulations and/or unpaid bills.</desc>
+ </event>
<!-- CREDIT EVENTS -->
<event code='4001' textcode='CREDIT_PROCESSOR_NOT_ENABLED'>
my($self, $conn, $auth, $user_id, $dest_user_id) = @_;
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
+
+ # Find all unclosed billings for for user $user_id, thereby, also checking for open circs
+ my $open_bills = $e->json_query({
+ select => { mbts => ['id'] },
+ from => 'mbts',
+ where => {
+ xact_finish => { '=' => undef },
+ usr => { '=' => $user_id },
+ }
+ }) or return $e->die_event;
+
my $user = $e->retrieve_actor_user($user_id) or return $e->die_event;
+
+ # No deleting patrons with open billings or checked out copies
+ return $e->die_event(OpenILS::Event->new('ACTOR_USER_DELETE_OPEN_XACTS')) if @$open_bills;
# No deleting yourself - UI is supposed to stop you first, though.
return $e->die_event unless $e->requestor->id != $user->id;
return $e->die_event unless $e->allowed('DELETE_USER', $user->home_ou);
my $evt = group_perm_failed($session, $e->requestor, $user);
return $e->die_event($evt) if $evt;
my $stat = $e->json_query(
- {from => ['actor.usr_delete', $user_id, $dest_user_id]})->[0]
+ {from => ['actor.usr_delete', $user_id, $dest_user_id]})->[0]
or return $e->die_event;
$e->commit;
return 1;
}
-
__PACKAGE__->register_method (
method => 'user_payments',
api_name => 'open-ils.actor.user.payments.retrieve',
staff.patron.display.cmd_patron_delete.dest_user.title=Destination User
staff.patron.display.cmd_patron_delete.dest_user.failure=Failed to retrieve destination user. User deletion aborted.
staff.patron.display.cmd_patron_delete.dest_user.self_reference_failure=Cannot specify the deleted user as the destination user. User deletion aborted.
+staff.patron.display.cmd_patron_delete.open_xact=The user you have attempted to delete cannot be deleted because it has open circulations and/or unpaid bills.
staff.patron.display.spawn_editor.editing_related_patron=Editing Related Patron
staff.patron.display.init.retrieving_patron=Retrieving Patron...
staff.patron.display.init.retrieving=Retrieving...
}
params.push( dest_usr.id() );
}
- obj.network.simple_request( 'FM_AU_DELETE', params );
+ var robj = obj.network.simple_request( 'FM_AU_DELETE', params );
+ alert(js2JSON(robj));
+ if (typeof robj.ilsevent != 'undefined') {
+ switch(Number(robj.ilsevent)) {
+ case 2004 /* ACTOR_USER_DELETE_OPEN_XACTS */ :
+ alert(document.getElementById('patronStrings').getString('staff.patron.display.cmd_patron_delete.open_xact'));
+ return;
+ break;
+ }
+ }
obj.refresh_all();
}
} catch(E) {