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

(-)a/Koha/Illbackend.pm (-11 / +31 lines)
Lines 48-53 Return a list of existing ILL statuses Link Here
48
sub existing_statuses {
48
sub existing_statuses {
49
    my ( $self, $backend_id ) = @_;
49
    my ( $self, $backend_id ) = @_;
50
50
51
    my @data;
52
51
    # NOTE: This query fetches all distinct status's found in the database for this backend.
53
    # NOTE: This query fetches all distinct status's found in the database for this backend.
52
    # We need the 'status' field for obvious reasons, the 'backend' field is required to not
54
    # We need the 'status' field for obvious reasons, the 'backend' field is required to not
53
    # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object.
55
    # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object.
Lines 61-79 sub existing_statuses { Link Here
61
            group_by => [qw/status backend/],
63
            group_by => [qw/status backend/],
62
        }
64
        }
63
    );
65
    );
66
    while ( my $request = $ill_requests->next ) {
67
        my $status_data = $request->strings_map;
64
68
65
    my @data;
69
        if ( $status_data->{status} ) {
66
    while (my $request = $ill_requests->next) {
70
            push @data, {
71
                  $status_data->{status}->{str}  ? ( str => $status_data->{status}->{str} )
72
                : $status_data->{status}->{code} ? ( str => $status_data->{status}->{code} )
73
                : (),
74
                $status_data->{status}->{code} ? ( code => $status_data->{status}->{code} ) : (),
75
            };
76
        }
77
    }
78
79
    # Now do the same to get all status_aliases
80
    $ill_requests = Koha::Illrequests->search(
81
        { backend => $backend_id },
82
        {
83
            select   => [ 'status_alias', \'MAX(illrequest_id)', 'backend' ],
84
            as       => [qw/ status_alias illrequest_id backend /],
85
            group_by => [qw/status_alias backend/],
86
        }
87
    );
88
    while ( my $request = $ill_requests->next ) {
67
        my $status_data = $request->strings_map;
89
        my $status_data = $request->strings_map;
68
90
69
        foreach my $status_class ( qw(status_alias status) ){
91
        if ( $status_data->{status_alias} ) {
70
            if ($status_data->{$status_class}){
92
            push @data, {
71
                push @data, {
93
                  $status_data->{status_alias}->{str}  ? ( str => $status_data->{status_alias}->{str} )
72
                    $status_data->{$status_class}->{str} ? (str => $status_data->{$status_class}->{str}) :
94
                : $status_data->{status_alias}->{code} ? ( str => $status_data->{status_alias}->{code} )
73
                        $status_data->{$status_class}->{code} ? (str => $status_data->{$status_class}->{code}) : (),
95
                : (),
74
                    $status_data->{$status_class}->{code} ? (code => $status_data->{$status_class}->{code}) : (),
96
                $status_data->{status_alias}->{code} ? ( code => $status_data->{status_alias}->{code} ) : (),
75
                }
97
            };
76
            }
77
        }
98
        }
78
    }
99
    }
79
100
80
- 

Return to bug 34223