Bugzilla – Attachment 73354 Details for
Bug 17983
Add minutes loan to DiscreteCalendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17983 - Enabled the use of minutes loan
Bug-17983---Enabled-the-use-of-minutes-loan.patch (text/plain), 4.32 KB, created by
Charles Farmer
on 2018-03-27 19:56:09 UTC
(
hide
)
Description:
Bug 17983 - Enabled the use of minutes loan
Filename:
MIME Type:
Creator:
Charles Farmer
Created:
2018-03-27 19:56:09 UTC
Size:
4.32 KB
patch
obsolete
>From f545101b43d0c7d512407cfe55f02ccf305ab1e2 Mon Sep 17 00:00:00 2001 >From: mehdi <mehdi@inlibro.com> >Date: Mon, 23 Jan 2017 16:55:48 -0500 >Subject: [PATCH] Bug 17983 - Enabled the use of minutes loan > >--- > C4/Circulation.pm | 21 +++++++++++++++++++-- > C4/Overdues.pm | 12 ++++++++++++ > .../prog/en/modules/admin/smart-rules.tt | 1 + > 3 files changed, 32 insertions(+), 2 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 018fd01..2f8dd7d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3438,12 +3438,14 @@ sub CalcDateDue { > ->truncate( to => 'minute' ); > } > >- >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); > # calculate the datedue as normal > if ( C4::Context->preference('useDaysMode') eq 'Days' ) > { # ignoring calendar > if ( $loanlength->{lengthunit} eq 'hours' ) { > $datedue->add( hours => $loanlength->{$length_key} ); >+ } elsif ( $loanlength->{lengthunit} eq 'minutes' ) { >+ $datedue->add( minutes => $loanlength->{$length_key}); > } else { # days > $datedue->add( days => $loanlength->{$length_key} ); > $datedue->set_hour(23); >@@ -3454,10 +3456,12 @@ sub CalcDateDue { > if ($loanlength->{lengthunit} eq 'hours') { > $dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); > } >+ elsif ($loanlength->{lengthunit} eq 'minutes') { >+ $dur = DateTime::Duration->new( minutes => $loanlength->{$length_key}); >+ } > else { # days > $dur = DateTime::Duration->new( days => $loanlength->{$length_key}); > } >- my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch }); > $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); > if ($loanlength->{lengthunit} eq 'days') { > $datedue->set_hour(23); >@@ -3503,6 +3507,19 @@ sub CalcDateDue { > } > } > } >+ >+ #check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours. >+ if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){ >+ my $dateInfo = $calendar->get_date_info($datedue); >+ my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz()); >+ >+ my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute()); >+ >+ if(DateTime->compare($datedue, $close_datetime) > 0) { >+ $datedue = $close_datetime->clone(); >+ } >+ } >+ > return $datedue; > } > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 3f1436a..c2f3cec 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -304,6 +304,18 @@ sub get_chargeable_units { > } > return $charge_duration->in_units('hours'); > } >+ elsif($unit eq 'minutes'){ >+ if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); >+ $charge_duration = $calendar->open_minutes_between( $date_due, $date_returned ); >+ } else { >+ $charge_duration = $date_returned->delta_ms( $date_due ); >+ } >+ if($charge_duration->in_units('minutes') == 0 && $charge_duration->in_units('seconds') > 0){ >+ return 1; >+ } >+ return $charge_duration->in_units('minutes'); >+ } > else { # days > if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { > my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode }); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index ffa8776..b765805 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -245,6 +245,7 @@ > <select name="lengthunit" id="lengthunit"> > <option value="days" selected="selected">Days</option> > <option value="hours">Hours</option> >+ <option value="minutes">Minutes</option> > </select> > </td> > <td> >-- >2.7.4
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 17983
:
59521
|
59522
|
59523
|
67880
|
67881
|
67882
|
67969
|
68016
|
68017
|
73353
|
73354
|
73355
|
75480
|
131929
|
131930
|
131931
|
131932
|
136414
|
136415
|
139519
|
144267
|
151452
|
167846