3 # Copyright Biblibre 2012
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use C4::Update::Database;
27 my $op = $query->param('op') || 'list';
29 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
30 { template_name => "admin/updatedatabase.tmpl",
34 flagsrequired => { parameters => 1 },
38 if ( $op eq 'update' ) {
39 my @versions = $query->param('version');
41 C4::Update::Database::TransformToNum( $a ) <=> C4::Update::Database::TransformToNum( $b )
45 for my $version ( @versions ) {
46 push @reports, C4::Update::Database::execute_version $version;
49 my @report_loop = map {
50 my ( $v, $r ) = each %$_;
51 my @errors = ref ( $r ) eq 'ARRAY'
63 $template->param( report_loop => \@report_loop );
68 if ( $op eq 'mark_as_ok' ) {
69 my @versions = $query->param('version');
70 C4::Update::Database::mark_as_ok $_ for @versions;
74 if ( $op eq 'list' ) {
75 my $versions_available = C4::Update::Database::list_versions_available;
76 my $versions = C4::Update::Database::list_versions_already_applied;
78 for my $v ( @$versions_available ) {
79 if ( not grep { $v eq $$_{version} } @$versions ) {
87 C4::Update::Database::TransformToNum( $$a{version} ) <=> C4::Update::Database::TransformToNum( $$b{version} )
90 my @available = grep { defined $$_{available} and $$_{available} == 1 } @sorted;
91 my @v_available = map { {version => $$_{version}} } @available;
94 dev_mode => $ENV{DEBUG},
96 nb_available => scalar @available,
97 available => [ map { {version => $$_{version}} } @available ],
101 output_html_with_http_headers $query, $cookie, $template->output;