|
Lines 111-153
sub approve {
Link Here
|
| 111 |
}; |
111 |
}; |
| 112 |
} |
112 |
} |
| 113 |
|
113 |
|
| 114 |
$self->_result->result_source->schema->txn_do( |
114 |
my $schema = $self->_result->result_source->schema; |
|
|
115 |
$schema->txn_do( |
| 115 |
sub { |
116 |
sub { |
| 116 |
try { |
117 |
try { |
| 117 |
$patron->store(); |
118 |
$schema->safe_do( |
| 118 |
|
119 |
sub { |
| 119 |
# Deal with attributes |
120 |
$patron->store(); |
| 120 |
my @codes = uniq( map { $_->{code} } @{$extended_attributes} ); |
121 |
|
| 121 |
foreach my $code (@codes) { |
122 |
# Deal with attributes |
| 122 |
map { $_->delete } Koha::Patron::Attributes->search( |
123 |
my @codes = uniq( map { $_->{code} } @{$extended_attributes} ); |
| 123 |
{ |
124 |
foreach my $code (@codes) { |
| 124 |
borrowernumber => $patron->borrowernumber, |
125 |
map { $_->delete } Koha::Patron::Attributes->search( |
| 125 |
code => $code |
126 |
{ |
|
|
127 |
borrowernumber => $patron->borrowernumber, |
| 128 |
code => $code |
| 129 |
} |
| 130 |
)->as_list; |
| 126 |
} |
131 |
} |
| 127 |
)->as_list; |
132 |
foreach my $attr ( @{$extended_attributes} ) { |
| 128 |
} |
133 |
$attr->{attribute} = exists $attr->{attribute} ? $attr->{attribute} : $attr->{value}; |
| 129 |
foreach my $attr ( @{$extended_attributes} ) { |
134 |
Koha::Patron::Attribute->new( |
| 130 |
$attr->{attribute} = exists $attr->{attribute} ? $attr->{attribute} : $attr->{value}; |
135 |
{ |
| 131 |
Koha::Patron::Attribute->new( |
136 |
borrowernumber => $patron->borrowernumber, |
| 132 |
{ |
137 |
code => $attr->{code}, |
| 133 |
borrowernumber => $patron->borrowernumber, |
138 |
attribute => $attr->{attribute}, |
| 134 |
code => $attr->{code}, |
139 |
} |
| 135 |
attribute => $attr->{attribute}, |
140 |
)->store |
|
|
141 |
if $attr->{attribute} # there's a value |
| 142 |
or ( |
| 143 |
defined $attr->{attribute} # there's a value that is 0, and not |
| 144 |
&& $attr->{attribute} ne "" # the empty string which means delete |
| 145 |
&& $attr->{attribute} == 0 |
| 146 |
); |
| 136 |
} |
147 |
} |
| 137 |
)->store |
148 |
} |
| 138 |
if $attr->{attribute} # there's a value |
149 |
); |
| 139 |
or ( |
|
|
| 140 |
defined $attr->{attribute} # there's a value that is 0, and not |
| 141 |
&& $attr->{attribute} ne "" # the empty string which means delete |
| 142 |
&& $attr->{attribute} == 0 |
| 143 |
); |
| 144 |
} |
| 145 |
} catch { |
150 |
} catch { |
| 146 |
if ( $_->isa('DBIx::Class::Exception') ) { |
151 |
|
| 147 |
Koha::Exceptions::Patron::Modification->throw( $_->{msg} ); |
152 |
# Convert any exception to domain-specific exception |
| 148 |
} else { |
153 |
Koha::Exceptions::Patron::Modification->throw($_); |
| 149 |
Koha::Exceptions::Patron::Modification->throw($_); |
|
|
| 150 |
} |
| 151 |
}; |
154 |
}; |
| 152 |
} |
155 |
} |
| 153 |
); |
156 |
); |
| 154 |
- |
|
|