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

(-)a/admin/background_jobs.pl (+67 lines)
Line 0 Link Here
1
#! /usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
use CGI qw ( -utf8 );
20
use JSON qw( decode_json );
21
use C4::Context;
22
use C4::Auth;
23
use C4::Output;
24
25
use Koha::BackgroundJob;
26
use Koha::BackgroundJobs;
27
28
my $input             = new CGI;
29
my $op                = $input->param('op') || 'list';
30
my @messages;
31
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "admin/background_jobs.tt",
35
        query           => $input,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => { parameters => 'manage_background_jobs' }, # TODO Add this new permission, so far only works for superlibrarians
39
        debug           => 1,
40
    }
41
);
42
43
my $dbh = C4::Context->dbh;
44
45
if ( $op eq 'view' ) {
46
    my $id = $input->param('id');
47
    if ( my $job = Koha::BackgroundJobs->find($id) ) {
48
        $template->param(
49
            job       => $job,
50
        );
51
    } else {
52
        $op = 'list';
53
    }
54
55
}
56
57
if ( $op eq 'list' ) {
58
    my $jobs = Koha::BackgroundJobs->search({}, { order_by => { -desc => 'enqueued_on' }});
59
    $template->param( jobs => $jobs, );
60
}
61
62
$template->param(
63
    messages => \@messages,
64
    op       => $op,
65
);
66
67
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt (-1 / +165 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Administration &rsaquo; [% IF op =='add_form' %]Background jobs&rsaquo; [% IF job %] View background job[% ELSE %] Background jobs[% END %][% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
8
9
<body id="admin_background_jobs" class="admin">
10
[% INCLUDE 'header.inc' %]
11
12
<div id="breadcrumbs">
13
    <a href="/cgi-bin/koha/mainpage.pl">Home</a>
14
    &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
15
    &rsaquo; <a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a>
16
</div>
17
18
<div class="main container-fluid">
19
    <div class="row">
20
        <div class="col-sm-10 col-sm-push-2">
21
            <main>
22
23
[% FOR m IN messages %]
24
    <div class="dialog [% m.type | html %]">
25
        [% SWITCH m.code %]
26
        [% CASE %]
27
            [% m.code | html %]
28
        [% END %]
29
    </div>
30
[% END %]
31
32
[% IF op == 'view' %]
33
    <h1>Detail of job #[% job.id | html %]</h1>
34
35
    <fieldset class="rows">
36
        <ol>
37
            <li><span class="label">Job ID: </span>[% job.id | html %]</li>
38
            <li><label for="job_status">Status: </label>[% job.status | html %]</li>
39
            <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
40
            <li><label for="job_type">Type: </label>[% job.type | html %]</li>
41
            <li><label for="job_enqueued_on">enqueued_on: </label>[% job.enqueued_on | html %]</li>
42
            <li><label for="job_started_on">started_on: </label>[% job.started_on | html %]</li>
43
            <li><label for="job_ended_on">ended_on: </label>[% job.ended_on | html %]</li>
44
            <li><label for="job_data">Report: </label>
45
                [% SWITCH job.type %]
46
                [% CASE 'batch_biblio_record_modification' %]
47
                    [% SET report = job.report %]
48
                    [% IF report %]
49
                        [% IF report.total_records == report.total_success %]
50
                            <div class="dialog message">
51
                                All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
52
                            </div>
53
                        [% ELSE %]
54
                            <div class="dialog message">
55
                                [% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred. <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
56
                            </div>
57
                        [% END %]
58
                    [% END %]
59
                [% CASE %][% job.type | html %]
60
                [% END %]
61
            </li>
62
            <li><label for="job_data">Detailed messages: </label>
63
                [% SWITCH job.type %]
64
                [% CASE 'batch_biblio_record_modification' %]
65
                    [% FOR m IN job.messages %]
66
                        <div class="dialog message">
67
                            [% IF m.type == 'success' %]
68
                                <i class="fa fa-check success"></i>
69
                            [% ELSIF m.type == 'warning' %]
70
                                <i class="fa fa-warning warn"></i>
71
                            [% ELSIF m.type == 'error' %]
72
                                <i class="fa fa-exclamation error"></i>
73
                            [% END %]
74
                            [% SWITCH m.code %]
75
                            [% CASE 'biblio_not_modified' %]
76
                                Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has not been modified. An error occurred on modifying it.
77
                            [% CASE 'biblio_modified' %]
78
                                Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has successfully been modified.
79
                            [% END %]
80
                        </div>
81
                    [% END %]
82
                [% CASE %][% job.type | html %]
83
                [% END %]
84
            </li>
85
        </ol>
86
    </fieldset>
87
88
    <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
89
[% END %]
90
91
[% IF op == 'list' %]
92
93
    <h2>Background jobs</h2>
94
95
    [% IF jobs.count %]
96
        <table id="table_background_jobs">
97
            <thead>
98
                <tr>
99
                    <th>Job ID</th>
100
                    <th>Status</th>
101
                    <th>Progress</th>
102
                    <th>Type</th>
103
                    <th>Enqueued on</th>
104
                    <th>Started on</th>
105
                    <th>Ended on</th>
106
                    <th>Actions (NIY)</th>
107
                </tr>
108
            </thead>
109
            <tbody>
110
                [% FOREACH job IN jobs %]
111
                <tr>
112
                    <td>[% job.id | html %]</td>
113
                    <td>[% job.status | html %]</td>
114
                    <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
115
                    <td>
116
                        [% SWITCH job.type %]
117
                        [% CASE 'batch_biblio_record_modification' %]Batch bibliographic record modification
118
                        [% CASE %][% job.type | html %]
119
                        [% END %]
120
                    </td>
121
                    <td>[% job.enqueued_on | html %]</td>
122
                    <td>[% job.started_on| html %]</td>
123
                    <td>[% job.ended_on| html %]</td>
124
                    <td class="actions">
125
                        <a class="btn btn-default btn-xs disabled" href="/cgi-bin/koha/admin/background_jobs.pl?op=delete_confirm&amp;id=[% job.id | html %]"><i class="fa fa-pencil"></i> Delete</a>
126
                        <a class="btn btn-default btn-xs  disabled" href="/cgi-bin/koha/admin/background_jobs.pl?op=replay&amp;id=[% job.id | html %]"><i class="fa fa-trash"></i> Replay</a>
127
                    </td>
128
                </tr>
129
                [% END %]
130
            </tbody>
131
        </table>
132
    [% ELSE %]
133
        <div class="dialog message">
134
            There are no background jobs yet.
135
        </div>
136
    [% END %]
137
[% END %]
138
139
            </main>
140
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
141
142
        <div class="col-sm-2 col-sm-pull-10">
143
            <aside>
144
                [% INCLUDE 'admin-menu.inc' %]
145
            </aside>
146
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
147
     </div> <!-- /.row -->
148
149
[% MACRO jsinclude BLOCK %]
150
    [% Asset.js("js/admin-menu.js") | $raw %]
151
    [% INCLUDE 'datatables.inc' %]
152
    <script>
153
        $(document).ready(function() {
154
            $("#table_cities").dataTable($.extend(true, {}, dataTablesDefaults, {
155
                "aoColumnDefs": [
156
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
157
                ],
158
                "aaSorting": [[ 1, "asc" ]],
159
                "iDisplayLength": 10,
160
                "sPaginationType": "full_numbers"
161
            }));
162
        });
163
    </script>
164
[% END %]
165
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 22417