View | Details | Raw Unified | Return to bug 8418
Collapse All | Expand All

(-)a/Koha/Calendar.pm (-24 / +7 lines)
Lines 49-60 sub _init { Link Here
49
          1;
49
          1;
50
    }
50
    }
51
    my $special = $dbh->prepare(
51
    my $special = $dbh->prepare(
52
'SELECT day, month, year, title, description FROM special_holidays WHERE ( branchcode = ? ) AND (isexception = ?)'
52
'SELECT day, month, year, title, description, isexception FROM special_holidays WHERE branchcode = ?'
53
    );
53
    );
54
    $special->execute( $branch, 1 );
54
    $special->execute( $branch );
55
    my $dates = [];
55
    my $dates = [];
56
    while ( my ( $day, $month, $year, $title, $description ) =
56
    while ( my ( $day, $month, $year, $title, $description, $isexception ) =
57
        $special->fetchrow ) {
57
        $special->fetchrow ) {
58
	# FIXME $isexception is not used since users can't enter calendar entries with it
58
        push @{$dates},
59
        push @{$dates},
59
          DateTime->new(
60
          DateTime->new(
60
            day       => $day,
61
            day       => $day,
Lines 63-83 sub _init { Link Here
63
            time_zone => C4::Context->tz()
64
            time_zone => C4::Context->tz()
64
          )->truncate( to => 'day' );
65
          )->truncate( to => 'day' );
65
    }
66
    }
66
    $self->{exception_holidays} =
67
    $self->{special_holidays} =
67
      DateTime::Set->from_datetimes( dates => $dates );
68
      DateTime::Set->from_datetimes( dates => $dates );
68
    $special->execute( $branch, 1 );
69
    $dates = [];
70
    while ( my ( $day, $month, $year, $title, $description ) =
71
        $special->fetchrow ) {
72
        push @{$dates},
73
          DateTime->new(
74
            day       => $day,
75
            month     => $month,
76
            year      => $year,
77
            time_zone => C4::Context->tz()
78
          )->truncate( to => 'day' );
79
    }
80
    $self->{single_holidays} = DateTime::Set->from_datetimes( dates => $dates );
81
    $self->{days_mode} = C4::Context->preference('useDaysMode');
69
    $self->{days_mode} = C4::Context->preference('useDaysMode');
82
    return;
70
    return;
83
}
71
}
Lines 153-162 sub is_holiday { Link Here
153
    if ( exists $self->{day_month_closed_days}->{$day}->{$month} ) {
141
    if ( exists $self->{day_month_closed_days}->{$day}->{$month} ) {
154
        return 1;
142
        return 1;
155
    }
143
    }
156
    if ( $self->{exception_holidays}->contains($dt) ) {
144
    if ( $self->{special_holidays}->contains($dt) ) {
157
        return 1;
158
    }
159
    if ( $self->{single_holidays}->contains($dt) ) {
160
        return 1;
145
        return 1;
161
    }
146
    }
162
147
Lines 210-216 sub _mockinit { Link Here
210
    $self->{weekly_closed_days} = [ 1, 0, 0, 0, 0, 0, 0 ];    # Sunday only
195
    $self->{weekly_closed_days} = [ 1, 0, 0, 0, 0, 0, 0 ];    # Sunday only
211
    $self->{day_month_closed_days} = { 6 => { 16 => 1, } };
196
    $self->{day_month_closed_days} = { 6 => { 16 => 1, } };
212
    my $dates = [];
197
    my $dates = [];
213
    $self->{exception_holidays} =
198
    $self->{special_holidays} =
214
      DateTime::Set->from_datetimes( dates => $dates );
199
      DateTime::Set->from_datetimes( dates => $dates );
215
    my $special = DateTime->new(
200
    my $special = DateTime->new(
216
        year      => 2011,
201
        year      => 2011,
Lines 219-225 sub _mockinit { Link Here
219
        time_zone => 'Europe/London',
204
        time_zone => 'Europe/London',
220
    );
205
    );
221
    push @{$dates}, $special;
206
    push @{$dates}, $special;
222
    $self->{single_holidays} = DateTime::Set->from_datetimes( dates => $dates );
223
    $self->{days_mode} = 'Calendar';
207
    $self->{days_mode} = 'Calendar';
224
    return;
208
    return;
225
}
209
}
226
- 

Return to bug 8418