From 29e31548ea1c0283f1724546d15cbc4e9475fe07 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 16 Jul 2015 07:55:27 -0400 Subject: [PATCH] Bug 8483 - Add checkout classes --- Koha/Checkout.pm | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ Koha/Checkouts.pm | 58 +++++++++++++++++++++++++++++++++++++ Koha/Old/Checkout.pm | 57 ++++++++++++++++++++++++++++++++++++ Koha/Old/Checkouts.pm | 63 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 254 insertions(+), 0 deletions(-) create mode 100644 Koha/Checkout.pm create mode 100644 Koha/Checkouts.pm create mode 100644 Koha/Old/Checkout.pm create mode 100644 Koha/Old/Checkouts.pm diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm new file mode 100644 index 0000000..f30f6e1 --- /dev/null +++ b/Koha/Checkout.pm @@ -0,0 +1,76 @@ +package Koha::Checkout; + +# Copyright ByWater Solutions 2015 +# +# 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::Items; +use Koha::Deleted::Items; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Checkout - Koha Checkout Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 item + +my $item = $checkout->item({ deleted => 1 }); + +Returns the related Koha::Item for this checkout. + +If the parameter delete is passed and true, and the itemnumber +is not found for current items, this method will look for a matching +deleted item. + +=cut + +sub item { + my ( $self, $params ) = @_; + + my $item = Koha::Items->search( { itemnumber => $self->itemnumber() } )->next(); + + $item ||= Koha::Deleted::Items->search( { itemnumber => $self->itemnumber() } )->next() if ( $params->{deleted} ); + + return $item || undef; +} + +=head3 type + +=cut + +sub type { + return 'Issue'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm new file mode 100644 index 0000000..9b1ddc1 --- /dev/null +++ b/Koha/Checkouts.pm @@ -0,0 +1,58 @@ +package Koha::Checkouts; + +# Copyright ByWater Solutions 2015 +# +# 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::Checkout; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Checkouts - Koha Checkouts Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Issue'; +} + +sub object_class { + return 'Koha::Checkout'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm new file mode 100644 index 0000000..27e8283 --- /dev/null +++ b/Koha/Old/Checkout.pm @@ -0,0 +1,57 @@ +package Koha::Old::Checkout; + +# Copyright ByWater Solutions 2015 +# +# 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::Checkout); + +=head1 NAME + +Koha::Old::Checkout - Koha Old Checkout Object class + +This class is an extension of Koha::Checkout. + +New methods should only be added to Koha::Checkout unless they are specifically +and only for dealing with old checkouts. + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'OldIssue'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm new file mode 100644 index 0000000..85dc15e --- /dev/null +++ b/Koha/Old/Checkouts.pm @@ -0,0 +1,63 @@ +package Koha::Old::Checkouts; + +# Copyright ByWater Solutions 2015 +# +# 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::Old::Checkout; + +use base qw(Koha::Checkouts); + +=head1 NAME + +Koha::Old::Checkouts - Koha Old Checkouts Object class + +This class is an extension of Koha::Checkouts. + +New methods should only be added to Koha::Checkouts unless they are specifically +and only for dealing with old checkouts. + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'OldIssue'; +} + +sub object_class { + return 'Koha::Old::Checkout'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; -- 1.7.2.5