Bugzilla – Attachment 104949 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.80 KB, created by
ByWater Sandboxes
on 2020-05-15 15:06:56 UTC
(
hide
)
Description:
Bug 4985: Edit a calendar entry for all branches
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2020-05-15 15:06:56 UTC
Size:
10.80 KB
patch
obsolete
>From 9c41b87d6d784a58209b2c03cea04a6c89036eb8 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> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> >--- > .../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 1f3b9672fb..680fe17130 100755 >--- a/tools/exceptionHolidays.pl >+++ b/tools/exceptionHolidays.pl >@@ -18,6 +18,7 @@ checkauth($input, 0, {tools=> 'edit_calendar'}, 'intranet'); > > > my $branchcode = $input->param('showBranchName'); >+my $originalbranchcode = $branchcode; > my $weekday = $input->param('showWeekday'); > my $day = $input->param('showDay'); > my $month = $input->param('showMonth'); >@@ -27,8 +28,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) { >@@ -50,77 +51,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