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

(-)a/Koha/BackgroundJob.pm (-15 / +23 lines)
Lines 29-49 sub enqueue { Link Here
29
29
30
    my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls
30
    my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls
31
    my $json_args = encode_json $job_args;
31
    my $json_args = encode_json $job_args;
32
    $self->set({
32
    my $job_id;
33
        status => 'new',
33
    $self->_result->result_source->schema->txn_do(
34
        type => $job_type,
34
        sub {
35
        size => $job_size,
35
            $self->set(
36
        data => $json_args,
36
                {
37
        enqueued_on => dt_from_string,
37
                    status         => 'new',
38
        borrowernumber => $borrowernumber,
38
                    type           => $job_type,
39
    })->store;
39
                    size           => $job_size,
40
40
                    data           => $json_args,
41
    my $job_id = $self->id;
41
                    enqueued_on    => dt_from_string,
42
    $job_args->{job_id} = $job_id;
42
                    borrowernumber => $borrowernumber,
43
    $json_args = encode_json $job_args,
43
                }
44
44
            )->store;
45
    my $conn = $self->connect;
45
46
    $conn->send({destination => $job_type, body => $json_args});
46
            $job_id = $self->id;
47
            $job_args->{job_id} = $job_id;
48
            $json_args = encode_json $job_args;
49
50
            my $conn = $self->connect;
51
            $conn->send_with_receipt( { destination => $job_type, body => $json_args } )
52
              or Koha::Exception->throw('Job has not been enqueued');
53
        }
54
    );
47
55
48
    return $job_id;
56
    return $job_id;
49
}
57
}
(-)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