|
Lines 50-55
sub restore_deleted_borrower {
Link Here
|
| 50 |
my $schema = Koha::Database->new->schema; |
50 |
my $schema = Koha::Database->new->schema; |
| 51 |
my $restored_patron; |
51 |
my $restored_patron; |
| 52 |
|
52 |
|
|
|
53 |
# Check if borrowernumber exists in borrowers. If it does thrown an exception, cannot restore. |
| 54 |
my $existing_borrower = Koha::Patrons->find( $self->borrowernumber ); |
| 55 |
if ($existing_borrower) { |
| 56 |
Koha::Exceptions::Patron::CannotRestore->throw( |
| 57 |
error => 'Borrowernumber already exists', |
| 58 |
type => 'borrowernumber', |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
# Check if cardnumber exists in borrowers. If it does thrown an exception, cannot restore. |
| 63 |
my $existing_cardnumber = Koha::Patrons->find( { cardnumber => $self->cardnumber } ); |
| 64 |
if ($existing_cardnumber) { |
| 65 |
Koha::Exceptions::Patron::CannotRestore->throw( |
| 66 |
error => 'Cardnumber already in use', |
| 67 |
type => 'cardnumber', |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
# Check if userid exists. If it does thrown an exception, cannot restore. |
| 72 |
if ( $self->userid ) { |
| 73 |
my $existing_userid = Koha::Patrons->find( { userid => $self->userid } ); |
| 74 |
if ($existing_userid) { |
| 75 |
Koha::Exceptions::Patron::CannotRestore->throw( |
| 76 |
error => 'Username already in use', |
| 77 |
type => 'userid', |
| 78 |
); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 53 |
$schema->txn_do( |
82 |
$schema->txn_do( |
| 54 |
sub { |
83 |
sub { |
| 55 |
# Retrive all the data about this patron from deleteborrowers table |
84 |
# Retrive all the data about this patron from deleteborrowers table |
| 56 |
- |
|
|