From bf0fd541d3bc1bb8159cbfc399e12f025104595f Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Tue, 13 Jun 2017 12:26:45 +0000 Subject: [PATCH] Bug 18760 - Add item printable checkin alert field Test plan: - Apply this patch(es), - update databases, - launch misc/devel/update_dbix_class_files.pl, - edit an item to have html or text content in chekin_alert (may need a koha to marc mapping for gui edition), - check out this item, - check it in: you should get a modal showing the alert, - check that you can print the alert. --- C4/Circulation.pm | 4 ++ circ/print-alert.pl | 52 ++++++++++++++++++++++ circ/returns.pl | 19 ++++++++ .../bug_18760-add-items-checkin-alert-column.sql | 1 + .../prog/en/modules/circ/printalert.tt | 19 ++++++++ .../intranet-tmpl/prog/en/modules/circ/returns.tt | 44 ++++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100755 circ/print-alert.pl create mode 100644 installer/data/mysql/atomicupdate/bug_18760-add-items-checkin-alert-column.sql create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/printalert.tt diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a439021..ce7a3ab 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2106,6 +2106,10 @@ sub AddReturn { } } + if ( $item->{checkin_alert} ) { + $messages->{checkin_alert} = $item->{checkin_alert}; + } + return ( $doreturn, $messages, $issue, $borrower ); } diff --git a/circ/print-alert.pl b/circ/print-alert.pl new file mode 100755 index 0000000..628f5f3 --- /dev/null +++ b/circ/print-alert.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + + +# Copyright 2008 LibLime +# +# 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, see . + +use strict; +#use warnings; FIXME - Bug 2505 +use C4::Context; +use C4::Output; +use CGI qw ( -utf8 ); +use C4::Auth qw/:DEFAULT get_session/; +use C4::Items qw/GetItem/; + +use vars qw($debug); + +BEGIN { + $debug = $ENV{DEBUG} || 0; +} + +my $input = new CGI; +my $itemnumber = $input->param('itemnumber'); +my $item = GetItem( $itemnumber ); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/printalert.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + debug => $debug, + } +); + +$template->param( alert => $item->{checkin_alert} ) if ($item->{checkin_alert}); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/circ/returns.pl b/circ/returns.pl index d1b95e8..a17e61c 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -190,6 +190,14 @@ my $messages; my $issueinformation; my $itemnumber; my $barcode = $query->param('barcode'); + +if ( $query->param('print_alert') ) { + $template->param( + print_alert => 1, + itemnumber => $query->param('itemnumber') + ); +} + my $exemptfine = $query->param('exemptfine'); if ( $exemptfine && @@ -483,6 +491,15 @@ if ( $messages->{'ResFound'}) { } # else { ; } # error? } +if ( $messages->{checkin_alert} ) { + $template->param( + found => 1, + checkin_alert => 1, + checkin_alert_message => $messages->{checkin_alert}, + itemnumber => $itemnumber + ); +} + # Error Messages my @errmsgloop; foreach my $code ( keys %$messages ) { @@ -550,6 +567,8 @@ foreach my $code ( keys %$messages ) { elsif ( $code eq 'NotForLoanStatusUpdated' ) { $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated}; } + elsif ( $code eq 'checkin_alert' ) { + } else { die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die. # This forces the issue of staying in sync w/ Circulation.pm diff --git a/installer/data/mysql/atomicupdate/bug_18760-add-items-checkin-alert-column.sql b/installer/data/mysql/atomicupdate/bug_18760-add-items-checkin-alert-column.sql new file mode 100644 index 0000000..1ce7a20 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_18760-add-items-checkin-alert-column.sql @@ -0,0 +1 @@ +ALTER TABLE items ADD checkin_alert longtext DEFAULT NULL; \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printalert.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printalert.tt new file mode 100644 index 0000000..2f25e1b --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printalert.tt @@ -0,0 +1,19 @@ +[% USE Koha %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Print alert +[% INCLUDE 'doc-head-close.inc' %] + + + +[% IF ( Koha.Preference('SlipCSS') ) %] + +[% END %] + +[% INCLUDE 'slip-print.inc' #printThenClose %] + + +
+ +[% IF ( alert ) %][% alert %][% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 56bfb6a..c32f260 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -58,6 +58,10 @@ $(document).ready(function () { Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&biblionumber=[% biblionumber %]'); [% END %] + [% IF print_alert %] + Dopop('print-alert.pl?itemnumber=[% itemnumber %]'); + [% END %] + var columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'returns', 'checkedintable', 'json' ) %] var returns_table = KohaTable("#checkedintable", { "bFilter":false, @@ -576,6 +580,46 @@ $(document).ready(function () {
[% END %] + [% IF ( checkin_alert ) %] + + [% END %] [% END %] [% IF ( errmsgloop ) %] -- 2.7.4