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