@@ -, +, @@ --- ...nsiderLibraryHoursInCirculation_syspref.pl | 16 -------------- .../bug_6796_-_add_library_hours_table.pl | 21 +++++++++++++------ 2 files changed, 15 insertions(+), 22 deletions(-) delete mode 100755 installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl --- a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl +++ a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl @@ -1,16 +0,0 @@ -use Modern::Perl; - -return { - bug_number => "6796", - description => "Overnight checkouts taking into account opening and closing hours", - up => sub { - my ($args) = @_; - my ( $dbh, $out ) = @$args{qw(dbh out)}; - - $dbh->do( - q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursInCirculation', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when circulating.", 'Choice' ) } - ); - - say $out "Added system preference 'ConsiderLibraryHoursInCirculation'"; - }, -}; --- a/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl +++ a/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl @@ -21,15 +21,24 @@ return { } ); - my @indexes = ( 0 .. 6 ); - for my $i (@indexes) { - $dbh->do( - q{ INSERT INTO library_hours (library_id, day) SELECT branchcode, ? FROM branches }, undef, - $i - ); + my $branches = + $dbh->selectall_arrayref( "SELECT branchcode FROM branches", { Slice => {} } ); + for my $branch (@$branches) { + my $branchcode = $branch->{branchcode}; + + my @indexes = ( 0 .. 6 ); + for my $i (@indexes) { + $dbh->do( q{ INSERT INTO library_hours (library_id, day) VALUES ( ?, ? ) }, undef, $branchcode, $i ); + } } say $out "Added table `library_hours`"; + + $dbh->do( + q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursInCirculation', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when circulating.", 'Choice' ) } + ); + + say $out "Added system preference 'ConsiderLibraryHoursInCirculation'"; } }, }; --