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