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