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

(-)a/Koha/Template/Plugin/Holds.pm (+48 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Holds;
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 base qw( Template::Plugin );
21
22
use Koha::Holds qw();
23
24
=pod
25
26
This plugin is a home for various patron related Template Toolkit functions
27
to help streamline Koha and to move logic from the Perl code into the
28
Templates when it makes sense to do so.
29
30
To use, first, include the line '[% USE Borrowers %]' at the top
31
of the template to enable the plugin.
32
33
For example: [% IF Borrowers.IsDebarred( borrower ) %]
34
removes the necessity of setting a template variable in Perl code to
35
find out if a patron is restricted even if that variable is not evaluated
36
in any way in the script.
37
38
=cut
39
40
sub count {
41
    my ( $self, $biblionumber ) = @_;
42
43
    return unless $biblionumber;
44
45
    return Koha::Holds->count( { biblionumber => $biblionumber } );
46
}
47
48
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Holds %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Catalog &rsaquo; [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %]</title>
4
<title>Koha &rsaquo; Catalog &rsaquo; [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 583-589 var holdForPatron = function () { Link Here
583
                            [% IF ( SEARCH_RESULT.norequests ) %]
584
                            [% IF ( SEARCH_RESULT.norequests ) %]
584
                                <span class="noholdstext">No holds allowed</span>
585
                                <span class="noholdstext">No holds allowed</span>
585
                            [% ELSE %]
586
                            [% ELSE %]
586
                                <a id="reserve_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Holds</a>
587
                                <a id="reserve_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Holds ([% Holds.count(SEARCH_RESULT.biblionumber) %])</a>
587
                                [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]&amp;findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></span>[% END %]
588
                                [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]&amp;findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></span>[% END %]
588
                            [% END %]
589
                            [% END %]
589
590
(-)a/t/db_dependent/Template/Plugin/Holds.t (-1 / +43 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
use Test::More tests => 3;
4
use t::lib::TestBuilder;
5
6
use C4::Context;
7
use Koha::Database;
8
use Koha::Library;
9
use Koha::Libraries;
10
use Koha::Template::Plugin::Holds;
11
12
my $schema  = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
14
15
my $builder = t::lib::TestBuilder->new;
16
17
my $dbh = C4::Context->dbh;
18
19
#$dbh->{AutoCommit} = 0;
20
#$dbh->{RaiseError} = 1;
21
22
my $biblio = $builder->build({
23
    source => 'Biblio',
24
    value => {}
25
});
26
27
my $plugin = Koha::Template::Plugin::Holds->new();
28
ok($plugin, "initialized Holds plugin");
29
30
my $count = $plugin->count($biblio->{biblionumber});
31
is($count, 0, 'No holds expected yet');
32
33
my $hold = $builder->build({
34
    source => 'Reserve',
35
    value => {
36
        biblionumber => $biblio->{biblionumber}
37
    }
38
});
39
40
$count = $plugin->count($biblio->{biblionumber});
41
is($count, 1, 'Now there is a hold');
42
43
$schema->storage->txn_rollback;

Return to bug 14876