@@ -, +, @@ --- Koha/Biblio.pm | 52 +++++++++++ Koha/Biblios.pm | 62 +++++++++++++ Koha/Branch.pm | 52 +++++++++++ Koha/Branches.pm | 62 +++++++++++++ Koha/Hold.pm | 96 ++++++++++++++++++++ Koha/Holds.pm | 77 ++++++++++++++++ Koha/Item.pm | 64 +++++++++++++ Koha/Items.pm | 62 +++++++++++++ circ/circulation.pl | 7 +- .../prog/en/modules/circ/circulation.tt | 36 +++++--- t/db_dependent/Reserves.t | 7 ++- 11 files changed, 560 insertions(+), 17 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 --- a/Koha/Biblio.pm +++ a/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 + +=cut + +1; --- a/Koha/Biblios.pm +++ a/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::Reserve - Koha Reserve Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 Type + +=cut + +sub Type { + return 'Biblio'; +} + +=head3 ObjectClass + +=cut + +sub ObjectClass { + return 'Koha::Biblio'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Branch.pm +++ a/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 Item Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub Type { + return 'Branch'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Branches.pm +++ a/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::Reserve - Koha Reserve Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 Type + +=cut + +sub Type { + return 'Branch'; +} + +=head3 ObjectClass + +=cut + +sub ObjectClass { + return 'Koha::Branch'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Hold.pm +++ a/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::Branch - Koha Item 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->new()->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->new()->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->new()->Find( $self->branchcode() ); + + return $self->{Branch}; +} + +=head3 type + +=cut + +sub Type { + return 'Reserve'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Holds.pm +++ a/Koha/Holds.pm @@ -0,0 +1,77 @@ +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::Reserve - Koha Reserve Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 Waiting + +=cut + +sub Waiting { + my ( $self, $params ) = @_; + + carp("No borrowernumber passed in to Koha::Reserves::Waiting!") + unless $params->{borrowernumber}; + + $params->{found} = 'W'; + + return $self->Search($params); +} + +=head3 Type + +=cut + +sub Type { + return 'Reserve'; +} + +=head3 ObjectClass + +=cut + +sub ObjectClass { + return 'Koha::Hold'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Item.pm +++ a/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 EffectiveItemtype + +Returns the itemtype for the item based on whether item level itemtypes are set or not. + +=cut + +sub EffectiveItemtype { + my ( $self ) = @_; + + return $self->{result}->effective_itemtype(); +} + +=head3 type + +=cut + +sub Type { + return 'Item'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Items.pm +++ a/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::Reserve - Koha Reserve Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 Type + +=cut + +sub Type { + return 'Item'; +} + +=head3 ObjectClass + +=cut + +sub ObjectClass { + return 'Koha::Item'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -37,6 +37,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); @@ -362,9 +363,11 @@ if ($borrowernumber) { # BUILD HTML # show all reserves of this borrower, and the position of the reservation .... if ($borrowernumber) { + my $holds = Koha::Holds->new(); $template->param( - holds_count => Koha::Database->new()->schema()->resultset('Reserve') - ->count( { borrowernumber => $borrowernumber } ) ); + holds_count => $holds->Count( { borrowernumber => $borrowernumber } ), + WaitingHolds => scalar $holds->Waiting( { borrowernumber => $borrowernumber } ), + ); $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -596,20 +596,28 @@ No patron matched [% message %] - [% IF ( WaitingReserveLoop ) %] -
-

Holds waiting:

- [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %] -
    -
  • [% WaitingReserveLoo.title |html %] ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] [% IF ( WaitingReserveLoo.itemcallnumber ) %][[% WaitingReserveLoo.itemcallnumber %]] [% END %]Hold placed on [% WaitingReserveLoo.reservedate %]. - [% IF ( WaitingReserveLoo.waitingat ) %] -
    [% IF ( WaitingReserveLoo.waitinghere ) %][% ELSE %][% END %]Waiting at [% WaitingReserveLoo.waitingat %] - [% END %] -
  • -
- [% END %] -
- [% END %] + [% IF ( WaitingHolds ) %] +
+

Holds waiting:

+ [% FOREACH w IN WaitingHolds %] +
    +
  • + [% w.Biblio.title | html %] + ([% w.Item.EffectiveItemtype %]), + [% IF ( w.Biblio.author ) %] by [% w.Biblio.author | html %] [% END %] + [% IF ( w.Item.itemcallnumber ) %] [[% w.Item.itemcallnumber %]] [% END %] + Hold placed on [% w.reservedate | $KohaDates %]. + +
    + [% IF ( w.Branch.branchcode == Branches.GetLoggedInBranchcode() ) %][% ELSE %][% END %] + Waiting at [% w.Branch.branchname | html %] + +
  • +
+ [% END %] +
+ [% END %] + [% IF ( notes ) %]

Notes:

--- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 35; +use Test::More tests => 37; use MARC::Record; use DateTime::Duration; @@ -12,6 +12,7 @@ use C4::Biblio; use C4::Items; use C4::Members; use C4::Circulation; +use Koha::Holds; use t::lib::Mocks; use Koha::DateUtils; @@ -225,6 +226,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->new()->Waiting({ borrowernumber => $requesters{'RPL'} }); +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, --