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