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 [% PROCESS 'authorities-search-results.inc' %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Batch record modification</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6 [% INCLUDE 'datatables.inc' %]
7 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8 <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
9 <script type="text/javascript">
10 //<![CDATA[
11 $(document).ready(function() {
12   $("#selectall").click(function(e){
13     e.preventDefault();
14     $(".records").checkCheckboxes();
15   });
16   $("#clearall").click(function(e){
17     e.preventDefault();
18     $(".records").unCheckCheckboxes();
19   });
20   $("#selectall").click();
21
22   $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
23     "aoColumnDefs": [
24       { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
25       { "aTargets": [ 1 ], "sType": "num-html" }
26     ],
27     "sDom": 't',
28     "aaSorting": [],
29     "bPaginate": false
30   }));
31
32   $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
33     "aoColumnDefs": [
34       { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
35       { "aTargets": [ 1 ], "sType": "num-html" }
36     ],
37     "sDom": 't',
38     "aaSorting": [],
39     "bPaginate": false
40   }));
41
42   $("#mainformsubmit").click(function(){
43     if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
44       alert(_("Please select at least one record to process"));
45       return false;
46     }
47     if ( $("#marc_modification_template_id").val() <= 0 ) {
48       alert(_("Please select a modification template."));
49       return false;
50     }
51     return submitBackgroundJob(document.getElementById("process"));
52   });
53
54   $("#marc_modification_template_id").change(function(){
55     var url = "/cgi-bin/koha/svc/records/preview?"
56     var mmtid = $(this).val();
57     $("a.previewMARC").each(function(){
58       $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
59     });
60   });
61
62     $("body").on("click",".previewMARC", function(e){
63         e.preventDefault();
64         var ltitle = $(this).text();
65         var page = $(this).attr("href");
66         $("#marcPreviewLabel").text(ltitle);
67         $("#marcPreview .modal-body").load(page + " div");
68         $('#marcPreview').modal({show:true});
69     });
70     $("#marcPreview").on("hidden.bs.modal", function(){
71         $("#marcPreviewLabel").html("");
72         $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
73     });
74
75 });
76 //]]>
77 </script>
78 </head>
79 <body id="tools_batch_record_modification" class="tools">
80 [% INCLUDE 'header.inc' %]
81 [% INCLUDE 'cat-search.inc' %]
82
83 <div id="breadcrumbs">
84     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
85     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
86     <a href="/cgi-bin/koha/tools/batch_record_modification.pl">Batch record modification</a>
87 </div>
88
89 <div id="doc3" class="yui-t2">
90 <div id="bd">
91 <div id="yui-main">
92 <div class="yui-b">
93   <h1>Batch record modification</h1>
94
95     [% IF ( messages ) %]
96         <div class="dialog message">
97
98             [% FOREACH message IN messages %]
99                 [% IF message.type == 'success' %]
100                     <div><i class="fa fa-check success"></i>
101                 [% ELSIF message.type == 'warning' %]
102                     <div><i class="fa fa-warning warn"></i>
103                 [% ELSIF message.type == 'error' %]
104                     <div><i class="fa fa-exclamation error"></i>
105                 [% END %]
106                 [% IF message.code == 'no_action_defined_for_the_template' %]
107                     The selected template (id=[% message.mmtid%]) does not exist or no action is defined.
108                 [% ELSIF message.code == 'biblio_not_exists' %]
109                     Bibliographic record [% message.biblionumber %] does not exist in the database.
110                 [% ELSIF message.code == 'authority_not_exists' %]
111                     Authority record [% message.authid %] does not exist in the database.
112                 [% ELSIF message.code == 'biblio_not_modified' %]
113                     Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber %]">[% message.biblionumber %]</a> has not been modified. An error occurred on modifying it.
114                 [% ELSIF message.code == 'authority_not_modified' %]
115                     Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid %]">[% message.authid %]</a> has not been modified. An error occurred on modifying it.
116                 [% ELSIF message.code == 'biblio_modified' %]
117                     Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber %]">[% message.biblionumber %]</a> has successfully been modified.
118                 [% ELSIF message.code == 'authority_modified' %]
119                     Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid %]">[% message.authid %]</a> has successfully been modified.
120                 [% END %]
121                 [% IF message.error %]
122                     (The error was: [% message.error%]. See the Koha logfile for more information).
123                 [% END %]
124                 </div>
125             [% END %]
126
127         </div>
128     [% END %]
129
130   [% IF view == 'form' %]
131     <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl">
132       <fieldset class="rows">
133         <legend>Record type</legend>
134         <ol>
135           <li><label for="biblio_type">Biblios: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
136           <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
137         </ol>
138       </fieldset>
139       <fieldset class="rows">
140         <legend>Use a file</legend>
141         <ol>
142           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
143         </ol>
144       </fieldset>
145       <fieldset class="rows">
146         <legend>Or enter a list of record numbers</legend>
147         <ol>
148           <li>
149             <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
150             <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
151           </li>
152         </ol>
153       </fieldset>
154       <fieldset class="rows">
155         <legend>Use MARC Modification Template:</legend>
156         <ol>
157           <li>
158             <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
159             <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
160               <option value="">Select a template</option>
161                 [% FOREACH mmt IN MarcModificationTemplatesLoop %]
162                   <option value="[% mmt.template_id %]">[% mmt.name %]</option>
163                 [% END %]
164             </select>
165           </li>
166         </ol>
167       </fieldset>
168       <fieldset class="action">
169         <input type="hidden" name="op" value="list" />
170         <input type="submit" value="Continue" class="button" />
171         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
172       </fieldset>
173     </form>
174   [% ELSIF view == 'list' %]
175     [% IF records %]
176       <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post" id="process">
177         <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
178         <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
179           <option value="">Select a template</option>
180           [% FOREACH mmt IN MarcModificationTemplatesLoop %]
181             [% IF mmt.selected %]
182               <option value="[% mmt.template_id %]" selected="selected">[% mmt.name %]</option>
183             [% ELSE %]
184               <option value="[% mmt.template_id %]">[% mmt.name %]</option>
185             [% END %]
186           [% END %]
187         </select>
188         <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
189             <div class="modal-dialog">
190                 <div class="modal-content">
191                     <div class="modal-header">
192                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
193                         <h3 id="marcPreviewLabel">MARC preview</h3>
194                     </div>
195                     <div class="modal-body">
196                         <div id="loading"> <img src="[% interface %]/[% theme %]/img/spinner-small.gif" alt="" /> Loading </div>
197                     </div>
198                     <div class="modal-footer">
199                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
200                     </div>
201                 </div>
202             </div>
203         </div>
204         [% IF recordtype == 'biblio' %]
205           <div id="toolbar">
206             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
207             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
208           </div>
209           <table id="biblios" class="records">
210             <thead>
211               <tr>
212                 <th>&nbsp;</th>
213                 <th>Biblionumber</th>
214                 <th>Title</th>
215                 <th>&nbsp;</th>
216               </tr>
217             </thead>
218             <tbody>
219               [% FOR biblio IN records %]
220                 <tr>
221                   <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber %]" /></td>
222                   <td>[% biblio.biblionumber %]</td>
223                   <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.title %]</a></td>
224                   <td class="actions">
225                     <a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber %]&mmtid=[% mmtid %]" class="previewMARC btn btn-default btn-xs" data-record_type="biblio" data-record_id="[% biblio.biblionumber %]" data-mmtid="[% mmtid %]" title="Preview MARC"><i class="fa fa-eye"></i> Show MARC</a>
226                   </td>
227                 </tr>
228               [% END %]
229             </tbody>
230           </table>
231           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
232         [% ELSE %]
233           <div id="toolbar">
234             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
235             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
236           </div>
237           <table id="authorities" class="records">
238             <thead>
239               <tr>
240                 <th></th>
241                 <th>Authid</th>
242                 <th>Summary</th>
243                 <th>&nbsp;</th>
244               </tr>
245             </thead>
246             <tbody>
247               [% FOR authority IN records %]
248                 <tr>
249                   <td><input type="checkbox" name="record_id" value="[% authority.authid %]" data-usage="[% authority.count_usage %]" /></td>
250                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid %]">[% authority.authid %]</a></td>
251                   <td>[% PROCESS authresult summary=authority.summary %]</td>
252                   <td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid %]&mmtid=[% mmtid %]" data-record_type="authority" data-record_id="[% authority.authid %]" data-mmtid="[% mmtid %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a>
253                 </tr>
254               [% END %]
255             </tbody>
256           </table>
257           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
258         [% END %]
259         <fieldset class="action">
260           <input type="hidden" name="op" value="modify" />
261           <input type="hidden" name="recordtype" value="[% recordtype %]" />
262           <input type="button" id="mainformsubmit" value="Modify selected records" class="button" />
263           <input type="hidden" name="runinbackground" id="runinbackground" value="" />
264           <input type="hidden" name="completedJobID" id="completedJobID" value="" />
265           <a class="cancel" href="/cgi-bin/koha/tools/batch_record_modification.pl">Cancel</a>
266         </fieldset>
267         <div id="jobpanel">
268           <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
269           <div id="jobfailed"></div>
270         </div>
271       </form>
272     [% ELSE %]
273         <div class="dialog message">
274             No records were modified. <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
275         </div>
276     [% END %]
277   [% ELSIF view == 'report' %]
278     [% IF report.total_records == report.total_success %]
279         <div class="dialog message">
280             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>
281         </div>
282     [% ELSE %]
283         <div class="dialog message">
284             [% report.total_success %] / [% report.total_records %] 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>
285         </div>
286     [% END %]
287   [% ELSIF view == 'errors' %]
288     [% FOR error IN errors %]
289       [% IF error == 'no_template_defined' %]
290         <div class="dialog alert">
291             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.
292         </div>
293       [% END %]
294     [% END %]
295   [% ELSE %]
296         <div class="dialog alert">
297             No action defined for the template.
298         </div>
299   [% END %]
300 </div>
301 </div>
302 <div class="yui-b">
303   [% INCLUDE 'tools-menu.inc' %]
304 </div>
305 </div>
306 [% INCLUDE 'intranet-bottom.inc' %]