View | Details | Raw Unified | Return to bug 20581
Collapse All | Expand All

(-)a/Koha/Illrequest.pm (-6 / +60 lines)
Lines 33-38 use Koha::Illcomments; Link Here
33
use Koha::Illrequestattributes;
33
use Koha::Illrequestattributes;
34
use Koha::AuthorisedValue;
34
use Koha::AuthorisedValue;
35
use Koha::Patron;
35
use Koha::Patron;
36
use Koha::AuthorisedValues;
36
37
37
use base qw(Koha::Object);
38
use base qw(Koha::Object);
38
39
Lines 115-130 available for request. Link Here
115
    my $statusalias = $request->statusalias;
116
    my $statusalias = $request->statusalias;
116
117
117
Returns a request's status alias, as a Koha::AuthorisedValue instance
118
Returns a request's status alias, as a Koha::AuthorisedValue instance
118
or implicit undef
119
or implicit undef. This is distinct from status_alias, which only returns
120
the value in the status_alias column, this method returns the entire
121
AuthorisedValue object
119
122
120
=cut
123
=cut
121
124
122
sub statusalias {
125
sub statusalias {
123
    my ( $self ) = @_;
126
    my ( $self ) = @_;
124
    return unless $self->status_alias;
127
    return unless $self->status_alias;
125
    return Koha::AuthorisedValue->_new_from_dbic(
128
    # We can't know which result is the right one if there are multiple
126
        scalar $self->_result->status_alias
129
    # ILLSTATUS authorised values with the same authorised_value column value
127
    );
130
    # so we just use the first
131
    return Koha::AuthorisedValues->search({
132
        branchcode => $self->branchcode,
133
        category => 'ILLSTATUS',
134
        authorised_value => $self->SUPER::status_alias
135
    })->next;
128
}
136
}
129
137
130
=head3 illrequestattributes
138
=head3 illrequestattributes
Lines 160-165 sub patron { Link Here
160
    );
168
    );
161
}
169
}
162
170
171
=head3 status_alias
172
Overloaded getter/setter for status_alias,
173
that only returns authorised values from the
174
correct category
175
176
=cut
177
178
sub status_alias {
179
    my ($self, $newval) = @_;
180
    if ($newval) {
181
        # This is hackery to enable us to undefine
182
        # status_alias, since we need to have an overloaded
183
        # status_alias method to get us around the problem described
184
        # here:
185
        # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156
186
        # We need a way of accepting implied undef, so we can nullify
187
        # the status_alias column, when called from $self->status
188
        my $val = $newval == -1 ? undef : $newval;
189
        my $newval = $self->SUPER::status_alias($newval);
190
        if ($newval) {
191
            return $newval;
192
        } else {
193
            return;
194
        }
195
    }
196
    # We can't know which result is the right one if there are multiple
197
    # ILLSTATUS authorised values with the same authorised_value column value
198
    # so we just use the first
199
    my $alias = Koha::AuthorisedValues->search({
200
        branchcode => $self->branchcode,
201
        category => 'ILLSTATUS',
202
        authorised_value => $self->SUPER::status_alias
203
    })->next;
204
    if ($alias) {
205
        return $alias->authorised_value;
206
    } else {
207
        return;
208
    }
209
}
210
163
=head3 status
211
=head3 status
164
212
165
Overloaded getter/setter for request status,
213
Overloaded getter/setter for request status,
Lines 170-176 also nullifies status_alias Link Here
170
sub status {
218
sub status {
171
    my ( $self, $newval) = @_;
219
    my ( $self, $newval) = @_;
172
    if ($newval) {
220
    if ($newval) {
173
        $self->status_alias(undef);
221
        # This is hackery to enable us to undefine
222
        # status_alias, since we need to have an overloaded
223
        # status_alias method to get us around the problem described
224
        # here:
225
        # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156
226
        # We need a way of passing implied undef to nullify status_alias
227
        # so we pass -1, which is special cased in the overloaded setter
228
        $self->status_alias(-1);
174
        return $self->SUPER::status($newval);
229
        return $self->SUPER::status($newval);
175
    }
230
    }
176
    return $self->SUPER::status;
231
    return $self->SUPER::status;
177
- 

Return to bug 20581