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