Bug 3268: Adds the ability to edit the description of a holiday.
Adds another radio button to the edit holiday form. This is a partial fix, because you cannot make an edit to a single holiday for multiple branches. Also fixed a small XHTML error and a wording error from my previous patch on holidays.tmpl (bug 3274). Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
4a9050f11f
commit
e3eeda2fb1
131
C4/Calendar.pm
131
C4/Calendar.pm
|
|
@ -37,6 +37,10 @@ BEGIN {
|
|||
&insert_day_month_holiday
|
||||
&insert_single_holiday
|
||||
&insert_exception_holiday
|
||||
&ModWeekdayholiday
|
||||
&ModDaymonthholiday
|
||||
&ModSingleholiday
|
||||
&ModExceptionholiday
|
||||
&delete_holiday
|
||||
&isHoliday
|
||||
&addDate
|
||||
|
|
@ -324,6 +328,133 @@ sub insert_exception_holiday {
|
|||
return $self;
|
||||
}
|
||||
|
||||
=item ModWeekdayholiday
|
||||
|
||||
ModWeekdayholiday(weekday =>$weekday,
|
||||
title => $title,
|
||||
description => $description)
|
||||
|
||||
Modifies the title and description of a weekday for $self->{branchcode}.
|
||||
|
||||
C<$weekday> Is the title to update for the holiday.
|
||||
|
||||
C<$description> Is the description to update for the holiday.
|
||||
|
||||
=cut
|
||||
|
||||
sub ModWeekdayholiday {
|
||||
my $self = shift @_;
|
||||
my %options = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $updateHoliday = $dbh->prepare("UPDATE repeatable_holidays SET title = ?, description = ? WHERE branchcode = ? AND weekday = ?");
|
||||
$updateHoliday->execute( $options{title},$options{description},$self->{branchcode},$options{weekday});
|
||||
$self->{'week_days_holidays'}->{$options{weekday}}{title} = $options{title};
|
||||
$self->{'week_days_holidays'}->{$options{weekday}}{description} = $options{description};
|
||||
return $self;
|
||||
}
|
||||
|
||||
=item ModDaymonthholiday
|
||||
|
||||
ModDaymonthholiday(day => $day,
|
||||
month => $month,
|
||||
title => $title,
|
||||
description => $description);
|
||||
|
||||
Modifies the title and description for a day/month holiday for $self->{branchcode}.
|
||||
|
||||
C<$day> The day of the month for the update.
|
||||
|
||||
C<$month> The month to be used for the update.
|
||||
|
||||
C<$title> The title to be updated for the holiday.
|
||||
|
||||
C<$description> The description to be update for the holiday.
|
||||
|
||||
=cut
|
||||
|
||||
sub ModDaymonthholiday {
|
||||
my $self = shift @_;
|
||||
my %options = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $updateHoliday = $dbh->prepare("UPDATE repeatable_holidays SET title = ?, description = ? WHERE month = ? AND day = ? AND branchcode = ?");
|
||||
$updateHoliday->execute( $options{title},$options{description},$options{month},$options{day},$self->{branchcode});
|
||||
$self->{'day_month_holidays'}->{"$options{month}/$options{day}"}{title} = $options{title};
|
||||
$self->{'day_month_holidays'}->{"$options{month}/$options{day}"}{description} = $options{description};
|
||||
return $self;
|
||||
}
|
||||
|
||||
=item ModSingleholiday
|
||||
|
||||
ModSingleholiday(day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description);
|
||||
|
||||
Modifies the title and description for a single holiday for $self->{branchcode}.
|
||||
|
||||
C<$day> Is the day of the month to make the update.
|
||||
|
||||
C<$month> Is the month to make the update.
|
||||
|
||||
C<$year> Is the year to make the update.
|
||||
|
||||
C<$title> Is the title to update for the holiday formed by $year/$month/$day.
|
||||
|
||||
C<$description> Is the description to update for the holiday formed by $year/$month/$day.
|
||||
|
||||
=cut
|
||||
|
||||
sub ModSingleholiday {
|
||||
my $self = shift @_;
|
||||
my %options = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $isexception = 0;
|
||||
my $updateHoliday = $dbh->prepare("UPDATE special_holidays SET title = ?, description = ? WHERE day = ? AND month = ? AND year = ? AND branchcode = ? AND isexception = ?");
|
||||
$updateHoliday->execute($options{title},$options{description},$options{day},$options{month},$options{year},$self->{branchcode},$isexception);
|
||||
$self->{'single_holidays'}->{"$options{year}/$options{month}/$options{day}"}{title} = $options{title};
|
||||
$self->{'single_holidays'}->{"$options{year}/$options{month}/$options{day}"}{description} = $options{description};
|
||||
return $self;
|
||||
}
|
||||
|
||||
=item ModExceptionholiday
|
||||
|
||||
ModExceptionholiday(day => $day,
|
||||
month => $month,
|
||||
year => $year,
|
||||
title => $title,
|
||||
description => $description);
|
||||
|
||||
Modifies the title and description for an exception holiday for $self->{branchcode}.
|
||||
|
||||
C<$day> Is the day of the month for the holiday.
|
||||
|
||||
C<$month> Is the month for the holiday.
|
||||
|
||||
C<$year> Is the year for the holiday.
|
||||
|
||||
C<$title> Is the title to be modified for the holiday formed by $year/$month/$day.
|
||||
|
||||
C<$description> Is the description to be modified for the holiday formed by $year/$month/$day.
|
||||
|
||||
=cut
|
||||
|
||||
sub ModExceptionholiday {
|
||||
my $self = shift @_;
|
||||
my %options = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $isexception = 1;
|
||||
my $updateHoliday = $dbh->prepare("UPDATE special_holidays SET title = ?, description = ? WHERE day = ? AND month = ? AND year = ? AND branchcode = ? AND isexception = ?");
|
||||
$updateHoliday->execute($options{title},$options{description},$options{day},$options{month},$options{year},$self->{branchcode},$isexception);
|
||||
$self->{'exception_holidays'}->{"$options{year}/$options{month}/$options{day}"}{title} = $options{title};
|
||||
$self->{'exception_holidays'}->{"$options{year}/$options{month}/$options{day}"}{description} = $options{description};
|
||||
return $self;
|
||||
}
|
||||
|
||||
=item delete_holiday
|
||||
|
||||
delete_holiday(weekday => $weekday
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
}
|
||||
|
||||
// This function shows the "Show Holiday" panel //
|
||||
function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, isException) {
|
||||
function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, holidayType) {
|
||||
$("#newHoliday").slideUp("fast");
|
||||
$("#showHoliday").slideDown("fast");
|
||||
document.getElementById('showDayname').value = dayName;
|
||||
|
|
@ -59,11 +59,12 @@
|
|||
document.getElementById('showDescription').value = description;
|
||||
document.getElementsByName('showWeekday')[0].value = weekDay;
|
||||
document.getElementById('showTitle').value = title;
|
||||
document.getElementById('showHolidayType').value = holidayType;
|
||||
|
||||
if (isException == 1) {
|
||||
if (holidayType == 'exception') {
|
||||
document.getElementById('showOperationDelLabel').innerHTML = 'Delete this exception.';
|
||||
} else {
|
||||
document.getElementById('showOperationDelLabel').innerHTML = 'Delete this program.';
|
||||
document.getElementById('showOperationDelLabel').innerHTML = 'Delete this holiday.';
|
||||
}
|
||||
|
||||
if (exceptionPosibility == 1) {
|
||||
|
|
@ -204,6 +205,7 @@ h1 select { width: 20em; }
|
|||
<!-- ********************** Panel for showing already loaded holidays *********************** -->
|
||||
<div class="panel" id="showHoliday">
|
||||
<form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
|
||||
<input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
|
||||
<h2>Edit this holiday</h2>
|
||||
<p>
|
||||
<label for="showBranchName">Library</label>
|
||||
|
|
@ -220,7 +222,7 @@ h1 select { width: 20em; }
|
|||
<label for="showYear">Year</label> <input type="text" size="4" id="showYear" name="showYear" readonly="readonly" />
|
||||
</div>
|
||||
<!-- showTitle is necessary for exception radio button to work properly -->
|
||||
<input type="hidden" id="showTitle" name="showTitle" value="">
|
||||
<input type="hidden" id="showTitle" name="showTitle" value="" />
|
||||
<p><label for="showDescription">Description:</label>
|
||||
<br />
|
||||
<textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
|
||||
|
|
@ -229,8 +231,10 @@ h1 select { width: 20em; }
|
|||
<input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception to this holiday.</label>
|
||||
<a href="#" onclick=" additionalInformation('You can make an exception for this holiday rule. This means that you will be able to say for a repeatable holiday, that there is one of those days that is going to be an exception.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a><br />
|
||||
</div>
|
||||
<input type="radio" name="showOperation" id="showOperationDel" value="delete" checked="checked" /> <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
|
||||
<a href="#" onclick=" additionalInformation('This will delete this holiday rule. If it is a repeatable holiday, this option checks for posible exceptions. If an exception exists, this option will remove the exception and set the date to a regular holiday.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
|
||||
<input type="radio" name="showOperation" id="showOperationDel" value="delete" /> <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
|
||||
<a href="#" onclick=" additionalInformation('This will delete this holiday rule. If it is a repeatable holiday, this option checks for posible exceptions. If an exception exists, this option will remove the exception and set the date to a regular holiday.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a><br />
|
||||
<input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
|
||||
<a href="#" onclick=" additionalInformation('This will save changes to the holiday\'s description. If the description for a repeatable holiday is modified, it affects all of the dates that the holiday is repeated.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
|
||||
<p>
|
||||
<input type="submit" name="submit" value="Save" />
|
||||
<input type="button" name="cancel2" value="Cancel" onclick=" hidePanel('showHoliday');hidePanel('information')" />
|
||||
|
|
@ -342,13 +346,13 @@ h1 select { width: 20em; }
|
|||
var dateString = year + '/' + month + '/' + day;
|
||||
if (calendar.dateClicked) {
|
||||
if (holidays[dateString] != null) {
|
||||
showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 0);
|
||||
showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
|
||||
} else if (exception_holidays[dateString] != null) {
|
||||
showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 1);
|
||||
showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
|
||||
} else if (week_days[weekDay] != null) {
|
||||
showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 0);
|
||||
showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
|
||||
} else if (day_month_holidays[dayMonth] != null) {
|
||||
showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 0);
|
||||
showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
|
||||
} else {
|
||||
newHoliday(dayName, day, month, year, weekDay);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ my $month = $input->param('showMonth');
|
|||
my $year = $input->param('showYear');
|
||||
my $title = $input->param('showTitle');
|
||||
my $description = $input->param('showDescription');
|
||||
my $holidaytype = $input->param('showHolidayType');
|
||||
|
||||
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
|
||||
my $isodate = C4::Dates->new($calendardate, 'iso');
|
||||
|
|
@ -40,6 +41,29 @@ if ($input->param('showOperation') eq 'exception') {
|
|||
year => $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,
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue