Bug 25626: Fix untranslatable strings on the 'OPAC problem reports' admin
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_record_modification.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% PROCESS 'authorities-search-results.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Tools &rsaquo; Batch record modification</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("css/humanmsg.css") | $raw %]
9 </head>
10
11 <body id="tools_batch_record_modification" class="tools">
12     [% INCLUDE 'header.inc' %]
13     [% INCLUDE 'cat-search.inc' %]
14
15     <div id="breadcrumbs">
16         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
17         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
18         <a href="/cgi-bin/koha/tools/batch_record_modification.pl">Batch record modification</a>
19     </div>
20
21     <div class="main container-fluid">
22         <div class="row">
23             <div class="col-sm-10 col-sm-push-2">
24                 <main>
25
26                     <h1>Batch record modification</h1>
27
28                     [% IF ( messages ) %]
29                         <div class="dialog message">
30
31                             [% FOREACH message IN messages %]
32                                 [% IF message.type == 'success' %]
33                                     <div><i class="fa fa-check success"></i>
34                                 [% ELSIF message.type == 'warning' %]
35                                     <div><i class="fa fa-warning warn"></i>
36                                 [% ELSIF message.type == 'error' %]
37                                     <div><i class="fa fa-exclamation error"></i>
38                                 [% END %]
39                                 [% IF message.code == 'no_action_defined_for_the_template' %]
40                                     The selected template (id=[% message.mmtid | html %]) does not exist or no action is defined.
41                                 [% ELSIF message.code == 'biblio_not_exists' %]
42                                     Bibliographic record [% message.biblionumber | html %] does not exist in the database.
43                                 [% ELSIF message.code == 'authority_not_exists' %]
44                                     Authority record [% message.authid | html %] does not exist in the database.
45                                 [% ELSIF message.code == 'biblio_not_modified' %]
46                                     Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.biblionumber | html %]</a> has not been modified. An error occurred on modifying it.
47                                 [% ELSIF message.code == 'authority_not_modified' %]
48                                     Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has not been modified. An error occurred on modifying it.
49                                 [% ELSIF message.code == 'biblio_modified' %]
50                                     Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.biblionumber | html %]</a> has successfully been modified.
51                                 [% ELSIF message.code == 'authority_modified' %]
52                                     Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has successfully been modified.
53                                 [% END %]
54                                 [% IF message.error %]
55                                     (The error was: [% message.error | html %]. See the Koha logfile for more information).
56                                 [% END %]
57                                 </div>
58                             [% END %]
59
60                         </div> <!-- /.dialog.message -->
61                     [% END %]
62
63                     [% IF view == 'form' %]
64                         <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="record_ids_selection">
65                             <fieldset class="rows">
66                                 <legend>Record type</legend>
67                                 <ol>
68                                     <li><label for="biblio_type">Biblios: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
69                                     <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
70                                 </ol>
71                             </fieldset>
72
73                             <br><br>
74
75                             <div id="batch_mod_form" class="toptabs" style="clear:both">
76                                 <ul>
77                                     <li><a href="#uploadfile_tab">Upload a file</a></li>
78                                         [% IF lists.count %]<li id="show_list_option"><a href="#shelves_tab">Select a list of records</a></li>[% END %]
79                                     <li><a href="#enterlist_tab">Enter a list of record numbers</a></li>
80                                 </ul>
81
82                                 <div id="uploadfile_tab">
83                                     <fieldset class="rows">
84                                         <legend>Use a file</legend>
85                                         <ol>
86                                             <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
87                                         </ol>
88                                     </fieldset>
89                                     &nbsp;
90                                 </div>
91
92                                 [% IF lists.count %]
93                                     <div id="shelves_tab">
94                                         <fieldset class="rows">
95                                             <legend>Or select a list of records</legend>
96                                             <ol>
97                                                 <li>
98                                                     <label for="shelf_number">Use records from the following list: </label>
99                                                     <select name="shelf_number" id="shelf_number">
100                                                         <option value="">Select a list</option>
101                                                         [% FOREACH list IN lists %]
102                                                         <option value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
103                                                         [% END %]
104                                                         </option>
105                                                     </select>
106                                                 </li>
107                                             </ol>
108                                         </fieldset>
109                                         &nbsp;
110                                     </div>
111                                 [% END %]
112
113                                 <div id="enterlist_tab">
114                                     <fieldset class="rows">
115                                         <legend>Or enter a list of record numbers</legend>
116                                         <ol>
117                                             <li>
118                                                 <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
119                                                 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
120                                             </li>
121                                         </ol>
122                                     </fieldset>
123                                     &nbsp;
124                                 </div>
125
126                             </div> <!-- /#batch_mod_form -->
127
128                             <fieldset class="rows">
129                                 <legend>Use MARC Modification Template:</legend>
130                                 <ol>
131                                     <li>
132                                         <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
133                                         <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
134                                             <option value="">Select a template</option>
135                                             [% FOREACH mmt IN MarcModificationTemplatesLoop %]
136                                             <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
137                                             [% END %]
138                                         </select>
139                                     </li>
140                                 </ol>
141                             </fieldset>
142                             <fieldset class="action">
143                                 <input type="hidden" name="op" value="list" />
144                                 <input type="submit" value="Continue" class="button" />
145                                 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
146                             </fieldset>
147                         </form> <!-- /#record_ids_selection -->
148                     [% ELSIF view == 'list' %]
149                         [% IF records %]
150                             <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post" id="process">
151                                 <label for="marc_modification_template_id" class="required">Modify record using the following 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                                         [% IF mmt.selected %]
156                                             <option value="[% mmt.template_id | html %]" selected="selected">[% mmt.name | html %]</option>
157                                         [% ELSE %]
158                                             <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
159                                         [% END %]
160                                     [% END %]
161                                 </select>
162                                 <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
163                                     <div class="modal-dialog">
164                                         <div class="modal-content">
165                                             <div class="modal-header">
166                                                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
167                                                 <h3 id="marcPreviewLabel">MARC preview</h3>
168                                             </div>
169                                             <div class="modal-body">
170                                                 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
171                                             </div>
172                                             <div class="modal-footer">
173                                                 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
174                                             </div>
175                                         </div>
176                                     </div>
177                                 </div>
178                                 [% IF recordtype == 'biblio' %]
179                                     <div id="toolbar">
180                                         <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
181                                         | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
182                                     </div>
183                                     <table id="biblios" class="records">
184                                         <thead>
185                                             <tr>
186                                                 <th>&nbsp;</th>
187                                                 <th>Biblionumber</th>
188                                                 <th>Title</th>
189                                                 <th>&nbsp;</th>
190                                             </tr>
191                                         </thead>
192                                         <tbody>
193                                             [% FOR biblio IN records %]
194                                                 <tr>
195                                                     <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber | html %]" /></td>
196                                                     <td>[% biblio.biblionumber | html %]</td>
197                                                     <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
198                                                     <td class="actions">
199                                                         <a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber | uri %]&mmtid=[% mmtid | uri %]" class="previewMARC btn btn-default btn-xs" data-record_type="biblio" data-record_id="[% biblio.biblionumber | html %]" data-mmtid="[% mmtid | html %]" title="Preview MARC"><i class="fa fa-eye"></i> Show MARC</a>
200                                                     </td>
201                                                 </tr>
202                                             [% END %]
203                                         </tbody>
204                                     </table> <!-- /#biblios -->
205                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
206                                 [% ELSE %]
207                                     <div id="toolbar">
208                                         <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
209                                         | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
210                                     </div>
211                                     <table id="authorities" class="records">
212                                         <thead>
213                                             <tr>
214                                                 <th></th>
215                                                 <th>Authid</th>
216                                                 <th>Summary</th>
217                                                 <th>&nbsp;</th>
218                                             </tr>
219                                         </thead>
220                                         <tbody>
221                                             [% FOR authority IN records %]
222                                                 <tr>
223                                                     <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
224                                                     <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
225                                                     <td>[% PROCESS authresult summary=authority.summary %]</td>
226                                                     <td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid | uri %]&mmtid=[% mmtid | uri %]" data-record_type="authority" data-record_id="[% authority.authid | html %]" data-mmtid="[% mmtid | html %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a>
227                                                 </tr>
228                                             [% END %]
229                                         </tbody>
230                                     </table> <!-- /#authorities -->
231                                     <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
232                                 [% END %]
233                                 <fieldset class="action">
234                                     <input type="hidden" name="op" value="modify" />
235                                     <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
236                                     <input type="button" id="mainformsubmit" value="Modify selected records" class="button" />
237                                     <input type="hidden" name="runinbackground" id="runinbackground" value="" />
238                                     <input type="hidden" name="completedJobID" id="completedJobID" value="" />
239                                     <a class="cancel" href="/cgi-bin/koha/tools/batch_record_modification.pl">Cancel</a>
240                                 </fieldset>
241                                 <div id="jobpanel">
242                                     <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
243                                     <div id="jobfailed"></div>
244                                 </div>
245                             </form> <!-- /#process -->
246                         [% ELSE %]
247                             <div class="dialog message">
248                                 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 %]
249                             </div>
250                         [% END %]
251                     [% ELSIF view == 'report' %]
252                         [% IF report.total_records == report.total_success %]
253                             <div class="dialog message">
254                                 All records have successfully been 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 %]
255                             </div>
256                         [% ELSE %]
257                             <div class="dialog message">
258                                 [% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred. <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
259                             </div>
260                         [% END %]
261
262                         [% IF recordtype == 'biblio' %]
263                             <h3>Next steps</h3>
264                             <ul>
265                                 <li><a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
266                                 [% IF lists.count %]
267                                 <li>
268                                     <label for="add_bibs_to_list">Add modified records to the following list: </label>
269                                     <select name="add_bibs_to_list" id="add_bibs_to_list">
270                                         <option value="">Select a list</option>
271                                         [% FOREACH list IN lists %]
272                                             <option class="shelf" value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
273                                         [% END %]
274                                     </select>
275                                 </li>
276                                 [% END %]
277                             </ul>
278                         [% END %]
279                     [% ELSIF view == 'errors' %]
280                         [% FOR error IN errors %]
281                             [% IF error == 'no_template_defined' %]
282                                 <div class="dialog alert">
283                                     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.
284                                 </div>
285                             [% END %]
286                         [% END %]
287                     [% ELSE %]
288                         <div class="dialog alert">
289                             No action defined for the template.
290                         </div>
291                     [% END %]
292                 </main>
293             </div> <!-- /.col-sm-10.col-sm-push-2 -->
294
295             <div class="col-sm-2 col-sm-pull-10">
296                 <aside>
297                     [% INCLUDE 'tools-menu.inc' %]
298                 </aside>
299             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
300         </div> <!-- /.row -->
301
302 [% MACRO jsinclude BLOCK %]
303     [% Asset.js("js/tools-menu.js") | $raw %]
304     [% INCLUDE 'datatables.inc' %]
305     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
306     [% Asset.js("js/background-job-progressbar.js") | $raw %]
307     <script>
308         $(document).ready(function() {
309
310             $("#batch_mod_form").tabs();
311
312             $("input[type='radio']").click(function() {
313                 if ($(this).attr('id') == 'authority_type') {
314                     $("#show_list_option").hide();
315                 } else if ($(this).attr('id') == 'biblio_type') {
316                     $("#show_list_option").show();
317                 }
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 submitBackgroundJob(document.getElementById("process"));
366             });
367
368             $("#record_ids_selection").on("submit", function(e) {
369                 var tab = $(this).find('.ui-tabs-active:first a').attr('href');
370                 if (tab == '#uploadfile_tab') {
371                     $("#shelf_number").empty('');
372                     $("#recordnumber_list").val('');
373                 } else if (tab == '#shelves_tab') {
374                     $("#uploadfile").val('')
375                     $("#recordnumber_list").val('');
376                 } else { // enterlist
377                     $("#uploadfile").val('')
378                     $("#shelf_number").empty('');
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);
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             $("#add_bibs_to_list").change(function(){
404                 var selected = $("#add_bibs_to_list").find("option:selected");
405                 if ( selected.attr("class") == "shelf" ){
406                     var shelfnumber = selected.attr("value");
407                     var bibs = new Array();
408                     [% FOREACH message IN messages %]
409                         [% IF message.code == 'biblio_modified' %]
410                             bibs.push("biblionumber="+[% message.biblionumber | html %]);
411                         [% END %]
412                     [% END %]
413                     var bibstring = bibs.join("&");
414                     window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&'+bibstring, 'popup', 'width=500,height=500,toolbar=false,scrollbars=yes,resizeable=yes');
415                     return false;
416                 }
417             });
418
419         });
420     </script>
421 [% END %]
422
423 [% INCLUDE 'intranet-bottom.inc' %]