Bugzilla – Attachment 31556 Details for
Bug 12353
Reserves last pickup date needs to respect holidays, and everybody need to know the last pickup date for reserves, even notices.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Initial commitmonster
0001-Bug-12353-Everybody-needs-to-know-the-last-pickup-da.patch (text/plain), 19.25 KB, created by
Olli-Antti Kivilahti
on 2014-09-12 14:24:31 UTC
(
hide
)
Description:
Initial commitmonster
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2014-09-12 14:24:31 UTC
Size:
19.25 KB
patch
obsolete
>From 35b02051fd4014ef84e35fe76412b397ada70c8f Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@pttk.fi> >Date: Wed, 28 May 2014 13:56:38 +0300 >Subject: [PATCH] Bug 12353 - Everybody needs to know the last pickup date for > reserves! > >When calculating the last date before reserve expires, skip all days marked as holidays. > >Add a new <<lastpickupdate>> marker usable in RESERVESLIP and HOLD. > >Display the last pickup date in > member/moremember.pl and > circ/circulation.pl and > circ/waitingreserves.pl > opac/opac-user.pl >--- > C4/Reserves.pm | 49 ++++++++++++++--- > Koha/Calendar.pm | 12 +++++ > Koha/Reserves.pm | 55 ++++++++++++++++++++ > circ/waitingreserves.pl | 19 +++---- > koha-tmpl/intranet-tmpl/prog/en/js/holds.js | 1 + > .../en/modules/admin/preferences/circulation.pref | 2 +- > .../prog/en/modules/circ/circulation.tt | 2 + > .../prog/en/modules/circ/waitingreserves.tt | 4 ++ > .../prog/en/modules/members/moremember.tt | 1 + > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 7 +++ > opac/opac-user.pl | 4 ++ > svc/holds | 8 ++- > 12 files changed, 143 insertions(+), 21 deletions(-) > create mode 100644 Koha/Reserves.pm > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index cf4211e..6483c8f 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -38,6 +38,9 @@ use C4::Branch qw( GetBranchDetail ); > use C4::Dates qw( format_date_in_iso ); > > use Koha::DateUtils; >+use Koha::Calendar; >+ >+use DateTime; > > use List::MoreUtils qw( firstidx ); > >@@ -132,6 +135,8 @@ BEGIN { > &ToggleSuspend > &SuspendAll > >+ &_reserve_last_pickup_date >+ > &GetReservesControlBranch > ); > @EXPORT_OK = qw( MergeHolds ); >@@ -719,7 +724,7 @@ sub GetReservesForBranch { > my $dbh = C4::Context->dbh; > > my $query = " >- SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate >+ SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate,branchcode > FROM reserves > WHERE priority='0' > AND found='W' >@@ -935,12 +940,16 @@ sub CancelExpiredReserves { > $sth = $dbh->prepare( $query ); > $sth->execute( $max_pickup_delay ); > >+ my $today = DateTime->now( time_zone => C4::Context->tz() ); >+ > while (my $res = $sth->fetchrow_hashref ) { >- if ( $charge ) { >- manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); >+ my $expiration = _reserve_last_pickup_date( $res ); >+ if ( $today > $expiration ) { >+ if ( $charge ) { >+ manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); >+ } >+ CancelReserve({ reserve_id => $res->{'reserve_id'} }); > } >- >- CancelReserve({ reserve_id => $res->{'reserve_id'} }); > } > } > >@@ -1815,6 +1824,24 @@ sub _Findgroupreserve { > return @results; > } > >+=head2 _reserve_last_pickup_date >+ >+ my $last_dt = _reserve_last_pickup_date($reserve); >+ >+Returns the DateTime for the last pickup date for reserve. >+ >+=cut >+ >+sub _reserve_last_pickup_date { >+ my ($reserve) = @_; >+ >+ my $startdate = $reserve->{waitingdate} ? dt_from_string($reserve->{waitingdate}) : DateTime->now( time_zone => C4::Context->tz() ); >+ my $calendar = Koha::Calendar->new( branchcode => $reserve->{branchcode} ); >+ my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') ); >+ >+ return $expiration; >+} >+ > =head2 _koha_notify_reserve > > _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber, $reserve_id ); >@@ -1851,6 +1878,8 @@ sub _koha_notify_reserve { > > my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); > >+ my $expiration = _reserve_last_pickup_date($reserve); >+ > my %letter_params = ( > module => 'reserves', > branchcode => $reserve->{branchcode}, >@@ -1861,7 +1890,10 @@ sub _koha_notify_reserve { > 'reserves' => $reserve, > 'items', $reserve->{'itemnumber'}, > }, >- substitute => { today => C4::Dates->new()->output() }, >+ substitute => { >+ 'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() >+ }, >+ > ); > > my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. >@@ -2195,6 +2227,8 @@ sub ReserveSlip { > }) or return; > my $reserve = GetReserveInfo($reserve_id) or return; > >+ my $expiration = _reserve_last_pickup_date($reserve); >+ > return C4::Letters::GetPreparedLetter ( > module => 'circulation', > letter_code => $transfer ? 'TRANSFERSLIP' : 'RESERVESLIP', >@@ -2206,6 +2240,9 @@ sub ReserveSlip { > 'biblio' => $reserve->{biblionumber}, > 'items' => $reserve->{itemnumber}, > }, >+ substitute => { >+ 'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() >+ }, > ); > } > >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 276c7ce..04f655d 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -267,6 +267,18 @@ sub prev_open_day { > return $base_date; > } > >+sub days_forward { >+ my $self = shift; >+ my $start_dt = shift; >+ my $num_days = shift; >+ >+ my $base_dt = $start_dt->clone(); >+ >+ while ($num_days--) { $base_dt = $self->next_open_day($base_dt); } >+ >+ return $base_dt; >+} >+ > sub days_between { > my $self = shift; > my $start_dt = shift; >diff --git a/Koha/Reserves.pm b/Koha/Reserves.pm >new file mode 100644 >index 0000000..6e2c370 >--- /dev/null >+++ b/Koha/Reserves.pm >@@ -0,0 +1,55 @@ >+package Koha::Reserves; >+ >+# Copyright (c) 2014 Vaarakirjastot.fi and everybody else! >+# 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 2 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; >+binmode STDOUT, ":encoding(UTF-8)"; >+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); >+ >+BEGIN { >+ # set the version for version checking >+ $VERSION = 3.16.3; >+ require Exporter; >+ @ISA = qw(Exporter); >+ @EXPORT = qw( >+ >+ &GetLastpickupdate >+ >+ ); >+} >+ >+use C4::Context; >+use Koha::DateUtils; >+ >+=head2 GetLastpickupdate >+ >+ my $last_dt = GetLastpickupdate($reserve); >+ >+@PARAM1 Koha::Schema::Result::Reserve-object received via DBIx searching >+@RETURNS the DateTime for the last pickup date for the given reserve. >+=cut >+ >+sub GetLastpickupdate { >+ my ($reserve) = @_; >+ >+ my $waitingdate = $reserve->waitingdate(); >+ my $startdate = $waitingdate ? Koha::DateUtils::dt_from_string($waitingdate) : DateTime->now( time_zone => C4::Context->tz() ); >+ my $calendar = Koha::Calendar->new( branchcode => $reserve->branchcode() ); >+ my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') ); >+ >+ return $expiration; >+} >\ No newline at end of file >diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl >index fb7a3d1..f4a93f0 100755 >--- a/circ/waitingreserves.pl >+++ b/circ/waitingreserves.pl >@@ -31,11 +31,8 @@ use C4::Members; > use C4::Biblio; > use C4::Items; > >-use Date::Calc qw( >- Today >- Add_Delta_Days >- Date_to_Days >-); >+use DateTime; >+ > use C4::Reserves; > use C4::Koha; > >@@ -86,7 +83,7 @@ my ($reservcount, $overcount); > my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch($default); > # get reserves for the branch we are logged into, or for all branches > >-my $today = Date_to_Days(&Today); >+my $today = DateTime->now(); > foreach my $num (@getreserves) { > next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); > >@@ -106,13 +103,11 @@ foreach my $num (@getreserves) { > my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'}); > my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype > $getreserv{'waitingdate'} = $num->{'waitingdate'}; >- my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'}); >- ( $waiting_year, $waiting_month, $waiting_day ) = >- Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, >- C4::Context->preference('ReservesMaxPickUpDelay')); >- my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day ); >+ >+ my $lastpickupdate = C4::Reserves::_reserve_last_pickup_date( $num ); > > $getreserv{'itemtype'} = $itemtypeinfo->{'description'}; >+ $getreserv{'lastpickupdate'} = C4::Dates->new($lastpickupdate->ymd(), 'iso')->output(); > $getreserv{'title'} = $gettitle->{'title'}; > $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; > $getreserv{'barcode'} = $gettitle->{'barcode'}; >@@ -132,7 +127,7 @@ foreach my $num (@getreserves) { > $getreserv{'borrowermail'} = $getborrower->{'emailaddress'}; > } > >- if ($today > $calcDate) { >+ if ( DateTime->compare( $today,$lastpickupdate ) == 1 ) { #If today is bigger than lastpickupdate, pickup time has expired > if ($cancelall) { > my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); > push @cancel_result, $res if $res; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >index 73807ea..c78e3ae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >@@ -10,6 +10,7 @@ $(document).ready(function() { > { > "mDataProp": "reservedate_formatted" > }, >+ { "mDataProp": "lastpickupdate_formatted" }, > { > "mDataProp": function ( oObj ) { > title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" >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 1ee6363..a205e24 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 >@@ -404,7 +404,7 @@ Circulation: > - Mark a hold as problematic if it has been waiting for more than > - pref: ReservesMaxPickUpDelay > class: integer >- - days. >+ - non-holiday days. > - > - pref: ExpireReservesMaxPickUpDelay > choices: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 597ef0d..37ed6f5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -622,6 +622,7 @@ No patron matched <span class="ex">[% message %]</span> > [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %] > <ul> > <li> <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% WaitingReserveLoo.biblionumber %]">[% WaitingReserveLoo.title |html %]</a> ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] [% IF ( WaitingReserveLoo.itemcallnumber ) %][[% WaitingReserveLoo.itemcallnumber %]] [% END %]Hold placed on [% WaitingReserveLoo.reservedate %]. >+[% IF ( WaitingReserveLoo.lastpickupdate ) %]Last pickup date: [% WaitingReserveLoo.lastpickupdate %][% END %] > [% IF ( WaitingReserveLoo.waitingat ) %] > <br />[% IF ( WaitingReserveLoo.waitinghere ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]Waiting at [% WaitingReserveLoo.waitingat %]</strong> > [% END %] >@@ -771,6 +772,7 @@ No patron matched <span class="ex">[% message %]</span> > <thead> > <tr> > <th>Hold date</th> >+ <th>Last pickup date</th> > <th>Title</th> > <th>Call number</th> > <th>Barcode</th> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt >index 7ba913a..f854de0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt >@@ -78,6 +78,7 @@ > <table id="holdst"> > <thead><tr> > <th class="title-string">Available since</th> >+ <th>Last pickup date</th> > <th class="anti-the">Title</th> > <th>Patron</th> > <th>Location</th> >@@ -88,6 +89,7 @@ > <tbody>[% FOREACH reserveloo IN reserveloop %] > <tr> > <td><span title="[% reserveloo.waitingdate %]">[% reserveloo.waitingdate | $KohaDates %]</span></td> >+ <td>[% reserveloo.lastpickupdate | $KohaDates %]</td> > <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = reserveloo.biblionumber %] > [% reserveloo.title |html %] [% reserveloo.subtitle |html %] > </a> >@@ -138,6 +140,7 @@ > <table id="holdso"> > <thead><tr> > <th class="title-string">Available since</th> >+ <th>Last pickup date</th> > <th class="anti-the">Title</th> > <th>Patron</th> > <th>Location</th> >@@ -148,6 +151,7 @@ > <tbody>[% FOREACH overloo IN overloop %] > <tr> > <td><p><span title="[% overloo.waitingdate %]">[% overloo.waitingdate | $KohaDates %]</span></p></td> >+ <td>[% overloo.lastpickupdate | $KohaDates %]</td> > <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = overloo.biblionumber %][% overloo.title |html %] [% overloo.subtitle |html %] > </a> > [% UNLESS ( item_level_itypes ) %][% IF ( overloo.itemtype ) %] (<b>[% overloo.itemtype %]</b>)[% END %][% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index d6b95f8..6a0cde0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -506,6 +506,7 @@ function validate1(date) { > <thead> > <tr> > <th>Hold date</th> >+ <th>Last pickup date</th> > <th>Title</th> > <th>Call number</th> > <th>Barcode</th> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index ec3de30..485cefb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -493,6 +493,7 @@ > <tr> > <th class="anti-the">Title</th> > <th class="psort">Placed on</th> >+ <th class="psort">Last pickup date</th> > <th>Expires on</th> > <th>Pick up location</th> > [% IF ( showpriority ) %] >@@ -530,6 +531,12 @@ > [% RESERVE.reservedate | $KohaDates %] > </span> > </td> >+ <td class="lastpickupdate"> >+ <span title="[% RESERVE.lastpickupdate %]"> >+ <span class="tdlabel">Last pickup date:</span> >+ [% RESERVE.lastpickupdate | $KohaDates %] >+ </span> >+ </td> > <td class="expirationdate"> > [% IF ( RESERVE.expirationdate ) %] > <span> >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 667ac3d..9bf9d4e 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -321,6 +321,10 @@ foreach my $res (@reserves) { > } > # set found to 1 if reserve is waiting for patron pickup > $res->{'found'} = 1 if $res->{'found'} eq 'W'; >+ >+ my $lastpickupdate = C4::Reserves::_reserve_last_pickup_date( $res ); >+ $res->{'lastpickupdate'} = $lastpickupdate if $lastpickupdate; >+ > } else { > my ($transfertwhen, $transfertfrom, $transfertto) = GetTransfers( $res->{'itemnumber'} ); > if ($transfertwhen) { >diff --git a/svc/holds b/svc/holds >index 3ff704f..7a72385 100755 >--- a/svc/holds >+++ b/svc/holds >@@ -31,6 +31,7 @@ use C4::Context; > > use Koha::Database; > use Koha::DateUtils; >+use Koha::Reserves; > > my $input = new CGI; > >@@ -53,8 +54,8 @@ my $borrowernumber = $input->param('borrowernumber'); > my $offset = $input->param('iDisplayStart'); > my $results_per_page = $input->param('iDisplayLength'); > my $sorting_direction = $input->param('sSortDir_0') || 'desc'; >-my $sorting_column = $sort_columns[ $input->param('iSortCol_0') ] >- || 'reservedate'; >+my $sorting_column = ( $input->param('iSortCol_0') ) ? >+ $sort_columns[ $input->param('iSortCol_0') ] : 'reservedate'; > > binmode STDOUT, ":encoding(UTF-8)"; > print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >@@ -73,6 +74,7 @@ while ( my $h = $holds_rs->next() ) { > my $item = $h->item(); > > my $biblionumber = $h->biblio()->biblionumber(); >+ my $lastpickupdate = Koha::Reserves::GetLastpickupdate( $h ); > > my $hold = { > DT_RowId => $h->reserve_id(), >@@ -93,6 +95,8 @@ while ( my $h = $holds_rs->next() ) { > 'subtitle', GetMarcBiblio($biblionumber), > GetFrameworkCode($biblionumber) > ), >+ lastpickupdate => $lastpickupdate->ymd(), >+ lastpickupdate_formatted => C4::Dates->new($lastpickupdate->ymd(), 'iso')->output(), > reservedate_formatted => $h->reservedate() ? output_pref( > { dt => dt_from_string( $h->reservedate() ), dateonly => 1 } > ) >-- >1.7.9.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12353
:
31556
|
31572
|
31584
|
31585
|
31586