Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batchMod-edit.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Batch item modification &rsaquo; Tools &rsaquo; Koha</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 <style>input[type=checkbox]{ margin : 0 .5em; }</style>
11 [% Asset.css("css/addbiblio.css") | $raw %]
12 [% Asset.css("css/humanmsg.css") | $raw %]
13 </head>
14
15 <body id="tools_batchMod-edit" class="tools">
16     [% WRAPPER 'header.inc' %]
17     [% INCLUDE 'cat-search.inc' %]
18 [% END %]
19
20 [% WRAPPER 'sub-header.inc' %]
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
22     <ol>
23         <li>
24             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
25         </li>
26         <li>
27             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
28         </li>
29         <li>
30             <a href="#" aria-current="page">Batch item modification</a>
31         </li>
32     </ol>
33 </nav>
34 [% END %]
35
36     <div class="main container-fluid">
37
38         <h1>Batch item modification</h1>
39         [% IF op == 'enqueued' %]
40             <div class="dialog message">
41               <p>The job has been enqueued! It will be processed as soon as possible.</p>
42               <p><a href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
43               | <a href="/cgi-bin/koha/tools/batchMod.pl" title="New batch item modification">New batch item modification</a></p>
44             </div>
45
46             <fieldset class="action">
47                 [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
48                     [% IF searchid %]
49                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&searchid=[% searchid | uri %]">Return to the record</a>
50                     [% ELSE %]
51                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
52                     [% END %]
53                 [% ELSIF src %]
54                     <a href="[% src | url %]">Return to where you were</a>
55                 [% ELSE %]
56                     <a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a>
57                 [% END %]
58             </fieldset>
59         [% END %]
60
61         [% FOREACH message IN messages %]
62           [% IF message.type == 'success' %]
63             <div class="dialog message">
64           [% ELSIF message.type == 'warning' %]
65             <div class="dialog alert">
66           [% ELSIF message.type == 'error' %]
67             <div class="dialog alert" style="margin:auto;">
68           [% END %]
69           [% IF message.code == 'cannot_enqueue_job' %]
70               <span>Cannot enqueue this job.</span>
71           [% END %]
72           [% IF message.error %]
73             <span>(The error was: [% message.error | html %], see the Koha log file for more information).</span>
74           [% END %]
75           </div>
76         [% END %]
77
78
79         [% IF ( barcode_not_unique ) %]
80             <div class="dialog alert">
81                 <strong>Error saving item</strong>: Barcode must be unique.
82             </div>
83         [% END %]
84         [% IF ( no_next_barcode ) %]
85             <div class="dialog alert">
86                 <strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.
87             </div>
88         [% END %]
89
90         [% IF ( notfoundbarcodes.size ) %]
91             <div class="dialog alert">
92                 <p>Warning, the following barcodes were not found:</p>
93             </div>
94
95             <table style="margin:auto;">
96                 <thead>
97                     <tr><th>Barcodes not found</th></tr>
98                 </thead>
99                 <tbody>
100                     [% FOREACH notfoundbarcode IN notfoundbarcodes %]
101                         <tr><td>[% notfoundbarcode |html %]</td></td>
102                     [% END %]
103                 </tbody>
104             </table>
105
106             [% IF ( item_loop ) %]
107                 [% UNLESS ( too_many_items_display ) %]
108                     <h4>The following barcodes were found: </h4>
109                 [% END %]
110             [% END %]
111         [% END # /IF notfoundbarcodes.size %]
112
113         [% IF ( notfounditemnumbers.size ) %]
114             <div class="dialog alert">
115                 <p>Warning, the following itemnumbers were not found:</p>
116             </div>
117
118             <table style="margin:auto;">
119                 <thead>
120                     <tr><th>Itemnumbers not found</th></tr>
121                 </thead>
122                 <tbody>
123                     [% FOREACH notfounditemnumber IN notfounditemnumbers %]
124                         <tr><td>[% notfounditemnumber |html %]</td></td>
125                     [% END %]
126                 </tbody>
127             </table>
128             [% IF ( item_loop ) %]
129                 [% UNLESS ( too_many_items_display ) %]
130                     <h4>The following itemnumbers were found: </h4>
131                 [% END %]
132             [% END %]
133         [% END # /IF notfounditemnumbers.size %]
134
135
136         <form name="f" action="batchMod.pl" method="post">
137             <input type="hidden" name="op" value="[% op | html %]" />
138             <input type="hidden" name="searchid" value="[% searchid | html %]" />
139             <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
140             <input type="hidden" name="src" id="src" value="[% src | html %]" />
141             [% IF biblionumber %]
142                 <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
143             [% END %]
144
145             [% IF items.size %]
146                     [% PROCESS items_table_batchmod headers => item_header_loop, items => items, checkboxes_edit => 1, display_columns_selection => 1 %]
147             [% END %]
148
149             [% IF ( simple_items_display || job_completed ) %]
150                 [% IF ( too_many_items_display ) %]
151                     <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>
152                 [% ELSE %]
153                     <p>The following items were modified:</p>
154                     <ul>
155                         [% FOREACH simple_items_displa IN simple_items_display %]
156                             <li>
157                                 [% 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 %]
158                             </li>
159                         [% END %]
160                     </ul>
161                 [% END # /IF too_many_items_display %]
162             [% END # /IF simple_items_display %]
163
164             [% IF ( show ) %]
165
166                 [% IF ( too_many_items_process ) %]
167                     <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>
168                 [% ELSIF ( too_many_items_display ) %]
169                     <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>
170                     [% FOREACH itemnumber IN itemnumbers_array %]
171                         <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
172                     [% END %]
173                 [% END # /IF too_many_items_process %]
174
175                 [% UNLESS (too_many_items_process) %]
176                     <div id="cataloguing_additem_newitem">
177                         <h2>Edit items</h2>
178                         <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>
179                         <fieldset class="rows">
180                             [%# no_plugin from batchMod-edit, jQuery is included at the end of the template and cataloguing plugins are not working in this situation %]
181                             [% PROCESS subfields_for_item subfields => subfields, add_regex => 1, add_delete_checkbox => 1, no_plugin => 1 %]
182                         </fieldset>
183
184                         <fieldset class="rows">
185                             <legend>Other attributes</legend>
186                             <ol>
187                                 <li>
188                                     <div class="subfield_line">
189                                         <label for="exclude_from_local_holds_priority">Exclude from local holds priority:</label>
190                                         <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority" class="input_marceditor select2" style="width: 50px">
191                                             <option selected></option>
192                                             <option value="1">Yes</option>
193                                             <option value="0">No</option>
194                                         </select>
195                                     </div>
196                                 </li>
197                             </ol>
198                         </fieldset>
199
200                         <fieldset class="action">
201                             <input type="submit" id="mainformsubmit" value="Save" />
202                             <a href="/cgi-bin/koha/tools/batchMod.pl" class="cancel">Cancel</a>
203                         </fieldset>
204                     </div> <!-- /#cataloguing_additem_newitem -->
205                 [% ELSE %]
206                     <p><a href="/cgi-bin/koha/tools/batchMod.pl">Return to batch item modification</a></p>
207                 [% END # /UNLESS too_many_items_process %]
208             [% ELSE # IF show %]
209                 <fieldset class="action">
210                     [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Edit items in a batch%]
211                         [% IF searchid %]
212                             <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>
213                         [% ELSE %]
214                             <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>
215                         [% END %]
216                     [% ELSIF src %]
217                         <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
218                     [% ELSE %]
219                         <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>
220                     [% END %]
221                 </fieldset> <!-- /.action -->
222             [% END %]
223         </form>
224
225     [% MACRO jsinclude BLOCK %]
226         [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
227         [% Asset.js("js/cataloging.js") | $raw %]
228         [% INCLUDE 'datatables.inc' %]
229         [% Asset.js("js/pages/batchMod.js") | $raw %]
230         [% INCLUDE 'select2.inc' %]
231         [% INCLUDE 'calendar.inc' %]
232         <script>
233             // Prepare array of all column headers, incrementing each index by
234             // two to accommodate control and title columns
235             var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count | html %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
236             for( x=0; x<allColumns.length; x++ ){
237                 allColumns[x] = Number(allColumns[x]) + 2;
238             }
239
240             $(document).ready(function(){
241                 $("input[name='disable_input']").click(function() {
242                     var row = $(this).attr("id");
243                     row = row.replace("row","hint");
244                     var todisable = $(this).parent().find(".input_marceditor,.tag,.subfield,.mandatory");
245                     var regex_link = $(this).parent().find(".field_regex");
246                     if ($(this).is(":checked")) {
247                         $(todisable).prop('disabled', true);
248                         $("#"+row).html(_("This subfield will be deleted"));
249                         $(regex_link).hide();
250                     } else {
251                         $(todisable).prop('disabled', false);
252                         $("#"+row).html("");
253                         $(regex_link).show();
254                     }
255                 });
256                 $('a.field_regex').click(function() {
257                     var editor = $(this).parent().find(".input_marceditor");
258                     var tag_editor = $(this).parent().find(".buttonDot");
259                     var regex = $(this).parent().find("[name='regex_fields']");
260                     var disable_input = $(this).parent().find(".disable_input");
261                     if ($(this).html() == 'RegEx') {
262                         $(editor).hide();
263                         $(regex).show();
264                         $(tag_editor).hide();
265                         $(this).html('Text');
266                         $(disable_input).prop('disabled', true);
267                         let input_name = $(editor).attr('name');
268                         let cloned = $("input[name='"+input_name+"']");
269                         if ( cloned.length > 1 ) {
270                             for( i = 1 ; i < cloned.length ; i++){
271                                 $(cloned[i]).parent().remove();
272                             }
273                         }
274                     } else {
275                         $(editor).show();
276                         $(tag_editor).show();
277                         $(regex).hide();
278                         $(this).html('RegEx');
279                         $(disable_input).prop('disabled', false);
280                     }
281                     return false;
282                 });
283             });
284         </script>
285         [% IF ( show ) %]
286             [%- # Loop over fields which may have plugin JavaScript -%]
287             [%- UNLESS (too_many_items_process) -%]
288                 [%- FOREACH subfield IN subfields -%]
289                     [% SET mv = subfield.marc_value %]
290                     [%- IF ( mv.type == 'text_plugin' ) -%]
291                         <!-- subfield[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %] -->
292                         [% mv.javascript | $raw %]
293                     [%- END -%]
294                 [%- END -%]
295             [%- END -%]
296         [%- END -%]
297     [% END %]
298
299 [% INCLUDE 'intranet-bottom.inc' %]