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