@@ -, +, @@ Toolkit [% IF checkout.is_from_today %]

[% checkout.item.biblio.title %]
Barcode: [% checkout.item.barcode %]
Date due: [% checkout.date_due | $KohaDates %]

[% END %] --- Koha/Biblio.pm | 11 ++ Koha/Borrower.pm | 13 +++ Koha/Checkout.pm | 119 ++++++++++++++++++++ Koha/Checkouts.pm | 62 ++++++++++ Koha/Item.pm | 15 ++- .../data/mysql/de-DE/mandatory/sample_notices.sql | 33 +++--- .../data/mysql/en/mandatory/sample_notices.sql | 26 +++-- .../data/mysql/es-ES/mandatory/sample_notices.sql | 26 +++-- .../mysql/fr-FR/1-Obligatoire/sample_notices.sql | 32 +++--- installer/data/mysql/it-IT/necessari/notices.sql | 32 +++--- .../mysql/nb-NO/1-Obligatorisk/sample_notices.sql | 32 +++--- .../data/mysql/pl-PL/mandatory/sample_notices.sql | 26 +++-- .../data/mysql/ru-RU/mandatory/sample_notices.sql | 26 +++-- .../data/mysql/uk-UA/mandatory/sample_notices.sql | 26 +++-- 14 files changed, 364 insertions(+), 115 deletions(-) create mode 100644 Koha/Checkout.pm create mode 100644 Koha/Checkouts.pm --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Biblioitems; use base qw(Koha::Object); @@ -35,6 +36,16 @@ Koha::Biblio - Koha Biblio Object class =cut +=head3 biblioitem + +=cut + +sub biblioitem { + my ( $self ) = @_; + + return Koha::Biblioitems->search( { biblionumber => $self->id } )->next(); +} + =head3 type =cut --- a/Koha/Borrower.pm +++ a/Koha/Borrower.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Checkouts; use base qw(Koha::Object); @@ -35,6 +36,18 @@ Koha::Borrower - Koha Borrower Object class =cut +=head3 checkouts + +=cut + +sub checkouts { + my ( $self, $params, $attributes ) = @_; + + $params->{borrowernumber} = $self->id; + + return Koha::Checkouts->search( $params, $attributes ); +} + =head3 type =cut --- a/Koha/Checkout.pm +++ a/Koha/Checkout.pm @@ -0,0 +1,119 @@ +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 C4::Overdues qw( GetFine ); +use Koha::DateUtils qw( dt_from_string output_pref ); + +use Koha::Items; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Issue - Koha Checkout object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 is_overdue + +=cut + +sub is_overdue { + my ($self) = @_; + + unless ( defined $self->{_is_overdue} ) { + my $today = dt_from_string(); + my $date_due = dt_from_string( $self->date_due ); + + $self->{_is_overdue} = DateTime->compare( $date_due, $today ) == -1; + } + + return $self->{_is_overdue}; +} + +=cut + +=head3 fine + +Returns the amount in fines owed for this checkout, if any + +=cut + +sub fine { + my ($self) = @_; + + return GetFine( $self->itemnumber, $self->borrowernumber ); +} + +=head3 is_from_today + +Returns true if this checkout was either created today, or the item was renewed today + +=cut + +sub is_from_today { + my ($self) = @_; + + unless ( defined $self->{_is_from_today} ) { + my $today = output_pref( { dt => dt_from_string, dateformat => 'iso', dateonly => 1 } ); + + $self->{_is_from_today} = ( + substr( $self->issuedate, 0, 10 ) eq $today + || substr( $self->lastreneweddate, 0, 10 ) eq $today + ); + } + + return $self->{_is_from_today}; +} + +=head3 item + +=cut + +sub item { + my ( $self ) = @_; + + $self->{_item} ||= Koha::Items->find( $self->itemnumber ); + + return $self->{_item}; +} + +=head3 type + +=cut + +sub type { + return 'Issue'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Checkouts.pm +++ a/Koha/Checkouts.pm @@ -0,0 +1,62 @@ +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::Issues - Koha Checkout object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Issue'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Checkout'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -56,7 +56,7 @@ sub effective_itemtype { sub home_branch { my ($self) = @_; - $self->{_home_branch} ||= Koha::Branches->find( $self->homebranch() ); + $self->{_home_branch} ||= Koha::Branches->find( $self->homebranch ); return $self->{_home_branch}; } @@ -68,11 +68,22 @@ sub home_branch { sub holding_branch { my ($self) = @_; - $self->{_holding_branch} ||= Koha::Branches->find( $self->holdingbranch() ); + $self->{_holding_branch} ||= Koha::Branches->find( $self->holdingbranch ); return $self->{_holding_branch}; } +=head3 biblio + +=cut + +sub biblio { + my ($self) = @_; + + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber ); + + return $self->{_biblio}; +} =head3 type --- a/installer/data/mysql/de-DE/mandatory/sample_notices.sql +++ a/installer/data/mysql/de-DE/mandatory/sample_notices.sql @@ -55,22 +55,23 @@ Fällig am: <>

', 1), -('circulation','ISSUEQSLIP','Kurzquittung','Kurzquittung', '

Ausleihquittung

-Bibliothek: <>
-Ausleihe an: <> <>
-Ausweisnummer: <>
-
-<>
-
-

Heutige Ausleihen

- -

-<>
-Barcode: <>
-Signatur: <>
-Fällig am: <>
-

-
', 1), +('circulation','ISSUEQSLIP','Kurzquittung','Kurzquittung', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
+ +[% today | $KohaDates %]
+ +

Checked Out Today

+[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %]', 1), ('circulation','RESERVESLIP','Vormerkquittung','Vormerkquittung', '

Vormerkung

Abholbereit seit: <>


--- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ a/installer/data/mysql/en/mandatory/sample_notices.sql @@ -63,20 +63,24 @@ Date due: <>

', 1), -('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '

<>

-Checked out to <> <> <> <>
-(<>)
+('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
-<>
+[% today | $KohaDates %]

Checked Out Today

- -

-<>
-Barcode: <>
-Date due: <>
-

-
', 1), +[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '
Date: <>

Transfer to/Hold in <>

--- a/installer/data/mysql/es-ES/mandatory/sample_notices.sql +++ a/installer/data/mysql/es-ES/mandatory/sample_notices.sql @@ -55,20 +55,24 @@ Date due: <>

', 1), -('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '

<>

-Checked out to <> <> <> <>
-(<>)
+('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
-<>
+[% today | $KohaDates %]

Checked Out Today

- -

-<>
-Barcode: <>
-Date due: <>
-

-
', 1), +[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '
Date: <>

Transfer to/Hold in <>

--- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql +++ a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql @@ -57,20 +57,24 @@ Retour le : <>

', 1), -('circulation','ISSUEQSLIP','Ticket rapide','Ticket rapide', '

<>

-Prêts à <> <> <> <>
-(<>)
- -<>
- -

Emprunts du jour

- -

-<>
-Code à barres : <>
-Retour le : <>
-

-
', 1), +('circulation','ISSUEQSLIP','Ticket rapide','Ticket rapide', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
+ +[% today | $KohaDates %]
+ +

Checked Out Today

+[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Ticket de réservation','Ticket de réservation', '
Date : <>

Transfert vers/Réservé à <>

--- a/installer/data/mysql/it-IT/necessari/notices.sql +++ a/installer/data/mysql/it-IT/necessari/notices.sql @@ -57,20 +57,24 @@ Data di scadenza: <>

', 1), -('circulation','ISSUEQSLIP','Ricevuta (sintetica)','Ricevuta (sintetica)', '

<>

-Prestato/i a <> <> <> <>
-(<>)
- -<>
- -

Prestati oggi

- -

-<>
-Codice a barre: <>
-Data di scadenza: <>
-

-
', 1), +('circulation','ISSUEQSLIP','Ricevuta (sintetica)','Ricevuta (sintetica)', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
+ +[% today | $KohaDates %]
+ +

Checked Out Today

+[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Ricevuta (prenotazione)', '
Data: <>

Trasferita a/Prenotata in <>

--- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql +++ a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql @@ -78,20 +78,24 @@ Innleveringsfrist: <>

', 1), -('circulation','ISSUEQSLIP','Utlån (enkel)','Utlån (enkel)', '

<>

-Utlånt til <> <> <> <>
-(<>)
- -<>
- -

Utlånt i dag

- -

-<>
-Strekkode: <>
-Innleveringsfrist: <>
-

-
', 1), +('circulation','ISSUEQSLIP','Utlån (enkel)','Utlån (enkel)', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
+ +[% today | $KohaDates %]
+ +

Checked Out Today

+[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reservasjon','Reservasjon', '
Dato: <>

Overfør til/Reservasjon hos <>

--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql +++ a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql @@ -56,20 +56,24 @@ Date due: <>

', 1), -('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '

<>

-Checked out to <> <> <> <>
-(<>)
+('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
-<>
+[% today | $KohaDates %]

Checked Out Today

- -

-<>
-Barcode: <>
-Date due: <>
-

-
', 1), +[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '
Date: <>

Transfer to/Hold in <>

--- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql +++ a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql @@ -56,20 +56,24 @@ estamp>>


', 1), -('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '

<>

-Checked out to <> <> <> <>
-(<>)
+('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
-<>
+[% today | $KohaDates %]

Checked Out Today

- -

-<>
-Barcode: <>
-Date due: <>
-

-
', 1), +[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '
Date: <>

Transfer to/Hold in <>

--- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql +++ a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql @@ -55,20 +55,24 @@ estamp>>


', 1), -('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '

<>

-Checked out to <> <> <> <>
-(<>)
+('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '[%- USE KohaDates -%] +

[% branch.branchname %]

+Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %]
+([% borrower.cardnumber %])
-<>
+[% today | $KohaDates %]

Checked Out Today

- -

-<>
-Barcode: <>
-Date due: <>
-

-
', 1), +[% FOREACH checkout IN borrower.checkouts %] + [% IF checkout.is_from_today %] +

+ [% checkout.item.biblio.title %]
+ Barcode: [% checkout.item.barcode %]
+ Date due: [% checkout.date_due %]
+

+ [% END %] +[% END %] +', 1), ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '
Date: <>

Transfer to/Hold in <>

--