Bug 22015: Move DataTables CSS to global include
[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 </head>
9
10 <body id="tools_batch_record_modification" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
13
14 <div id="breadcrumbs">
15     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
16     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
17     <a href="/cgi-bin/koha/tools/batch_record_modification.pl">Batch record modification</a>
18 </div>
19
20 <div class="main container-fluid">
21     <div class="row">
22         <div class="col-sm-10 col-sm-push-2">
23             <main>
24
25   <h1>Batch record modification</h1>
26
27     [% IF ( messages ) %]
28         <div class="dialog message">
29
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>
37                 [% END %]
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.
52                 [% END %]
53                 [% IF message.error %]
54                     (The error was: [% message.error | html %]. See the Koha logfile for more information).
55                 [% END %]
56                 </div>
57             [% END %]
58
59         </div>
60     [% END %]
61
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>
66         <ol>
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>
69         </ol>
70       </fieldset>
71
72       <br><br>
73
74       <div id="batch_mod_form" class="toptabs">
75         <ul>
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>
79         </ul>
80
81         <div id="uploadfile_tab">
82           <fieldset class="rows">
83             <legend>Use a file</legend>
84             <ol>
85               <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
86             </ol>
87           </fieldset>
88           &nbsp;
89         </div>
90
91         [% IF lists.count %]
92             <div id="shelves_tab">
93               <fieldset class="rows">
94                 <legend>Or select a list of records</legend>
95                 <ol>
96                   <li>
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>
102                         [% END %]
103                       </option>
104                     </select>
105                   </li>
106                 </ol>
107               </fieldset>
108               &nbsp;
109             </div>
110         [% END %]
111
112         <div id="enterlist_tab">
113           <fieldset class="rows">
114             <legend>Or enter a list of record numbers</legend>
115             <ol>
116               <li>
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>
119               </li>
120             </ol>
121           </fieldset>
122           &nbsp;
123         </div>
124
125       </div>
126
127       <fieldset class="rows">
128         <legend>Use MARC Modification Template:</legend>
129         <ol>
130           <li>
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>
136                 [% END %]
137             </select>
138           </li>
139         </ol>
140       </fieldset>
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>
145       </fieldset>
146     </form>
147   [% ELSIF view == 'list' %]
148     [% IF records %]
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>
156             [% ELSE %]
157               <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
158             [% END %]
159           [% END %]
160         </select>
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>
167                     </div>
168                     <div class="modal-body">
169                         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
170                     </div>
171                     <div class="modal-footer">
172                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
173                     </div>
174                 </div>
175             </div>
176         </div>
177         [% IF recordtype == 'biblio' %]
178           <div id="toolbar">
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>
181           </div>
182           <table id="biblios" class="records">
183             <thead>
184               <tr>
185                 <th>&nbsp;</th>
186                 <th>Biblionumber</th>
187                 <th>Title</th>
188                 <th>&nbsp;</th>
189               </tr>
190             </thead>
191             <tbody>
192               [% FOR biblio IN records %]
193                 <tr>
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>
197                   <td class="actions">
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>
199                   </td>
200                 </tr>
201               [% END %]
202             </tbody>
203           </table>
204           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
205         [% ELSE %]
206           <div id="toolbar">
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>
209           </div>
210           <table id="authorities" class="records">
211             <thead>
212               <tr>
213                 <th></th>
214                 <th>Authid</th>
215                 <th>Summary</th>
216                 <th>&nbsp;</th>
217               </tr>
218             </thead>
219             <tbody>
220               [% FOR authority IN records %]
221                 <tr>
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>
226                 </tr>
227               [% END %]
228             </tbody>
229           </table>
230           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
231         [% END %]
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>
239         </fieldset>
240         <div id="jobpanel">
241           <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
242           <div id="jobfailed"></div>
243         </div>
244       </form>
245     [% ELSE %]
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>
248         </div>
249     [% END %]
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>
254         </div>
255     [% ELSE %]
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>
258         </div>
259     [% END %]
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.
265         </div>
266       [% END %]
267     [% END %]
268   [% ELSE %]
269         <div class="dialog alert">
270             No action defined for the template.
271         </div>
272   [% END %]
273             </main>
274         </div> <!-- /.col-sm-10.col-sm-push-2 -->
275
276         <div class="col-sm-2 col-sm-pull-10">
277             <aside>
278                 [% INCLUDE 'tools-menu.inc' %]
279             </aside>
280         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
281      </div> <!-- /.row -->
282
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 %]
288     <script>
289         $(document).ready(function() {
290
291           $("#batch_mod_form").tabs();
292
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();
298             }
299           });
300           $("#selectall").click(function(e){
301             e.preventDefault();
302             $(".records").checkCheckboxes();
303           });
304           $("#clearall").click(function(e){
305             e.preventDefault();
306             $(".records").unCheckCheckboxes();
307           });
308           $("#selectall").click();
309
310           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
311             "aoColumnDefs": [
312               { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
313               { "aTargets": [ 1 ], "sType": "num-html" }
314             ],
315             "sDom": 't',
316             "aaSorting": [],
317             "bPaginate": false
318           }));
319
320           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
321             "aoColumnDefs": [
322               { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
323               { "aTargets": [ 1 ], "sType": "num-html" }
324             ],
325             "sDom": 't',
326             "aaSorting": [],
327             "bPaginate": false
328           }));
329
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"));
333               return false;
334             }
335             if ( $("#marc_modification_template_id").val() <= 0 ) {
336               alert(_("Please select a modification template."));
337               return false;
338             }
339             return submitBackgroundJob(document.getElementById("process"));
340           });
341
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('');
353             }
354           });
355
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);
361             });
362           });
363
364             $("body").on("click",".previewMARC", function(e){
365                 e.preventDefault();
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});
371             });
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>");
375             });
376
377         });
378     </script>
379 [% END %]
380
381 [% INCLUDE 'intranet-bottom.inc' %]