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

(-)a/C4/HoldsQueue.pm (-19 / +16 lines)
Lines 133-139 sub GetHoldsQueueItems { Link Here
133
        $query .=" WHERE tmp_holdsqueue.holdingbranch = ?";
133
        $query .=" WHERE tmp_holdsqueue.holdingbranch = ?";
134
        push @bind_params, $branchlimit;
134
        push @bind_params, $branchlimit;
135
    }
135
    }
136
    if (C4::Context->preference('printSlipFromHoldsQueue')){
136
    if (C4::Context->preference('printSlipFromHoldsQueue') && defined $printstatus){
137
        $query .= $branchlimit ? " AND" : " WHERE";
137
        $query .= $branchlimit ? " AND" : " WHERE";
138
        $query .= " tmp_holdsqueue.print_status = ?";
138
        $query .= " tmp_holdsqueue.print_status = ?";
139
        push @bind_params, $printstatus;
139
        push @bind_params, $printstatus;
Lines 657-670 sub least_cost_branch { Link Here
657
sub MarkHoldPrinted {
657
sub MarkHoldPrinted {
658
   my ( $reserve_id ) = @_;
658
   my ( $reserve_id ) = @_;
659
   my $dbh = C4::Context->dbh;
659
   my $dbh = C4::Context->dbh;
660
   my $strsth="UPDATE reserves INNER JOIN tmp_holdsqueue USING (reserve_id)
660
   my $strsth="UPDATE reserves LEFT JOIN tmp_holdsqueue USING (reserve_id)
661
                SET reserves.print_status = 1 , tmp_holdsqueue.print_status = 1
661
                SET reserves.print_status = '1' , tmp_holdsqueue.print_status = '1'
662
                WHERE reserve_id = ?
662
                WHERE reserve_id = ?
663
		";
663
               ";
664
    my $sth = $dbh->prepare($strsth);
664
    my $sth = $dbh->prepare($strsth);
665
	$sth->execute($reserve_id);
665
    return $sth->execute($reserve_id);
666
667
    return 1;
668
}
666
}
669
667
670
=head2 GetItemNumberFromTmpHold
668
=head2 GetItemNumberFromTmpHold
Lines 672-691 sub MarkHoldPrinted { Link Here
672
    Returns itemnumber associated with hold.
670
    Returns itemnumber associated with hold.
673
    Item number is taken from tmp_holdsqueue table, which is
671
    Item number is taken from tmp_holdsqueue table, which is
674
    populated by bulid_holds_queue.pl script.
672
    populated by bulid_holds_queue.pl script.
675
676
=cut
673
=cut
677
sub	GetItemNumberFromTmpHold{
674
sub GetItemNumberFromTmpHold {
678
	my ( $reserve_id ) = @_;
675
    my ( $reserve_id ) = @_;
679
	my $dbh = C4::Context->dbh;
676
    my $dbh = C4::Context->dbh;
680
	my $strsth="SELECT itemnumber
677
    my $strsth="SELECT itemnumber
681
                  FROM tmp_holdsqueue
678
               FROM tmp_holdsqueue
682
                WHERE reserve_id = ?
679
               WHERE reserve_id = ?
683
		";
680
        ";
684
	my $sth = $dbh->prepare($strsth);
681
    my $sth = $dbh->prepare($strsth);
685
	$sth->execute($reserve_id);
682
    $sth->execute($reserve_id);
686
683
687
	my $data = $sth->fetchrow;
684
    my $data = $sth->fetchrow;
688
	return $data;
685
    return $data;
689
}
686
}
690
687
691
1;
688
1;
(-)a/C4/Reserves.pm (-5 / +8 lines)
Lines 2292-2318 sub ReserveSlip { Link Here
2292
}
2292
}
2293
2293
2294
=head2 HoldSlip
2294
=head2 HoldSlip
2295
    HoldSlip($branch, $reserve_id, $itemnumber)
2295
    HoldSlip( { branch     => $branch,
2296
                reserve_id => $reserve_id,
2297
                itemnumber => $itemnumber,
2298
                } )
2296
2299
2297
    Returns letter hash ( see C4::Letters::GetPreparedLetter ) or undef
2300
    Returns letter hash ( see C4::Letters::GetPreparedLetter ) or undef
2298
2301
2299
=cut
2302
=cut
2300
2303
2301
sub HoldSlip {
2304
sub HoldSlip {
2302
    my ($branch, $reserve_id, $itemnumber) = @_;
2305
    my $params = shift @_;
2303
2306
2304
    my $reserve = GetReserveInfo($reserve_id) or return;
2307
    my $reserve = GetReserveInfo($params->{reserve_id}) or return;
2305
2308
2306
    return  C4::Letters::GetPreparedLetter (
2309
    return  C4::Letters::GetPreparedLetter (
2307
        module => 'circulation',
2310
        module => 'circulation',
2308
        letter_code => 'RESERVESLIP',
2311
        letter_code => 'RESERVESLIP',
2309
        branchcode => $branch,
2312
        branchcode => $params->{branch},
2310
        tables => {
2313
        tables => {
2311
            'reserves'    => $reserve,
2314
            'reserves'    => $reserve,
2312
            'branches'    => $reserve->{branchcode},
2315
            'branches'    => $reserve->{branchcode},
2313
            'borrowers'   => $reserve->{borrowernumber},
2316
            'borrowers'   => $reserve->{borrowernumber},
2314
            'biblio'      => $reserve->{biblionumber},
2317
            'biblio'      => $reserve->{biblionumber},
2315
            'items'       => $itemnumber,
2318
            'items'       => $params->{itemnumber},
2316
        },
2319
        },
2317
    );
2320
    );
2318
}
2321
}
(-)a/circ/hold-pull-print.pl (-19 / +23 lines)
Lines 2-22 Link Here
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
5
# Koha is free software; you can redistribute it and/or modify it
6
# terms of the GNU General Public License as published by the Free Software
6
# under the terms of the GNU General Public License as published by
7
# Foundation; either version 2 of the License, or (at your option) any later
7
# the Free Software Foundation; either version 3 of the License, or
8
# version.
8
# (at your option) any later version.
9
#
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
10
# Koha is distributed in the hope that it will be useful, but
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
13
#
14
#
14
# You should have received a copy of the GNU General Public License along
15
# You should have received a copy of the GNU General Public License
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
18
use strict;
18
use Modern::Perl;
19
#use warnings; #FIXME - Bug 2505
20
use C4::Context;
19
use C4::Context;
21
use C4::Output;
20
use C4::Output;
22
use CGI;
21
use CGI;
Lines 38-44 my @reservations = $input->param('reserve_id'); Link Here
38
37
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
    {
39
    {
41
        template_name   => "circ/printslip.tmpl",
40
        template_name   => "circ/printslip.tt",
42
        query           => $input,
41
        query           => $input,
43
        type            => "intranet",
42
        type            => "intranet",
44
        authnotrequired => 0,
43
        authnotrequired => 0,
Lines 49-72 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
49
48
50
my $userenv = C4::Context->userenv;
49
my $userenv = C4::Context->userenv;
51
my $branch = $session->param('branch') || $userenv->{branch} || '';
50
my $branch = $session->param('branch') || $userenv->{branch} || '';
52
my ($slip, $is_html);
51
my ($slip, $is_html, @errors);
53
52
54
foreach my $reserve_id (@reservations){
53
foreach my $reserve_id (@reservations){
55
        my $itemnumber = GetItemNumberFromTmpHold($reserve_id);
54
        my $itemnumber = GetItemNumberFromTmpHold($reserve_id);
56
55
57
        if ( my $letter = HoldSlip ($branch, $reserve_id, $itemnumber) ) {
56
        my $slip_params = ({
57
                branch     => $branch,
58
                reserve_id => $reserve_id,
59
                itemnumber => $itemnumber,
60
        });
61
        if ( my $letter = HoldSlip ($slip_params) ) {
58
            $slip .= $letter->{content};
62
            $slip .= $letter->{content};
59
            $is_html = $letter->{is_html};
63
            $is_html = $letter->{is_html};
64
            MarkHoldPrinted($reserve_id);
65
        } else {
66
            push @errors, $reserve_id;
60
        }
67
        }
61
        else {
62
            $slip .= "Reserve not found";
63
        }
64
        MarkHoldPrinted($reserve_id);
65
}
68
}
66
69
67
$template->param(
70
$template->param(
68
    slip => $slip,
71
    slip => $slip,
69
    plain => !$is_html,
72
    plain => !$is_html,
73
    errors => \@errors,
70
    title => "Koha -- Circulation: Hold print",
74
    title => "Koha -- Circulation: Hold print",
71
    stylesheet => C4::Context->preference("SlipCSS"),
75
    stylesheet => C4::Context->preference("SlipCSS"),
72
);
76
);
(-)a/circ/view_holdsqueue.pl (-3 / +2 lines)
Lines 4-10 Link Here
4
#
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
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
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
8
# version.
9
#
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
Lines 22-29 This script displays items in the tmp_holdsqueue table Link Here
22
22
23
=cut
23
=cut
24
24
25
use strict;
25
use Modern::Perl;
26
use warnings;
27
use CGI;
26
use CGI;
28
use C4::Auth;
27
use C4::Auth;
29
use C4::Output;
28
use C4::Output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt (+3 lines)
Lines 27-31 Link Here
27
[% ELSE %]
27
[% ELSE %]
28
[% IF ( slip ) %][% slip %][% ELSE %]No hold found[% END %]
28
[% IF ( slip ) %][% slip %][% ELSE %]No hold found[% END %]
29
[% END %]
29
[% END %]
30
[% FOREACH error IN errors %]
31
    No hold found. (id: [% error %] )
32
[% END %]
30
33
31
[% INCLUDE 'intranet-bottom.inc' %]
34
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-24 / +28 lines)
Lines 12-50 Link Here
12
[% INCLUDE 'cat-search.inc' %]
12
[% INCLUDE 'cat-search.inc' %]
13
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
13
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
14
[% INCLUDE 'datatables.inc' %]
14
[% INCLUDE 'datatables.inc' %]
15
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
15
<script type="text/javascript">//<![CDATA[
16
<script type="text/javascript">//<![CDATA[
16
$(document).ready(function() {
17
$(document).ready(function() {
17
    $("#holdst").dataTable({
18
    $("#holdst").dataTable({
18
        "aaSorting": [[ 3, "asc" ]],
19
        "aaSorting": [[ 3, "asc" ]],
19
        "aoColumns": [
20
        "aoColumns": [
21
            [%- IF (printenable) -%]
22
            { "bSortable": false },{ "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null
23
            [%- ELSE -%]
20
            { "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null
24
            { "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null
25
            [%- END -%]
21
        ],
26
        ],
22
        "sDom": 't',
27
        "sDom": 't',
23
        "bPaginate": false
28
        "bPaginate": false
24
    });
29
    });
30
[% IF ( printenable ) %]
31
    $("#CheckAll").click(function(){
32
        $(".checkboxed").checkCheckboxes();
33
        return false;
34
    });
35
    $("#CheckNone").click(function(){
36
        $(".checkboxed").unCheckCheckboxes();
37
        return false;
38
    });
25
});
39
});
26
27
function printReservations() {
40
function printReservations() {
28
    document.hold_print.submit();
41
    if ( $('input[name="reserve_id"]:checked').length > 0 ){
29
}
42
        document.hold_print.submit();
30
function selectAll () {
43
    } else {
31
    if(document.hold_print.reserve_id.length == undefined ){
44
        alert(_("Select holds to print."));
32
        document.hold_print.reserve_id.checked=true;
33
    }else if(document.hold_print.reserve_id.length > 0) {
34
        for (var i=0; i < document.hold_print.reserve_id.length; i++) {
35
            document.hold_print.reserve_id[i].checked=true;
36
        }
37
    }
38
}
39
function clearAll () {
40
    if(document.hold_print.reserve_id.length == undefined ){
41
        document.hold_print.reserve_id.checked=false;
42
    }else if(document.hold_print.reserve_id.length > 0) {
43
        for (var i=0; i < document.hold_print.reserve_id.length; i++) {
44
            document.hold_print.reserve_id[i].checked=false;
45
        }
46
    }
45
    }
47
}
46
}
47
[% ELSE %]
48
});
49
[% END%]
48
//]]>
50
//]]>
49
</script>
51
</script>
50
52
Lines 73-80 function clearAll () { Link Here
73
    [% IF ( printenable ) %]
75
    [% IF ( printenable ) %]
74
        <p>
76
        <p>
75
        <input id="printhold" type="submit" class="submit" onclick="printReservations()" value="Print checked holds"/>
77
        <input id="printhold" type="submit" class="submit" onclick="printReservations()" value="Print checked holds"/>
76
        <a href="#" onclick="selectAll(); return false;">Select all</a> |
78
        <a id="CheckAll" href="#" >Select all</a> |
77
        <a href="#" onclick="clearAll(); return false;">Clear all</a>
79
        <a id="CheckNone" href="#" >Clear all</a>
78
        <br/>
80
        <br/>
79
        </p>
81
        </p>
80
        <form id="showprinted" name="showprinted" method="get" action="/cgi-bin/koha/circ/view_holdsqueue.pl">
82
        <form id="showprinted" name="showprinted" method="get" action="/cgi-bin/koha/circ/view_holdsqueue.pl">
Lines 90-100 function clearAll () { Link Here
90
        </form>
92
        </form>
91
    [% END %]
93
    [% END %]
92
    [% IF ( itemsloop ) %]
94
    [% IF ( itemsloop ) %]
93
        <form id="hold_print" name="hold_print" method="get" action="/cgi-bin/koha/circ/hold-pull-print.pl" target="_blank">
95
        [% IF ( printenable ) %]
96
        <form id="hold_print" name="hold_print" class="checkboxed" method="get" action="/cgi-bin/koha/circ/hold-pull-print.pl" target="_blank">
97
        [% END %]
94
<table id="holdst">
98
<table id="holdst">
95
	<thead>
99
	<thead>
96
	<tr>
100
	<tr>
97
       [% IF (printenable) %]<th class="hq-check">Check</th>[% END %]
101
       [% IF (printenable) %]<th class="hq-check">&nbsp;</th>[% END %]
98
        <th class="hq-title">Title</th>
102
        <th class="hq-title">Title</th>
99
        <th class="hq-collection">Collection</th>
103
        <th class="hq-collection">Collection</th>
100
        <th class="hq-itemtype">Item type</th>
104
        <th class="hq-itemtype">Item type</th>
Lines 111-117 function clearAll () { Link Here
111
     <tbody>[% FOREACH itemsloo IN itemsloop %]
115
     <tbody>[% FOREACH itemsloo IN itemsloop %]
112
        <tr>
116
        <tr>
113
        [% IF ( printenable ) %]
117
        [% IF ( printenable ) %]
114
			<td class="hq-print"><input type="checkbox" id="res[% itemsloo.reserve_id %]" name="reserve_id" value="[% itemsloo.reserve_id %]"/></td>
118
            <td class="hq-print"><input type="checkbox" id="res[% itemsloo.reserve_id %]" name="reserve_id" value="[% itemsloo.reserve_id %]"/></td>
115
        [% END %]
119
        [% END %]
116
            <td class="hq-title"><p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itemsloo.biblionumber %]"><strong>[% itemsloo.title |html %]</strong> [% IF ( itemsloo.subtitle ) %][% itemsloo.subtitle %][% END %]</a></p>
120
            <td class="hq-title"><p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itemsloo.biblionumber %]"><strong>[% itemsloo.title |html %]</strong> [% IF ( itemsloo.subtitle ) %][% itemsloo.subtitle %][% END %]</a></p>
117
                         <p><strong>[% itemsloo.author %]</strong>
121
                         <p><strong>[% itemsloo.author %]</strong>
(-)a/t/db_dependent/HoldsQueue.t (-1 / +25 lines)
Lines 12-18 use C4::Context; Link Here
12
12
13
use Data::Dumper;
13
use Data::Dumper;
14
14
15
use Test::More tests => 21;
15
use Test::More tests => 28;
16
16
17
17
18
use C4::Branch;
18
use C4::Branch;
Lines 281-286 $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) Link Here
281
#warn "RESERVES" . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM reserves", { Slice => {} }) );
281
#warn "RESERVES" . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM reserves", { Slice => {} }) );
282
#warn "ITEMS: " . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM items WHERE biblionumber = $biblionumber", { Slice => {} }) );
282
#warn "ITEMS: " . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM items WHERE biblionumber = $biblionumber", { Slice => {} }) );
283
283
284
my $reserve_id = $dbh->selectcol_arrayref("SELECT reserve_id FROM reserves");
285
my $print_status = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[0]);
286
is( $print_status->[0], "0", "Default print status in reserves for new reserve set as 0");
287
C4::HoldsQueue::MarkHoldPrinted($reserve_id->[0]);
288
$print_status = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[0]);
289
is( $print_status->[0], "1", "Hold status in reserves correctly marked as printed");
290
C4::HoldsQueue::MarkHoldPrinted($reserve_id->[1]);
291
284
my $holds_queue;
292
my $holds_queue;
285
293
286
$dbh->do("DELETE FROM default_circ_rules");
294
$dbh->do("DELETE FROM default_circ_rules");
Lines 298-303 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
298
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
306
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" );
299
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue );
307
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue );
300
308
309
my $print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[1]);
310
is( $print_status_tmp->[0], "1", "Hold status printed moved to tmp_holdsqueue from reserves");
311
$print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[2]);
312
is( $print_status_tmp->[0], "0", "Default print status in tmp_holdsqueue moved from reserves");
313
C4::HoldsQueue::MarkHoldPrinted($reserve_id->[2]);
314
$print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[2]);
315
is( $print_status_tmp->[0], "1", "Hold status in tmp_holdsqueue correctly marked as printed");
316
317
my $select_itnum = $dbh->selectcol_arrayref("SELECT itemnumber FROM tmp_holdsqueue WHERE reserve_id = ?", undef, $reserve_id->[0]);
318
my $get_itnum = C4::HoldsQueue::GetItemNumberFromTmpHold($reserve_id->[0]);
319
is( $select_itnum->[0],  $get_itnum, "Correct itemnumber selected from tmp_holdsqueue");
320
321
C4::Context->set_preference('printSlipFromHoldsQueue', 1);
322
my $getholds_queue = C4::HoldsQueue::GetHoldsQueueItems(undef, 1);
323
is( @$getholds_queue, "3", "Get printed holds from tmp_holdsqueue");
324
301
# Cleanup
325
# Cleanup
302
$dbh->rollback;
326
$dbh->rollback;
303
327
(-)a/t/db_dependent/Reserves.t (-2 / +7 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 50;
20
use Test::More tests => 51;
21
21
22
use MARC::Record;
22
use MARC::Record;
23
use DateTime::Duration;
23
use DateTime::Duration;
Lines 470-475 $cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{'CP Link Here
470
is($cancancel, 0, 'Reserve in waiting status cant be canceled');
470
is($cancancel, 0, 'Reserve in waiting status cant be canceled');
471
471
472
# End of tests for bug 12876
472
# End of tests for bug 12876
473
@results = GetReservesFromItemnumber($itemnumber);
474
my $hold_slip = C4::Reserves::HoldSlip({
475
        branch     => 'CPL',
476
        reserve_id => $results[3],
477
        itemnumber => $itemnumber });
478
ok(defined($hold_slip), 'can successfully generate hold slip');
473
479
474
$dbh->rollback;
480
$dbh->rollback;
475
481
476
- 

Return to bug 11651