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

(-)a/Koha/BackgroundJob.pm (-15 / +23 lines)
Lines 27-47 sub enqueue { Link Here
27
27
28
    my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls
28
    my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls
29
    my $json_args = encode_json $job_args;
29
    my $json_args = encode_json $job_args;
30
    $self->set({
30
    my $job_id;
31
        status => 'new',
31
    $self->_result->result_source->schema->txn_do(
32
        type => $job_type,
32
        sub {
33
        size => $job_size,
33
            $self->set(
34
        data => $json_args,
34
                {
35
        enqueued_on => dt_from_string,
35
                    status         => 'new',
36
        borrowernumber => $borrowernumber,
36
                    type           => $job_type,
37
    })->store;
37
                    size           => $job_size,
38
38
                    data           => $json_args,
39
    my $job_id = $self->id;
39
                    enqueued_on    => dt_from_string,
40
    $job_args->{job_id} = $job_id;
40
                    borrowernumber => $borrowernumber,
41
    $json_args = encode_json $job_args,
41
                }
42
42
            )->store;
43
    my $conn = $self->connect;
43
44
    $conn->send({destination => $job_type, body => $json_args});
44
            $job_id = $self->id;
45
            $job_args->{job_id} = $job_id;
46
            $json_args = encode_json $job_args;
47
48
            my $conn = $self->connect;
49
            $conn->send_with_receipt( { destination => $job_type, body => $json_args } )
50
              or Koha::Exception->throw('Job has not been enqueued');
51
        }
52
    );
45
53
46
    return $job_id;
54
    return $job_id;
47
}
55
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt (+2 lines)
Lines 46-51 Link Here
46
                                    Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has not been modified. An error occurred on modifying it.
46
                                    Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has not been modified. An error occurred on modifying it.
47
                                [% ELSIF message.code == 'authority_modified' %]
47
                                [% ELSIF message.code == 'authority_modified' %]
48
                                    Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has successfully been modified.
48
                                    Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has successfully been modified.
49
                                [% ELSIF message.code == 'cannot_enqueue_job' %]
50
                                    Cannot enqueue this job.
49
                                [% END %]
51
                                [% END %]
50
                                [% IF message.error %]
52
                                [% IF message.error %]
51
                                    (The error was: [% message.error | html %]. See the Koha logfile for more information).
53
                                    (The error was: [% message.error | html %]. See the Koha logfile for more information).
(-)a/tools/batch_record_modification.pl (-12 / +21 lines)
Lines 23-28 use Modern::Perl; Link Here
23
use CGI;
23
use CGI;
24
use List::MoreUtils qw( uniq );
24
use List::MoreUtils qw( uniq );
25
use JSON qw( encode_json );
25
use JSON qw( encode_json );
26
use Try::Tiny;
26
27
27
use C4::Auth qw( get_template_and_user );
28
use C4::Auth qw( get_template_and_user );
28
use C4::Output qw( output_html_with_http_headers );
29
use C4::Output qw( output_html_with_http_headers );
Lines 149-165 if ( $op eq 'form' ) { Link Here
149
    # We want to modify selected records!
150
    # We want to modify selected records!
150
    my @record_ids = $input->multi_param('record_id');
151
    my @record_ids = $input->multi_param('record_id');
151
152
152
    my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
153
    try {
153
        {
154
        my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
154
            mmtid       => $mmtid,
155
            {
155
            record_type => $recordtype,
156
                mmtid       => $mmtid,
156
            record_ids  => \@record_ids,
157
                record_type => $recordtype,
157
        }
158
                record_ids  => \@record_ids,
158
    );
159
            }
159
    $template->param(
160
        );
160
        view => 'enqueued',
161
        $template->param(
161
        job_id => $job_id,
162
            view => 'enqueued',
162
    );
163
            job_id => $job_id,
164
        );
165
    } catch {
166
        push @messages, {
167
            type => 'error',
168
            code => 'cannot_enqueue_job',
169
            error => $_,
170
        };
171
        $template->param( view => 'errors' );
172
    };
163
}
173
}
164
174
165
$template->param(
175
$template->param(
166
- 

Return to bug 22417