Bug 1440: Show a list of holidays. Fix for the date formats.

This patch fixes the date formats in the holiday display tables.  They are now based on the syspref for date formats.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
Garry Collum 2009-05-15 07:37:50 -04:00 committed by Galen Charlton
parent b7aff5cde0
commit ec73dc92f9
3 changed files with 30 additions and 6 deletions

View File

@ -104,7 +104,9 @@ sub _init {
while (my $row = $repeatable->fetchrow_hashref) {
my $key = $row->{month} . "/" . $row->{day};
$day_month_holidays{$key}{title} = $row->{title};
$day_month_holidays{$key}{description} = $row->{description}
$day_month_holidays{$key}{description} = $row->{description};
$day_month_holidays{$key}{day} = sprintf("%02d", $row->{day});
$day_month_holidays{$key}{month} = sprintf("%02d", $row->{month});
}
$self->{'day_month_holidays'} = \%day_month_holidays;
@ -117,6 +119,8 @@ sub _init {
while (my ($day, $month, $year, $title, $description) = $special->fetchrow) {
$exception_holidays{"$year/$month/$day"}{title} = $title;
$exception_holidays{"$year/$month/$day"}{description} = $description;
$exception_holidays{"$year/$month/$day"}{date} =
sprintf("%04d-%02d-%02d", $year, $month, $day);
}
$self->{'exception_holidays'} = \%exception_holidays;
@ -125,6 +129,8 @@ sub _init {
while (my ($day, $month, $year, $title, $description) = $special->fetchrow) {
$single_holidays{"$year/$month/$day"}{title} = $title;
$single_holidays{"$year/$month/$day"}{description} = $description;
$single_holidays{"$year/$month/$day"}{date} =
sprintf("%04d-%02d-%02d", $year, $month, $day);
}
$self->{'single_holidays'} = \%single_holidays;
return $self;

View File

@ -357,7 +357,7 @@ h1 select { width: 20em; }
<h3>Exceptions</h3>
<table id="holidayexceptions">
<thead><tr>
<th class="exception">Year/Month/Day</th>
<th class="exception">Date</th>
<th class="exception">Title</th>
<th class="exception">Description</th>
</tr>
@ -365,7 +365,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="EXCEPTION_HOLIDAYS_LOOP" -->
<tr>
<td><!-- TMPL_VAR NAME="KEY" --></td>
<td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>
@ -405,7 +405,11 @@ h1 select { width: 20em; }
<table id="holidaysyearlyrepeatable">
<thead>
<tr>
<!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
<th class="repeatableday">Day/Month</th>
<!-- TMPL_ELSE -->
<th class="repeatableday">Month/Day</th>
<!-- /TMPL_IF -->
<th class="repeatableday">Title</th>
<th class="repeatableday">Description</th>
</tr>
@ -413,7 +417,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
<tr>
<td><!-- TMPL_VAR NAME="KEY" --></td>
<td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>
@ -427,7 +431,7 @@ h1 select { width: 20em; }
<table id="holidaysunique">
<thead>
<tr>
<th class="holiday">Year/Month/Day</th>
<th class="holiday">Date</th>
<th class="holiday">Title</th>
<th class="holiday">Description</th>
</tr>
@ -435,7 +439,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="HOLIDAYS_LOOP" -->
<tr>
<td><!-- TMPL_VAR NAME="KEY" --></td>
<td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>

View File

@ -76,8 +76,18 @@ foreach my $weekday (keys %$week_days_holidays) {
my $day_month_holidays = $calendar->get_day_month_holidays();
my @day_month_holidays;
foreach my $monthDay (keys %$day_month_holidays) {
# Determine date format on month and day.
my $day_monthdate;
if (C4::Context->preference("dateformat") eq "metric") {
$day_monthdate = "$day_month_holidays->{$monthDay}{day}/$day_month_holidays->{$monthDay}{month}";
} elsif (C4::Context->preference("dateformat") eq "us") {
$day_monthdate = "$day_month_holidays->{$monthDay}{month}/$day_month_holidays->{$monthDay}{day}";
} else {
$day_monthdate = "$day_month_holidays->{$monthDay}{month}-$day_month_holidays->{$monthDay}{day}";
}
my %day_month;
%day_month = (KEY => $monthDay,
DATE => $day_monthdate,
TITLE => $day_month_holidays->{$monthDay}{title},
DESCRIPTION => $day_month_holidays->{$monthDay}{description});
push @day_month_holidays, \%day_month;
@ -86,8 +96,10 @@ foreach my $monthDay (keys %$day_month_holidays) {
my $exception_holidays = $calendar->get_exception_holidays();
my @exception_holidays;
foreach my $yearMonthDay (keys %$exception_holidays) {
my $exceptiondate = C4::Dates->new($exception_holidays->{$yearMonthDay}{date}, "iso");
my %exception_holiday;
%exception_holiday = (KEY => $yearMonthDay,
DATE => $exceptiondate->output("syspref"),
TITLE => $exception_holidays->{$yearMonthDay}{title},
DESCRIPTION => $exception_holidays->{$yearMonthDay}{description});
push @exception_holidays, \%exception_holiday;
@ -96,8 +108,10 @@ foreach my $yearMonthDay (keys %$exception_holidays) {
my $single_holidays = $calendar->get_single_holidays();
my @holidays;
foreach my $yearMonthDay (keys %$single_holidays) {
my $holidaydate = C4::Dates->new($single_holidays->{$yearMonthDay}{date}, "iso");
my %holiday;
%holiday = (KEY => $yearMonthDay,
DATE => $holidaydate->output("syspref"),
TITLE => $single_holidays->{$yearMonthDay}{title},
DESCRIPTION => $single_holidays->{$yearMonthDay}{description});
push @holidays, \%holiday;