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

(-)a/Koha/Exceptions/Ill.pm (+16 lines)
Line 0 Link Here
1
package Koha::Exceptions::Ill;
2
3
use Modern::Perl;
4
5
use Exception::Class (
6
7
    'Koha::Exceptions::Ill' => {
8
        description => 'Something went wrong!',
9
    },
10
    'Koha::Exceptions::Ill::InvalidBackendId' => {
11
        isa => 'Koha::Exceptions::Ill',
12
        description => "Invalid backend name required",
13
    }
14
);
15
16
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_id && $backend_id 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 (+15 lines)
Lines 100-105 sub backend_dir { Link Here
100
    return $self->{configuration}->{backend_directory};
100
    return $self->{configuration}->{backend_directory};
101
}
101
}
102
102
103
=head3 available_backends
104
105
Return a list of available backends.
106
107
=cut
108
109
sub available_backends {
110
    my ( $self ) = @_;
111
    my $backend_dir = $self->backend_dir;
112
    my @backends = ();
113
    @backends = glob "$backend_dir/*" if ( $backend_dir );
114
    @backends = map { basename($_) } @backends;
115
    return \@backends;
116
}
117
103
=head3 partner_code
118
=head3 partner_code
104
119
105
    $partner_code = $config->partner_code($new_code);
120
    $partner_code = $config->partner_code($new_code);
(-)a/ill/ill-requests.pl (-6 / +7 lines)
Lines 224-237 if ( $op eq 'illview' ) { Link Here
224
}
224
}
225
225
226
# Get a list of backends
226
# Get a list of backends
227
my $ir = Koha::Illrequest->new;
227
my $available_backends = Koha::Illrequest::Config->new->available_backends;
228
228
229
$template->param(
229
$template->param(
230
    backends    => $ir->available_backends,
230
    backends_available => ( scalar $available_backends > 0 ),
231
    media       => [ "Book", "Article", "Journal" ],
231
    backends           => $available_backends,
232
    query_type  => $op,
232
    media              => [ "Book", "Article", "Journal" ],
233
    branches    => Koha::Libraries->search->unblessed,
233
    query_type         => $op,
234
    here_link   => "/cgi-bin/koha/ill/ill-requests.pl"
234
    branches           => Koha::Libraries->search,
235
    here_link          => "/cgi-bin/koha/ill/ill-requests.pl"
235
);
236
);
236
237
237
output_html_with_http_headers( $cgi, $cookie, $template->output );
238
output_html_with_http_headers( $cgi, $cookie, $template->output );
(-)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 available_backends %]
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/ill/ill-requests.tt (-3 / +1 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">
12
- 

Return to bug 7317