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