Bug 23753: Add missing humanMsg library to pages using background job JavaScript
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batchMod-edit.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Tools &rsaquo; Batch item modification</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
8 [% Asset.js("js/background-job-progressbar.js") | $raw %]
9 [% Asset.js("js/cataloging.js") | $raw %]
10 [% INCLUDE 'datatables.inc' %]
11 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
12 [% Asset.js("js/pages/batchMod.js") | $raw %]
13 <script type="text/javascript">
14 //<![CDATA[
15
16 // Prepare array of all column headers, incrementing each index by
17 // two to accommodate control and title columns
18 var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count | html %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
19 for( x=0; x<allColumns.length; x++ ){
20   allColumns[x] = Number(allColumns[x]) + 2;
21 }
22 $(document).ready(function(){
23
24   $("input[name='disable_input']").click(function() {
25       var row = $(this).attr("id");
26       row = row.replace("row","hint");
27       var todisable = $(this).parent().find("[name='field_value'],[name='tag'],[name='subfield'],[name='mandatory']");
28       var regex_link = $(this).parent().find("[name='field_regex']");
29       if ($(this).is(":checked")) {
30           $(todisable).prop('disabled', true);
31           $("#"+row).html(_("This subfield will be deleted"));
32           $(regex_link).hide();
33       } else {
34           $(todisable).prop('disabled', false);
35           $("#"+row).html("");
36           $(regex_link).show();
37       }
38   });
39     $("#mainformsubmit").on("click",function(){
40         return submitBackgroundJob(this.form);
41     });
42     $('a[name="field_regex"]').click(function() {
43         var id = $(this).attr('id');
44         var editor = $(this).parent().find("[name='field_value']");
45         var regex = $(this).parent().find("[name='regex_fields']");
46         var disable_input = $(this).parent().find("[name='disable_input']");
47         if ($(this).html() == 'RegEx') {
48             $(editor).hide();
49             $(regex).show();
50             $(this).html('Text');
51             $(disable_input).prop('disabled', true);
52         } else {
53             $(editor).show();
54             $(regex).hide();
55             $(this).html('RegEx');
56             $(disable_input).prop('disabled', false);
57         }
58         return false;
59     });
60 });
61 //]]>
62 </script>
63 <!--[if IE]>
64 <style>#selections { display: none; }</style>
65 <![endif]-->
66 <style>input[type=checkbox]{ margin : 0 .5em; }</style>
67 [% Asset.css("css/addbiblio.css") | $raw %]
68 [% Asset.css("css/humanmsg.css") | $raw %]
69 [% INCLUDE 'select2.inc' %]
70 <script type="text/javascript">
71   $(document).ready(function() {
72     $('.subfield_line select').select2();
73   });
74 </script>
75
76 </head>
77 <body id="tools_batchMod-edit" class="tools">
78 [% INCLUDE 'header.inc' %]
79 [% INCLUDE 'cat-search.inc' %]
80
81 <div id="breadcrumbs">
82   <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
83   <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
84   <a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a>
85 </div>
86
87 <div class="main container-fluid">
88
89             [% IF ( show ) %]
90               <h1>Batch item modification</h1>
91             [% ELSE %]
92               <h1>Batch item modification results</h1>
93               <div class="dialog message">
94                 [% IF (modified_items) %]
95                   [% modified_items | html %] item(s) modified (with [% modified_fields | html %] field(s) modified).
96                 [% ELSE %]
97                   No items modified.
98                 [% END %]
99               <fieldset class="action">
100                   [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
101                       <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
102                   [% ELSIF src %]
103                       <a href="[% src | url %]">Return to where you were</a>
104                   [% ELSE %]
105                       <a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a>
106                   [% END %]
107               </fieldset>
108               </div>
109             [% END %]
110 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
111 [% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
112 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div>[% END %]
113 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div>[% END %]
114
115     [% IF ( notfoundbarcodes.size ) %]
116         <div class="dialog alert"><p>Warning, the following barcodes were not found:</p></div>
117         <table style="margin:auto;">
118             <thead>
119                 <tr><th>Barcodes not found</th></tr>
120             </thead>
121             <tbody>
122                 [% FOREACH notfoundbarcode IN notfoundbarcodes %]
123                     <tr><td>[% notfoundbarcode |html %]</td></td>
124                 [% END %]
125             </tbody>
126         </table>
127         [% IF ( item_loop ) %]
128             [% UNLESS ( too_many_items_display ) %]
129                 <h4>The following barcodes were found: </h4>
130             [% END %]
131         [% END %]
132     [% END %] <!-- /notfoundbarcodes -->
133     [% IF ( notfounditemnumbers.size ) %]
134         <div class="dialog alert"><p>Warning, the following itemnumbers were not found:</p></div>
135         <table style="margin:auto;">
136             <thead>
137                 <tr><th>Itemnumbers not found</th></tr>
138             </thead>
139             <tbody>
140                 [% FOREACH notfounditemnumber IN notfounditemnumbers %]
141                     <tr><td>[% notfounditemnumber |html %]</td></td>
142                 [% END %]
143             </tbody>
144         </table>
145         [% IF ( item_loop ) %]
146             [% UNLESS ( too_many_items_display ) %]
147                 <h4>The following itemnumbers were found: </h4>
148             [% END %]
149         [% END %]
150     [% END %] <!-- /notfounditemnumbers -->
151
152
153 <form name="f" action="batchMod.pl" method="post">
154      <input type="hidden" name="op" value="[% op | html %]" />
155      <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
156      <input type="hidden" name="runinbackground" id="runinbackground" value="" />
157      <input type="hidden" name="completedJobID" id="completedJobID" value="" />
158      <input type="hidden" name="src" id="src" value="[% src | html %]" />
159      [% IF biblionumber %]
160         <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
161      [% END %]
162
163 [% IF ( item_loop ) %]
164   [% IF show %]
165     <div id="toolbar">
166       <a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-remove"></i> Clear all</a> | <a id="clearonloanbutton" href="#">Clear on loan</a>
167     </div>
168   [% END %]
169 <div id="cataloguing_additem_itemlist">
170
171 <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span> 
172         [% FOREACH item_header_loo IN item_header_loop %]
173         <span class="selected"><input id="checkheader[% loop.count | html %]" type="checkbox" checked="checked" /> <label for="checkheader[% loop.count | html %]">[% item_header_loo.header_value | html %]</label> </span>
174         [% END %]
175 </p>
176         <table id="itemst">
177       <thead>
178     <tr>
179         <th>&nbsp;</th>
180         <th class="anti-the">Title</th>
181         <th class="holds_count" title="Item holds / Total holds">Holds</th>
182         [% FOREACH item_header_loo IN item_header_loop %]
183         <th> [% item_header_loo.header_value | html %] </th>
184         [% END %] 
185     </tr>
186       </thead>
187       <tbody>
188             [% FOREACH item_loo IN item_loop %]
189               <tr>
190                 [% IF show %]
191                   [% IF item_loo.nomod %]
192                     <td class="error">Cannot edit</td>
193                   [% ELSE %]
194                     <td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber | html %]" id="row[% item_loo.itemnumber | html %]" checked="checked" data-is-onloan="[% item_loo.onloan | html %]" /></td>
195                   [% END %]
196                 [% ELSE %]
197                   <td>&nbsp;</td>
198                 [% END %]
199                 <td>
200                     <label for="row[% item_loo.itemnumber | html %]">
201                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber | uri %]">
202                             [% item_loo.title | html %]
203                         </a>
204                         [% IF ( item_loo.author ) %], by [% item_loo.author | html %][% END %]
205                     </label>
206                 </td>
207                 <td class="holds_count">
208                     [% IF item_loo.holds %]
209                         [% IF item_loo.item_holds %]
210                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this item: [% item_loo.item_holds | html %] / Total holds on this record: [% item_loo.holds | html -%]" >
211                         [% ELSE %]
212                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this item / Total holds on this record: [% item_loo.holds | html -%]" >
213                         [% END %]
214                     [% ELSE %]
215                         [% IF item_loo.holds %]
216                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this record: [% item_loo.holds | html -%]" >
217                         [% ELSE %]
218                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this record" >
219                         [% END %]
220                     [% END %]
221                                 [% IF item_loo.holds %]
222                                     [% item_loo.item_holds | html %]/[% item_loo.holds | html %]
223                                 [% ELSE %]
224                                     [% item_loo.holds | html %]
225                                 [% END %]
226                             </a>
227                 </td>
228                 [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field | html %]</td>
229         [% END %] </tr>
230             [% END %]
231       </tbody>
232         </table>
233 </div>
234 [% END %]<!-- /item_loop -->
235
236 [% IF ( simple_items_display || job_completed ) %]
237     [% IF ( too_many_items_display ) %]
238         <p>Too many items ([% too_many_items_display | html %]): You have edited more than [% Koha.Preference('MaxItemsToDisplayForBatchMod') | html %] items in a batch, items will not be shown.</p>
239     [% ELSE %]
240         <p>The following items were modified:</p>
241         <ul>
242         [% FOREACH simple_items_displa IN simple_items_display %]
243       <li>
244           [% IF ( CAN_user_editcatalogue_edit_items ) %]<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% simple_items_displa.biblionumber | uri %]&amp;itemnumber=[% simple_items_displa.itemnumber | uri %]">[% simple_items_displa.barcode | html %]</a>[% ELSE %][% simple_items_displa.barcode | html %][% END %]
245       </li>
246         [% END %]
247         </ul>
248     [% END %]
249 [% END %]<!-- /simple_items_display -->
250
251 [% IF ( show ) %]
252
253 [% IF ( too_many_items_process ) %]
254     <p>Too many items ([% too_many_items_process | html %]): You are not allowed to edit more than [% Koha.Preference('MaxItemsToProcessForBatchMod') | html %] items in a batch.</p>
255 [% ELSIF ( too_many_items_display ) %]
256     <p>Too many items ([% too_many_items_display | html %]): You are editing more than [% Koha.Preference('MaxItemsToDisplayForBatchMod') | html %] items in a batch, items will not be shown.</p>
257     [% FOREACH itemnumber IN itemnumbers_array %]
258   <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
259     [% END %]
260 [% END %]<!-- /too_many_items -->
261
262 [% UNLESS (too_many_items_process) %]
263 <div id="cataloguing_additem_newitem">
264         <h2>Edit Items</h2>
265         <div class="hint">Checking the box right next to the subfield label will disable the entry and delete the subfield on all selected items. Leave fields blank to make no change.</div>
266   <fieldset class="rows">
267   <ol>
268         [% FOREACH ite IN item %]
269           <li>
270             <div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]">
271               [% SET mv = ite.marc_value %]
272               [% IF ( ite.mandatory ) %]
273                 <label class="required" for="[%- mv.id | html -%]">
274               [% ELSE %]
275                 <label for="[%- mv.id | html -%]">
276               [% END %]
277                 [% ite.subfield | html %] - [% ite.marc_lib | $raw %]
278               </label>
279
280               [% IF ( mv.type == 'select' ) -%]
281                 <select name="[%- mv.name | html -%]" id="[%- mv.id | html -%]" size="1" tabindex="1" class="input_marceditor">
282                   [%- FOREACH aval IN mv.values %]
283               [% ite.subfield | html %] -
284                     [% IF aval == mv.default %]
285                       <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
286                     [% ELSE %]
287                       <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
288                     [% END %]
289                   [%- END -%]
290                 </select>
291               [% ELSIF ( mv.type == 'text1' ) %]
292                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
293                 <a href="#" class="buttonDot" onclick="Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=[%- mv.authtypecode | uri -%]&index=[%- mv.id | uri -%]','[%- mv.id | uri -%]'); return false;" title="Tag editor">...</a>
294               [% ELSIF ( mv.type == 'text2' ) %]
295                 <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
296                 [% IF mv.noclick %]
297                   <a href="#" class="buttonDot disabled" title="No popup">...</a>
298                 [% ELSE %]
299                   <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot" title="Tag editor">...</a>
300                 [% END %]
301                 [% mv.javascript | $raw %]
302               [% ELSIF ( mv.type == 'text' ) %]
303                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
304               [% ELSIF ( mv.type == 'hidden' ) %]
305                 <input type="hidden" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
306               [% ELSIF ( mv.type == 'textarea' ) %]
307                 <textarea tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255">[%- mv.value | html -%]"</textarea>
308               [%- END -%]
309
310               <span name="regex_fields" style="display: none;">
311                   s/<input type="text" id="[% mv.id | html %]" name="regex_search" placeholder="regex pattern" />/
312                   <input type="text" id="[% mv.id | html %]" name="regex_replace" placeholder="regex replacement" />/
313                   <input type="text" id="[% mv.id | html %]" name="regex_modifiers" placeholder="ig" size="3" />
314               </span>
315
316               [% UNLESS ( ite.mandatory ) %]
317                 <input type="checkbox" id="row[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]" title="Check to delete subfield [% ite.subfield | html %]" name="disable_input" value="[% ite.subfield | html %]" />
318               [% ELSE %]
319                 <span class="required">Required</span>
320               [% END %]
321
322               [% IF (mv.type == 'text' || mv.type == 'textarea' ) %]
323                   <a href="#" name="field_regex" id="[% ite.id | html %]" >RegEx</a>
324               [% END %]
325
326               <input type="hidden" name="tag"       value="[% ite.tag | html %]" />
327               <input type="hidden" name="subfield"       value="[% ite.subfield | html %]" />
328               <input type="hidden" name="mandatory"       value="[% ite.mandatory | html %]" />
329               [% IF ( ite.repeatable ) %]
330                 <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode.parentNode); return false;">
331                   <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
332                 </a>
333               [% END %]
334               <span class="hint" id="hint[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]"></span>
335             </div>
336           </li>
337         [% END %]
338     </ol>
339     </fieldset>
340     <fieldset class="action">    
341    <div id="jobpanel">
342        <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
343        <div id="jobfailed"></div>
344    </div>
345    <input type="submit" id="mainformsubmit" value="Save" />
346          <a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel">Cancel</a>
347     </fieldset>
348 </div>
349 [% ELSE %]
350     <p><a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a></p>
351 [% END %]
352 [% ELSE %] <!-- // show -->
353 <fieldset class="action">
354 [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
355    <a class="btn btn-default" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]"><i class="fa fa-check-square-o"></i> Return to the record</a>
356 [% ELSIF src %]
357    <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
358 [% ELSE %]
359    <a class="btn btn-default" href="/cgi-bin/koha/tools/batchMod.pl"><i class="fa fa-check-square-o"></i> Return to batch item modification</a>
360 [% END %]
361 </fieldset>
362
363 [% END %]
364
365 [% INCLUDE 'intranet-bottom.inc' %]