Bugzilla – Attachment 98565 Details for
Bug 4985
Copy a change on the calendar to all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4985: Edit a calendar entry for all branches
Bug-4985-Edit-a-calendar-entry-for-all-branches.patch (text/plain), 10.65 KB, created by
ByWater Sandboxes
on 2020-02-07 14:01:04 UTC
(
hide
)
Description:
Bug 4985: Edit a calendar entry for all branches
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2020-02-07 14:01:04 UTC
Size:
10.65 KB
patch
obsolete
>From faf31f1c1f5c742ace0feb1e2393b33c2edadbcd Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Fri, 7 Feb 2020 12:43:54 +0200 >Subject: [PATCH] Bug 4985: Edit a calendar entry for all branches > >This patch adds functionality to calendar tool to >make edits or deletes to all branches at once. > >To test: >-Apply patch >-Add holiday for a library and copy it to all or some >libraries >-Edit previosly made holiday (edit, delete etc.) and >check out "Copy changes to all libraries." checkbox >=> Changes are made to all libraries sharing changed >holiday > >Sponsored by: Koha-Suomi Oy > >Signed-off-by: Christofer <christofer.zorn@ajaxlibrary.ca> >--- > .../prog/en/modules/tools/holidays.tt | 6 + > tools/exceptionHolidays.pl | 147 ++++++++++++--------- > 2 files changed, 88 insertions(+), 65 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >index f7771c0953..7900be3f35 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >@@ -111,6 +111,12 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl > <li class="radio"><input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label> > <a href="#" class="helptext">[?]</a> > <div class="hint">This will save changes to the holiday's title and description. If the information for a repeatable holiday is modified, it affects all of the dates on which the holiday is repeated.</div></li> >+ <li class="checkbox"> >+ <input type="checkbox" name="allBranches" id="allBranches" /> >+ <label for="allBranches">Copy changes to all libraries</label>. >+ <a href="#" class="helptext">[?]</a> >+ <div class="hint">If checked, changes for this holiday will be copied to all libraries. If the holiday doesn't exists for a library, no change is made.</div> >+ </li> > </ol> > <fieldset class="action"> > <input type="submit" name="submit" value="Save" /> >diff --git a/tools/exceptionHolidays.pl b/tools/exceptionHolidays.pl >index 90b17bc6cf..2c1d24f18b 100755 >--- a/tools/exceptionHolidays.pl >+++ b/tools/exceptionHolidays.pl >@@ -15,6 +15,7 @@ my $input = new CGI; > my $dbh = C4::Context->dbh(); > > my $branchcode = $input->param('showBranchName'); >+my $originalbranchcode = $branchcode; > my $weekday = $input->param('showWeekday'); > my $day = $input->param('showDay'); > my $month = $input->param('showMonth'); >@@ -24,8 +25,8 @@ my $description = $input->param('showDescription'); > my $holidaytype = $input->param('showHolidayType'); > my $datecancelrange_dt = eval { dt_from_string( scalar $input->param('datecancelrange') ) }; > my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); >- >-my $calendar = C4::Calendar->new(branchcode => $branchcode); >+my $showoperation = $input->param('showOperation'); >+my $allbranches = $input->param('allBranches'); > > $title || ($title = ''); > if ($description) { >@@ -47,77 +48,93 @@ if ($datecancelrange_dt){ > push @holiday_list, $dt->clone(); > } > } >-if ($input->param('showOperation') eq 'exception') { >- $calendar->insert_exception_holiday(day => $day, >- month => $month, >- year => $year, >- title => $title, >- description => $description); >-} elsif ($input->param('showOperation') eq 'exceptionrange' ) { >- if (@holiday_list){ >- foreach my $date (@holiday_list){ >- $calendar->insert_exception_holiday( >- day => $date->{local_c}->{day}, >- month => $date->{local_c}->{month}, >- year => $date->{local_c}->{year}, >- title => $title, >- description => $description >- ); >+ >+if($allbranches) { >+ my $libraries = Koha::Libraries->search; >+ while ( my $library = $libraries->next ) { >+ edit_holiday($showoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype); >+ } >+} else { >+ edit_holiday($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype); >+} >+ >+print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate"); >+ >+sub edit_holiday { >+ ($showoperation, $branchcode, $weekday, $day, $month, $year, $title, $description, $holidaytype) = @_; >+ my $calendar = C4::Calendar->new(branchcode => $branchcode); >+ >+ if ($showoperation eq 'exception') { >+ $calendar->insert_exception_holiday(day => $day, >+ month => $month, >+ year => $year, >+ title => $title, >+ description => $description); >+ } elsif ($showoperation eq 'exceptionrange' ) { >+ if (@holiday_list){ >+ foreach my $date (@holiday_list){ >+ $calendar->insert_exception_holiday( >+ day => $date->{local_c}->{day}, >+ month => $date->{local_c}->{month}, >+ year => $date->{local_c}->{year}, >+ title => $title, >+ description => $description >+ ); >+ } > } >- } >-} elsif ($input->param('showOperation') eq 'edit') { >- if($holidaytype eq 'weekday') { >- $calendar->ModWeekdayholiday(weekday => $weekday, >- title => $title, >- description => $description); >- } elsif ($holidaytype eq 'daymonth') { >- $calendar->ModDaymonthholiday(day => $day, >+ } elsif ($showoperation eq 'edit') { >+ if($holidaytype eq 'weekday') { >+ $calendar->ModWeekdayholiday(weekday => $weekday, >+ title => $title, >+ description => $description); >+ } elsif ($holidaytype eq 'daymonth') { >+ $calendar->ModDaymonthholiday(day => $day, >+ month => $month, >+ title => $title, >+ description => $description); >+ } elsif ($holidaytype eq 'ymd') { >+ $calendar->ModSingleholiday(day => $day, > month => $month, >+ year => $year, > title => $title, > description => $description); >- } elsif ($holidaytype eq 'ymd') { >- $calendar->ModSingleholiday(day => $day, >- month => $month, >- year => $year, >- title => $title, >- description => $description); >- } elsif ($holidaytype eq 'exception') { >- $calendar->ModExceptionholiday(day => $day, >- month => $month, >- year => $year, >- title => $title, >- description => $description); >- } >-} elsif ($input->param('showOperation') eq 'delete') { >- $calendar->delete_holiday(weekday => $weekday, >- day => $day, >- month => $month, >- year => $year); >-}elsif ($input->param('showOperation') eq 'deleterange') { >- if (@holiday_list){ >- foreach my $date (@holiday_list){ >- $calendar->delete_holiday_range(weekday => $weekday, >+ } elsif ($holidaytype eq 'exception') { >+ $calendar->ModExceptionholiday(day => $day, >+ month => $month, >+ year => $year, >+ title => $title, >+ description => $description); >+ } >+ } elsif ($showoperation eq 'delete') { >+ $calendar->delete_holiday(weekday => $weekday, >+ day => $day, >+ month => $month, >+ year => $year); >+ }elsif ($showoperation eq 'deleterange') { >+ if (@holiday_list){ >+ foreach my $date (@holiday_list){ >+ $calendar->delete_holiday_range(weekday => $weekday, >+ day => $date->{local_c}->{day}, >+ month => $date->{local_c}->{month}, >+ year => $date->{local_c}->{year}); >+ } >+ } >+ }elsif ($showoperation eq 'deleterangerepeat') { >+ if (@holiday_list){ >+ foreach my $date (@holiday_list){ >+ $calendar->delete_holiday_range_repeatable(weekday => $weekday, >+ day => $date->{local_c}->{day}, >+ month => $date->{local_c}->{month}); >+ } >+ } >+ }elsif ($showoperation eq 'deleterangerepeatexcept') { >+ if (@holiday_list){ >+ foreach my $date (@holiday_list){ >+ $calendar->delete_exception_holiday_range(weekday => $weekday, > day => $date->{local_c}->{day}, > month => $date->{local_c}->{month}, > year => $date->{local_c}->{year}); > } >- } >-}elsif ($input->param('showOperation') eq 'deleterangerepeat') { >- if (@holiday_list){ >- foreach my $date (@holiday_list){ >- $calendar->delete_holiday_range_repeatable(weekday => $weekday, >- day => $date->{local_c}->{day}, >- month => $date->{local_c}->{month}); >- } >- } >-}elsif ($input->param('showOperation') eq 'deleterangerepeatexcept') { >- if (@holiday_list){ >- foreach my $date (@holiday_list){ >- $calendar->delete_exception_holiday_range(weekday => $weekday, >- day => $date->{local_c}->{day}, >- month => $date->{local_c}->{month}, >- year => $date->{local_c}->{year}); > } > } > } >-print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate"); >-- >2.11.0
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 4985
:
98556
|
98565
|
98620
|
100880
|
100994
|
104664
|
104949
|
104950
|
106129
|
106130