Bug 8656 Calendar needs to load both exception and nonexception dates
authorColin Campbell <colin.campbell@ptfs-europe.com>
Mon, 20 Aug 2012 14:24:58 +0000 (15:24 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 14 Sep 2012 11:59:34 +0000 (13:59 +0200)
single_holidays and exception_holidays were both being selected
with the same parameter with the result that single holidays were not
being loaded.

Have removed the retrieval of the unused parameters title and
description.

In effect the distinction is not meaningful for these routines and
the two structures could become one. This patch just fixes the
current bug

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Koha/Calendar.pm

index 298cdb2..7608dce 100644 (file)
@@ -48,13 +48,13 @@ sub _init {
         $self->{day_month_closed_days}->{ $tuple->{day} }->{ $tuple->{month} } =
           1;
     }
+
     my $special = $dbh->prepare(
-'SELECT day, month, year, title, description FROM special_holidays WHERE ( branchcode = ? ) AND (isexception = ?)'
+'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = ?'
     );
     $special->execute( $branch, 1 );
     my $dates = [];
-    while ( my ( $day, $month, $year, $title, $description ) =
-        $special->fetchrow ) {
+    while ( my ( $day, $month, $year ) = $special->fetchrow ) {
         push @{$dates},
           DateTime->new(
             day       => $day,
@@ -65,10 +65,10 @@ sub _init {
     }
     $self->{exception_holidays} =
       DateTime::Set->from_datetimes( dates => $dates );
-    $special->execute( $branch, 1 );
+
+    $special->execute( $branch, 0 );
     $dates = [];
-    while ( my ( $day, $month, $year, $title, $description ) =
-        $special->fetchrow ) {
+    while ( my ( $day, $month, $year ) = $special->fetchrow ) {
         push @{$dates},
           DateTime->new(
             day       => $day,
@@ -78,8 +78,8 @@ sub _init {
           )->truncate( to => 'day' );
     }
     $self->{single_holidays} = DateTime::Set->from_datetimes( dates => $dates );
-    $self->{days_mode} = C4::Context->preference('useDaysMode');
-    $self->{test} = 0;
+    $self->{days_mode}       = C4::Context->preference('useDaysMode');
+    $self->{test}            = 0;
     return;
 }