Bugzilla – Attachment 38080 Details for
Bug 11651
Add possibility to print holds from holds queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11651: (QA Follow-up) Add possibility to print holds from holds queue.
Bug-11651-QA-Follow-up-Add-possibility-to-print-ho.patch (text/plain), 17.70 KB, created by
Rafal Kopaczka
on 2015-04-17 14:51:45 UTC
(
hide
)
Description:
Bug 11651: (QA Follow-up) Add possibility to print holds from holds queue.
Filename:
MIME Type:
Creator:
Rafal Kopaczka
Created:
2015-04-17 14:51:45 UTC
Size:
17.70 KB
patch
obsolete
>From b44010d58b7d9ba97d1c87818f28b654bf4ff386 Mon Sep 17 00:00:00 2001 >From: Rafal Kopaczka <rkk0@poczta.onet.pl> >Date: Fri, 30 May 2014 15:15:37 +0200 >Subject: [PATCH] Bug 11651: (QA Follow-up) Add possibility to print holds > from holds queue. > >Added unit tests, for new and modified subroutines. >Fixed minor qa suggestions. >Koha-qa.pl - pass. >--- > C4/HoldsQueue.pm | 35 +++++----- > C4/Reserves.pm | 13 ++-- > circ/hold-pull-print.pl | 42 ++++++------ > circ/view_holdsqueue.pl | 5 +- > .../prog/en/modules/circ/printslip.tt | 3 + > .../prog/en/modules/circ/view_holdsqueue.tt | 67 +++++++++++--------- > t/db_dependent/HoldsQueue.t | 26 +++++++- > t/db_dependent/Reserves.t | 8 ++- > 8 files changed, 121 insertions(+), 78 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index 200cf53..ff1df23 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -133,7 +133,7 @@ sub GetHoldsQueueItems { > $query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; > push @bind_params, $branchlimit; > } >- if (C4::Context->preference('printSlipFromHoldsQueue')){ >+ if (C4::Context->preference('printSlipFromHoldsQueue') && defined $printstatus){ > $query .= $branchlimit ? " AND" : " WHERE"; > $query .= " tmp_holdsqueue.print_status = ?"; > push @bind_params, $printstatus; >@@ -657,14 +657,12 @@ sub least_cost_branch { > sub MarkHoldPrinted { > my ( $reserve_id ) = @_; > my $dbh = C4::Context->dbh; >- my $strsth="UPDATE reserves INNER JOIN tmp_holdsqueue USING (reserve_id) >- SET reserves.print_status = 1 , tmp_holdsqueue.print_status = 1 >+ my $strsth="UPDATE reserves LEFT JOIN tmp_holdsqueue USING (reserve_id) >+ SET reserves.print_status = '1' , tmp_holdsqueue.print_status = '1' > WHERE reserve_id = ? >- "; >+ "; > my $sth = $dbh->prepare($strsth); >- $sth->execute($reserve_id); >- >- return 1; >+ return $sth->execute($reserve_id); > } > > =head2 GetItemNumberFromTmpHold >@@ -672,20 +670,19 @@ sub MarkHoldPrinted { > Returns itemnumber associated with hold. > Item number is taken from tmp_holdsqueue table, which is > populated by bulid_holds_queue.pl script. >- > =cut >-sub GetItemNumberFromTmpHold{ >- my ( $reserve_id ) = @_; >- my $dbh = C4::Context->dbh; >- my $strsth="SELECT itemnumber >- FROM tmp_holdsqueue >- WHERE reserve_id = ? >- "; >- my $sth = $dbh->prepare($strsth); >- $sth->execute($reserve_id); >+sub GetItemNumberFromTmpHold { >+ my ( $reserve_id ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $strsth="SELECT itemnumber >+ FROM tmp_holdsqueue >+ WHERE reserve_id = ? >+ "; >+ my $sth = $dbh->prepare($strsth); >+ $sth->execute($reserve_id); > >- my $data = $sth->fetchrow; >- return $data; >+ my $data = $sth->fetchrow; >+ return $data; > } > > 1; >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 3593993..c7f46fe 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -2418,27 +2418,30 @@ sub ReserveSlip { > } > > =head2 HoldSlip >- HoldSlip($branch, $reserve_id, $itemnumber) >+ HoldSlip( { branch => $branch, >+ reserve_id => $reserve_id, >+ itemnumber => $itemnumber, >+ } ) > > Returns letter hash ( see C4::Letters::GetPreparedLetter ) or undef > > =cut > > sub HoldSlip { >- my ($branch, $reserve_id, $itemnumber) = @_; >+ my $params = shift @_; > >- my $reserve = GetReserveInfo($reserve_id) or return; >+ my $reserve = GetReserveInfo($params->{reserve_id}) or return; > > return C4::Letters::GetPreparedLetter ( > module => 'circulation', > letter_code => 'RESERVESLIP', >- branchcode => $branch, >+ branchcode => $params->{branch}, > tables => { > 'reserves' => $reserve, > 'branches' => $reserve->{branchcode}, > 'borrowers' => $reserve->{borrowernumber}, > 'biblio' => $reserve->{biblionumber}, >- 'items' => $itemnumber, >+ 'items' => $params->{itemnumber}, > }, > ); > } >diff --git a/circ/hold-pull-print.pl b/circ/hold-pull-print.pl >index 106b479..7099652 100755 >--- a/circ/hold-pull-print.pl >+++ b/circ/hold-pull-print.pl >@@ -2,21 +2,20 @@ > > # This file is part of Koha. > # >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-#use warnings; #FIXME - Bug 2505 >+use Modern::Perl; > use C4::Context; > use C4::Output; > use CGI; >@@ -38,7 +37,7 @@ my @reservations = $input->param('reserve_id'); > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >- template_name => "circ/printslip.tmpl", >+ template_name => "circ/printslip.tt", > query => $input, > type => "intranet", > authnotrequired => 0, >@@ -49,24 +48,29 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > my $userenv = C4::Context->userenv; > my $branch = $session->param('branch') || $userenv->{branch} || ''; >-my ($slip, $is_html); >+my ($slip, $is_html, @errors); > > foreach my $reserve_id (@reservations){ > my $itemnumber = GetItemNumberFromTmpHold($reserve_id); > >- if ( my $letter = HoldSlip ($branch, $reserve_id, $itemnumber) ) { >+ my $slip_params = ({ >+ branch => $branch, >+ reserve_id => $reserve_id, >+ itemnumber => $itemnumber, >+ }); >+ if ( my $letter = HoldSlip ($slip_params) ) { > $slip .= $letter->{content}; > $is_html = $letter->{is_html}; >+ MarkHoldPrinted($reserve_id); >+ } else { >+ push @errors, $reserve_id; > } >- else { >- $slip .= "Reserve not found"; >- } >- MarkHoldPrinted($reserve_id); > } > > $template->param( > slip => $slip, > plain => !$is_html, >+ errors => \@errors, > title => "Koha -- Circulation: Hold print", > stylesheet => C4::Context->preference("SlipCSS"), > ); >diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl >index 1e2855c..d11887e 100755 >--- a/circ/view_holdsqueue.pl >+++ b/circ/view_holdsqueue.pl >@@ -4,7 +4,7 @@ > # > # Koha is free software; you can redistribute it and/or modify it under the > # terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >+# Foundation; either version 3 of the License, or (at your option) any later > # version. > # > # Koha is distributed in the hope that it will be useful, but WITHOUT ANY >@@ -22,8 +22,7 @@ This script displays items in the tmp_holdsqueue table > > =cut > >-use strict; >-use warnings; >+use Modern::Perl; > use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index b14ed28..5064125 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -27,5 +27,8 @@ > [% ELSE %] > [% IF ( slip ) %][% slip %][% ELSE %]No hold found[% END %] > [% END %] >+[% FOREACH error IN errors %] >+ No hold found. (id: [% error %] ) >+[% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >index 552bcae..e062b19 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >@@ -12,39 +12,41 @@ > [% INCLUDE 'cat-search.inc' %] > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] >+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> > <script type="text/javascript">//<![CDATA[ > $(document).ready(function() { > $("#holdst").dataTable({ > "aaSorting": [[ 3, "asc" ]], > "aoColumns": [ >+ [%- IF (printenable) -%] >+ { "bSortable": false },{ "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null >+ [%- ELSE -%] > { "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null >+ [%- END -%] > ], > "sDom": 't', > "bPaginate": false > }); >+[% IF ( printenable ) %] >+ $("#CheckAll").click(function(){ >+ $(".checkboxed").checkCheckboxes(); >+ return false; >+ }); >+ $("#CheckNone").click(function(){ >+ $(".checkboxed").unCheckCheckboxes(); >+ return false; >+ }); > }); >- > function printReservations() { >- document.hold_print.submit(); >-} >-function selectAll () { >- if(document.hold_print.reserve_id.length == undefined ){ >- document.hold_print.reserve_id.checked=true; >- }else if(document.hold_print.reserve_id.length > 0) { >- for (var i=0; i < document.hold_print.reserve_id.length; i++) { >- document.hold_print.reserve_id[i].checked=true; >- } >- } >-} >-function clearAll () { >- if(document.hold_print.reserve_id.length == undefined ){ >- document.hold_print.reserve_id.checked=false; >- }else if(document.hold_print.reserve_id.length > 0) { >- for (var i=0; i < document.hold_print.reserve_id.length; i++) { >- document.hold_print.reserve_id[i].checked=false; >- } >+ if ( $('input[name="reserve_id"]:checked').length > 0 ){ >+ document.hold_print.submit(); >+ } else { >+ alert(_("Select holds to print.")); > } > } >+[% ELSE %] >+}); >+[% END%] > //]]> > </script> > >@@ -71,30 +73,35 @@ function clearAll () { > <div class="dialog message">No items found.</div> > [% END %] > [% IF ( printenable ) %] >- <p> >- <input id="printhold" type="submit" class="submit" onclick="printReservations()" value="Print checked holds"/> >- <a href="#" onclick="selectAll(); return false;">Select all</a> | >- <a href="#" onclick="clearAll(); return false;">Clear all</a> >- <br/> >- </p> >+ <div id="toolbar" class="btn-toolbar"> >+ <div class="btn-group"> > <form id="showprinted" name="showprinted" method="get" action="/cgi-bin/koha/circ/view_holdsqueue.pl"> > <input type="hidden" name="run_report" value="1"/> > <input type="hidden" name="branchlimit" value="[% branchlimit %]"/> > [% IF ( showprinted ) %] > <input type="hidden" name="showprinted" value="0"/> >- <input id="submit_printed" type="submit" class="submit" value="Hide printed holds"/> >+ <input id="submit_printed" type="submit" class="btn btn-small" value="View non-printed holds"/> > [% ELSE %] > <input type="hidden" name="showprinted" value="1"/> >- <input id="submit_printed" type="submit" class="submit" value="Show printed holds"/> >+ <input id="submit_printed" type="submit" class="btn btn-small" value="View printed holds"/> > [% END %] > </form> >+ </div> >+ <div class="btn-group"> >+ <input id="printhold" type="submit" class="btn btn-small" onclick="printReservations()" value="Print selected"/> >+ </div> >+ </div> >+ <a id="CheckAll" href="#" >Select all</a> | >+ <a id="CheckNone" href="#" >Clear all</a> > [% END %] > [% IF ( itemsloop ) %] >- <form id="hold_print" name="hold_print" method="get" action="/cgi-bin/koha/circ/hold-pull-print.pl" target="_blank"> >+ [% IF ( printenable ) %] >+ <form id="hold_print" name="hold_print" class="checkboxed" method="get" action="/cgi-bin/koha/circ/hold-pull-print.pl" target="_blank"> >+ [% END %] > <table id="holdst"> > <thead> > <tr> >- [% IF (printenable) %]<th class="hq-check">Check</th>[% END %] >+ [% IF (printenable) %]<th class="hq-check"> </th>[% END %] > <th class="hq-title">Title</th> > <th class="hq-collection">Collection</th> > <th class="hq-itemtype">Item type</th> >@@ -111,7 +118,7 @@ function clearAll () { > <tbody>[% FOREACH itemsloo IN itemsloop %] > <tr> > [% IF ( printenable ) %] >- <td class="hq-print"><input type="checkbox" id="res[% itemsloo.reserve_id %]" name="reserve_id" value="[% itemsloo.reserve_id %]"/></td> >+ <td class="hq-print"><input type="checkbox" id="res[% itemsloo.reserve_id %]" name="reserve_id" value="[% itemsloo.reserve_id %]"/></td> > [% END %] > <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> > <p><strong>[% itemsloo.author %]</strong> >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 0a96143..bec0ec4 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -12,7 +12,7 @@ use C4::Context; > > use Data::Dumper; > >-use Test::More tests => 21; >+use Test::More tests => 28; > > > use C4::Branch; >@@ -281,6 +281,14 @@ $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) > #warn "RESERVES" . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM reserves", { Slice => {} }) ); > #warn "ITEMS: " . Data::Dumper::Dumper( $dbh->selectall_arrayref("SELECT * FROM items WHERE biblionumber = $biblionumber", { Slice => {} }) ); > >+my $reserve_id = $dbh->selectcol_arrayref("SELECT reserve_id FROM reserves"); >+my $print_status = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[0]); >+is( $print_status->[0], "0", "Default print status in reserves for new reserve set as 0"); >+C4::HoldsQueue::MarkHoldPrinted($reserve_id->[0]); >+$print_status = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[0]); >+is( $print_status->[0], "1", "Hold status in reserves correctly marked as printed"); >+C4::HoldsQueue::MarkHoldPrinted($reserve_id->[1]); >+ > my $holds_queue; > > $dbh->do("DELETE FROM default_circ_rules"); >@@ -298,6 +306,22 @@ $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice > ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); > #warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); > >+my $print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[1]); >+is( $print_status_tmp->[0], "1", "Hold status printed moved to tmp_holdsqueue from reserves"); >+$print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[2]); >+is( $print_status_tmp->[0], "0", "Default print status in tmp_holdsqueue moved from reserves"); >+C4::HoldsQueue::MarkHoldPrinted($reserve_id->[2]); >+$print_status_tmp = $dbh->selectcol_arrayref("SELECT print_status FROM reserves WHERE reserve_id = ?", undef, $reserve_id->[2]); >+is( $print_status_tmp->[0], "1", "Hold status in tmp_holdsqueue correctly marked as printed"); >+ >+my $select_itnum = $dbh->selectcol_arrayref("SELECT itemnumber FROM tmp_holdsqueue WHERE reserve_id = ?", undef, $reserve_id->[0]); >+my $get_itnum = C4::HoldsQueue::GetItemNumberFromTmpHold($reserve_id->[0]); >+is( $select_itnum->[0], $get_itnum, "Correct itemnumber selected from tmp_holdsqueue"); >+ >+C4::Context->set_preference('printSlipFromHoldsQueue', 1); >+my $getholds_queue = C4::HoldsQueue::GetHoldsQueueItems(undef, 1); >+is( @$getholds_queue, "3", "Get printed holds from tmp_holdsqueue"); >+ > # Cleanup > $dbh->rollback; > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index fa0cf94..5a41eb3 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 56; >+use Test::More tests => 57; > > use MARC::Record; > use DateTime::Duration; >@@ -473,6 +473,12 @@ $cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{'CP > is($cancancel, 0, 'Reserve in waiting status cant be canceled'); > > # End of tests for bug 12876 >+@results = GetReservesFromItemnumber($itemnumber); >+my $hold_slip = C4::Reserves::HoldSlip({ >+ branch => 'CPL', >+ reserve_id => $results[3], >+ itemnumber => $itemnumber }); >+ok(defined($hold_slip), 'can successfully generate hold slip'); > > #### > ####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11651
:
24948
|
26239
|
26252
|
26262
|
28574
|
32126
|
32127
|
32680
|
32681
|
38079
| 38080