Bugzilla – Attachment 67723 Details for
Bug 17015
New Koha Calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17015 - Koha now uses the new DiscreteCalendar module
Bug-17015---Koha-now-uses-the-new-DiscreteCalendar.patch (text/plain), 13.55 KB, created by
David Bourgault
on 2017-10-06 15:26:38 UTC
(
hide
)
Description:
Bug 17015 - Koha now uses the new DiscreteCalendar module
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-10-06 15:26:38 UTC
Size:
13.55 KB
patch
obsolete
>From 68421cd5df7e290f365ebd6202be82c25e463f51 Mon Sep 17 00:00:00 2001 >From: Mehdi Hamidi <mehdi.hamidi@inlibro.com> >Date: Mon, 16 Jan 2017 10:09:23 -0500 >Subject: [PATCH] Bug 17015 - Koha now uses the new DiscreteCalendar module > >--- > C4/Circulation.pm | 8 ++++---- > C4/HoldsQueue.pm | 8 ++++---- > C4/Overdues.pm | 5 +++-- > C4/Reserves.pm | 4 ++-- > Koha/Hold.pm | 4 ++-- > circ/returns.pl | 5 +++-- > .../intranet-tmpl/prog/en/modules/tools/tools-home.tt | 5 +++++ > misc/cronjobs/fines.pl | 4 ++-- > misc/cronjobs/overdue_notices.pl | 18 +++++++----------- > misc/cronjobs/staticfines.pl | 4 ++-- > misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl | 4 ++-- > 11 files changed, 36 insertions(+), 33 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index eb0f6d5..f4e4cfc 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -43,7 +43,7 @@ use Koha::Account; > use Koha::AuthorisedValues; > use Koha::Biblioitems; > use Koha::DateUtils; >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::Checkouts; > use Koha::IssuingRules; > use Koha::Items; >@@ -1211,7 +1211,7 @@ sub checkHighHolds { > > my $issuedate = DateTime->now( time_zone => C4::Context->tz() ); > >- my $calendar = Koha::Calendar->new( branchcode => $branch ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); > > my $itype = $item_object->effective_itemtype; > my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower ); >@@ -2151,7 +2151,7 @@ sub MarkIssueReturned { > my $query = 'UPDATE issues SET returndate='; > my @bind; > if ($dropbox_branch) { >- my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $dropbox_branch ); > my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 ); > $query .= ' ? '; > push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M'); >@@ -3474,7 +3474,7 @@ sub CalcDateDue { > else { # days > $dur = DateTime::Duration->new( days => $loanlength->{$length_key}); > } >- my $calendar = Koha::Calendar->new( branchcode => $branch ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); > $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); > if ($loanlength->{lengthunit} eq 'days') { > $datedue->set_hour(23); >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index ce525ba..8765308 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -30,7 +30,7 @@ use C4::Members; > use C4::Biblio; > use Koha::DateUtils; > use Koha::Patrons; >- >+use Koha::DiscreteCalendar; > use List::Util qw(shuffle); > use List::MoreUtils qw(any); > use Data::Dumper; >@@ -77,7 +77,7 @@ sub TransportCostMatrix { > }; > > if ( C4::Context->preference("HoldsQueueSkipClosed") ) { >- $calendars->{$from} ||= Koha::Calendar->new( branchcode => $from ); >+ $calendars->{$from} ||= Koha::DiscreteCalendar->new( branchcode => $from ); > $transport_cost_matrix{$to}{$from}{disable_transfer} ||= > $calendars->{$from}->is_holiday( $today ); > } >@@ -206,7 +206,7 @@ sub CreateQueue { > $total_requests += scalar(@$hold_requests); > $total_available_items += scalar(@$available_items); > >- my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix); >+ my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix); > $item_map or next; > my $item_map_size = scalar(keys %$item_map) > or next; >@@ -742,7 +742,7 @@ sub load_branches_to_pull_from { > my $today = dt_from_string(); > if ( C4::Context->preference('HoldsQueueSkipClosed') ) { > @branches_to_use = grep { >- !Koha::Calendar->new( branchcode => $_ ) >+ !Koha::DiscreteCalendar->new( branchcode => $_ ) > ->is_holiday( $today ) > } @branches_to_use; > } >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 65b1296..6d1b8ab 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -34,6 +34,7 @@ use C4::Accounts; > use C4::Log; # logaction > use C4::Debug; > use Koha::DateUtils; >+use Koha::DiscreteCalendar; > use Koha::Account::Line; > use Koha::Account::Lines; > use Koha::IssuingRules; >@@ -298,7 +299,7 @@ sub get_chargeable_units { > my $charge_duration; > if ($unit eq 'hours') { > if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { >- my $calendar = Koha::Calendar->new( branchcode => $branchcode ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); > $charge_duration = $calendar->hours_between( $date_due, $date_returned ); > } else { > $charge_duration = $date_returned->delta_ms( $date_due ); >@@ -310,7 +311,7 @@ sub get_chargeable_units { > } > else { # days > if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { >- my $calendar = Koha::Calendar->new( branchcode => $branchcode ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); > $charge_duration = $calendar->days_between( $date_due, $date_returned ); > } else { > $charge_duration = $date_returned->delta_days( $date_due ); >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index fbf03fb..809daac 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -38,7 +38,7 @@ use C4::Log; > > use Koha::Biblios; > use Koha::DateUtils; >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::Database; > use Koha::Hold; > use Koha::Old::Hold; >@@ -811,7 +811,7 @@ sub CancelExpiredReserves { > ); > > while ( my $hold = $holds->next ) { >- my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode ); > > next if !$cancel_on_holidays && $calendar->is_holiday( $today ); > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index d27bbae..37fa04f 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -25,7 +25,7 @@ use Data::Dumper qw(Dumper); > > use C4::Context qw(preference); > use C4::Log; >- >+use Koha::DiscreteCalendar; > use Koha::DateUtils qw(dt_from_string output_pref); > use Koha::Patrons; > use Koha::Biblios; >@@ -136,7 +136,7 @@ sub set_waiting { > > my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); > my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); >- my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode ); > > my $expirationdate = $today->clone; > $expirationdate->add(days => $max_pickup_delay); >diff --git a/circ/returns.pl b/circ/returns.pl >index c42e750..7312359 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -51,7 +51,8 @@ use C4::Koha; # FIXME : is it still useful ? > use C4::RotatingCollections; > use Koha::AuthorisedValues; > use Koha::DateUtils; >-use Koha::Calendar; >+use Koha::DiscreteCalendar; >+use Koha::Checkouts; > use Koha::BiblioFrameworks; > use Koha::Checkouts; > use Koha::Holds; >@@ -211,7 +212,7 @@ my $dropboxmode = $query->param('dropboxmode'); > my $dotransfer = $query->param('dotransfer'); > my $canceltransfer = $query->param('canceltransfer'); > my $dest = $query->param('dest'); >-my $calendar = Koha::Calendar->new( branchcode => $userenv_branch ); >+my $calendar = Koha::DiscreteCalendar->new( branchcode => $userenv_branch ); > #dropbox: get last open day (today - 1) > my $today = DateTime->now( time_zone => C4::Context->tz()); > my $dropboxdate = $calendar->addDate($today, -1); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >index 4c8cca9..3642d4f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >@@ -79,6 +79,11 @@ > <dd>Define days when the library is closed</dd> > [% END %] > >+ [% IF ( CAN_user_tools_edit_calendar ) %] >+ <dt><a href="/cgi-bin/koha/tools/discrete_calendar.pl">Discrete Calendar</a></dt> >+ <dd>Define days when the library is closed</dd> >+ [% END %] >+ > [% IF ( CAN_user_tools_manage_csv_profiles ) %] > <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt> > <dd>Manage CSV export profiles</dd> >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index 6c3f830..d544537 100755 >--- a/misc/cronjobs/fines.pl >+++ b/misc/cronjobs/fines.pl >@@ -36,7 +36,7 @@ use Getopt::Long; > use Carp; > use File::Spec; > >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::DateUtils; > use C4::Log; > >@@ -176,7 +176,7 @@ EOM > sub set_holiday { > my ( $branch, $dt ) = @_; > >- my $calendar = Koha::Calendar->new( branchcode => $branch ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); > return $calendar->is_holiday($dt); > } > >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index a1b477c..0b52ff1 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -40,7 +40,7 @@ use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_lette > use C4::Log; > use Koha::Patron::Debarments qw(AddUniqueDebarment); > use Koha::DateUtils; >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::Libraries; > use Koha::Acquisition::Currencies; > >@@ -443,9 +443,8 @@ elsif ( defined $text_filename ) { > } > > foreach my $branchcode (@branches) { >- my $calendar; > if ( C4::Context->preference('OverdueNoticeCalendar') ) { >- $calendar = Koha::Calendar->new( branchcode => $branchcode ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); > if ( $calendar->is_holiday($date_to_run) ) { > next; > } >@@ -546,13 +545,11 @@ END_SQL > my $days_between; > if ( C4::Context->preference('OverdueNoticeCalendar') ) > { >- $days_between = >- $calendar->days_between( dt_from_string($data->{date_due}), >- $date_to_run ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); >+ $days_between = $calendar->days_between( dt_from_string($data->{date_due}), $date_to_run ); > } > else { >- $days_between = >- $date_to_run->delta_days( dt_from_string($data->{date_due}) ); >+ $days_between = $date_to_run->delta_days( dt_from_string($data->{date_due}) ); > } > $days_between = $days_between->in_units('days'); > if ($triggered) { >@@ -628,9 +625,8 @@ END_SQL > my $exceededPrintNoticesMaxLines = 0; > while ( my $item_info = $sth2->fetchrow_hashref() ) { > if ( C4::Context->preference('OverdueNoticeCalendar') ) { >- $days_between = >- $calendar->days_between( >- dt_from_string( $item_info->{date_due} ), $date_to_run ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode ); >+ $days_between = $calendar->days_between( dt_from_string( $item_info->{date_due} ), $date_to_run ); > } > else { > $days_between = >diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl >index c57e99e..1535790 100755 >--- a/misc/cronjobs/staticfines.pl >+++ b/misc/cronjobs/staticfines.pl >@@ -40,7 +40,7 @@ use Date::Calc qw/Date_to_Days/; > use C4::Context; > use C4::Circulation; > use C4::Overdues; >-use C4::Calendar qw(); # don't need any exports from Calendar >+use Koha::DiscreteCalendar qw(); # don't need any exports from Calendar > use C4::Biblio; > use C4::Debug; # supplying $debug and $cgi_debug > use C4::Log; >@@ -176,7 +176,7 @@ for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { > > my $calendar; > unless ( defined( $calendars{$branchcode} ) ) { >- $calendars{$branchcode} = C4::Calendar->new( branchcode => $branchcode ); >+ $calendars{$branchcode} = Koha::DiscreteCalendar->new( branchcode => $branchcode ); > } > $calendar = $calendars{$branchcode}; > my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear ); >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index 5826526..91e65a6 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -35,7 +35,7 @@ use C4::Context; > use C4::Items; > use C4::Letters; > use C4::Overdues; >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::DateUtils; > > sub usage { >@@ -294,7 +294,7 @@ sub GetWaitingHolds { > $sth->execute(); > my @results; > while ( my $issue = $sth->fetchrow_hashref() ) { >- my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $issue->{'site'} ); > > my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); > my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); >-- >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 17015
:
53859
|
54318
|
54419
|
59166
|
59167
|
59168
|
59169
|
59170
|
59171
|
59267
|
59268
|
59269
|
59270
|
59271
|
59463
|
59516
|
59517
|
59518
|
59519
|
59520
|
59561
|
59562
|
59586
|
59587
|
59888
|
59889
|
60902
|
60903
|
60904
|
60905
|
60906
|
60986
|
61737
|
62375
|
62376
|
62380
|
63257
|
63282
|
63362
|
63363
|
63364
|
63365
|
63366
|
63367
|
64235
|
65073
|
65074
|
65075
|
65076
|
65077
|
67721
|
67722
|
67723
|
67724
|
67725
|
67879
|
67929
|
67930
|
67931
|
67932
|
67933
|
67934
|
68392
|
68393
|
68394
|
68395
|
68396
|
68397
|
71634
|
71635
|
71636
|
71637
|
71638
|
72890
|
73145
|
74859
|
74860
|
74861
|
74862
|
74863
|
74864
|
74865
|
74866
|
75444
|
75479
|
76594
|
77249
|
77250
|
77607
|
77608
|
77609
|
77610
|
77611
|
77612
|
77613
|
77770
|
77771
|
77772
|
77773
|
77774
|
79035
|
80523
|
80524
|
80525
|
80526
|
80527
|
80528
|
80529
|
80530
|
80531
|
80532
|
80533
|
80534
|
80535
|
83547
|
85394
|
85677
|
85678
|
85679
|
85680
|
85681
|
85682
|
85683
|
85684
|
85685
|
85686
|
85687
|
85688
|
85689
|
85690
|
85691
|
92595
|
92596
|
92597
|
92598
|
100079
|
110383
|
110384
|
110386
|
110387
|
110388
|
110389
|
113541
|
113905
|
115501
|
115502
|
115503
|
115504
|
115505
|
115506
|
115507
|
115508
|
115509
|
115510
|
115511
|
118554
|
118555
|
118556
|
118557
|
118558
|
118559
|
119095
|
119097
|
119099
|
119100
|
119101
|
119102
|
131619
|
131620
|
131621
|
131622
|
131623
|
131624
|
131625
|
131626
|
131634
|
131635
|
131636
|
131637
|
131638
|
131639
|
131640
|
131641
|
131667
|
132199
|
133596
|
133597
|
133598
|
133599
|
133600
|
133601
|
133602
|
133603
|
133604
|
133605
|
133678
|
137219
|
137220
|
137221
|
137222
|
137223
|
137224
|
137225
|
137226
|
137227
|
137228
|
137229
|
139378
|
139379
|
139380
|
139381
|
139382
|
139599
|
139600
|
139601
|
139602
|
139603
|
139851
|
140150
|
141176
|
144257
|
144258
|
144259
|
144260
|
144261
|
144262
|
144264
|
144268
|
144269
|
144270
|
144271
|
144272
|
144273
|
151438
|
151439
|
151440
|
151441
|
151442
|
151443
|
151444
|
151445
|
151446
|
151447
|
151448
|
151449
|
151450
|
156340
|
156341
|
156342
|
156343
|
156344
|
156345
|
156346
|
156347
|
156348
|
156349
|
156350
|
156351
|
156352
|
156353
|
156354
|
156355
|
157656
|
157657
|
157658
|
157659
|
157660
|
157661
|
157662
|
157663
|
157664
|
157665
|
157666
|
157667
|
157668
|
157669
|
157670
|
157671
|
157672
|
167805
|
167806
|
167807
|
167808
|
167809