Bug 32164: Add link to MARC modification templates from batch record modification...
[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" class="btn btn-primary" value="Continue" />
166                                 <a class="cancel" href="/cgi-bin/koha/cataloguing/cataloging-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 class="btn-toolbar selections-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                                     <div class="page-section">
205                                         <table id="biblios" class="records">
206                                             <thead>
207                                                 <tr>
208                                                     <th>&nbsp;</th>
209                                                     <th>Biblionumber</th>
210                                                     <th>Title</th>
211                                                     <th>&nbsp;</th>
212                                                 </tr>
213                                             </thead>
214                                             <tbody>
215                                                 [% FOR biblio IN records %]
216                                                     <tr>
217                                                         <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber | html %]" /></td>
218                                                         <td>[% biblio.biblionumber | html %]</td>
219                                                         <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
220                                                         <td class="actions">
221                                                             <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>
222                                                         </td>
223                                                     </tr>
224                                                 [% END %]
225                                             </tbody>
226                                         </table> <!-- /#biblios -->
227                                     </div>
228                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
229                                 [% ELSE %]
230                                     <div class="btn-toolbar selections-toolbar">
231                                         <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
232                                         | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
233                                     </div>
234                                     <div class="page-section">
235                                         <table id="authorities" class="records">
236                                             <thead>
237                                                 <tr>
238                                                     <th></th>
239                                                     <th>AuthID</th>
240                                                     <th>Summary</th>
241                                                     <th>&nbsp;</th>
242                                                 </tr>
243                                             </thead>
244                                             <tbody>
245                                                 [% FOR authority IN records %]
246                                                     <tr>
247                                                         <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
248                                                         <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
249                                                         <td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td>
250                                                         <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>
251                                                     </tr>
252                                                 [% END %]
253                                             </tbody>
254                                         </table> <!-- /#authorities -->
255                                     </div>
256                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
257                                 [% END %]
258                                 <fieldset class="action">
259                                     <input type="hidden" name="op" value="modify" />
260                                     <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
261                                     <input type="submit" id="mainformsubmit" value="Modify selected records" class="button" />
262                                 </fieldset>
263                             </form> <!-- /#process -->
264                         [% ELSE %]
265                             <div class="dialog message">
266                                 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 %]
267                             </div>
268                         [% END %]
269                     [% ELSIF view == 'errors' %]
270                         [% FOR error IN errors %]
271                             [% IF error == 'no_template_defined' %]
272                                 <div class="dialog message">
273                                     <p>No MARC modification template is defined. You have to create at least one template in order to use this tool.</p>
274                                     [% IF ( CAN_user_tools_marc_modification_templates ) %]
275                                         <a class="btn btn-default" href="/cgi-bin/koha/tools/marc_modification_templates.pl"><i class="fa fa-plus"></i> Create a new MARC modification template</a>
276                                     [% END %]
277                                 </div>
278                             [% END %]
279                         [% END %]
280                      [% ELSIF view == 'enqueued' %]
281                         <div class="dialog message">
282                             <p>The job has been enqueued! It will be processed as soon as possible.</p>
283                             <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>
284                             | <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a></p>
285                         </div>
286                     [% ELSE %]
287                         <div class="dialog alert">
288                             No action defined for the template.
289                         </div>
290                     [% END %]
291                 </main>
292             </div> <!-- /.col-sm-10.col-sm-push-2 -->
293             <div class="col-sm-2 col-sm-pull-10">
294                 <aside>
295                     [% INCLUDE 'cat-menu.inc' %]
296                 </aside>
297             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
298         </div> <!-- /.row -->
299
300 [% MACRO jsinclude BLOCK %]
301     [% INCLUDE 'datatables.inc' %]
302     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
303     <script>
304         $(document).ready(function() {
305
306             $("input[type='radio']").click(function() {
307                 if ($(this).attr('id') == 'authority_type') {
308                     $("#show_list_option").hide();
309                 } else if ($(this).attr('id') == 'biblio_type') {
310                     $("#show_list_option").show();
311                 }
312             });
313
314             $("#selectall").click(function(e){
315                 e.preventDefault();
316                 $(".records input[type='checkbox']").each(function(){
317                     $(this).prop("checked", true);
318                 });
319             });
320
321             $("#clearall").click(function(e){
322                 e.preventDefault();
323                 $(".records input[type='checkbox']").each(function(){
324                     $(this).prop("checked", false);
325                 });
326             });
327
328             $("#selectall").click();
329
330             $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
331                 "aoColumnDefs": [
332                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
333                     { "aTargets": [1], "sType": "num-html" }
334                 ],
335                 "sDom": 't',
336                 "aaSorting": [],
337                 "bPaginate": false
338             }));
339
340             $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
341                 "aoColumnDefs": [
342                     { "aTargets": [0, 3], "bSortable": false, "bSearchable": false },
343                     { "aTargets": [1], "sType": "num-html" }
344                 ],
345                 "sDom": 't',
346                 "aaSorting": [],
347                 "bPaginate": false
348             }));
349
350             $("#mainformsubmit").click(function() {
351                 if ($("input[type=checkbox][name='record_id']:checked").length == 0) {
352                     alert(_("Please select at least one record to process"));
353                     return false;
354                 }
355                 if ($("#marc_modification_template_id").val() <= 0) {
356                     alert(_("Please select a modification template."));
357                     return false;
358                 }
359                 return true;
360             });
361
362             $("#record_ids_selection").on("submit", function(e) {
363                 var tab = $(this).find('#batch_mod_form li.active:first a').attr('href');
364                 if (tab == '#uploadfile_tab') {
365                     $("#shelf_number").empty('');
366                     $("#recordnumber_list").val('');
367                 } else if (tab == '#shelves_tab') {
368                     $("#uploadfile").val('')
369                     $("#recordnumber_list").val('');
370                 } else { // enterlist
371                     $("#uploadfile").val('')
372                     $("#shelf_number").empty('');
373                 }
374             });
375
376             $("#marc_modification_template_id").change(function() {
377                 var url = "/cgi-bin/koha/svc/records/preview?"
378                 var mmtid = $(this).val();
379                 $("a.previewMARC").each(function() {
380                     $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod");
381                 });
382             });
383
384             $("body").on("click", ".previewMARC", function(e) {
385                 e.preventDefault();
386                 var ltitle = $(this).text();
387                 var page = $(this).attr("href");
388                 $("#marcPreviewLabel").text(ltitle);
389                 $("#marcPreview .modal-body").load(page + " div");
390                 $('#marcPreview').modal({ show: true });
391             });
392             $("#marcPreview").on("hidden.bs.modal", function() {
393                 $("#marcPreviewLabel").html("");
394                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
395             });
396         });
397     </script>
398 [% END %]
399
400 [% INCLUDE 'intranet-bottom.inc' %]