Bugzilla – Attachment 157664 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: Allow holiday edits to be applied to all branches
Bug-17015-Allow-holiday-edits-to-be-applied-to-all.patch (text/plain), 7.51 KB, created by
Maryse Simard
on 2023-10-23 15:17:26 UTC
(
hide
)
Description:
Bug 17015: Allow holiday edits to be applied to all branches
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2023-10-23 15:17:26 UTC
Size:
7.51 KB
patch
obsolete
>From 680912a4d624d4b704204786ea73a32262d22e8e Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >Date: Thu, 20 Oct 2022 16:51:21 -0400 >Subject: [PATCH] Bug 17015: Allow holiday edits to be applied to all branches > >--- > Koha/DiscreteCalendar.pm | 37 ++++++++----------- > .../en/modules/tools/discrete_calendar.tt | 6 +++ > tools/discrete_calendar.pl | 2 + > 3 files changed, 23 insertions(+), 22 deletions(-) > >diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm >index 92b5b704ee..b6d4c3bfcc 100644 >--- a/Koha/DiscreteCalendar.pm >+++ b/Koha/DiscreteCalendar.pm >@@ -565,10 +565,9 @@ sub edit_holiday { > my $close_hour = $params->{close_hour} || ''; > > my $delete_type = $params->{delete_type} || undef; >+ my $all_branches = $params->{all_branches} // 0; > my $today = $params->{today} || dt_from_string()->truncate( to => 'day' ); > >- my $branchcode = $self->{branchcode}; >- > # When override param is set, this function will allow past dates to be set as holidays, > # otherwise it will not. This is meant to only be used for testing. > my $override = $params->{override} || 0; >@@ -591,15 +590,15 @@ sub edit_holiday { > $updateValues{open_hour} = $open_hour if $open_hour ne ''; > $updateValues{close_hour} = $close_hour if $close_hour ne ''; > >+ my $limits = ( $all_branches ) ? {} : { branchcode => $self->{branchcode} }; >+ > if ($holiday_type eq $HOLIDAYS->{WEEKLY}) { > #Update weekly holidays > if ($start_date_string eq $end_date_string) { > $end_date_string = $self->get_max_date(); > } > my $rs = $schema->resultset('DiscreteCalendar')->search( >- { >- branchcode => $branchcode, >- }, >+ $limits, > { > where => \[ 'DAYOFWEEK(date) = ? AND date >= DATE(?) AND date <= DATE(?)', $weekday, $start_date_string, $end_date_string], > } >@@ -617,9 +616,7 @@ sub edit_holiday { > $where->{date}{'>='} = $today unless $override; > > my $rs = $schema->resultset('DiscreteCalendar')->search( >- { >- branchcode => $branchcode, >- }, >+ $limits, > { > where => $where, > } >@@ -640,9 +637,7 @@ sub edit_holiday { > my $where = { -and => [ \["(DATE_FORMAT(date, '\%m-\%d') BETWEEN ? AND ?)", $start_date, $end_date] ] }; > push @{$where->{'-and'}}, { 'date' => { '>=' => $today } } unless $override; > my $rs = $schema->resultset('DiscreteCalendar')->search( >- { >- branchcode => $branchcode, >- }, >+ $limits, > { > where => $where, > } >@@ -660,9 +655,7 @@ sub edit_holiday { > $where->{date}{'>='} = $today unless $override; > > my $rs = $schema->resultset('DiscreteCalendar')->search( >- { >- branchcode => $branchcode, >- }, >+ $limits, > { > where => $where, > } >@@ -679,9 +672,9 @@ sub edit_holiday { > while (my $date = $rs->next()) { > if ($delete_type) { > if ($date->holiday_type() eq $HOLIDAYS->{WEEKLY}) { >- $self->remove_weekly_holidays($weekday, \%updateValues, $today); >+ $self->remove_weekly_holidays($weekday, \%updateValues, $today, $date->branchcode); > } elsif ($date->holiday_type() eq $HOLIDAYS->{REPEATABLE}) { >- $self->remove_repeatable_holidays($start_date, $end_date, \%updateValues, $today); >+ $self->remove_repeatable_holidays($start_date, $end_date, \%updateValues, $today, $date->branchcode); > } > } else { > $date->update(\%updateValues); >@@ -694,18 +687,18 @@ sub edit_holiday { > > =head2 remove_weekly_holidays > >- $calendar->remove_weekly_holidays($weekday, $updateValues, $today); >+ $calendar->remove_weekly_holidays($weekday, $updateValues, $today, $branchcode); > > Removes a weekly holiday and updates the days' parameters > C<$weekday> is the weekday to un-holiday > C<$updatevalues> is hashref containing the new parameters > C<$today> is today's date >+C<$branchcode> is the branchcode of the library > > =cut > > sub remove_weekly_holidays { >- my ($self, $weekday, $updateValues, $today) = @_; >- my $branchcode = $self->{branchcode}; >+ my ($self, $weekday, $updateValues, $today, $branchcode) = @_; > my $schema = Koha::Database->new->schema; > > my $rs = $schema->resultset('DiscreteCalendar')->search( >@@ -726,19 +719,19 @@ sub remove_weekly_holidays { > > =head2 remove_repeatable_holidays > >- $calendar->remove_repeatable_holidays($startDate, $endDate, $today); >+ $calendar->remove_repeatable_holidays($startDate, $endDate, $today, $branchcode); > > Removes a repeatable holiday and updates the days' parameters > C<$startDatey> is the start date of the repeatable holiday > C<$endDate> is the end date of the repeatble holiday > C<$updatevalues> is hashref containing the new parameters > C<$today> is today's date >+C<$branchcode> is the branchcode of the library > > =cut > > sub remove_repeatable_holidays { >- my ($self, $startDate, $endDate, $updateValues, $today) = @_; >- my $branchcode = $self->{branchcode}; >+ my ($self, $startDate, $endDate, $updateValues, $today, $branchcode) = @_; > my $schema = Koha::Database->new->schema; > my $parser = DateTime::Format::Strptime->new( > pattern => '%m-%d', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >index 75acc57204..863d39c0cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >@@ -170,6 +170,12 @@ > <label>To:</label> > <input type="text" id="copyto_to_flatpickr" size="20"/> > </li> >+ <li class="checkbox"> >+ <input type="checkbox" name="all_branches" id="all_branches" /> >+ <label for="all_branches">Copy to all libraries</label>. >+ <a href="#" class="helptext">[?]</a> >+ <div class="hint">If checked, this holiday will be copied to all libraries.</div> >+ </li> > </ol> > > <!-- These yyyy-mm-dd --> >diff --git a/tools/discrete_calendar.pl b/tools/discrete_calendar.pl >index b85e470ef3..f7c041520f 100755 >--- a/tools/discrete_calendar.pl >+++ b/tools/discrete_calendar.pl >@@ -95,6 +95,7 @@ if ($action eq 'copyBranch') { > my $startDate = $input->param('from_date'); > my $endDate = $input->param('to_date'); > my $deleteType = $input->param('deleteType') || 0; >+ my $all_branches = $input->param('all_branches') || 0; > #Get today from javascript for a precise local time > my $local_today = $input->param('local_today'); > $local_today = eval { dt_from_string( $local_today, 'iso') }; >@@ -118,6 +119,7 @@ if ($action eq 'copyBranch') { > start_date => $startDate, > end_date => $endDate, > delete_type => $deleteType, >+ all_branches => $all_branches, > today => $local_today > }); > } else { >-- >2.34.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 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