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