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