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 150-166 if ( $op eq 'form' ) { Link Here
150
    # We want to modify selected records!
151
    # We want to modify selected records!
151
    my @record_ids = $input->multi_param('record_id');
152
    my @record_ids = $input->multi_param('record_id');
152
153
153
    my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
154
    try {
154
        {
155
        my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
155
            mmtid       => $mmtid,
156
            {
156
            record_type => $recordtype,
157
                mmtid       => $mmtid,
157
            record_ids  => \@record_ids,
158
                record_type => $recordtype,
158
        }
159
                record_ids  => \@record_ids,
159
    );
160
            }
160
    $template->param(
161
        );
161
        view => 'enqueued',
162
        $template->param(
162
        job_id => $job_id,
163
            view => 'enqueued',
163
    );
164
            job_id => $job_id,
165
        );
166
    } catch {
167
        push @messages, {
168
            type => 'error',
169
            code => 'cannot_enqueue_job',
170
            error => $_,
171
        };
172
        $template->param( view => 'errors' );
173
    };
164
}
174
}
165
175
166
$template->param(
176
$template->param(
167
- 

Return to bug 22417