Bugzilla – Attachment 59521 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 - Added minutes loan to Koha/DiscreteCalendar
Bug-17983---Added-minutes-loan-to-KohaDiscreteCale.patch (text/plain), 3.77 KB, created by
Mehdi Hamidi
on 2017-01-24 17:21:13 UTC
(
hide
)
Description:
Bug 17983 - Added minutes loan to Koha/DiscreteCalendar
Filename:
MIME Type:
Creator:
Mehdi Hamidi
Created:
2017-01-24 17:21:13 UTC
Size:
3.77 KB
patch
obsolete
>From 290e7c6a01a3a6bca4183a2cc972557894870fae Mon Sep 17 00:00:00 2001 >From: mehdi <mehdi@inlibro.com> >Date: Mon, 23 Jan 2017 16:54:48 -0500 >Subject: [PATCH] Bug 17983 - Added minutes loan to Koha/DiscreteCalendar > >--- > Koha/DiscreteCalendar.pm | 81 ++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 79 insertions(+), 2 deletions(-) > >diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm >index b347343..effef1d 100644 >--- a/Koha/DiscreteCalendar.pm >+++ b/Koha/DiscreteCalendar.pm >@@ -875,6 +875,65 @@ sub open_hours_between { > > return ($working_hours_between->next()->get_column('hours_between') - $not_used_hours->next()->get_column('not_used_hours')); > } >+ >+sub open_minutes_between { >+ my ($self, $start_date, $end_date) = @_; >+ my $branchcode = $self->{branchcode}; >+ my $schema = Koha::Database->new->schema; >+ my $dtf = $schema->storage->datetime_parser; >+ $start_date = $dtf->format_datetime($start_date); >+ $end_date = $dtf->format_datetime($end_date); >+ >+ my $working_minutes_between = $schema->resultset('DiscreteCalendar')->search( >+ { >+ branchcode => $branchcode, >+ isopened => 1, >+ }, >+ { >+ select => \['sum(time_to_sec(timediff(closehour, openhour)) / 60)'], >+ as => [qw /minutes_between/], >+ where => \['date BETWEEN DATE(?) AND DATE(?)', $start_date, $end_date] >+ } >+ ); >+ >+ my $loan_day = $schema->resultset('DiscreteCalendar')->search( >+ { >+ branchcode => $branchcode, >+ }, >+ { >+ where => \['date = DATE(?)', $start_date], >+ } >+ ); >+ >+ my $return_day = $schema->resultset('DiscreteCalendar')->search( >+ { >+ branchcode => $branchcode, >+ }, >+ { >+ where => \['date = DATE(?)', $end_date], >+ } >+ ); >+ >+ #Capture the time portion of the date >+ $start_date =~ /\s(.*)/; >+ my $loan_date_time = $1; >+ $end_date =~ /\s(.*)/; >+ my $return_date_time = $1; >+ >+ my $not_used_minutes = $schema->resultset('DiscreteCalendar')->search( >+ { >+ branchcode => $branchcode, >+ isopened => 1, >+ }, >+ { >+ select => \[ '(time_to_sec(timediff(?, ?)) + time_to_sec(timediff(?, ?)) ) / 60', $return_day->next()->closehour(), $return_date_time, $loan_date_time, $loan_day->next()->openhour()], >+ as => [qw /not_used_minutes/], >+ } >+ ); >+ >+ return DateTime::Duration->new( minutes => $working_minutes_between->next()->get_column('minutes_between') - $not_used_minutes->next()->get_column('not_used_minutes')); >+} >+ > sub addDate { > my ( $self, $startdate, $add_duration, $unit ) = @_; > >@@ -889,9 +948,10 @@ sub addDate { > if ( $unit eq 'hours' ) { > # Fixed for legacy support. Should be set as a branch parameter > my $return_by_hour = 10; >- > $dt = $self->addHours($startdate, $add_duration, $return_by_hour); >- } else { >+ } elsif($unit eq 'minutes'){ >+ $dt = $self->addMinutes($startdate, $add_duration); >+ }else { > # days > $dt = $self->addDays($startdate, $add_duration); > } >@@ -899,6 +959,23 @@ sub addDate { > return $dt; > } > >+sub addMinutes { >+ my ( $self, $startdate, $minutes_duration) = @_; >+ my $base_date = $startdate->clone(); >+ >+ $base_date->add_duration($minutes_duration); >+ >+ my $dateInfo = $self->get_date_info($base_date); >+ >+ my $close_datetime = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso'); >+ >+ if(DateTime->compare($base_date, $close_datetime) > 0) { >+ return $close_datetime; >+ } >+ >+ return $base_date; >+} >+ > sub addHours { > my ( $self, $startdate, $hours_duration, $return_by_hour ) = @_; > my $base_date = $startdate->clone(); >-- >1.9.1
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