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