Bugzilla – Attachment 67881 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.48 KB, created by
David Bourgault
on 2017-10-10 15:20:49 UTC
(
hide
)
Description:
Bug 17983 - Enabled the use of minutes loan
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-10-10 15:20:49 UTC
Size:
4.48 KB
patch
obsolete
>From 4d797e3d5b51e6a74fe53288a2e9365f695ad99e 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 | 22 ++++++++++++++++++---- > C4/Overdues.pm | 14 ++++++++++++-- > .../prog/en/modules/admin/smart-rules.tt | 1 + > 3 files changed, 31 insertions(+), 6 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f4e4cfc..922dd5b 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3455,12 +3455,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); >@@ -3470,11 +3472,11 @@ sub CalcDateDue { > my $dur; > if ($loanlength->{lengthunit} eq 'hours') { > $dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); >- } >- else { # days >+ }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); >@@ -3521,6 +3523,18 @@ 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 6d1b8ab..fbe2823 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -308,8 +308,18 @@ sub get_chargeable_units { > return 1; > } > return $charge_duration->in_units('hours'); >- } >- else { # days >+ }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 ); > $charge_duration = $calendar->days_between( $date_due, $date_returned ); >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 5bc44ba..0cbee5d 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 >@@ -334,6 +334,7 @@ $(document).ready(function() { > <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