From 0af1dd3cd563df70c16877bd39bdf1db586c0b02 Mon Sep 17 00:00:00 2001
From: Kyle M Hall
Date: Wed, 2 Dec 2015 16:35:13 +0000
Subject: [PATCH] Bug 15283 - Switch default ISSUEQSLIP notice to Template
Toolkit
Test Plan:
1) Apply this patch
2) Replace your ISSUESLIP with the following:
[% 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 | $KohaDates %]
[% END %]
[% END %]
3) Print a quick slip for a patron, note the data is complete
---
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
diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm
index 9c467d7..0957c2d 100644
--- a/Koha/Biblio.pm
+++ b/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
diff --git a/Koha/Borrower.pm b/Koha/Borrower.pm
index 93426bf..2e4d24e 100644
--- a/Koha/Borrower.pm
+++ b/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
diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm
new file mode 100644
index 0000000..0ac3275
--- /dev/null
+++ b/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;
diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm
new file mode 100644
index 0000000..b58718e
--- /dev/null
+++ b/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;
diff --git a/Koha/Item.pm b/Koha/Item.pm
index 2dcccfb..47f7d07 100644
--- a/Koha/Item.pm
+++ b/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
diff --git a/installer/data/mysql/de-DE/mandatory/sample_notices.sql b/installer/data/mysql/de-DE/mandatory/sample_notices.sql
index 1305997..560545b 100644
--- a/installer/data/mysql/de-DE/mandatory/sample_notices.sql
+++ b/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: <>
diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql
index 26bef7f..e886ad8 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/es-ES/mandatory/sample_notices.sql b/installer/data/mysql/es-ES/mandatory/sample_notices.sql
index 59f4101..c732077 100644
--- a/installer/data/mysql/es-ES/mandatory/sample_notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
index f241572..3d16f07 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
+++ b/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é à <>
diff --git a/installer/data/mysql/it-IT/necessari/notices.sql b/installer/data/mysql/it-IT/necessari/notices.sql
index 9b3b7fd..fea8270 100644
--- a/installer/data/mysql/it-IT/necessari/notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql
index 30b2a85..7a54bdd 100644
--- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
index 839f2f6..fdf0fb2 100644
--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
index 0f75599..d42e2c9 100644
--- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
+++ b/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 <>
diff --git a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
index d8c2227..0ebd2ec 100644
--- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
+++ b/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 <>
--
1.7.10.4