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

(-)a/C4/Calendar.pm (+1 lines)
Lines 733-735 __END__ Link Here
733
Koha Physics Library UNLP <matias_veleda@hotmail.com>
733
Koha Physics Library UNLP <matias_veleda@hotmail.com>
734
734
735
=cut
735
=cut
736
(-)a/Koha/Calendar.pm (-3 / +2 lines)
Lines 71-77 sub _holidays { Link Here
71
71
72
        # Add holidays for each branch
72
        # Add holidays for each branch
73
        my $holidays_sth = $dbh->prepare(
73
        my $holidays_sth = $dbh->prepare(
74
'SELECT day, month, year, isexception FROM special_holidays WHERE branchcode = ?'
74
'SELECT day, month, year, MAX(isexception) FROM special_holidays WHERE branchcode = ? GROUP BY day, month, year'
75
        );
75
        );
76
        $holidays_sth->execute($self->{branchcode});
76
        $holidays_sth->execute($self->{branchcode});
77
77
Lines 83-93 sub _holidays { Link Here
83
              . sprintf( "%02d", $month )
83
              . sprintf( "%02d", $month )
84
              . sprintf( "%02d", $day );
84
              . sprintf( "%02d", $day );
85
85
86
            $holidays->{$datestring} = !$exception;
86
            $holidays->{$datestring} = $exception ? 0 : 1;
87
        }
87
        }
88
        $cache->set_in_cache( $key, $holidays, { expiry => 76800 } );
88
        $cache->set_in_cache( $key, $holidays, { expiry => 76800 } );
89
    }
89
    }
90
91
    return $holidays // {};
90
    return $holidays // {};
92
}
91
}
93
92
(-)a/t/Calendar.t (-2 / +10 lines)
Lines 31-37 use Module::Load::Conditional qw/check_install/; Link Here
31
31
32
BEGIN {
32
BEGIN {
33
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
33
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
34
        plan tests => 39;
34
        plan tests => 40;
35
    } else {
35
    } else {
36
        plan skip_all => "Need Test::DBIx::Class"
36
        plan skip_all => "Need Test::DBIx::Class"
37
    }
37
    }
Lines 73-78 fixtures_ok [ Link Here
73
        [ 'MPL', 1,  6,  2011, '', '', 0 ],
73
        [ 'MPL', 1,  6,  2011, '', '', 0 ],
74
        [ 'MPL', 4,  7,  2012, '', '', 0 ],
74
        [ 'MPL', 4,  7,  2012, '', '', 0 ],
75
        [ 'CPL', 6,  8,  2012, '', '', 0 ],
75
        [ 'CPL', 6,  8,  2012, '', '', 0 ],
76
        [ 'MPL', 7,  7,  2012, '', '', 1 ], # holiday exception
77
        [ 'MPL', 7,  7,  2012, '', '', 0 ], # holiday
76
      ],
78
      ],
77
], "add fixtures";
79
], "add fixtures";
78
80
Lines 139-144 my $holiday_for_another_branch = DateTime->new( Link Here
139
    day => 6, # This is a monday
141
    day => 6, # This is a monday
140
);
142
);
141
143
144
my $holiday_excepted = DateTime->new(
145
    year => 2012,
146
    month => 7,
147
    day => 7, # Both a holiday and exception
148
);
149
142
{   # Syspref-agnostic tests
150
{   # Syspref-agnostic tests
143
    is ( $saturday->day_of_week, 6, '\'$saturday\' is actually a saturday (6th day of week)');
151
    is ( $saturday->day_of_week, 6, '\'$saturday\' is actually a saturday (6th day of week)');
144
    is ( $sunday->day_of_week, 7, '\'$sunday\' is actually a sunday (7th day of week)');
152
    is ( $sunday->day_of_week, 7, '\'$sunday\' is actually a sunday (7th day of week)');
Lines 151-156 my $holiday_for_another_branch = DateTime->new( Link Here
151
    is ( $cal->is_holiday($notspecial), 0, 'Fixed single date that is not a holiday test' );
159
    is ( $cal->is_holiday($notspecial), 0, 'Fixed single date that is not a holiday test' );
152
    is ( $cal->is_holiday($sunday_exception), 0, 'Exception holiday is not a closed day test' );
160
    is ( $cal->is_holiday($sunday_exception), 0, 'Exception holiday is not a closed day test' );
153
    is ( $cal->is_holiday($holiday_for_another_branch), 0, 'Holiday defined for another branch should not be defined as an holiday' );
161
    is ( $cal->is_holiday($holiday_for_another_branch), 0, 'Holiday defined for another branch should not be defined as an holiday' );
162
    is ( $cal->is_holiday($holiday_excepted), 0, 'Holiday defined and excepted should not be a holiday' );
154
}
163
}
155
164
156
{   # Bugzilla #8966 - is_holiday truncates referenced date
165
{   # Bugzilla #8966 - is_holiday truncates referenced date
157
- 

Return to bug 25723