Bugzilla – Attachment 39740 Details for
Bug 13851
Replace waiting holds logic in circulation.pl with Koha Objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects
Bug-13851---Replace-waiting-holds-logic-in-circula.patch (text/plain), 19.43 KB, created by
Kyle M Hall (khall)
on 2015-06-01 13:11:44 UTC
(
hide
)
Description:
Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-06-01 13:11:44 UTC
Size:
19.43 KB
patch
obsolete
>From 02ae6035ffb5bc29e8b83f01d80618ad93a7524f Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 30 Sep 2014 15:07:50 -0400 >Subject: [PATCH] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects > >This is the original patch for bug 12892 and replaces the older style of >fetching the holds data with Koha Objects. It will be used as a >foundation for future features. > >Test Plan: >1) Apply this patch >2) Create a hold, set to waiting >3) Browse to circulation.pl for that patron >4) Note you see the list of waiting holds >5) Switch your logged in branch to a different branch >6) Note the "Waiting at" line is no longer emphasized. >--- > Koha/Biblio.pm | 52 +++++++++++ > Koha/Biblios.pm | 62 +++++++++++++ > Koha/Branch.pm | 52 +++++++++++ > Koha/Branches.pm | 62 +++++++++++++ > Koha/Hold.pm | 96 ++++++++++++++++++++ > Koha/Holds.pm | 74 +++++++++++++++ > Koha/Item.pm | 64 +++++++++++++ > Koha/Items.pm | 62 +++++++++++++ > circ/circulation.pl | 36 ++------ > .../prog/en/modules/circ/circulation.tt | 37 +++++--- > t/db_dependent/Reserves.t | 7 ++- > 11 files changed, 560 insertions(+), 44 deletions(-) > create mode 100644 Koha/Biblio.pm > create mode 100644 Koha/Biblios.pm > create mode 100644 Koha/Branch.pm > create mode 100644 Koha/Branches.pm > create mode 100644 Koha/Hold.pm > create mode 100644 Koha/Holds.pm > create mode 100644 Koha/Item.pm > create mode 100644 Koha/Items.pm > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >new file mode 100644 >index 0000000..9c467d7 >--- /dev/null >+++ b/Koha/Biblio.pm >@@ -0,0 +1,52 @@ >+package Koha::Biblio; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Biblio - Koha Biblio Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Biblio'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Biblios.pm b/Koha/Biblios.pm >new file mode 100644 >index 0000000..cba48ea >--- /dev/null >+++ b/Koha/Biblios.pm >@@ -0,0 +1,62 @@ >+package Koha::Biblios; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Biblio; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Biblios - Koha Biblio object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Biblio'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Biblio'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Branch.pm b/Koha/Branch.pm >new file mode 100644 >index 0000000..cd36c74 >--- /dev/null >+++ b/Koha/Branch.pm >@@ -0,0 +1,52 @@ >+package Koha::Branch; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Branch - Koha Branch object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Branch'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Branches.pm b/Koha/Branches.pm >new file mode 100644 >index 0000000..d6f3f80 >--- /dev/null >+++ b/Koha/Branches.pm >@@ -0,0 +1,62 @@ >+package Koha::Branches; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Branch; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Branches - Koha Reserve object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Branch'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Branch'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >new file mode 100644 >index 0000000..5bb1fc7 >--- /dev/null >+++ b/Koha/Hold.pm >@@ -0,0 +1,96 @@ >+package Koha::Hold; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Branches; >+use Koha::Biblios; >+use Koha::Items; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Hold - Koha Hold object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 biblio >+ >+Returns the related Koha::Biblio object for this hold >+ >+=cut >+ >+sub biblio { >+ my ($self) = @_; >+ >+ $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); >+ >+ return $self->{_biblio}; >+} >+ >+=head3 item >+ >+Returns the related Koha::Item object for this Hold >+ >+=cut >+ >+sub item { >+ my ($self) = @_; >+ >+ $self->{_item} ||= Koha::Items->find( $self->itemnumber() ); >+ >+ return $self->{_item}; >+} >+ >+=head3 branch >+ >+Returns the related Koha::Branch object for this Hold >+ >+=cut >+ >+sub branch { >+ my ($self) = @_; >+ >+ $self->{_branch} ||= Koha::Branches->find( $self->branchcode() ); >+ >+ return $self->{_branch}; >+} >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Reserve'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >new file mode 100644 >index 0000000..41ab3f6 >--- /dev/null >+++ b/Koha/Holds.pm >@@ -0,0 +1,74 @@ >+package Koha::Holds; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Hold; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Holds - Koha Hold object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 waiting >+ >+Returns a set of holds that are waiting from an existing set >+ >+=cut >+ >+sub waiting { >+ my ( $self ) = @_; >+ >+ return $self->search( { found => 'W' } ); >+} >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Reserve'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Hold'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Item.pm b/Koha/Item.pm >new file mode 100644 >index 0000000..4dcefd2 >--- /dev/null >+++ b/Koha/Item.pm >@@ -0,0 +1,64 @@ >+package Koha::Item; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Item - Koha Item object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 effective_itemtype >+ >+Returns the itemtype for the item based on whether item level itemtypes are set or not. >+ >+=cut >+ >+sub effective_itemtype { >+ my ( $self ) = @_; >+ >+ return $self->_result()->effective_itemtype(); >+} >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Item'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Items.pm b/Koha/Items.pm >new file mode 100644 >index 0000000..072113f >--- /dev/null >+++ b/Koha/Items.pm >@@ -0,0 +1,62 @@ >+package Koha::Items; >+ >+# Copyright ByWater Solutions 2014 >+# >+# 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 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. >+# >+# 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. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Item; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Items - Koha Item object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'Item'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Item'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/circ/circulation.pl b/circ/circulation.pl >index ab6db3b..dccde18 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -40,6 +40,7 @@ use C4::Biblio; > use C4::Search; > use MARC::Record; > use C4::Reserves; >+use Koha::Holds; > use C4::Context; > use CGI::Session; > use C4::Members::Attributes qw(GetBorrowerAttributes); >@@ -392,36 +393,13 @@ if ($borrowernumber) { > # BUILD HTML > # show all reserves of this borrower, and the position of the reservation .... > if ($borrowernumber) { >+ my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); > $template->param( >- holds_count => Koha::Database->new()->schema()->resultset('Reserve') >- ->count( { borrowernumber => $borrowernumber } ) ); >- my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber); >- >- my @WaitingReserveLoop; >- foreach my $num_res (@borrowerreserv) { >- if ( $num_res->{'found'} && $num_res->{'found'} eq 'W' ) { >- my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} ); >- my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} ); >- my %getWaitingReserveInfo; >- $getWaitingReserveInfo{title} = $getiteminfo->{'title'}; >- $getWaitingReserveInfo{biblionumber} = >- $getiteminfo->{'biblionumber'}; >- $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'}; >- $getWaitingReserveInfo{author} = $getiteminfo->{'author'}; >- $getWaitingReserveInfo{itemcallnumber} = >- $getiteminfo->{'itemcallnumber'}; >- $getWaitingReserveInfo{reservedate} = >- format_date( $num_res->{'reservedate'} ); >- $getWaitingReserveInfo{waitingat} = >- GetBranchName( $num_res->{'branchcode'} ); >- $getWaitingReserveInfo{waitinghere} = 1 >- if $num_res->{'branchcode'} eq $branch; >- push( @WaitingReserveLoop, \%getWaitingReserveInfo ); >- } >- } >- $template->param( WaitingReserveLoop => \@WaitingReserveLoop ); >- $template->param( adultborrower => 1 ) >- if ( $borrower->{'category_type'} eq 'A' ); >+ holds_count => $holds->count(), >+ WaitingHolds => scalar $holds->waiting(), >+ ); >+ >+ $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' ); > } > > #title >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 35447b7..3a255a2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -2,6 +2,7 @@ > [% USE Branches %] > [% USE KohaDates %] > [% USE ColumnsSettings %] >+[% USE ItemTypes %] > [% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %] > [% SET exports_enabled = 1 %] > [% END %] >@@ -753,20 +754,28 @@ No patron matched <span class="ex">[% message %]</span> > </ul> > </div> > >- [% IF ( WaitingReserveLoop ) %] >- <div id="holdswaiting" class="circmessage"> >- <h4>Holds waiting:</h4> >- [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %] >- <ul> >- <li> <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% WaitingReserveLoo.biblionumber %]">[% WaitingReserveLoo.title |html %]</a> ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] [% IF ( WaitingReserveLoo.itemcallnumber ) %][[% WaitingReserveLoo.itemcallnumber %]] [% END %]Hold placed on [% WaitingReserveLoo.reservedate %]. >- [% IF ( WaitingReserveLoo.waitingat ) %] >- <br />[% IF ( WaitingReserveLoo.waitinghere ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]Waiting at [% WaitingReserveLoo.waitingat %]</strong> >- [% END %] >- </li> >- </ul> >- [% END %] >- </div> >- <!-- /If WaitingReserveLoop -->[% END %] >+ [% IF ( WaitingHolds ) %] >+ <div id="holdswaiting" class="circmessage"> >+ <h4>Holds waiting:</h4> >+ [% FOREACH w IN WaitingHolds %] >+ <ul> >+ <li> >+ <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% w.biblio.biblionumber %]">[% w.biblio.title | html %]</a> >+ ([% ItemTypes.GetDescription( w.item.effective_itemtype ) %]), >+ [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %] >+ [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber %]] [% END %] >+ Hold placed on [% w.reservedate | $KohaDates %]. >+ >+ <br/> >+ [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode() ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %] >+ Waiting at [% w.branch.branchname | html %] >+ </strong> >+ </li> >+ </ul> >+ [% END %] >+ </div> >+ [% END %] >+ > [% IF ( notes ) %] > <div id="circnotes" class="circmessage"> > <h4>Notes:</h4> >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index fa0cf94..340b7bf 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 => 58; > > use MARC::Record; > use DateTime::Duration; >@@ -27,6 +27,7 @@ use C4::Biblio; > use C4::Items; > use C4::Members; > use C4::Circulation; >+use Koha::Holds; > use t::lib::Mocks; > > use Koha::DateUtils; >@@ -241,6 +242,10 @@ is($reserves[0]{priority}, 0, 'Item is correctly waiting'); > is($reserves[1]{priority}, 1, 'Item is correctly priority 1'); > is($reserves[2]{priority}, 2, 'Item is correctly priority 2'); > >+@reserves = Koha::Holds->search({ borrowernumber => $requesters{'RPL'} })->waiting(); >+is( @reserves, 1, 'GetWaiting got only the waiting reserve' ); >+is( $reserves[0]->borrowernumber(), $requesters{'RPL'}, 'GetWaiting got the reserve for the correct borrower' ); >+ > > $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); > AddReserve('RPL', $requesters{'RPL'}, $bibnum2, >-- >1.7.2.5
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 13851
:
36947
|
37303
|
38175
|
39740
|
40028
|
40039
|
40247
|
40256
|
40257
|
40258
|
40668
|
40669
|
40670