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