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