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

(-)a/Koha/Exceptions/Ill.pm (+47 lines)
Line 0 Link Here
1
package Koha::Exceptions::Ill;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Exception::Class (
21
22
    'Koha::Exceptions::Ill' => {
23
        description => 'Something went wrong!',
24
    },
25
    'Koha::Exceptions::Ill::InvalidBackendId' => {
26
        isa => 'Koha::Exceptions::Ill',
27
        description => "Invalid backend name required",
28
    }
29
);
30
31
=head1 NAME
32
33
Koha::Exceptions::Ill - Base class for ILL exceptions
34
35
=head1 Exceptions
36
37
=head2 Koha::Exceptions::Ill
38
39
Generic Ill exception
40
41
=head2 Koha::Exceptions::Ill::InvalidBackend
42
43
Exception to be used when the required ILL backend is invalid.
44
45
=cut
46
47
1;
(-)a/Koha/Illrequest.pm (-6 / +12 lines)
Lines 18-33 package Koha::Illrequest; Link Here
18
# Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin
18
# Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin
19
# Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
20
21
use Modern::Perl;
22
21
use Clone 'clone';
23
use Clone 'clone';
22
use File::Basename qw/basename/;
24
use File::Basename qw/basename/;
23
use Koha::Database;
25
use Koha::Database;
24
use Koha::Email;
26
use Koha::Email;
27
use Koha::Exceptions::Ill;
25
use Koha::Illrequest;
28
use Koha::Illrequest;
26
use Koha::Illrequestattributes;
29
use Koha::Illrequestattributes;
27
use Koha::Patron;
30
use Koha::Patron;
28
use Mail::Sendmail;
31
use Mail::Sendmail;
29
use Try::Tiny;
32
use Try::Tiny;
30
use Modern::Perl;
31
33
32
use base qw(Koha::Object);
34
use base qw(Koha::Object);
33
35
Lines 139-151 sub load_backend { Link Here
139
    my @raw = qw/Koha Illbackends/; # Base Path
141
    my @raw = qw/Koha Illbackends/; # Base Path
140
142
141
    my $backend_name = $backend_id || $self->backend;
143
    my $backend_name = $backend_id || $self->backend;
142
    my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load
144
145
    unless ( defined $backend_name && $backend_name ne '' ) {
146
        Koha::Exceptions::Ill::InvalidBackendId->throw(
147
            "An invalid backend ID was requested ('')");
148
    }
149
150
    my $location = join "/", @raw, $backend_name, "Base.pm";    # File to load
143
    my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name
151
    my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name
144
    require $location;
152
    require $location;
145
    $self->{_my_backend} = $backend_class->new({ config => $self->_config });
153
    $self->{_my_backend} = $backend_class->new({ config => $self->_config });
146
    return $self;
154
    return $self;
147
}
155
}
148
156
157
149
=head3 _backend
158
=head3 _backend
150
159
151
    my $backend = $abstract->_backend($new_backend);
160
    my $backend = $abstract->_backend($new_backend);
Lines 468-477 Return a list of available backends. Link Here
468
477
469
sub available_backends {
478
sub available_backends {
470
    my ( $self ) = @_;
479
    my ( $self ) = @_;
471
    my $backend_dir = $self->_config->backend_dir;
480
    my @backends = $self->_config->available_backends;
472
    my @backends = ();
473
    @backends = glob "$backend_dir/*" if ( $backend_dir );
474
    @backends = map { basename($_) } @backends;
475
    return \@backends;
481
    return \@backends;
476
}
482
}
477
483
(-)a/Koha/Illrequest/Config.pm (+18 lines)
Lines 18-23 package Koha::Illrequest::Config; Link Here
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
22
use File::Basename;
23
21
use C4::Context;
24
use C4::Context;
22
25
23
=head1 NAME
26
=head1 NAME
Lines 100-105 sub backend_dir { Link Here
100
    return $self->{configuration}->{backend_directory};
103
    return $self->{configuration}->{backend_directory};
101
}
104
}
102
105
106
=head3 available_backends
107
108
Return a list of available backends.
109
110
=cut
111
112
sub available_backends {
113
    my ( $self ) = @_;
114
    my $backend_dir = $self->backend_dir;
115
    my @backends = ();
116
    @backends = glob "$backend_dir/*" if ( $backend_dir );
117
    @backends = map { basename($_) } @backends;
118
    return \@backends;
119
}
120
103
=head3 partner_code
121
=head3 partner_code
104
122
105
    $partner_code = $config->partner_code($new_code);
123
    $partner_code = $config->partner_code($new_code);
(-)a/Koha/Illrequestattribute.pm (-2 / +2 lines)
Lines 30-40 Koha::Illrequestattribute - Koha Illrequestattribute Object class Link Here
30
30
31
=head1 API
31
=head1 API
32
32
33
=head2 Class Methods
33
=head2 Internal methods
34
34
35
=cut
35
=cut
36
36
37
=head3 type
37
=head3 _type
38
38
39
=cut
39
=cut
40
40
(-)a/about.pl (+14 lines)
Lines 38-43 use Koha::Acquisition::Currencies; Link Here
38
use Koha::Patrons;
38
use Koha::Patrons;
39
use Koha::Caches;
39
use Koha::Caches;
40
use Koha::Config::SysPrefs;
40
use Koha::Config::SysPrefs;
41
use Koha::Illrequest::Config;
41
use C4::Members::Statistics;
42
use C4::Members::Statistics;
42
43
43
#use Smart::Comments '####';
44
#use Smart::Comments '####';
Lines 260-265 if ( !defined C4::Context->config('use_zebra_facets') ) { Link Here
260
    }
261
    }
261
}
262
}
262
263
264
if ( C4::Context->preference('ILLModule') ) {
265
    my $warnILLConfiguration = 0;
266
    my $available_ill_backends =
267
      ( scalar @{ Koha::Illrequest::Config->new->available_backends } > 0 );
268
269
    if ( !$available_ill_backends ) {
270
        $template->param( no_ill_backends => 1 );
271
        $warnILLConfiguration = 1;
272
    }
273
274
    $template->param( warnILLConfiguration => $warnILLConfiguration );
275
}
276
263
# Sco Patron should not contain any other perms than circulate => self_checkout
277
# Sco Patron should not contain any other perms than circulate => self_checkout
264
if (  C4::Context->preference('WebBasedSelfCheck')
278
if (  C4::Context->preference('WebBasedSelfCheck')
265
      and C4::Context->preference('AutoSelfCheckAllowed')
279
      and C4::Context->preference('AutoSelfCheckAllowed')
(-)a/ill/ill-requests.pl (-163 / +166 lines)
Lines 50-237 my ( $template, $patronnumber, $cookie ) = get_template_and_user( { Link Here
50
    flagsrequired => { ill => '*' },
50
    flagsrequired => { ill => '*' },
51
} );
51
} );
52
52
53
if ( $op eq 'illview' ) {
53
# Are we able to actually work?
54
    # View the details of an ILL
54
my $backends = Koha::Illrequest::Config->new->available_backends;
55
    my $request = Koha::Illrequests->find($params->{illrequest_id});
55
my $backends_available = ( scalar @{$backends} > 0 );
56
56
$template->param( backends_available => $backends_available );
57
    $template->param(
57
58
        request => $request
58
if ( $backends_available ) {
59
    );
59
    if ( $op eq 'illview' ) {
60
60
        # View the details of an ILL
61
} elsif ( $op eq 'create' ) {
61
        my $request = Koha::Illrequests->find($params->{illrequest_id});
62
    # We're in the process of creating a request
62
63
    my $request = Koha::Illrequest->new
63
        $template->param(
64
        ->load_backend($params->{backend});
64
            request => $request
65
    my $backend_result = $request->backend_create($params);
65
        );
66
    $template->param(
66
67
        whole   => $backend_result,
67
    } elsif ( $op eq 'create' ) {
68
        request => $request
68
        # We're in the process of creating a request
69
    );
69
        my $request = Koha::Illrequest->new->load_backend( $params->{backend} );
70
    handle_commit_maybe($backend_result, $request);
70
        my $backend_result = $request->backend_create($params);
71
72
} elsif ( $op eq 'confirm' ) {
73
    # Backend 'confirm' method
74
    # confirm requires a specific request, so first, find it.
75
    my $request = Koha::Illrequests->find($params->{illrequest_id});
76
    my $backend_result = $request->backend_confirm($params);
77
    $template->param(
78
        whole   => $backend_result,
79
        request => $request,
80
    );
81
82
    # handle special commit rules & update type
83
    handle_commit_maybe($backend_result, $request);
84
85
} elsif ( $op eq 'cancel' ) {
86
    # Backend 'cancel' method
87
    # cancel requires a specific request, so first, find it.
88
    my $request = Koha::Illrequests->find($params->{illrequest_id});
89
    my $backend_result = $request->backend_cancel($params);
90
    $template->param(
91
        whole   => $backend_result,
92
        request => $request,
93
    );
94
95
    # handle special commit rules & update type
96
    handle_commit_maybe($backend_result, $request);
97
98
} elsif ( $op eq 'edit_action' ) {
99
    # Handle edits to the Illrequest object.
100
    # (not the Illrequestattributes)
101
    # We simulate the API for backend requests for uniformity.
102
    # So, init:
103
    my $request = Koha::Illrequests->find($params->{illrequest_id});
104
    if ( !$params->{stage} ) {
105
        my $backend_result = {
106
            error   => 0,
107
            status  => '',
108
            message => '',
109
            method  => 'edit_action',
110
            stage   => 'init',
111
            next    => '',
112
            value   => {}
113
        };
114
        $template->param(
71
        $template->param(
115
            whole   => $backend_result,
72
            whole   => $backend_result,
116
            request => $request
73
            request => $request
117
        );
74
        );
118
    } else {
119
        # Commit:
120
        # Save the changes
121
        $request->borrowernumber($params->{borrowernumber});
122
        $request->biblio_id($params->{biblio_id});
123
        $request->branchcode($params->{branchcode});
124
        $request->notesopac($params->{notesopac});
125
        $request->notesstaff($params->{notesstaff});
126
        $request->store;
127
        my $backend_result = {
128
            error   => 0,
129
            status  => '',
130
            message => '',
131
            method  => 'edit_action',
132
            stage   => 'commit',
133
            next    => 'illlist',
134
            value   => {}
135
        };
136
        handle_commit_maybe($backend_result, $request);
75
        handle_commit_maybe($backend_result, $request);
137
    }
138
76
139
} elsif ( $op eq 'moderate_action' ) {
77
    } elsif ( $op eq 'confirm' ) {
140
    # Moderate action is required for an ILL submodule / syspref.
78
        # Backend 'confirm' method
141
    # Currently still needs to be implemented.
79
        # confirm requires a specific request, so first, find it.
142
    redirect_to_list();
80
        my $request = Koha::Illrequests->find($params->{illrequest_id});
81
        my $backend_result = $request->backend_confirm($params);
82
        $template->param(
83
            whole   => $backend_result,
84
            request => $request,
85
        );
143
86
144
} elsif ( $op eq 'delete_confirm') {
87
        # handle special commit rules & update type
145
    my $request = Koha::Illrequests->find($params->{illrequest_id});
88
        handle_commit_maybe($backend_result, $request);
89
90
    } elsif ( $op eq 'cancel' ) {
91
        # Backend 'cancel' method
92
        # cancel requires a specific request, so first, find it.
93
        my $request = Koha::Illrequests->find($params->{illrequest_id});
94
        my $backend_result = $request->backend_cancel($params);
95
        $template->param(
96
            whole   => $backend_result,
97
            request => $request,
98
        );
146
99
147
    $template->param(
100
        # handle special commit rules & update type
148
        request => $request
101
        handle_commit_maybe($backend_result, $request);
149
    );
150
102
151
} elsif ( $op eq 'delete' ) {
103
    } elsif ( $op eq 'edit_action' ) {
104
        # Handle edits to the Illrequest object.
105
        # (not the Illrequestattributes)
106
        # We simulate the API for backend requests for uniformity.
107
        # So, init:
108
        my $request = Koha::Illrequests->find($params->{illrequest_id});
109
        if ( !$params->{stage} ) {
110
            my $backend_result = {
111
                error   => 0,
112
                status  => '',
113
                message => '',
114
                method  => 'edit_action',
115
                stage   => 'init',
116
                next    => '',
117
                value   => {}
118
            };
119
            $template->param(
120
                whole   => $backend_result,
121
                request => $request
122
            );
123
        } else {
124
            # Commit:
125
            # Save the changes
126
            $request->borrowernumber($params->{borrowernumber});
127
            $request->biblio_id($params->{biblio_id});
128
            $request->branchcode($params->{branchcode});
129
            $request->notesopac($params->{notesopac});
130
            $request->notesstaff($params->{notesstaff});
131
            $request->store;
132
            my $backend_result = {
133
                error   => 0,
134
                status  => '',
135
                message => '',
136
                method  => 'edit_action',
137
                stage   => 'commit',
138
                next    => 'illlist',
139
                value   => {}
140
            };
141
            handle_commit_maybe($backend_result, $request);
142
        }
152
143
153
    # Check if the request is confirmed, if not, redirect
144
    } elsif ( $op eq 'moderate_action' ) {
154
    # to the confirmation view
145
        # Moderate action is required for an ILL submodule / syspref.
155
    if ($params->{confirmed} == 1) {
146
        # Currently still needs to be implemented.
156
        # We simply delete the request...
157
        my $request = Koha::Illrequests->find(
158
            $params->{illrequest_id}
159
        )->delete;
160
        # ... then return to list view.
161
        redirect_to_list();
147
        redirect_to_list();
162
    } else {
163
        print $cgi->redirect(
164
            "/cgi-bin/koha/ill/ill-requests.pl?" .
165
            "method=delete_confirm&illrequest_id=" .
166
            $params->{illrequest_id});
167
    }
168
148
169
} elsif ( $op eq 'mark_completed' ) {
149
    } elsif ( $op eq 'delete_confirm') {
170
    my $request = Koha::Illrequests->find($params->{illrequest_id});
150
        my $request = Koha::Illrequests->find($params->{illrequest_id});
171
    my $backend_result = $request->mark_completed($params);
151
172
    $template->param(
152
        $template->param(
173
        whole => $backend_result,
153
            request => $request
174
        request => $request,
154
        );
175
    );
155
176
156
    } elsif ( $op eq 'delete' ) {
177
    # handle special commit rules & update type
157
178
    handle_commit_maybe($backend_result, $request);
158
        # Check if the request is confirmed, if not, redirect
179
159
        # to the confirmation view
180
} elsif ( $op eq 'generic_confirm' ) {
160
        if ($params->{confirmed}) {
181
    my $request = Koha::Illrequests->find($params->{illrequest_id});
161
            # We simply delete the request...
182
    $params->{current_branchcode} = C4::Context->mybranch;
162
            Koha::Illrequests->find( $params->{illrequest_id} )->delete;
183
    my $backend_result = $request->generic_confirm($params);
163
            # ... then return to list view.
184
    $template->param(
164
            redirect_to_list();
185
        whole => $backend_result,
165
        } else {
186
        request => $request,
166
            print $cgi->redirect(
187
    );
167
                "/cgi-bin/koha/ill/ill-requests.pl?" .
188
168
                "method=delete_confirm&illrequest_id=" .
189
    # handle special commit rules & update type
169
                $params->{illrequest_id});
190
    handle_commit_maybe($backend_result, $request);
170
            exit;
191
192
} elsif ( $op eq 'illlist') {
193
    # Display all current ILLs
194
    my $requests = $illRequests->search();
195
196
    $template->param(
197
        requests => $requests
198
    );
199
200
    # If we receive a pre-filter, make it available to the template
201
    my $possible_filters = ['borrowernumber'];
202
    my $active_filters = [];
203
    foreach my $filter(@{$possible_filters}) {
204
        if ($params->{$filter}) {
205
            push @{$active_filters},
206
                { name => $filter, value => $params->{$filter}};
207
        }
171
        }
208
    }
172
209
    if (scalar @{$active_filters} > 0) {
173
    } elsif ( $op eq 'mark_completed' ) {
174
        my $request = Koha::Illrequests->find($params->{illrequest_id});
175
        my $backend_result = $request->mark_completed($params);
176
        $template->param(
177
            whole => $backend_result,
178
            request => $request,
179
        );
180
181
        # handle special commit rules & update type
182
        handle_commit_maybe($backend_result, $request);
183
184
    } elsif ( $op eq 'generic_confirm' ) {
185
        my $request = Koha::Illrequests->find($params->{illrequest_id});
186
        $params->{current_branchcode} = C4::Context->mybranch;
187
        my $backend_result = $request->generic_confirm($params);
210
        $template->param(
188
        $template->param(
211
            prefilters => $active_filters
189
            whole => $backend_result,
190
            request => $request,
212
        );
191
        );
192
193
        # handle special commit rules & update type
194
        handle_commit_maybe($backend_result, $request);
195
196
    } elsif ( $op eq 'illlist') {
197
        # Display all current ILLs
198
        my $requests = $illRequests->search();
199
200
        $template->param(
201
            requests => $requests
202
        );
203
204
        # If we receive a pre-filter, make it available to the template
205
        my $possible_filters = ['borrowernumber'];
206
        my $active_filters = [];
207
        foreach my $filter(@{$possible_filters}) {
208
            if ($params->{$filter}) {
209
                push @{$active_filters},
210
                    { name => $filter, value => $params->{$filter}};
211
            }
212
        }
213
        if (scalar @{$active_filters} > 0) {
214
            $template->param(
215
                prefilters => $active_filters
216
            );
217
        }
218
    } else {
219
        my $request = Koha::Illrequests->find($params->{illrequest_id});
220
        my $backend_result = $request->custom_capability($op, $params);
221
        $template->param(
222
            whole => $backend_result,
223
            request => $request,
224
        );
225
226
        # handle special commit rules & update type
227
        handle_commit_maybe($backend_result, $request);
213
    }
228
    }
214
} else {
215
    my $request = Koha::Illrequests->find($params->{illrequest_id});
216
    my $backend_result = $request->custom_capability($op, $params);
217
    $template->param(
218
        whole => $backend_result,
219
        request => $request,
220
    );
221
222
    # handle special commit rules & update type
223
    handle_commit_maybe($backend_result, $request);
224
}
229
}
225
230
226
# Get a list of backends
227
my $ir = Koha::Illrequest->new;
228
229
$template->param(
231
$template->param(
230
    backends    => $ir->available_backends,
232
    backends   => $backends,
231
    media       => [ "Book", "Article", "Journal" ],
233
    media      => [ "Book", "Article", "Journal" ],
232
    query_type  => $op,
234
    query_type => $op,
233
    branches    => Koha::Libraries->search->unblessed,
235
    branches   => Koha::Libraries->search,
234
    here_link   => "/cgi-bin/koha/ill/ill-requests.pl"
236
    here_link  => "/cgi-bin/koha/ill/ill-requests.pl"
235
);
237
);
236
238
237
output_html_with_http_headers( $cgi, $cookie, $template->output );
239
output_html_with_http_headers( $cgi, $cookie, $template->output );
Lines 255-258 sub handle_commit_maybe { Link Here
255
257
256
sub redirect_to_list {
258
sub redirect_to_list {
257
    print $cgi->redirect('/cgi-bin/koha/ill/ill-requests.pl');
259
    print $cgi->redirect('/cgi-bin/koha/ill/ill-requests.pl');
260
    exit;
258
}
261
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc (-2 / +8 lines)
Lines 1-7 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% IF Koha.Preference('ILLModule ') %]
2
[% IF Koha.Preference('ILLModule ') %]
3
    <div id="toolbar" class="btn-toolbar">
3
    <div id="toolbar" class="btn-toolbar">
4
        [% IF backends.size > 1 %]
4
        [% IF backends_available %]
5
          [% IF backends.size > 1 %]
5
            <div class="dropdown btn-group">
6
            <div class="dropdown btn-group">
6
                <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
7
                <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
7
                    <i class="fa fa-plus"></i> New ILL request <span class="caret"></span>
8
                    <i class="fa fa-plus"></i> New ILL request <span class="caret"></span>
Lines 12-21 Link Here
12
                    [% END %]
13
                    [% END %]
13
                </ul>
14
                </ul>
14
            </div>
15
            </div>
15
        [% ELSE %]
16
          [% ELSE %]
16
            <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&amp;backend=[% backends.0 %]">
17
            <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&amp;backend=[% backends.0 %]">
17
                <i class="fa fa-plus"></i> New ILL request
18
                <i class="fa fa-plus"></i> New ILL request
18
            </a>
19
            </a>
20
          [% END %]
21
        [% ELSE %]
22
            <a id="ill-new" class="btn btn-sm btn-default disabled" href="">
23
                <i class="fa fa-plus"></i> New ILL request
24
            </a>
19
        [% END %]
25
        [% END %]
20
        <a id="ill-list" class="btn btn-sm btn-default btn-group" href="/cgi-bin/koha/ill/ill-requests.pl">
26
        <a id="ill-list" class="btn btn-sm btn-default btn-group" href="/cgi-bin/koha/ill/ill-requests.pl">
21
            <i class="fa fa-list"></i> List requests
27
            <i class="fa fa-list"></i> List requests
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-1 / +6 lines)
Lines 176-182 Link Here
176
            <br/>
176
            <br/>
177
        [% END %]
177
        [% END %]
178
178
179
        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching %]
179
        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration %]
180
            <h2>Warnings regarding the system configuration</h2>
180
            <h2>Warnings regarding the system configuration</h2>
181
            <table>
181
            <table>
182
                <caption>Preferences and parameters</caption>
182
                <caption>Preferences and parameters</caption>
Lines 226-231 Link Here
226
                    That will bring a performance boost to enable it.
226
                    That will bring a performance boost to enable it.
227
                    </td></tr>
227
                    </td></tr>
228
                [% END %]
228
                [% END %]
229
                [% IF warnILLConfiguration %]
230
                    <tr><th scope="row"><b>Warning</b> </th><td>
231
                    [% IF no_ill_backends %]The ILL module is enabled, but there are no backends available.[%END %]
232
                    </td></tr>
233
                [% END %]
229
            </table>
234
            </table>
230
        [% END %]
235
        [% END %]
231
236
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-6 / +8 lines)
Lines 4-11 Link Here
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; ILL requests  &rsaquo;</title>
5
<title>Koha &rsaquo; ILL requests  &rsaquo;</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
7
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
9
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css">
8
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css">
10
[% INCLUDE 'datatables.inc' %]
9
[% INCLUDE 'datatables.inc' %]
11
<script type="text/javascript">
10
<script type="text/javascript">
Lines 370-381 Link Here
370
369
371
<div id="breadcrumbs">
370
<div id="breadcrumbs">
372
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
371
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
372
    <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
373
    [% IF query_type == 'create' %]
373
    [% IF query_type == 'create' %]
374
        <a href=[% parent %]>ILL requests</a> &rsaquo; New request
374
         &rsaquo; New request
375
    [% ELSIF query_type == 'status' %]
375
    [% ELSIF query_type == 'status' %]
376
        <a href=[% parent %]>ILL requests</a> &rsaquo; Status
376
         &rsaquo; Status
377
    [% ELSE %]
378
        ILL requests
379
    [% END %]
377
    [% END %]
380
</div>
378
</div>
381
379
Lines 383-388 Link Here
383
    <div id="bd">
381
    <div id="bd">
384
        <div id="yui-main">
382
        <div id="yui-main">
385
            <div id="interlibraryloans" class="yui-b">
383
            <div id="interlibraryloans" class="yui-b">
384
        [% IF !backends_available %]
385
            <div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div>
386
        [% ELSE %]
386
                [% INCLUDE 'ill-toolbar.inc' %]
387
                [% INCLUDE 'ill-toolbar.inc' %]
387
388
388
                [% IF whole.error %]
389
                [% IF whole.error %]
Lines 680-685 Link Here
680
                [% INCLUDE $whole.template %]
681
                [% INCLUDE $whole.template %]
681
682
682
                [% END %]
683
                [% END %]
684
        [% END %]
683
            </div>
685
            </div>
684
        </div>
686
        </div>
685
    </div>
687
    </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (+4 lines)
Lines 48-53 Link Here
48
        [% ELSE %]
48
        [% ELSE %]
49
            <div class="span12">
49
            <div class="span12">
50
        [% END %]
50
        [% END %]
51
          [% IF !backends_available %]
52
            <div class="alert">ILL module configuration problem. Contact your administrator.</div>
53
          [% ELSE %]
51
            <div id="illrequests" class="maincontent">
54
            <div id="illrequests" class="maincontent">
52
                [% IF method == 'create' %]
55
                [% IF method == 'create' %]
53
                    <h2>New Interlibrary loan request</h2>
56
                    <h2>New Interlibrary loan request</h2>
Lines 193-198 Link Here
193
                        </form>
196
                        </form>
194
                    [% END %]
197
                    [% END %]
195
                </div> <!-- / .maincontent -->
198
                </div> <!-- / .maincontent -->
199
          [% END %]
196
            </div> <!-- / .span10/12 -->
200
            </div> <!-- / .span10/12 -->
197
        </div> <!-- / .row-fluid -->
201
        </div> <!-- / .row-fluid -->
198
    </div> <!-- / .container-fluid -->
202
    </div> <!-- / .container-fluid -->
(-)a/opac/opac-illrequests.pl (+1 lines)
Lines 24-29 use C4::Auth; Link Here
24
use C4::Koha;
24
use C4::Koha;
25
use C4::Output;
25
use C4::Output;
26
26
27
use Koha::Illrequest::Config;
27
use Koha::Illrequests;
28
use Koha::Illrequests;
28
use Koha::Libraries;
29
use Koha::Libraries;
29
use Koha::Patrons;
30
use Koha::Patrons;
(-)a/t/db_dependent/Illrequests.t (-21 / +33 lines)
Lines 357-363 subtest 'Backend testing (mocks)' => sub { Link Here
357
357
358
subtest 'Backend core methods' => sub {
358
subtest 'Backend core methods' => sub {
359
359
360
    plan tests => 16;
360
    plan tests => 18;
361
361
362
    $schema->storage->txn_begin;
362
    $schema->storage->txn_begin;
363
363
Lines 371-383 subtest 'Backend core methods' => sub { Link Here
371
    $config->set_always('getLimitRules',
371
    $config->set_always('getLimitRules',
372
                        { default => { count => 0, method => 'active' } });
372
                        { default => { count => 0, method => 'active' } });
373
373
374
    my $illrq = $builder->build({source => 'Illrequest'});
374
    my $illrq = $builder->build_object({
375
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
375
        class => 'Koha::Illrequests',
376
    $illrq_obj->_config($config);
376
        value => { backend => undef }
377
    $illrq_obj->_backend($backend);
377
    });
378
    $illrq->_config($config);
379
380
    # Test error conditions (no backend)
381
    throws_ok { $illrq->load_backend; }
382
        'Koha::Exceptions::Ill::InvalidBackendId',
383
        'Exception raised correctly';
384
385
    throws_ok { $illrq->load_backend(''); }
386
        'Koha::Exceptions::Ill::InvalidBackendId',
387
        'Exception raised correctly';
388
389
    # Now load the mocked backend
390
    $illrq->_backend($backend);
378
391
379
    # expandTemplate:
392
    # expandTemplate:
380
    is_deeply($illrq_obj->expandTemplate({ test => 1, method => "bar" }),
393
    is_deeply($illrq->expandTemplate({ test => 1, method => "bar" }),
381
              {
394
              {
382
                  test => 1,
395
                  test => 1,
383
                  method => "bar",
396
                  method => "bar",
Lines 394-400 subtest 'Backend core methods' => sub { Link Here
394
                         { stage => 'commit', method => 'create' });
407
                         { stage => 'commit', method => 'create' });
395
    # Test Copyright Clearance
408
    # Test Copyright Clearance
396
    t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", "Test Copyright Clearance.");
409
    t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", "Test Copyright Clearance.");
397
    is_deeply($illrq_obj->backend_create({test => 1}),
410
    is_deeply($illrq->backend_create({test => 1}),
398
              {
411
              {
399
                  error   => 0,
412
                  error   => 0,
400
                  status  => '',
413
                  status  => '',
Lines 408-414 subtest 'Backend core methods' => sub { Link Here
408
              "Backend create: copyright clearance.");
421
              "Backend create: copyright clearance.");
409
    t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", "");
422
    t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", "");
410
    # Test non-commit
423
    # Test non-commit
411
    is_deeply($illrq_obj->backend_create({test => 1}),
424
    is_deeply($illrq->backend_create({test => 1}),
412
              {
425
              {
413
                  stage => 'bar', method => 'create',
426
                  stage => 'bar', method => 'create',
414
                  template => "/tmp/Mock/intra-includes/create.inc",
427
                  template => "/tmp/Mock/intra-includes/create.inc",
Lines 416-443 subtest 'Backend core methods' => sub { Link Here
416
              },
429
              },
417
              "Backend create: arbitrary stage.");
430
              "Backend create: arbitrary stage.");
418
    # Test commit
431
    # Test commit
419
    is_deeply($illrq_obj->backend_create({test => 1}),
432
    is_deeply($illrq->backend_create({test => 1}),
420
              {
433
              {
421
                  stage => 'commit', method => 'create', permitted => 0,
434
                  stage => 'commit', method => 'create', permitted => 0,
422
                  template => "/tmp/Mock/intra-includes/create.inc",
435
                  template => "/tmp/Mock/intra-includes/create.inc",
423
                  opac_template => "/tmp/Mock/opac-includes/create.inc",
436
                  opac_template => "/tmp/Mock/opac-includes/create.inc",
424
              },
437
              },
425
              "Backend create: arbitrary stage, not permitted.");
438
              "Backend create: arbitrary stage, not permitted.");
426
    is($illrq_obj->status, "QUEUED", "Backend create: queued if restricted.");
439
    is($illrq->status, "QUEUED", "Backend create: queued if restricted.");
427
    $config->set_always('getLimitRules', {});
440
    $config->set_always('getLimitRules', {});
428
    $illrq_obj->status('NEW');
441
    $illrq->status('NEW');
429
    is_deeply($illrq_obj->backend_create({test => 1}),
442
    is_deeply($illrq->backend_create({test => 1}),
430
              {
443
              {
431
                  stage => 'commit', method => 'create', permitted => 1,
444
                  stage => 'commit', method => 'create', permitted => 1,
432
                  template => "/tmp/Mock/intra-includes/create.inc",
445
                  template => "/tmp/Mock/intra-includes/create.inc",
433
                  opac_template => "/tmp/Mock/opac-includes/create.inc",
446
                  opac_template => "/tmp/Mock/opac-includes/create.inc",
434
              },
447
              },
435
              "Backend create: arbitrary stage, permitted.");
448
              "Backend create: arbitrary stage, permitted.");
436
    is($illrq_obj->status, "NEW", "Backend create: not-queued.");
449
    is($illrq->status, "NEW", "Backend create: not-queued.");
437
450
438
    # backend_renew
451
    # backend_renew
439
    $backend->set_series('renew', { stage => 'bar', method => 'renew' });
452
    $backend->set_series('renew', { stage => 'bar', method => 'renew' });
440
    is_deeply($illrq_obj->backend_renew({test => 1}),
453
    is_deeply($illrq->backend_renew({test => 1}),
441
              {
454
              {
442
                  stage => 'bar', method => 'renew',
455
                  stage => 'bar', method => 'renew',
443
                  template => "/tmp/Mock/intra-includes/renew.inc",
456
                  template => "/tmp/Mock/intra-includes/renew.inc",
Lines 447-453 subtest 'Backend core methods' => sub { Link Here
447
460
448
    # backend_cancel
461
    # backend_cancel
449
    $backend->set_series('cancel', { stage => 'bar', method => 'cancel' });
462
    $backend->set_series('cancel', { stage => 'bar', method => 'cancel' });
450
    is_deeply($illrq_obj->backend_cancel({test => 1}),
463
    is_deeply($illrq->backend_cancel({test => 1}),
451
              {
464
              {
452
                  stage => 'bar', method => 'cancel',
465
                  stage => 'bar', method => 'cancel',
453
                  template => "/tmp/Mock/intra-includes/cancel.inc",
466
                  template => "/tmp/Mock/intra-includes/cancel.inc",
Lines 457-463 subtest 'Backend core methods' => sub { Link Here
457
470
458
    # backend_update_status
471
    # backend_update_status
459
    $backend->set_series('update_status', { stage => 'bar', method => 'update_status' });
472
    $backend->set_series('update_status', { stage => 'bar', method => 'update_status' });
460
    is_deeply($illrq_obj->backend_update_status({test => 1}),
473
    is_deeply($illrq->backend_update_status({test => 1}),
461
              {
474
              {
462
                  stage => 'bar', method => 'update_status',
475
                  stage => 'bar', method => 'update_status',
463
                  template => "/tmp/Mock/intra-includes/update_status.inc",
476
                  template => "/tmp/Mock/intra-includes/update_status.inc",
Lines 467-473 subtest 'Backend core methods' => sub { Link Here
467
480
468
    # backend_confirm
481
    # backend_confirm
469
    $backend->set_series('confirm', { stage => 'bar', method => 'confirm' });
482
    $backend->set_series('confirm', { stage => 'bar', method => 'confirm' });
470
    is_deeply($illrq_obj->backend_confirm({test => 1}),
483
    is_deeply($illrq->backend_confirm({test => 1}),
471
              {
484
              {
472
                  stage => 'bar', method => 'confirm',
485
                  stage => 'bar', method => 'confirm',
473
                  template => "/tmp/Mock/intra-includes/confirm.inc",
486
                  template => "/tmp/Mock/intra-includes/confirm.inc",
Lines 489-495 subtest 'Backend core methods' => sub { Link Here
489
        source => 'Borrower',
502
        source => 'Borrower',
490
        value => { categorycode => "ILLTSTLIB" },
503
        value => { categorycode => "ILLTSTLIB" },
491
    });
504
    });
492
    my $gen_conf = $illrq_obj->generic_confirm({
505
    my $gen_conf = $illrq->generic_confirm({
493
        current_branchcode => $illbrn->{branchcode}
506
        current_branchcode => $illbrn->{branchcode}
494
    });
507
    });
495
    isnt(index($gen_conf->{value}->{draft}->{body}, $backend->metadata->{Test}), -1,
508
    isnt(index($gen_conf->{value}->{draft}->{body}, $backend->metadata->{Test}), -1,
Lines 502-514 subtest 'Backend core methods' => sub { Link Here
502
       "Generic confirm: partner 2 is correct."
515
       "Generic confirm: partner 2 is correct."
503
    );
516
    );
504
517
505
    dies_ok { $illrq_obj->generic_confirm({
518
    dies_ok { $illrq->generic_confirm({
506
        current_branchcode => $illbrn->{branchcode},
519
        current_branchcode => $illbrn->{branchcode},
507
        stage => 'draft'
520
        stage => 'draft'
508
    }) }
521
    }) }
509
        "Generic confirm: missing to dies OK.";
522
        "Generic confirm: missing to dies OK.";
510
523
511
    dies_ok { $illrq_obj->generic_confirm({
524
    dies_ok { $illrq->generic_confirm({
512
        current_branchcode => $illbrn->{branchcode},
525
        current_branchcode => $illbrn->{branchcode},
513
        partners => $partner1->{email},
526
        partners => $partner1->{email},
514
        stage => 'draft'
527
        stage => 'draft'
515
- 

Return to bug 7317