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