@@ -, +, @@ --- misc/cronjobs/add_days_discrete_calendar.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/misc/cronjobs/add_days_discrete_calendar.pl +++ a/misc/cronjobs/add_days_discrete_calendar.pl @@ -91,7 +91,7 @@ for ($newDay->add(days => 1); $newDay <= $latestedDate; $newDay->add(days => 1)) my $yearAgo = $newDay->clone(); $yearAgo = $yearAgo->add(years => -1); my $last_year = 'SELECT is_opened, holiday_type, note FROM discrete_calendar WHERE date=? AND branchcode=?'; - my $day_last_week = "SELECT open_hour, close_hour FROM discrete_calendar WHERE DAYOFWEEK(date)=DAYOFWEEK(?) and date < ? order by date desc limit 1"; + my $day_last_week = "SELECT open_hour, close_hour, holiday_type, note FROM discrete_calendar WHERE DAYOFWEEK(date)=DAYOFWEEK(?) and date < ? order by date desc limit 1"; my $add_Day = 'INSERT INTO discrete_calendar (date,branchcode,is_opened,open_hour,close_hour) VALUES (?,?,?,?,?)'; my $note =''; #insert into discrete_calendar for each branch @@ -112,7 +112,15 @@ for ($newDay->add(days => 1); $newDay <= $latestedDate; $newDay->add(days => 1)) $holiday_type = '' if $is_opened; $statement = $dbh->prepare($day_last_week); $statement->execute($newDay, $newDay); - my ($open_hour,$close_hour ) = $statement->fetchrow_array; + my ( $open_hour, $close_hour, $weekly_holiday_type, $weekly_note ) = $statement->fetchrow_array; + + # weekly repeatable holidays + if ( $weekly_holiday_type eq 'W' ) { + $is_opened = 0; + $holiday_type = $weekly_holiday_type unless $holiday_type; + $note = $weekly_note unless $note; + } + my $add_Day = 'INSERT INTO discrete_calendar (date,branchcode,is_opened,holiday_type, note,open_hour,close_hour) VALUES (?,?,?,?,?,?,?)'; $statement = $dbh->prepare($add_Day); $statement->execute($newDay,$branchCode,$is_opened,$holiday_type,$note, $open_hour,$close_hour); --