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

(-)a/installer/data/mysql/atomicupdate/bug_17015_part2_fill_discrete_calendar.perl (-16 / +9 lines)
Lines 41-57 my $add_default_branch = 'INSERT IGNORE INTO branches (branchname, branchcode) V Link Here
41
my $add_Branch_Sth = $dbh->prepare($add_default_branch);
41
my $add_Branch_Sth = $dbh->prepare($add_default_branch);
42
$add_Branch_Sth->execute('Default', '');
42
$add_Branch_Sth->execute('Default', '');
43
# finds branches;
43
# finds branches;
44
my $selectBranchesSt = 'SELECT branchcode FROM branches';
44
my $selectBranchesSt = 'SELECT branchname, branchcode FROM branches';
45
my $selectBranchesSth = $dbh->prepare($selectBranchesSt);
45
my $selectBranchesSth = $dbh->prepare($selectBranchesSt);
46
$selectBranchesSth->execute();
46
$selectBranchesSth->execute();
47
my @branches = ();
47
my @branches = ();
48
for my $branchCode ( $selectBranchesSth->fetchrow_array ) {
48
while (my @row = $selectBranchesSth->fetchrow_array ) {
49
    print $branchCode . "\n";
49
    print "[$row[1]] $row[0]\n";
50
    push @branches,$branchCode;
50
    push @branches, $row[1];
51
}
51
}
52
print "REACH\n";
53
print Dumper(\@branches);
54
55
52
56
# finds what days are closed for each branch
53
# finds what days are closed for each branch
57
my %repeatableHolidaysPerBranch = ();
54
my %repeatableHolidaysPerBranch = ();
Lines 103-111 for (my $tempDate = $startDate->clone(); $tempDate <= $endDate;$tempDate->add(da Link Here
103
        # Representation fix
100
        # Representation fix
104
        # DateTime object dow (1-7) where Monday is 1
101
        # DateTime object dow (1-7) where Monday is 1
105
        # Arrays are 0-based where 0 = Sunday, not 7.
102
        # Arrays are 0-based where 0 = Sunday, not 7.
106
        $dayOfWeek -=1 unless $dayOfWeek ==7;
107
        $dayOfWeek =0 if $dayOfWeek ==7;
108
109
        my $open_hour = "09:00:00";
103
        my $open_hour = "09:00:00";
110
        my $close_hour = "17:00:00";
104
        my $close_hour = "17:00:00";
111
105
Lines 113-125 for (my $tempDate = $startDate->clone(); $tempDate <= $endDate;$tempDate->add(da Link Here
113
        my $is_opened =1;
107
        my $is_opened =1;
114
        my $specialDescription = "";
108
        my $specialDescription = "";
115
        my $holiday_type ='';
109
        my $holiday_type ='';
116
        $dayOfWeek = $tempDate->day_of_week;
110
        $dayOfWeek = $tempDate->day_of_week % 7;
117
        foreach my $holidayWeekDay (@{$repeatableHolidaysPerBranch{$branch}}){
111
        foreach my $holidayWeekDay ( @{$repeatableHolidaysPerBranch{$branch}} ) {
118
            if($holidayWeekDay->{weekday} && $dayOfWeek == $holidayWeekDay->{weekday}){
112
            if (defined($holidayWeekDay) && $dayOfWeek == $holidayWeekDay->{weekday}) {
119
                $is_opened = 0;
113
                $is_opened = 0;
120
                $specialDescription = $holidayWeekDay->{title};
114
                $specialDescription = $holidayWeekDay->{title};
121
                $holiday_type = 'W';
115
                $holiday_type = 'W';
122
            }elsif($holidayWeekDay->{day} && $holidayWeekDay->{month}){
116
            } elsif ($holidayWeekDay->{day} && $holidayWeekDay->{month}) {
123
                my $date = DateTime->new(
117
                my $date = DateTime->new(
124
                day       => $holidayWeekDay->{day},
118
                day       => $holidayWeekDay->{day},
125
                month     => $holidayWeekDay->{month},
119
                month     => $holidayWeekDay->{month},
Lines 136-142 for (my $tempDate = $startDate->clone(); $tempDate <= $endDate;$tempDate->add(da Link Here
136
        }
130
        }
137
131
138
        foreach my $specialDate (@{$specialHolidaysPerBranch{$branch}}){
132
        foreach my $specialDate (@{$specialHolidaysPerBranch{$branch}}){
139
            if($tempDate->datetime() eq $specialDate->{date}->datetime() ){
133
            if ($tempDate->datetime() eq $specialDate->{date}->datetime()) {
140
                $is_opened = 0;
134
                $is_opened = 0;
141
                $specialDescription = $specialDate->{title};
135
                $specialDescription = $specialDate->{title};
142
                $holiday_type = 'E';
136
                $holiday_type = 'E';
143
- 

Return to bug 17015