Bug 26703: tools folder
[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="runinbackground" id="runinbackground" value="" />
122             <input type="hidden" name="completedJobID" id="completedJobID" value="" />
123             <input type="hidden" name="src" id="src" value="[% src | html %]" />
124             [% IF biblionumber %]
125                 <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
126             [% END %]
127
128             [% IF ( item_loop ) %]
129                 [% IF show %]
130                     <div id="toolbar">
131                         <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>
132                     </div>
133                 [% END %]
134
135                 <div id="cataloguing_additem_itemlist">
136
137                     <p id="selections">
138                         <strong>Show/hide columns:</strong>
139                         <span class="selected">
140                             <input type="checkbox" checked="checked" id="showall" />
141                             <label for="showall">Show all columns</label>
142                         </span>
143                         <span>
144                             <input type="checkbox" id="hideall" />
145                             <label for="hideall">Hide all columns</label>
146                         </span>
147
148                         [% FOREACH item_header_loo IN item_header_loop %]
149                             <span class="selected">
150                                 <input id="checkheader[% loop.count | html %]" type="checkbox" checked="checked" />
151                                 <label for="checkheader[% loop.count | html %]">[% item_header_loo.header_value | html %]</label>
152                             </span>
153                         [% END %]
154                     </p> <!-- /#selections -->
155
156                     <table id="itemst">
157                         <thead>
158                             <tr>
159                                 <th>&nbsp;</th>
160                                 <th class="anti-the">Title</th>
161                                 <th class="holds_count" title="Item holds / Total holds">Holds</th>
162                                 [% FOREACH item_header_loo IN item_header_loop %]
163                                     <th> [% item_header_loo.header_value | html %] </th>
164                                 [% END %]
165                             </tr>
166                         </thead>
167                         <tbody>
168                             [% FOREACH item_loo IN item_loop %]
169                                 <tr>
170                                     [% IF show %]
171                                         [% IF item_loo.nomod %]
172                                             <td class="error">Cannot edit</td>
173                                         [% ELSE %]
174                                             <td>
175                                                 <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 %]" />
176                                             </td>
177                                         [% END %]
178                                     [% ELSE %]
179                                         <td>&nbsp;</td>
180                                     [% END %]
181                                     <td>
182                                         <label for="row[% item_loo.itemnumber | html %]">
183                                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber | uri %]">
184                                                 [% item_loo.title | html %]
185                                             </a>
186                                             [% IF ( item_loo.author ) %], by [% item_loo.author | html %][% END %]
187                                         </label>
188                                     </td>
189                                     <td class="holds_count">
190                                         [% IF item_loo.holds %]
191                                             [% IF item_loo.item_holds %]
192                                                 <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 -%]" >
193                                             [% ELSE %]
194                                                 <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 -%]" >
195                                             [% END %]
196                                         [% ELSE %]
197                                             [% IF item_loo.holds %]
198                                                 <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this record: [% item_loo.holds | html -%]" >
199                                             [% ELSE %]
200                                                 <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this record" >
201                                             [% END %]
202                                         [% END # /IF item_loo.holds %]
203                                         [% IF item_loo.holds %]
204                                             [% item_loo.item_holds | html %]/[% item_loo.holds | html %]
205                                         [% ELSE %]
206                                             [% item_loo.holds | html %]
207                                         [% END %]
208                                         </a>
209                                     </td>
210                                     [% FOREACH item_valu IN item_loo.item_value %]
211                                         <td>
212                                             [% item_valu.field | html %]
213                                         </td>
214                                     [% END %]
215                                 </tr>
216                             [% END # /FOREACH item_loo %]
217                         </tbody>
218                     </table> <!-- /#itemst -->
219                 </div> <!-- /#cataloguing_additem_itemlist -->
220             [% END # /IF item_loop %]
221
222             [% IF ( simple_items_display || job_completed ) %]
223                 [% IF ( too_many_items_display ) %]
224                     <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>
225                 [% ELSE %]
226                     <p>The following items were modified:</p>
227                     <ul>
228                         [% FOREACH simple_items_displa IN simple_items_display %]
229                             <li>
230                                 [% 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 %]
231                             </li>
232                         [% END %]
233                     </ul>
234                 [% END # /IF too_many_items_display %]
235             [% END # /IF simple_items_display %]
236
237             [% IF ( show ) %]
238
239                 [% IF ( too_many_items_process ) %]
240                     <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>
241                 [% ELSIF ( too_many_items_display ) %]
242                     <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>
243                     [% FOREACH itemnumber IN itemnumbers_array %]
244                         <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
245                     [% END %]
246                 [% END # /IF too_many_items_process %]
247
248                 [% UNLESS (too_many_items_process) %]
249                     <div id="cataloguing_additem_newitem">
250                         <h2>Edit items</h2>
251                         <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>
252                         <fieldset class="rows">
253                             <ol>
254                                 [% FOREACH ite IN item %]
255                                     <li>
256                                         <div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]">
257                                             [% SET mv = ite.marc_value %]
258                                             [% IF ( ite.mandatory ) %]
259                                                 <label class="required" for="[%- mv.id | html -%]">
260                                             [% ELSE %]
261                                                 <label for="[%- mv.id | html -%]">
262                                             [% END %]
263                                                 [% ite.subfield | html %] - [% ite.marc_lib | $raw %]
264                                             </label>
265
266                                             [% IF ( mv.type == 'select' ) -%]
267                                                 <select name="[%- mv.name | html -%]" id="[%- mv.id | html -%]" tabindex="1" class="input_marceditor select2">
268                                                     [%- FOREACH aval IN mv.values %]
269                                                         [% ite.subfield | html %] -
270                                                         [% IF aval == mv.default %]
271                                                             <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
272                                                         [% ELSE %]
273                                                             <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
274                                                         [% END %]
275                                                     [%- END -%]
276                                                 </select>
277                                             [% ELSIF ( mv.type == 'text1' ) %]
278                                                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
279                                                 <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>
280                                             [% ELSIF ( mv.type == 'text2' ) %]
281                                                 <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
282                                                 [% IF mv.noclick %]
283                                                     <a href="#" class="buttonDot disabled" title="No popup">...</a>
284                                                 [% ELSE %]
285                                                     <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot" title="Tag editor">...</a>
286                                                 [% END %]
287                                             [% ELSIF ( mv.type == 'text' ) %]
288                                                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
289                                             [% ELSIF ( mv.type == 'hidden' ) %]
290                                                 <input type="hidden" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
291                                             [% ELSIF ( mv.type == 'textarea' ) %]
292                                                 <textarea tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255">[%- mv.value | html -%]"</textarea>
293                                             [%- END # /IF mv.type == ... -%]
294
295                                             <span name="regex_fields" style="display: none;">
296                                                 s/<input type="text" id="[% mv.id | html %]" name="regex_search" placeholder="regex pattern" />/
297                                                 <input type="text" id="[% mv.id | html %]" name="regex_replace" placeholder="regex replacement" />/
298                                                 <input type="text" id="[% mv.id | html %]" name="regex_modifiers" placeholder="ig" size="3" />
299                                             </span>
300
301                                             [% UNLESS ( ite.mandatory ) %]
302                                                 <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 %]" />
303                                             [% ELSE %]
304                                                 <span class="required">Required</span>
305                                             [% END %]
306
307                                             [% IF (mv.type == 'text' || mv.type == 'textarea' ) %]
308                                                 <a href="#" name="field_regex" id="[% ite.id | html %]" >RegEx</a>
309                                             [% END %]
310
311                                             <input type="hidden" name="tag" value="[% ite.tag | html %]" />
312                                             <input type="hidden" name="subfield" value="[% ite.subfield | html %]" />
313                                             <input type="hidden" name="mandatory" value="[% ite.mandatory | html %]" />
314                                             [% IF ( ite.repeatable ) %]
315                                                 <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode.parentNode); return false;">
316                                                     <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
317                                                 </a>
318                                             [% END %]
319                                             <span class="hint" id="hint[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]"></span>
320                                         </div> <!-- /.subfield_line -->
321                                     </li>
322                                 [% END # /FOREACH ite %]
323                             </ol>
324                         </fieldset>
325
326                         <fieldset class="rows">
327                             <legend>Other attributes</legend>
328                             <ol>
329                                 <li>
330                                     <div class="subfield_line">
331                                         <label for="exclude_from_local_holds_priority">Exclude from local holds priority:</label>
332                                         <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority" class="input_marceditor select2" style="width: 50px">
333                                             <option selected></option>
334                                             <option value="1">Yes</option>
335                                             <option value="0">No</option>
336                                         </select>
337                                     </div>
338                                 </li>
339                             </ol>
340                         </fieldset>
341
342                         <fieldset class="action">
343                             <div id="jobpanel">
344                                 <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
345                                 <div id="jobfailed"></div>
346                             </div>
347                             <input type="submit" id="mainformsubmit" value="Save" />
348                             <a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel">Cancel</a>
349                         </fieldset>
350                     </div> <!-- /#cataloguing_additem_newitem -->
351                 [% ELSE %]
352                     <p><a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a></p>
353                 [% END # /UNLESS too_many_items_process %]
354             [% ELSE # IF show %]
355                 <fieldset class="action">
356                     [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
357                         [% IF searchid %]
358                             <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>
359                         [% ELSE %]
360                             <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>
361                         [% END %]
362                     [% ELSIF src %]
363                         <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
364                     [% ELSE %]
365                         <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>
366                     [% END %]
367                 </fieldset> <!-- /.action -->
368             [% END #/IF show %]
369         </form>
370
371     [% MACRO jsinclude BLOCK %]
372         [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
373         [% Asset.js("js/background-job-progressbar.js") | $raw %]
374         [% Asset.js("js/cataloging.js") | $raw %]
375         [% INCLUDE 'datatables.inc' %]
376         [% Asset.js("js/pages/batchMod.js") | $raw %]
377         [% INCLUDE 'select2.inc' %]
378         <script>
379             // Prepare array of all column headers, incrementing each index by
380             // two to accommodate control and title columns
381             var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count | html %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
382             for( x=0; x<allColumns.length; x++ ){
383                 allColumns[x] = Number(allColumns[x]) + 2;
384             }
385
386             $(document).ready(function(){
387                 $("input[name='disable_input']").click(function() {
388                     var row = $(this).attr("id");
389                     row = row.replace("row","hint");
390                     var todisable = $(this).parent().find("[name='field_value'],[name='tag'],[name='subfield'],[name='mandatory']");
391                     var regex_link = $(this).parent().find("[name='field_regex']");
392                     if ($(this).is(":checked")) {
393                         $(todisable).prop('disabled', true);
394                         $("#"+row).html(_("This subfield will be deleted"));
395                         $(regex_link).hide();
396                     } else {
397                         $(todisable).prop('disabled', false);
398                         $("#"+row).html("");
399                         $(regex_link).show();
400                     }
401                 });
402                 $("#mainformsubmit").on("click",function(){
403                     return submitBackgroundJob(this.form);
404                 });
405                 $('a[name="field_regex"]').click(function() {
406                     var id = $(this).attr('id');
407                     var editor = $(this).parent().find("[name='field_value']");
408                     var regex = $(this).parent().find("[name='regex_fields']");
409                     var disable_input = $(this).parent().find("[name='disable_input']");
410                     if ($(this).html() == 'RegEx') {
411                         $(editor).hide();
412                         $(regex).show();
413                         $(this).html('Text');
414                         $(disable_input).prop('disabled', true);
415                     } else {
416                         $(editor).show();
417                         $(regex).hide();
418                         $(this).html('RegEx');
419                         $(disable_input).prop('disabled', false);
420                     }
421                     return false;
422                 });
423             });
424         </script>
425         [% IF ( show ) %]
426             [%- # Loop over fields which may have plugin JavaScript -%]
427             [%- UNLESS (too_many_items_process) -%]
428                 [%- FOREACH ite IN item -%]
429                     [% SET mv = ite.marc_value %]
430                     [%- IF ( mv.type == 'text2' ) -%]
431                         <!-- subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %] -->
432                         [% mv.javascript | $raw %]
433                     [%- END -%]
434                 [%- END -%]
435             [%- END -%]
436         [%- END -%]
437     [% END %]
438
439 [% INCLUDE 'intranet-bottom.inc' %]