Bug 21186: Incorrect Bootstrap modal event name in multiple templates
[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/datatables.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 id="doc3" class="yui-t2">
22 <div id="bd">
23 <div id="yui-main">
24 <div class="yui-b">
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">
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       <fieldset class="rows">
72         <legend>Use a file</legend>
73         <ol>
74           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
75         </ol>
76       </fieldset>
77       <fieldset class="rows">
78         <legend>Or enter a list of record numbers</legend>
79         <ol>
80           <li>
81             <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
82             <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
83           </li>
84         </ol>
85       </fieldset>
86       <fieldset class="rows">
87         <legend>Use MARC Modification Template:</legend>
88         <ol>
89           <li>
90             <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
91             <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
92               <option value="">Select a template</option>
93                 [% FOREACH mmt IN MarcModificationTemplatesLoop %]
94                   <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
95                 [% END %]
96             </select>
97           </li>
98         </ol>
99       </fieldset>
100       <fieldset class="action">
101         <input type="hidden" name="op" value="list" />
102         <input type="submit" value="Continue" class="button" />
103         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
104       </fieldset>
105     </form>
106   [% ELSIF view == 'list' %]
107     [% IF records %]
108       <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post" id="process">
109         <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
110         <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
111           <option value="">Select a template</option>
112           [% FOREACH mmt IN MarcModificationTemplatesLoop %]
113             [% IF mmt.selected %]
114               <option value="[% mmt.template_id | html %]" selected="selected">[% mmt.name | html %]</option>
115             [% ELSE %]
116               <option value="[% mmt.template_id | html %]">[% mmt.name | html %]</option>
117             [% END %]
118           [% END %]
119         </select>
120         <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
121             <div class="modal-dialog">
122                 <div class="modal-content">
123                     <div class="modal-header">
124                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
125                         <h3 id="marcPreviewLabel">MARC preview</h3>
126                     </div>
127                     <div class="modal-body">
128                         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
129                     </div>
130                     <div class="modal-footer">
131                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
132                     </div>
133                 </div>
134             </div>
135         </div>
136         [% IF recordtype == 'biblio' %]
137           <div id="toolbar">
138             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
139             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
140           </div>
141           <table id="biblios" class="records">
142             <thead>
143               <tr>
144                 <th>&nbsp;</th>
145                 <th>Biblionumber</th>
146                 <th>Title</th>
147                 <th>&nbsp;</th>
148               </tr>
149             </thead>
150             <tbody>
151               [% FOR biblio IN records %]
152                 <tr>
153                   <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber | html %]" /></td>
154                   <td>[% biblio.biblionumber | html %]</td>
155                   <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
156                   <td class="actions">
157                     <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>
158                   </td>
159                 </tr>
160               [% END %]
161             </tbody>
162           </table>
163           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
164         [% ELSE %]
165           <div id="toolbar">
166             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
167             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
168           </div>
169           <table id="authorities" class="records">
170             <thead>
171               <tr>
172                 <th></th>
173                 <th>Authid</th>
174                 <th>Summary</th>
175                 <th>&nbsp;</th>
176               </tr>
177             </thead>
178             <tbody>
179               [% FOR authority IN records %]
180                 <tr>
181                   <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
182                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
183                   <td>[% PROCESS authresult summary=authority.summary %]</td>
184                   <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>
185                 </tr>
186               [% END %]
187             </tbody>
188           </table>
189           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
190         [% END %]
191         <fieldset class="action">
192           <input type="hidden" name="op" value="modify" />
193           <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
194           <input type="button" id="mainformsubmit" value="Modify selected records" class="button" />
195           <input type="hidden" name="runinbackground" id="runinbackground" value="" />
196           <input type="hidden" name="completedJobID" id="completedJobID" value="" />
197           <a class="cancel" href="/cgi-bin/koha/tools/batch_record_modification.pl">Cancel</a>
198         </fieldset>
199         <div id="jobpanel">
200           <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
201           <div id="jobfailed"></div>
202         </div>
203       </form>
204     [% ELSE %]
205         <div class="dialog message">
206             No records were modified. <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
207         </div>
208     [% END %]
209   [% ELSIF view == 'report' %]
210     [% IF report.total_records == report.total_success %]
211         <div class="dialog message">
212             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>
213         </div>
214     [% ELSE %]
215         <div class="dialog message">
216             [% 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>
217         </div>
218     [% END %]
219   [% ELSIF view == 'errors' %]
220     [% FOR error IN errors %]
221       [% IF error == 'no_template_defined' %]
222         <div class="dialog alert">
223             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.
224         </div>
225       [% END %]
226     [% END %]
227   [% ELSE %]
228         <div class="dialog alert">
229             No action defined for the template.
230         </div>
231   [% END %]
232 </div>
233 </div>
234 <div class="yui-b">
235   [% INCLUDE 'tools-menu.inc' %]
236 </div>
237 </div>
238
239 [% MACRO jsinclude BLOCK %]
240     [% Asset.js("js/tools-menu.js") | $raw %]
241     [% INCLUDE 'datatables.inc' %]
242     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
243     [% Asset.js("js/background-job-progressbar.js") | $raw %]
244     <script type="text/javascript">
245         $(document).ready(function() {
246           $("#selectall").click(function(e){
247             e.preventDefault();
248             $(".records").checkCheckboxes();
249           });
250           $("#clearall").click(function(e){
251             e.preventDefault();
252             $(".records").unCheckCheckboxes();
253           });
254           $("#selectall").click();
255
256           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
257             "aoColumnDefs": [
258               { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
259               { "aTargets": [ 1 ], "sType": "num-html" }
260             ],
261             "sDom": 't',
262             "aaSorting": [],
263             "bPaginate": false
264           }));
265
266           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
267             "aoColumnDefs": [
268               { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
269               { "aTargets": [ 1 ], "sType": "num-html" }
270             ],
271             "sDom": 't',
272             "aaSorting": [],
273             "bPaginate": false
274           }));
275
276           $("#mainformsubmit").click(function(){
277             if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
278               alert(_("Please select at least one record to process"));
279               return false;
280             }
281             if ( $("#marc_modification_template_id").val() <= 0 ) {
282               alert(_("Please select a modification template."));
283               return false;
284             }
285             return submitBackgroundJob(document.getElementById("process"));
286           });
287
288           $("#marc_modification_template_id").change(function(){
289             var url = "/cgi-bin/koha/svc/records/preview?"
290             var mmtid = $(this).val();
291             $("a.previewMARC").each(function(){
292               $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
293             });
294           });
295
296             $("body").on("click",".previewMARC", function(e){
297                 e.preventDefault();
298                 var ltitle = $(this).text();
299                 var page = $(this).attr("href");
300                 $("#marcPreviewLabel").text(ltitle);
301                 $("#marcPreview .modal-body").load(page + " div");
302                 $('#marcPreview').modal({show:true});
303             });
304             $("#marcPreview").on("hidden.bs.modal", function(){
305                 $("#marcPreviewLabel").html("");
306                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
307             });
308
309         });
310     </script>
311 [% END %]
312
313 [% INCLUDE 'intranet-bottom.inc' %]