Bugzilla – Attachment 31583 Details for
Bug 12917
Centralize reserves "last pickup date" calculation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Introduces last pickup date calculation functions.
0002-Bug-12353-Introducing-last-pickup-date-calculation-f.patch (text/plain), 4.22 KB, created by
Olli-Antti Kivilahti
on 2014-09-14 10:35:01 UTC
(
hide
)
Description:
Introduces last pickup date calculation functions.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2014-09-14 10:35:01 UTC
Size:
4.22 KB
patch
obsolete
>From f2b9e3b0bf0986ece301a22cf6b9d2acfa571dec Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Sun, 14 Sep 2014 12:05:42 +0300 >Subject: [PATCH 2/6] Bug 12353 - Introducing last pickup date calculation > functions. > >--- > C4/Reserves.pm | 23 +++++++++++++++ > Koha/Calendar.pm | 12 ++++++++ > Koha/Reserves.pm | 30 +++++++++++++++++++- > .../en/modules/admin/preferences/circulation.pref | 2 +- > 4 files changed, 65 insertions(+), 2 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index cf4211e..08f452a 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 ); >@@ -1815,6 +1820,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 ); >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 >index fb4adbc..6580a55 100644 >--- a/Koha/Reserves.pm >+++ b/Koha/Reserves.pm >@@ -27,7 +27,8 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > >- >+ &GetLastpickupdate >+ &GetWaitingReserves > ); > } > >@@ -35,3 +36,30 @@ use C4::Context; > use Koha::DateUtils; > use Koha::Database; > >+=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 $branchcode = $reserve->branchcode(); >+ if (ref $branchcode eq 'Koha::Schema::Result::Branch') { >+ $branchcode = $branchcode->branchcode(); >+ } >+ >+ 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 => $branchcode ); >+ my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') ); >+ >+ return $expiration; >+} >+ >+ >+ >+return 1; >\ No newline at end of file >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: >-- >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 12917
:
31582
| 31583