Bug 26922: Regression tests
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batchMod-edit.tt
blob5228d77f3108d6ecc93afc8b7725855fc22f69ef
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 type="text/javascript">
13 //<![CDATA[
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;
21 $(document).ready(function(){
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_link = $(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_link).hide();
32       } else {
33           $(todisable).prop('disabled', false);
34           $("#"+row).html("");
35           $(regex_link).show();
36       }
37   });
38     $("#mainformsubmit").on("click",function(){
39         return submitBackgroundJob(this.form);
40     });
41     $('a[name="field_regex"]').click(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).html() == 'RegEx') {
47             $(editor).hide();
48             $(regex).show();
49             $(this).html('Text');
50             $(disable_input).prop('disabled', true);
51         } else {
52             $(editor).show();
53             $(regex).hide();
54             $(this).html('RegEx');
55             $(disable_input).prop('disabled', false);
56         }
57         return false;
58     });
59 });
60 //]]>
61 </script>
62 <!--[if IE]>
63 <style>#selections { display: none; }</style>
64 <![endif]-->
65 <style>input[type=checkbox]{ margin : 0 .5em; }</style>
66 [% Asset.css("css/addbiblio.css") | $raw %]
67 [% Asset.css("css/humanmsg.css") | $raw %]
68 [% INCLUDE 'select2.inc' %]
70 </head>
71 <body id="tools_batchMod-edit" class="tools">
72 [% INCLUDE 'header.inc' %]
73 [% INCLUDE 'cat-search.inc' %]
75 <div id="breadcrumbs">
76   <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
77   <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
78   <a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a>
79 </div>
81 <div class="main container-fluid">
83             [% IF ( show ) %]
84               <h1>Batch item modification</h1>
85             [% ELSE %]
86               <h1>Batch item modification results</h1>
87               <div class="dialog message">
88                 [% IF (modified_items) %]
89                   [% modified_items | html %] item(s) modified (with [% modified_fields | html %] field(s) modified).
90                 [% ELSE %]
91                   No items modified.
92                 [% END %]
93               <fieldset class="action">
94                   [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
95                       [% IF searchid %]
96                           <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&searchid=[% searchid | uri %]">Return to the record</a>
97                       [% ELSE %]
98                           <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
99                       [% END %]
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 %]
111     [% IF ( notfoundbarcodes.size ) %]
112         <div class="dialog alert"><p>Warning, the following barcodes were not found:</p></div>
113         <table style="margin:auto;">
114             <thead>
115                 <tr><th>Barcodes not found</th></tr>
116             </thead>
117             <tbody>
118                 [% FOREACH notfoundbarcode IN notfoundbarcodes %]
119                     <tr><td>[% notfoundbarcode |html %]</td></td>
120                 [% END %]
121             </tbody>
122         </table>
123         [% IF ( item_loop ) %]
124             [% UNLESS ( too_many_items_display ) %]
125                 <h4>The following barcodes were found: </h4>
126             [% END %]
127         [% END %]
128     [% END %] <!-- /notfoundbarcodes -->
129     [% IF ( notfounditemnumbers.size ) %]
130         <div class="dialog alert"><p>Warning, the following itemnumbers were not found:</p></div>
131         <table style="margin:auto;">
132             <thead>
133                 <tr><th>Itemnumbers not found</th></tr>
134             </thead>
135             <tbody>
136                 [% FOREACH notfounditemnumber IN notfounditemnumbers %]
137                     <tr><td>[% notfounditemnumber |html %]</td></td>
138                 [% END %]
139             </tbody>
140         </table>
141         [% IF ( item_loop ) %]
142             [% UNLESS ( too_many_items_display ) %]
143                 <h4>The following itemnumbers were found: </h4>
144             [% END %]
145         [% END %]
146     [% END %] <!-- /notfounditemnumbers -->
149 <form name="f" action="batchMod.pl" method="post">
150      <input type="hidden" name="op" value="[% op | html %]" />
151      <input type="hidden" name="searchid" value="[% searchid | html %]" />
152      <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
153      <input type="hidden" name="runinbackground" id="runinbackground" value="" />
154      <input type="hidden" name="completedJobID" id="completedJobID" value="" />
155      <input type="hidden" name="src" id="src" value="[% src | html %]" />
156      [% IF biblionumber %]
157         <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
158      [% END %]
160 [% IF ( item_loop ) %]
161   [% IF show %]
162     <div id="toolbar">
163       <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>
164     </div>
165   [% END %]
166 <div id="cataloguing_additem_itemlist">
168 <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> 
169         [% FOREACH item_header_loo IN item_header_loop %]
170         <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>
171         [% END %]
172 </p>
173         <table id="itemst">
174       <thead>
175     <tr>
176         <th>&nbsp;</th>
177         <th class="anti-the">Title</th>
178         <th class="holds_count" title="Item holds / Total holds">Holds</th>
179         [% FOREACH item_header_loo IN item_header_loop %]
180         <th> [% item_header_loo.header_value | html %] </th>
181         [% END %] 
182     </tr>
183       </thead>
184       <tbody>
185             [% FOREACH item_loo IN item_loop %]
186               <tr>
187                 [% IF show %]
188                   [% IF item_loo.nomod %]
189                     <td class="error">Cannot edit</td>
190                   [% ELSE %]
191                     <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>
192                   [% END %]
193                 [% ELSE %]
194                   <td>&nbsp;</td>
195                 [% END %]
196                 <td>
197                     <label for="row[% item_loo.itemnumber | html %]">
198                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber | uri %]">
199                             [% item_loo.title | html %]
200                         </a>
201                         [% IF ( item_loo.author ) %], by [% item_loo.author | html %][% END %]
202                     </label>
203                 </td>
204                 <td class="holds_count">
205                     [% IF item_loo.holds %]
206                         [% IF item_loo.item_holds %]
207                             <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 -%]" >
208                         [% ELSE %]
209                             <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 -%]" >
210                         [% END %]
211                     [% ELSE %]
212                         [% IF item_loo.holds %]
213                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this record: [% item_loo.holds | html -%]" >
214                         [% ELSE %]
215                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this record" >
216                         [% END %]
217                     [% END %]
218                                 [% IF item_loo.holds %]
219                                     [% item_loo.item_holds | html %]/[% item_loo.holds | html %]
220                                 [% ELSE %]
221                                     [% item_loo.holds | html %]
222                                 [% END %]
223                             </a>
224                 </td>
225                 [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field | html %]</td>
226         [% END %] </tr>
227             [% END %]
228       </tbody>
229         </table>
230 </div>
231 [% END %]<!-- /item_loop -->
233 [% IF ( simple_items_display || job_completed ) %]
234     [% IF ( too_many_items_display ) %]
235         <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>
236     [% ELSE %]
237         <p>The following items were modified:</p>
238         <ul>
239         [% FOREACH simple_items_displa IN simple_items_display %]
240       <li>
241           [% 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 %]
242       </li>
243         [% END %]
244         </ul>
245     [% END %]
246 [% END %]<!-- /simple_items_display -->
248 [% IF ( show ) %]
250 [% IF ( too_many_items_process ) %]
251     <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>
252 [% ELSIF ( too_many_items_display ) %]
253     <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>
254     [% FOREACH itemnumber IN itemnumbers_array %]
255   <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
256     [% END %]
257 [% END %]<!-- /too_many_items -->
259 [% UNLESS (too_many_items_process) %]
260 <div id="cataloguing_additem_newitem">
261         <h2>Edit items</h2>
262         <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>
263   <fieldset class="rows">
264   <ol>
265         [% FOREACH ite IN item %]
266           <li>
267             <div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]">
268               [% SET mv = ite.marc_value %]
269               [% IF ( ite.mandatory ) %]
270                 <label class="required" for="[%- mv.id | html -%]">
271               [% ELSE %]
272                 <label for="[%- mv.id | html -%]">
273               [% END %]
274                 [% ite.subfield | html %] - [% ite.marc_lib | $raw %]
275               </label>
277               [% IF ( mv.type == 'select' ) -%]
278                 <select name="[%- mv.name | html -%]" id="[%- mv.id | html -%]" size="1" tabindex="1" class="input_marceditor select2">
279                   [%- FOREACH aval IN mv.values %]
280               [% ite.subfield | html %] -
281                     [% IF aval == mv.default %]
282                       <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
283                     [% ELSE %]
284                       <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
285                     [% END %]
286                   [%- END -%]
287                 </select>
288               [% ELSIF ( mv.type == 'text1' ) %]
289                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
290                 <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>
291               [% ELSIF ( mv.type == 'text2' ) %]
292                 <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
293                 [% IF mv.noclick %]
294                   <a href="#" class="buttonDot disabled" title="No popup">...</a>
295                 [% ELSE %]
296                   <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot" title="Tag editor">...</a>
297                 [% END %]
298                 [% mv.javascript | $raw %]
299               [% ELSIF ( mv.type == 'text' ) %]
300                 <input type="text" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
301               [% ELSIF ( mv.type == 'hidden' ) %]
302                 <input type="hidden" tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255" value="[%- mv.value | html -%]" />
303               [% ELSIF ( mv.type == 'textarea' ) %]
304                 <textarea tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255">[%- mv.value | html -%]"</textarea>
305               [%- END -%]
307               <span name="regex_fields" style="display: none;">
308                   s/<input type="text" id="[% mv.id | html %]" name="regex_search" placeholder="regex pattern" />/
309                   <input type="text" id="[% mv.id | html %]" name="regex_replace" placeholder="regex replacement" />/
310                   <input type="text" id="[% mv.id | html %]" name="regex_modifiers" placeholder="ig" size="3" />
311               </span>
313               [% UNLESS ( ite.mandatory ) %]
314                 <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 %]" />
315               [% ELSE %]
316                 <span class="required">Required</span>
317               [% END %]
319               [% IF (mv.type == 'text' || mv.type == 'textarea' ) %]
320                   <a href="#" name="field_regex" id="[% ite.id | html %]" >RegEx</a>
321               [% END %]
323               <input type="hidden" name="tag"       value="[% ite.tag | html %]" />
324               <input type="hidden" name="subfield"       value="[% ite.subfield | html %]" />
325               <input type="hidden" name="mandatory"       value="[% ite.mandatory | html %]" />
326               [% IF ( ite.repeatable ) %]
327                 <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode.parentNode); return false;">
328                   <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
329                 </a>
330               [% END %]
331               <span class="hint" id="hint[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]"></span>
332             </div>
333           </li>
334         [% END %]
335     </ol>
336     </fieldset>
337     <fieldset class="rows">
338       <legend>Other attributes</legend>
339       <ol>
340         <li>
341           <div class="subfield_line">
342           <label for="exclude_from_local_holds_priority">Exclude from local holds priority:</label>
343             <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority" class="input_marceditor select2" style="width: 50px">
344                 <option selected></option>
345                 <option value="1">Yes</option>
346                 <option value="0">No</option>
347             </select>
348           </div>
349         </li>
350       </ol>
351     </fieldset>
352     <fieldset class="action">    
353    <div id="jobpanel">
354        <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
355        <div id="jobfailed"></div>
356    </div>
357    <input type="submit" id="mainformsubmit" value="Save" />
358          <a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel">Cancel</a>
359     </fieldset>
360 </div>
361 [% ELSE %]
362     <p><a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a></p>
363 [% END %]
364 [% ELSE %] <!-- // show -->
365 <fieldset class="action">
366 [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
367     [% IF searchid %]
368         <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>
369     [% ELSE %]
370         <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>
371     [% END %]
372 [% ELSIF src %]
373    <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
374 [% ELSE %]
375    <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>
376 [% END %]
377 </fieldset>
379 [% END %]
381 [% INCLUDE 'intranet-bottom.inc' %]