Bug 33667: Allow copying holidays to all libraries when editing
When editing an existing holiday and checking the "copy to all libraires" checkbox, the other calendars won't get updates. Allow this by first checking if holiday exists in target calendar and if not, add it. To test: 1. Add unique holiday to branch A. 2. Don't check checkbox "Copy to all libraries". 3. Save. 4. Verify the holidays shows on all calendars as a green box. 5. Edit the holiday, now check "Copy to all libraries" and save. => Verify nothing has changed in other calendars: only the green box, no holiday in list on the right 6. Edit again, make a change to description, check checkbox, save. => Verify it's still not showing in the other calendars. 9. Apply this patch. 10. Edit holiday again, check "Copy to all libraries" and save. => Verify holiday is now added to other calendars. 11. Edit again, this time do not copy and save. => Verify holiday was edited just in branch A. 12. Again edit, check and save. => Verify holiday was edited in all libraries. Sponsored-by: Koha-Suomi Oy Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
7e1104da83
commit
83589f0317
2 changed files with 78 additions and 22 deletions
|
@ -123,7 +123,7 @@
|
|||
<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>
|
||||
<div class="hint">If checked, changes for this holiday will be copied to all libraries. If the holiday doesn't exists for a library, holiday is added to calendar. NOTE! This might overwrite existing holidays in other calendars.</div>
|
||||
</li>
|
||||
</ol>
|
||||
<fieldset class="action">
|
||||
|
|
|
@ -86,27 +86,83 @@ sub edit_holiday {
|
|||
}
|
||||
}
|
||||
} 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 'exception') {
|
||||
$calendar->ModExceptionholiday(day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description);
|
||||
if ( $holidaytype eq 'weekday' ) {
|
||||
my $isHoliday = $calendar->isHoliday( $day, $month, $year );
|
||||
if ($isHoliday) {
|
||||
$calendar->ModWeekdayholiday(
|
||||
weekday => $weekday,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
else {
|
||||
$calendar->insert_week_day_holiday(
|
||||
weekday => $weekday,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
}
|
||||
elsif ( $holidaytype eq 'daymonth' ) {
|
||||
my $isHoliday = $calendar->isHoliday( $day, $month, $year );
|
||||
if ($isHoliday) {
|
||||
$calendar->ModDaymonthholiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
else {
|
||||
$calendar->insert_day_month_holiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
}
|
||||
elsif ( $holidaytype eq 'ymd' ) {
|
||||
my $isHoliday = $calendar->isHoliday( $day, $month, $year );
|
||||
if ($isHoliday) {
|
||||
$calendar->ModSingleholiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
else {
|
||||
$calendar->insert_single_holiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
}
|
||||
elsif ( $holidaytype eq 'exception' ) {
|
||||
my $isHoliday = $calendar->isHoliday( $day, $month, $year );
|
||||
if ($isHoliday) {
|
||||
$calendar->ModExceptionholiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
else {
|
||||
$calendar->insert_exception_holiday(
|
||||
day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description
|
||||
);
|
||||
}
|
||||
}
|
||||
} elsif ($showoperation eq 'delete') {
|
||||
$calendar->delete_holiday(weekday => $weekday,
|
||||
|
|
Loading…
Reference in a new issue