4 [% PROCESS 'authorities-search-results.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Tools › Batch record modification</title>
7 [% INCLUDE 'doc-head-close.inc' %]
10 <body id="tools_batch_record_modification" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
14 <div id="breadcrumbs">
15 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
16 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
17 <a href="/cgi-bin/koha/tools/batch_record_modification.pl">Batch record modification</a>
20 <div class="main container-fluid">
22 <div class="col-sm-10 col-sm-push-2">
25 <h1>Batch record modification</h1>
28 <div class="dialog message">
30 [% FOREACH message IN messages %]
31 [% IF message.type == 'success' %]
32 <div><i class="fa fa-check success"></i>
33 [% ELSIF message.type == 'warning' %]
34 <div><i class="fa fa-warning warn"></i>
35 [% ELSIF message.type == 'error' %]
36 <div><i class="fa fa-exclamation error"></i>
38 [% IF message.code == 'no_action_defined_for_the_template' %]
39 The selected template (id=[% message.mmtid | html %]) does not exist or no action is defined.
40 [% ELSIF message.code == 'biblio_not_exists' %]
41 Bibliographic record [% message.biblionumber | html %] does not exist in the database.
42 [% ELSIF message.code == 'authority_not_exists' %]
43 Authority record [% message.authid | html %] does not exist in the database.
44 [% ELSIF message.code == 'biblio_not_modified' %]
45 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.
46 [% ELSIF message.code == 'authority_not_modified' %]
47 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.
48 [% ELSIF message.code == 'biblio_modified' %]
49 Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.biblionumber | html %]</a> has successfully been modified.
50 [% ELSIF message.code == 'authority_modified' %]
51 Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has successfully been modified.
53 [% IF message.error %]
54 (The error was: [% message.error | html %]. See the Koha logfile for more information).
62 [% IF view == 'form' %]
63 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="record_ids_selection">
64 <fieldset class="rows">
65 <legend>Record type</legend>
67 <li><label for="biblio_type">Biblios: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
68 <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
74 <div id="batch_mod_form" class="toptabs">
76 <li><a href="#uploadfile_tab">Upload a file</a></li>
77 [% IF lists.count %]<li id="show_list_option"><a href="#shelves_tab">Select a list of records</a></li>[% END %]
78 <li><a href="#enterlist_tab">Enter a list of record numbers</a></li>
81 <div id="uploadfile_tab">
82 <fieldset class="rows">
83 <legend>Use a file</legend>
85 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
92 <div id="shelves_tab">
93 <fieldset class="rows">
94 <legend>Or select a list of records</legend>
97 <label for="shelf_number">Use records from the following list: </label>
98 <select name="shelf_number" id="shelf_number">
99 <option value="">Select a list</option>
100 [% FOREACH list IN lists %]
101 <option value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
112 <div id="enterlist_tab">
113 <fieldset class="rows">
114 <legend>Or enter a list of record numbers</legend>
117 <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
118 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
127 <fieldset class="rows">
128 <legend>Use MARC Modification Template:</legend>
131 <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
132 <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
133 <option value="">Select a template</option>
134 [% FOREACH mmt IN MarcModificationTemplatesLoop %]
135 <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
141 <fieldset class="action">
142 <input type="hidden" name="op" value="list" />
143 <input type="submit" value="Continue" class="button" />
144 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
147 [% ELSIF view == 'list' %]
149 <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post" id="process">
150 <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
151 <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
152 <option value="">Select a template</option>
153 [% FOREACH mmt IN MarcModificationTemplatesLoop %]
154 [% IF mmt.selected %]
155 <option value="[% mmt.template_id | html %]" selected="selected">[% mmt.name | html %]</option>
157 <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
161 <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
162 <div class="modal-dialog">
163 <div class="modal-content">
164 <div class="modal-header">
165 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
166 <h3 id="marcPreviewLabel">MARC preview</h3>
168 <div class="modal-body">
169 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
171 <div class="modal-footer">
172 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
177 [% IF recordtype == 'biblio' %]
179 <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
180 | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
182 <table id="biblios" class="records">
186 <th>Biblionumber</th>
192 [% FOR biblio IN records %]
194 <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber | html %]" /></td>
195 <td>[% biblio.biblionumber | html %]</td>
196 <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
198 <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>
204 <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
207 <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
208 | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
210 <table id="authorities" class="records">
220 [% FOR authority IN records %]
222 <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
223 <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
224 <td>[% PROCESS authresult summary=authority.summary %]</td>
225 <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>
230 <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
232 <fieldset class="action">
233 <input type="hidden" name="op" value="modify" />
234 <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
235 <input type="button" id="mainformsubmit" value="Modify selected records" class="button" />
236 <input type="hidden" name="runinbackground" id="runinbackground" value="" />
237 <input type="hidden" name="completedJobID" id="completedJobID" value="" />
238 <a class="cancel" href="/cgi-bin/koha/tools/batch_record_modification.pl">Cancel</a>
241 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
242 <div id="jobfailed"></div>
246 <div class="dialog message">
247 No records were modified. <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
250 [% ELSIF view == 'report' %]
251 [% IF report.total_records == report.total_success %]
252 <div class="dialog message">
253 All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
256 <div class="dialog message">
257 [% 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>
260 [% ELSIF view == 'errors' %]
261 [% FOR error IN errors %]
262 [% IF error == 'no_template_defined' %]
263 <div class="dialog alert">
264 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.
269 <div class="dialog alert">
270 No action defined for the template.
274 </div> <!-- /.col-sm-10.col-sm-push-2 -->
276 <div class="col-sm-2 col-sm-pull-10">
278 [% INCLUDE 'tools-menu.inc' %]
280 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
281 </div> <!-- /.row -->
283 [% MACRO jsinclude BLOCK %]
284 [% Asset.js("js/tools-menu.js") | $raw %]
285 [% INCLUDE 'datatables.inc' %]
286 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
287 [% Asset.js("js/background-job-progressbar.js") | $raw %]
289 $(document).ready(function() {
291 $("#batch_mod_form").tabs();
293 $("input[type='radio']").click(function(){
294 if ($(this).attr('id') == 'authority_type') {
295 $("#show_list_option").hide();
296 } else if ($(this).attr('id') == 'biblio_type') {
297 $("#show_list_option").show();
300 $("#selectall").click(function(e){
302 $(".records").checkCheckboxes();
304 $("#clearall").click(function(e){
306 $(".records").unCheckCheckboxes();
308 $("#selectall").click();
310 $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
312 { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
313 { "aTargets": [ 1 ], "sType": "num-html" }
320 $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
322 { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
323 { "aTargets": [ 1 ], "sType": "num-html" }
330 $("#mainformsubmit").click(function(){
331 if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
332 alert(_("Please select at least one record to process"));
335 if ( $("#marc_modification_template_id").val() <= 0 ) {
336 alert(_("Please select a modification template."));
339 return submitBackgroundJob(document.getElementById("process"));
342 $("#record_ids_selection").on("submit", function(e){
343 var tab = $(this).find('.ui-tabs-active:first a').attr('href');
344 if ( tab == '#uploadfile_tab' ) {
345 $("#shelf_number").empty('');
346 $("#recordnumber_list").val('');
347 } else if ( tab == '#shelves_tab' ) {
348 $("#uploadfile").val('')
349 $("#recordnumber_list").val('');
350 } else { // enterlist
351 $("#uploadfile").val('')
352 $("#shelf_number").empty('');
356 $("#marc_modification_template_id").change(function(){
357 var url = "/cgi-bin/koha/svc/records/preview?"
358 var mmtid = $(this).val();
359 $("a.previewMARC").each(function(){
360 $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
364 $("body").on("click",".previewMARC", function(e){
366 var ltitle = $(this).text();
367 var page = $(this).attr("href");
368 $("#marcPreviewLabel").text(ltitle);
369 $("#marcPreview .modal-body").load(page + " div");
370 $('#marcPreview').modal({show:true});
372 $("#marcPreview").on("hidden.bs.modal", function(){
373 $("#marcPreviewLabel").html("");
374 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
381 [% INCLUDE 'intranet-bottom.inc' %]