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> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commitce2219425d) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commit6f85f47365) Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com> (cherry picked from commitdbb2717123) Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
parent
181b4ecb3d
commit
5d8d84bba2
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
month => $month,
|
||||
} elsif ($showoperation eq 'edit') {
|
||||
if($holidaytype eq 'weekday') {
|
||||
$calendar->ModWeekdayholiday(weekday => $weekday,
|
||||
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 '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);
|
||||
}
|
||||
} 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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue