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