From 6eb9359b5ff9b3ad0c502d664b8000c12a70a15d Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Sun, 19 Nov 2017 22:04:32 +0000 Subject: [PATCH] Bug 19532: Recalls awaiting pickup report this patch adds reports for all recalls awaiting pickup, and recalls that have been waiting more than X days. a syspref, RecallsMaxPickUpDelay, is added to give a general max shelf time for recalls Signed-off-by: Nick Clemens --- circ/recalls_waiting.pl | 71 +++++++++ ...g_19532_-_add_RecallsMaxPickUpDelay_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 5 + .../prog/en/modules/circ/recalls_waiting.tt | 163 +++++++++++++++++++++ 5 files changed, 241 insertions(+) create mode 100755 circ/recalls_waiting.pl create mode 100644 installer/data/mysql/atomicupdate/bug_19532_-_add_RecallsMaxPickUpDelay_syspref.sql create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt diff --git a/circ/recalls_waiting.pl b/circ/recalls_waiting.pl new file mode 100755 index 0000000000..1eafdd899c --- /dev/null +++ b/circ/recalls_waiting.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +# Copyright 2017 Aleisha Amohia +# +# 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 Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::Recalls; +use Koha::BiblioFrameworks; +use Koha::DateUtils; +use Koha::Patrons; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "circ/recalls_waiting.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; + +if ($op eq 'expire_recall') { + my $recall_id = $query->param('recall_id'); + Koha::Recalls->find($recall_id)->update({ expirationdate => dt_from_string(), status => 'E' }); + $op = 'list'; +} + +if ($op eq 'list') { + my @recalls = Koha::Recalls->search({ status => 'W' }); + my $borrower = Koha::Patrons->find($loggedinuser); + my @over; + my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7; + my $today = dt_from_string(); + foreach my $r (@recalls){ + my $lastwaitingday = dt_from_string($r->waitingdate)->add( days => $maxdelay ); + if ( $today > $lastwaitingday ){ + push @over, $r; + } + } + $template->param( + recalls => \@recalls, + over => \@over, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_19532_-_add_RecallsMaxPickUpDelay_syspref.sql b/installer/data/mysql/atomicupdate/bug_19532_-_add_RecallsMaxPickUpDelay_syspref.sql new file mode 100644 index 0000000000..0cd21dd77d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_19532_-_add_RecallsMaxPickUpDelay_syspref.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('RecallsMaxPickUpDelay','7','','Define the maximum time a recall can be waiting for pickup','Integer'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 4a8d3e80c3..247b0f2a52 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -451,6 +451,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'), ('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'), ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), +('RecallsMaxPickUpDelay','7','','Define the maximum time a recall can be waiting for pickup','Integer'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), ('RenewalLog','0','','If ON, log information about renewals','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index b609344364..52d582ed26 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -160,6 +160,11 @@ Circulation: Checkout Policy: - + - Mark a recall as problematic if it has been waiting to be picked up for + - pref: RecallsMaxPickUpDelay + - class: integer + - days. + - - pref: AllowTooManyOverride choices: yes: Allow diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt new file mode 100644 index 0000000000..effb4316a8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt @@ -0,0 +1,163 @@ +[% USE Koha %] +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Recalls awaiting pickup +[% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'datatables.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +[% IF Koha.Preference('CircSidebar') %]
[% ELSE %]
[% END %] + +
+
+ [% IF Koha.Preference('CircSidebar') %]
[% END %] +
+ +

Recalls awaiting pickup

+ + [% IF recalls.size > 0 %] + +
+ + + +
+ [% IF ( recalls.size > 0 ) %] + + + + + + + + + + [% FOREACH recall IN recalls %] + + + + + + [% END %] + +
Available sinceTitleRequested byPickup locationExpire
[% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title %] + [% FOREACH s IN recall.biblio.subtitles %] + [% s %] + [% END %] + [% recall.item.enumchron %] + + [% recall.biblio.author %] +
Barcode: [% recall.item.barcode %] +
+ [% recall.borrower.firstname %] [% recall.borrower.surname %] + [% IF ( recall.borrower.phone ) %]
[% recall.borrower.phone %][% END %] + [% IF ( recall.borrower.email ) %]
[% recall.borrower.email %][% END %] +
[% recall.branch.branchname %] +
+ + +
+ +
+
+
+ [% ELSE %] +
No recalls waiting.
+ [% END %] +
+ +
+ [% IF ( over.size > 0 ) %] + [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]

Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.

[% END %] + + + + + + + + + + [% FOREACH recall IN over %] + + + + + + [% END %] + +
Available sinceTitleRequested byPickup locationExpire
[% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title %] + [% FOREACH s IN recall.biblio.subtitles %] + [% s %] + [% END %] + [% recall.item.enumchron %] + + [% recall.biblio.author %] +
Barcode: [% recall.item.barcode %] +
+ [% recall.borrower.firstname %] [% recall.borrower.surname %] + [% IF ( recall.borrower.phone ) %]
[% recall.borrower.phone %][% END %] + [% IF ( recall.borrower.email ) %]
[% recall.borrower.email %][% END %] +
[% recall.branch.branchname %] +
+ + +
+ +
+
+
+ [% ELSE %] +
No recalls waiting.
+ [% END %] +
+ +
+ + [% END %] + +
+
+ +
+ + [% IF Koha.Preference('CircSidebar') %] +
+ [% INCLUDE 'circ-nav.inc' %] +
+ [% END %] +
+ +[% INCLUDE 'intranet-bottom.inc' %] -- 2.11.0