Bug 33088: Remove background-job-progressbar.js in batch_record_modification.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_record_modification.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% PROCESS 'authorities-search-results.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Batch record modification &rsaquo; Tools &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("css/humanmsg.css") | $raw %]
9 </head>
10
11 <body id="tools_batch_record_modification" class="tools">
12     [% INCLUDE 'header.inc' %]
13     [% INCLUDE 'cat-search.inc' %]
14
15     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
16         <ol>
17             <li>
18                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19             </li>
20             <li>
21                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
22             </li>
23             <li>
24                 <a href="#" aria-current="page">Batch record modification</a>
25             </li>
26         </ol>
27     </nav>
28
29     <div class="main container-fluid">
30         <div class="row">
31             <div class="col-sm-10 col-sm-push-2">
32                 <main>
33
34                     <h1>Batch record modification</h1>
35
36                     [% IF ( messages ) %]
37                         <div class="dialog message">
38
39                             [% FOREACH message IN messages %]
40                                 [% IF message.type == 'success' %]
41                                     <div><i class="fa fa-check success"></i>
42                                 [% ELSIF message.type == 'warning' %]
43                                     <div><i class="fa fa-warning warn"></i>
44                                 [% ELSIF message.type == 'error' %]
45                                     <div><i class="fa fa-exclamation error"></i>
46                                 [% END %]
47                                 [% IF message.code == 'no_action_defined_for_the_template' %]
48                                     <span>The selected template (id=[% message.mmtid | html %]) does not exist or no action is defined.</span>
49                                 [% ELSIF message.code == 'biblio_not_exists' %]
50                                     <span>Bibliographic record [% message.biblionumber | html %] does not exist in the database.</span>
51                                 [% ELSIF message.code == 'authority_not_exists' %]
52                                     <span>Authority record [% message.authid | html %] does not exist in the database.</span>
53                                 [% ELSIF message.code == 'cannot_enqueue_job' %]
54                                     <span>Cannot enqueue this job.</span>
55                                 [% END %]
56                                 [% IF message.error %]
57                                     <span>(The error was: [% message.error | html %]. See the Koha logfile for more information).</span>
58                                 [% END %]
59                                 </div>
60                             [% END %]
61
62                         </div> <!-- /.dialog.message -->
63                     [% END %]
64
65                     [% IF view == 'form' %]
66                         <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="record_ids_selection">
67                             <fieldset class="rows">
68                                 <legend>Record type</legend>
69                                 <ol>
70                                     <li><label for="biblio_type">Biblios: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
71                                     <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
72                                 </ol>
73                             </fieldset>
74
75                             <br><br>
76
77                             <div id="batch_mod_form" class="toptabs" style="clear:both">
78                                 <ul class="nav nav-tabs" role="tablist">
79                                     <li role="presentation" class="active">
80                                         <a href="#uploadfile_tab" aria-controls="uploadfile_tab" role="tab" data-toggle="tab">Upload a file</a>
81                                     </li>
82                                     [% IF lists.count %]
83                                         <li id="show_list_option">
84                                             <a href="#shelves_tab" aria-controls="shelves_tab" role="tab" data-toggle="tab">Select a list of records</a>
85                                         </li>
86                                     [% END %]
87                                     <li role="presentation">
88                                         <a href="#enterlist_tab" aria-controls="enterlist_tab" role="tab" data-toggle="tab">Enter a list of record numbers</a>
89                                     </li>
90                                 </ul>
91
92                                 <div class="tab-content">
93                                     <div id="uploadfile_tab" role="tabpanel" class="tab-pane active">
94                                         <fieldset class="rows">
95                                             <ol>
96                                                 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
97                                             </ol>
98                                         </fieldset>
99                                         &nbsp;
100                                     </div>
101
102                                     [% IF lists.count %]
103                                         <div id="shelves_tab" role="tabpanel" class="tab-pane">
104                                             <fieldset class="rows">
105                                                 <ol>
106                                                     <li>
107                                                         <label for="shelf_number">List: </label>
108                                                         <select name="shelf_number" id="shelf_number">
109                                                             <option value="">Select a list</option>
110                                                             [% FOREACH list IN lists %]
111                                                             <option value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
112                                                             [% END %]
113                                                             </option>
114                                                         </select>
115                                                     </li>
116                                                 </ol>
117                                             </fieldset>
118                                             &nbsp;
119                                         </div>
120                                     [% END %]
121
122                                     <div id="enterlist_tab" role="tabpanel" class="tab-pane">
123                                         <fieldset class="rows">
124                                             <ol>
125                                                 <li>
126                                                     <label for="recordnumber_list">Record numbers: </label>
127                                                     <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
128                                                     <div class="hint">Enter a list of biblionumbers or authority IDs, one per line.</div>
129                                                 </li>
130                                             </ol>
131                                         </fieldset>
132                                         &nbsp;
133                                     </div>
134                                 </div> <!-- /.tab-content -->
135                             </div> <!-- /#batch_mod_form -->
136
137                             <fieldset class="rows">
138                                 <legend>MARC modification template</legend>
139                                 <ol>
140                                     <li>
141                                         <label for="marc_modification_template_id" class="required">Template: </label>
142                                         <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
143                                             <option value="">Select a template</option>
144                                             [% FOREACH mmt IN MarcModificationTemplatesLoop %]
145                                             <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
146                                             [% END %]
147                                         </select>
148                                     </li>
149                                 </ol>
150                             </fieldset>
151                             <fieldset class="action">
152                                 <input type="hidden" name="op" value="list" />
153                                 <input type="submit" value="Continue" class="button" />
154                                 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
155                             </fieldset>
156                         </form> <!-- /#record_ids_selection -->
157                     [% ELSIF view == 'list' %]
158                         [% IF records %]
159                             <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post">
160                                 <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
161                                 <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
162                                     <option value="">Select a template</option>
163                                     [% FOREACH mmt IN MarcModificationTemplatesLoop %]
164                                         [% IF mmt.selected %]
165                                             <option value="[% mmt.template_id | html %]" selected="selected">[% mmt.name | html %]</option>
166                                         [% ELSE %]
167                                             <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
168                                         [% END %]
169                                     [% END %]
170                                 </select>
171                                 <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
172                                     <div class="modal-dialog">
173                                         <div class="modal-content">
174                                             <div class="modal-header">
175                                                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
176                                                 <h3 id="marcPreviewLabel">MARC preview</h3>
177                                             </div>
178                                             <div class="modal-body">
179                                                 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
180                                             </div>
181                                             <div class="modal-footer">
182                                                 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
183                                             </div>
184                                         </div>
185                                     </div>
186                                 </div>
187                                 [% IF recordtype == 'biblio' %]
188                                     <div id="toolbar">
189                                         <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
190                                         | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
191                                     </div>
192                                     <table id="biblios" class="records">
193                                         <thead>
194                                             <tr>
195                                                 <th>&nbsp;</th>
196                                                 <th>Biblionumber</th>
197                                                 <th>Title</th>
198                                                 <th>&nbsp;</th>
199                                             </tr>
200                                         </thead>
201                                         <tbody>
202                                             [% FOR biblio IN records %]
203                                                 <tr>
204                                                     <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber | html %]" /></td>
205                                                     <td>[% biblio.biblionumber | html %]</td>
206                                                     <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
207                                                     <td class="actions">
208                                                         <a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber | uri %]&mmtid=[% mmtid | uri %]&overlay_context=batchmod" class="previewMARC btn btn-default btn-xs" data-record_type="biblio" data-record_id="[% biblio.biblionumber | html %]" data-mmtid="[% mmtid | html %]" title="Preview MARC"><i class="fa fa-eye"></i> Show MARC</a>
209                                                     </td>
210                                                 </tr>
211                                             [% END %]
212                                         </tbody>
213                                     </table> <!-- /#biblios -->
214                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
215                                 [% ELSE %]
216                                     <div id="toolbar">
217                                         <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
218                                         | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
219                                     </div>
220                                     <table id="authorities" class="records">
221                                         <thead>
222                                             <tr>
223                                                 <th></th>
224                                                 <th>AuthID</th>
225                                                 <th>Summary</th>
226                                                 <th>&nbsp;</th>
227                                             </tr>
228                                         </thead>
229                                         <tbody>
230                                             [% FOR authority IN records %]
231                                                 <tr>
232                                                     <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
233                                                     <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
234                                                     <td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td>
235                                                     <td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid | uri %]&mmtid=[% mmtid | uri %]&overlay_context=batchmod" data-record_type="authority" data-record_id="[% authority.authid | html %]" data-mmtid="[% mmtid | html %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a>
236                                                 </tr>
237                                             [% END %]
238                                         </tbody>
239                                     </table> <!-- /#authorities -->
240                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
241                                 [% END %]
242                                 <fieldset class="action">
243                                     <input type="hidden" name="op" value="modify" />
244                                     <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
245                                     <input type="submit" id="mainformsubmit" value="Modify selected records" class="button" />
246                                 </fieldset>
247                             </form> <!-- /#process -->
248                         [% ELSE %]
249                             <div class="dialog message">
250                                 No records were modified. [% IF recordtype != 'biblio' %]<a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>[% END %]
251                             </div>
252                         [% END %]
253                     [% ELSIF view == 'errors' %]
254                         [% FOR error IN errors %]
255                             [% IF error == 'no_template_defined' %]
256                                 <div class="dialog alert">
257                                     No MARC modification template is defined. You have <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">to create</a> at least one template for using this tool.
258                                 </div>
259                             [% END %]
260                         [% END %]
261                      [% ELSIF view == 'enqueued' %]
262                         <div class="dialog message">
263                             <p>The job has been enqueued! It will be processed as soon as possible.</p>
264                             <p><a href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
265                             | <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a></p>
266                         </div>
267                     [% ELSE %]
268                         <div class="dialog alert">
269                             No action defined for the template.
270                         </div>
271                     [% END %]
272                 </main>
273             </div> <!-- /.col-sm-10.col-sm-push-2 -->
274             <div class="col-sm-2 col-sm-pull-10">
275                 <aside>
276                     [% INCLUDE 'tools-menu.inc' %]
277                 </aside>
278             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
279         </div> <!-- /.row -->
280
281 [% MACRO jsinclude BLOCK %]
282     [% Asset.js("js/tools-menu.js") | $raw %]
283     [% INCLUDE 'datatables.inc' %]
284     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
285     <script>
286         $(document).ready(function() {
287
288             $("input[type='radio']").click(function() {
289                 if ($(this).attr('id') == 'authority_type') {
290                     $("#show_list_option").hide();
291                 } else if ($(this).attr('id') == 'biblio_type') {
292                     $("#show_list_option").show();
293                 }
294             });
295
296             $("#selectall").click(function(e){
297                 e.preventDefault();
298                 $(".records input[type='checkbox']").each(function(){
299                     $(this).prop("checked", true);
300                 });
301             });
302
303             $("#clearall").click(function(e){
304                 e.preventDefault();
305                 $(".records input[type='checkbox']").each(function(){
306                     $(this).prop("checked", false);
307                 });
308             });
309
310             $("#selectall").click();
311
312             $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
313                 "aoColumnDefs": [
314                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
315                     { "aTargets": [1], "sType": "num-html" }
316                 ],
317                 "sDom": 't',
318                 "aaSorting": [],
319                 "bPaginate": false
320             }));
321
322             $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
323                 "aoColumnDefs": [
324                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
325                     { "aTargets": [1], "sType": "num-html" }
326                 ],
327                 "sDom": 't',
328                 "aaSorting": [],
329                 "bPaginate": false
330             }));
331
332             $("#mainformsubmit").click(function() {
333                 if ($("input[type=checkbox][name='record_id']:checked").length == 0) {
334                     alert(_("Please select at least one record to process"));
335                     return false;
336                 }
337                 if ($("#marc_modification_template_id").val() <= 0) {
338                     alert(_("Please select a modification template."));
339                     return false;
340                 }
341                 return true;
342             });
343
344             $("#record_ids_selection").on("submit", function(e) {
345                 var tab = $(this).find('#batch_mod_form li.active:first a').attr('href');
346                 if (tab == '#uploadfile_tab') {
347                     $("#shelf_number").empty('');
348                     $("#recordnumber_list").val('');
349                 } else if (tab == '#shelves_tab') {
350                     $("#uploadfile").val('')
351                     $("#recordnumber_list").val('');
352                 } else { // enterlist
353                     $("#uploadfile").val('')
354                     $("#shelf_number").empty('');
355                 }
356             });
357
358             $("#marc_modification_template_id").change(function() {
359                 var url = "/cgi-bin/koha/svc/records/preview?"
360                 var mmtid = $(this).val();
361                 $("a.previewMARC").each(function() {
362                     $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod");
363                 });
364             });
365
366             $("body").on("click", ".previewMARC", function(e) {
367                 e.preventDefault();
368                 var ltitle = $(this).text();
369                 var page = $(this).attr("href");
370                 $("#marcPreviewLabel").text(ltitle);
371                 $("#marcPreview .modal-body").load(page + " div");
372                 $('#marcPreview').modal({ show: true });
373             });
374             $("#marcPreview").on("hidden.bs.modal", function() {
375                 $("#marcPreviewLabel").html("");
376                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
377             });
378         });
379     </script>
380 [% END %]
381
382 [% INCLUDE 'intranet-bottom.inc' %]