Bug 28149: (follow-up) Add string for job status "new"
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / background_jobs.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% SET footerjs = 1 %]
5 [% BLOCK show_job_status %]
6     [% SWITCH job.status %]
7         [% CASE "new" %]
8             New
9         [% CASE "cancelled" %]
10             Cancelled
11         [% CASE "finished" %]
12             Finished
13         [% CASE "started" %]
14             Started
15         [% CASE "running" %]
16             Running
17         [% CASE # Default case %]
18             [% job.status | html %]
19     [% END -%]
20 [% END %]
21 [% BLOCK show_job_type %]
22     [% SWITCH job.type %]
23         [% CASE "batch_biblio_record_modification" %]
24             Batch bibliographic record modification
25         [% CASE "batch_authority_record_modification" %]
26             Batch authority record modification
27         [% CASE # Default case %]
28             [% job.type | html %]
29     [% END %]
30 [% END %]
31 [% INCLUDE 'doc-head-open.inc' %]
32 <title>
33     [% IF op == 'view' %]
34         Details of job #[% job.id | html %] &rsaquo;
35     [% END %]
36     Background jobs &rsaquo;
37     Administration &rsaquo; Koha
38 </title>
39
40 [% INCLUDE 'doc-head-close.inc' %]
41 </head>
42
43 <body id="admin_background_jobs" class="admin">
44 [% INCLUDE 'header.inc' %]
45 [% INCLUDE 'prefs-admin-search.inc' %]
46
47 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
48     <ol>
49         <li>
50             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
51         </li>
52
53     [% IF CAN_user_parameters_manage_background_jobs %]
54         <li>
55             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
56         </li>
57         [% IF op == 'view' %]
58             <li>
59                 <a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a>
60             </li>
61             <li>
62                 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
63             </li>
64         [% ELSE %]
65             <li>
66                 <a href="#" aria-current="page">Background jobs</a>
67             </li>
68         [% END %]
69     [% ELSE %]
70         <li>
71             <a href="#" aria-current="page">Administration</a>
72         </li>
73     [% END %]
74     </ol>
75 </nav>
76
77 <div class="main container-fluid">
78     <div class="row">
79         <div class="col-sm-10 col-sm-push-2">
80             <main>
81
82 [% FOR m IN messages %]
83     <div class="dialog message">
84         [% SWITCH m.code %]
85         [% CASE 'cannot_view_job' %]
86             <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
87         [% CASE %]
88             [% m.code | html %]
89         [% END %]
90     </div>
91 [% END %]
92
93 [% IF op == 'view' %]
94     <h1>Details of job #[% job.id | html %]</h1>
95
96     <fieldset class="rows">
97         <ol>
98             <li><span class="label">Job ID: </span>[% job.id | html %]</li>
99             <li>
100                 <label for="job_status">Status: </label>
101                 [% PROCESS show_job_status %]
102             </li>
103             <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
104             <li>
105                 <label for="job_type">Type: </label>
106                 [% PROCESS show_job_type %]
107             </li>
108             <li>
109                 <label for="job_enqueued_on">Queued: </label>
110                 [% job.enqueued_on | $KohaDates with_hours = 1 %]
111             </li>
112             <li>
113                 <label for="job_started_on">Started: </label>
114                 [% job.started_on | $KohaDates with_hours = 1 %]
115             </li>
116             <li>
117                 <label for="job_ended_on">Ended: </label>
118                 [% job.ended_on | $KohaDates with_hours = 1 %]
119             </li>
120             <li><label for="job_data">Report: </label>
121                 [% SWITCH job.type %]
122                 [% CASE 'batch_biblio_record_modification' %]
123                     [% SET report = job.report %]
124                     [% IF report %]
125                         [% IF report.total_records == report.total_success %]
126                             <div class="dialog message">
127                                 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>
128                                 [% IF lists.count %]
129                                     <br />
130                                     Add modified records to the following list:
131                                     <select name="add_bibs_to_list" id="add_bibs_to_list">
132                                         <option value="">Select a list</option>
133                                         [% FOREACH list IN lists %]
134                                             <option class="shelf" value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
135                                         [% END %]
136                                     </select>
137                                 [% END %]
138                             </div>
139                         [% ELSE %]
140                             <div class="dialog message">
141                                 [% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
142                                 [% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
143                                 <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
144                             </div>
145                         [% END %]
146                     [% END %]
147                 [% CASE 'batch_authority_record_modification' %]
148                     [% SET report = job.report %]
149                     [% IF report %]
150                         [% IF report.total_records == report.total_success %]
151                             <div class="dialog message">
152                                 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>
153                             </div>
154                         [% ELSE %]
155                             <div class="dialog message">
156                                 [% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
157                                 [% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
158                                 <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
159                             </div>
160                         [% END %]
161                     [% END %]
162                 [% CASE %]Job type "[% job.type | html %]" not handled in the template
163                 [% END %]
164             </li>
165             <li><label for="job_data">Detailed messages: </label>
166                 [% SWITCH job.type %]
167                 [% CASE 'batch_biblio_record_modification' %]
168                     [% FOR m IN job.messages %]
169                         <div class="dialog message">
170                             [% IF m.type == 'success' %]
171                                 <i class="fa fa-check success"></i>
172                             [% ELSIF m.type == 'warning' %]
173                                 <i class="fa fa-warning warn"></i>
174                             [% ELSIF m.type == 'error' %]
175                                 <i class="fa fa-exclamation error"></i>
176                             [% END %]
177                             [% SWITCH m.code %]
178                             [% CASE 'biblio_not_modified' %]
179                                 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.[% IF m.error %] ([% m.error | html %])[% END %].
180                             [% CASE 'biblio_modified' %]
181                                 Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has successfully been modified.
182                             [% END %]
183                         </div>
184                     [% END %]
185                 [% CASE 'batch_authority_record_modification' %]
186                     [% FOR m IN job.messages %]
187                         <div class="dialog message">
188                             [% IF m.type == 'success' %]
189                                 <i class="fa fa-check success"></i>
190                             [% ELSIF m.type == 'warning' %]
191                                 <i class="fa fa-warning warn"></i>
192                             [% ELSIF m.type == 'error' %]
193                                 <i class="fa fa-exclamation error"></i>
194                             [% END %]
195                             [% SWITCH m.code %]
196                             [% CASE 'authority_not_modified' %]
197                                 Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has not been modified. An error occurred on modifying it[% IF m.error %] ([% m.error | html %])[% END %].
198                             [% CASE 'authority_modified' %]
199                                 Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has successfully been modified.
200                             [% END %]
201                         </div>
202                     [% END %]
203                 [% CASE %]Job type "[% job.type | html %]" not handled in the template
204                 [% END %]
205             </li>
206         </ol>
207     </fieldset>
208
209     [% IF CAN_user_parameters_manage_background_jobs %]
210         <fieldset class="action">
211             <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
212         </fieldset>
213     [% END %]
214 [% END %]
215
216 [% IF op == 'list' %]
217
218     <h2>Background jobs</h2>
219
220     [% IF jobs.count %]
221         <table id="table_background_jobs">
222             <thead>
223                 <tr>
224                     <th>Job ID</th>
225                     <th>Status</th>
226                     <th>Progress</th>
227                     <th>Type</th>
228                     <th>Queued</th>
229                     <th>Started</th>
230                     <th>Ended</th>
231                     <th class="noExport">Actions</th>
232                 </tr>
233             </thead>
234             <tbody>
235                 [% FOREACH job IN jobs %]
236                 <tr>
237                     <td>[% job.id | html %]</td>
238                     <td>
239                         [% PROCESS show_job_status %]
240                     </td>
241                     <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
242                     <td>
243                         [% SWITCH job.type %]
244                         [% CASE 'batch_biblio_record_modification' %]Batch bibliographic record modification
245                         [% CASE 'batch_authority_record_modification' %]Batch authority record modification
246                         [% CASE %][% job.type | html %]
247                         [% END %]
248                     </td>
249                     <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
250                     <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
251                     <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
252                     <td class="actions">
253                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&amp;id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a>
254                         [% IF job.status == 'new' || job.status == 'started' %]
255                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&amp;id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a>
256                         [% END %]
257                     </td>
258                 </tr>
259                 [% END %]
260             </tbody>
261         </table>
262     [% ELSE %]
263         <div class="dialog message">
264             There are no background jobs yet.
265         </div>
266     [% END %]
267 [% END %]
268
269             </main>
270         </div> <!-- /.col-sm-10.col-sm-push-2 -->
271
272         <div class="col-sm-2 col-sm-pull-10">
273             <aside>
274                 [% INCLUDE 'admin-menu.inc' %]
275             </aside>
276         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
277      </div> <!-- /.row -->
278
279 [% MACRO jsinclude BLOCK %]
280     [% Asset.js("js/admin-menu.js") | $raw %]
281     [% INCLUDE 'datatables.inc' %]
282     <script>
283         $(document).ready(function() {
284             $("#table_background_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
285                 "aoColumnDefs": [
286                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
287                 ],
288                 "aaSorting": [[ 0, "desc" ]],
289                 "iDisplayLength": 10,
290                 "sPaginationType": "full_numbers"
291             }));
292
293             $("#add_bibs_to_list").change(function(){
294                 var selected = $("#add_bibs_to_list").find("option:selected");
295                 if ( selected.attr("class") == "shelf" ){
296                     var shelfnumber = selected.attr("value");
297                     var bibs = new Array();
298                     [% FOREACH message IN job.messages %]
299                         [% IF message.code == 'biblio_modified' %]
300                             bibs.push("biblionumber="+[% message.biblionumber | html %]);
301                         [% END %]
302                     [% END %]
303                     var bibstring = bibs.join("&");
304                     window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&'+bibstring, 'popup', 'width=500,height=500,toolbar=false,scrollbars=yes,resizable=yes');
305                     return false;
306                 }
307             });
308         });
309     </script>
310 [% END %]
311 [% INCLUDE 'intranet-bottom.inc' %]