Bug 15173: Restore SubfieldsToAllowForRestrictedEditing
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / additem.tt
1 [% USE Koha %]
2 [% USE ColumnsSettings %]
3
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Cataloging &rsaquo; [% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %]) &rsaquo; Items</title>
6 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% INCLUDE 'datatables.inc' %]
9 <script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging.js"></script>
10 [% INCLUDE 'columns_settings.inc' %]
11 [% INCLUDE 'browser-strings.inc' %]
12 <!--[if lt IE 9]>
13 <script type="text/javascript" src="[% interface %]/lib/shims/json2.min.js"></script>
14 <![endif]-->
15 <script type="text/javascript" src="[% interface %]/js/browser.js"></script>
16 <script type="text/javascript">
17 //<![CDATA[
18     var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10));
19     browser.show();
20
21 $(document).ready(function(){
22
23     // Remove the onclick event defined in browser.js,
24     // otherwise the deletion confirmation will not work correctly
25     $('a[href*="biblionumber="]').off('click');
26
27     [% IF (popup) %]
28         [% IF (opisadd) %]
29             window.close();
30         [% END %]
31     [% END %]
32             $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
33             /* Inline edit/delete links */
34             var biblionumber = $("input[name='biblionumber']").attr("value");
35             $("tr.editable").each(function(){
36                 $(this).find("td:not(:first)").on('click', function(){
37                     var rowid = $(this).parent().attr("id");
38                     num_rowid = rowid.replace("row","");
39                     $(".linktools").remove();
40                     var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]#edititem"></a>');
41                     $(edit_link).text(_("Edit item"));
42                     var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]"></a>');
43                     $(delete_link).text(_("Delete item"));
44                     $(delete_link).on('click', function(e) {
45                         return confirm_deletion();
46                     });
47                     var tools_node = $('<span class="linktools"></span>');
48                     $(tools_node).append(edit_link);
49                     $(tools_node).append(delete_link);
50                     $(this).append(tools_node);
51                 });
52             });
53
54     var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) %]
55     // Skip the first column
56     columns_settings.unshift( { cannot_be_toggled: "1" } );
57
58     var itemst = KohaTable("#itemst", {
59         "aoColumnDefs": [
60           { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
61         ],
62         'bPaginate': false,
63         'bInfo': false,
64         "bAutoWidth": false,
65         "bKohaColumnsUseNames": true
66     }, columns_settings);
67
68     var multiCopyControl = $("#add_multiple_copies_span");
69     var addMultipleBlock = $("#addmultiple");
70     var addSingleBlock = $("#addsingle");
71     multiCopyControl.hide();
72     $("#add_multiple_copies").on("click",function(e){
73         e.preventDefault;
74         addMultipleBlock.toggle();
75         addSingleBlock.toggle();
76         multiCopyControl.toggle();
77         $('body,html').animate({ scrollTop: $('body').height() }, 100);
78     });
79     $("#cancel_add_multiple").on("click",function(e){
80         e.preventDefault();
81         addMultipleBlock.toggle();
82         addSingleBlock.toggle();
83         multiCopyControl.toggle();
84     });
85 });
86
87 function Check(f) {
88     var total_errors = CheckMandatorySubfields(f);
89     if (total_errors==0) {
90         // Explanation about this line:
91         // In case of limited edition permission, we have to prevent user from modifying some fields.
92         // But there is no such thing as readonly attribute for select elements.
93         // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
94         // So we "un-disable" the elements just before submitting.
95         // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
96         $("select[name=field_value]").prop('disabled', false);
97         return true;
98     } else {
99         var alertString2 = _("Form not submitted because of the following problem(s)");
100         alertString2 += "\n------------------------------------------------------------------------------------\n";
101         alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
102         alert(alertString2);
103         return false;
104     }
105     return true;
106 }
107 function CheckMultipleAdd(f) {
108
109     if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
110         alert(_("Please enter a number of items to create."));
111         return false;
112     }
113     <!-- Add a soft-limit of 99 with a reminder about potential data entry error -->
114     if (f>99) {
115         return confirm(_("You are about to add %s items. Continue?").format(f));
116     }
117 }
118 function Dopop(link,i) {
119     defaultvalue=document.forms[0].field_value[i].value;
120     newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
121 }
122
123 function confirm_deletion() {
124     return confirm(_("Are you sure you want to delete this item?"));
125 }
126
127 //]]>
128 </script>
129 <link type="text/css" rel="stylesheet" href="[% interface %]/[% theme %]/css/addbiblio.css" />
130
131 [% INCLUDE 'select2.inc' %]
132 <script type="text/javascript">
133   $(document).ready(function() {
134     $('.subfield_line select').select2();
135   });
136 </script>
137
138 [% IF ( bidi ) %]
139    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/right-to-left.css" />
140 [% END %]
141 </head>
142 <body id="cat_additem" class="cat">
143 [% INCLUDE 'header.inc' %]
144 [% INCLUDE 'cataloging-search.inc' %]
145
146 <div id="breadcrumbs">
147           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
148  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
149  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %])</a>
150  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
151 </div>
152
153 <div id="doc3" class="yui-t7">
154
155    <div id="bd">
156         <div id="yui-main">
157
158 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %])</h1>
159
160 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
161 [% 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 %]
162 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
163 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
164 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %]
165 [% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&amp;analyze=1">analytics.</a>.</div>[% END %]
166
167 <div id="cataloguing_additem_itemlist">
168     [% IF ( item_loop ) %]
169         <div>
170         <table id="itemst">
171           <thead>
172             <tr>
173                 <th>&nbsp;</th>
174                 [% FOREACH item_header IN item_header_loop %]
175                     [% IF item_header.column_name %]
176                         <th data-colname="[% item_header.column_name %]">
177                     [% ELSE %]
178                         <th>
179                     [% END %]
180                         [% item_header.header_value %]
181                     </th>
182                 [% END %]
183             </tr>
184           </thead>
185           <tbody>
186                 [% FOREACH item_loo IN item_loop %]
187                     [% IF ( item_loo.itemnumber == itemnumber) %]
188                         [% IF item_loo.nomod %]
189                            <tr id="row[% item_loo.itemnumber %]" class="active">
190                         [% ELSE %]
191                             <tr id="row[% item_loo.itemnumber %]" class="active editable">
192                         [% END %]
193                     [% ELSE %]
194                         [% IF item_loo.nomod %]
195                            <tr id="row[% item_loo.itemnumber %]">
196                         [% ELSE %]
197                             <tr id="row[% item_loo.itemnumber %]" class="editable">
198                         [% END %]
199                     [% END %]
200                     [% IF ( item_loo.nomod ) %]
201                       <td>&nbsp;</td>
202                     [% ELSE %]
203                       <td>
204                           <div class="dropdown">
205                           <a class="btn btn-default btn-xs dropdown-toggle" id="itemactions[% item_loo.itemnumber %]" role="button" data-toggle="dropdown" href="#">
206                               Actions <b class="caret"></b>
207                           </a>
208                           <ul class="dropdown-menu" role="menu" aria-labelledby="itemactions[% item_loo.itemnumber %]">
209
210                         [% IF ( item_loo.hostitemflag ) %]
211                               <li><a href="additem.pl?op=edititem&amp;biblionumber=[% item_loo.hostbiblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a> &nbsp; <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]">Delink</a></li>
212                         [% ELSE %]
213                               <li><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]#edititem">Edit</a></li>
214                               <li><a href="additem.pl?op=dupeitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]#additema">Duplicate</a></li>
215                           [% IF ( item_loo.countanalytics ) %]
216                               <li><a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=% item_loo.itemnumber %]">View analytics</a></li>
217                           [% ELSE %]
218                               <li><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]" onclick="return confirm_deletion();">Delete</a></li>
219                           [% END %]
220                         [% END %]
221                             [% IF ( OPACBaseURL ) %]
222                                 <li class="view-in-opac"><a target="_blank" href="[% Koha.Preference('OPACBaseURL') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]">OPAC view</a></li>
223                             [% END %]
224                           </ul>
225                           </div>
226                       </td>
227                     [% END %]
228                 [% FOREACH item_valu IN item_loo.item_value %]
229                     <td>[% item_valu.field |html %]</td>
230                 [% END %]
231                 </tr>
232                 [% END %]
233           </tbody>
234         </table>
235         </div>
236     [% END %]
237 </div>
238 <div class="yui-gf">
239 <div class="yui-u first">
240 [% INCLUDE 'biblio-view-menu.inc' %]
241 </div>
242 <div class="yui-u">
243 <div id="cataloguing_additem_newitem">
244     <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
245     <input type="hidden" name="op" value="[% op %]" />
246     [% IF (popup) %]
247         <input type="hidden" name="popup" value="1" />
248     [% END %]
249     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
250     [% IF ( opisadd ) %]
251         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
252     [% ELSE %]
253         <h2 id="edititem">Edit Item #[% itemnumber %][% IF ( barcode ) %] / Barcode [% barcode %][% END %]</h2>
254     [% END %]
255         <fieldset class="rows">
256         <ol>
257         [% FOREACH ite IN item %]
258                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
259                 [% IF ( ite.mandatory ) %]
260                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
261                [% ELSE %]
262                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
263                [% END %]
264
265                 [% SET mv = ite.marc_value %]
266                 [% IF ( mv.type == 'hidden' ) %]
267                     <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]">
268                 [% ELSIF ( mv.type == 'select' ) %]
269                     [% IF ( mv.readonly ) %]
270                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
271                     [% ELSE %]
272                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor">
273                     [% END %]
274                     [% FOREACH aval IN mv.values %]
275                         [% IF aval == mv.default %]
276                         <option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
277                         [% ELSE %]
278                         <option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
279                         [% END %]
280                     [% END %]
281                     </select>
282                 [% ELSIF ( mv.type == 'text_auth' ) %]
283                     [% IF mv.readonly %]
284                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
285                     [% ELSE %]
286                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
287                         [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
288                         <a href="#" class="buttonDot"  onclick="[%- dopop -%]; return false;" title="Tag editor">...</a>
289                     [% END %]
290                 [% ELSIF ( mv.type == 'text_plugin' ) %]
291                     [% IF mv.readonly %]
292                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
293                     [% ELSE %]
294                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
295                         [% IF ( mv.nopopup ) %]
296                             <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="No popup">...</a>
297                         [% ELSE  %]
298                             <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="Tag editor">...</a>
299                         [% END %]
300                         [%- mv.javascript -%]
301                     [% END %]
302                 [% ELSIF ( mv.type == 'text' ) %]
303                     [% IF mv.readonly %]
304                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
305                     [% ELSE %]
306                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
307                     [% END %]
308                 [% ELSIF ( mv.type == 'textarea' ) %]
309                     [% IF mv.readonly %]
310                         <textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value %]</textarea>
311                     [% ELSE %]
312                         <textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value %]</textarea>
313                     [% END %]
314                 [% END %]
315
316                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
317                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
318                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
319                 [% IF ( ite.repeatable ) %]
320                     <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;">
321                         <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
322                     </a>
323                 [% END %]
324                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
325             </div></li>
326         [% END %]
327     </ol>
328     </fieldset>
329     <input type="hidden" name="indicator" value=" " />
330     <input type="hidden" name="indicator" value=" " />
331     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
332
333 <fieldset class="action">    [% IF ( opisadd ) %]
334     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
335     <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
336                 when pressing the enter key, while in fact it is the first submit button that is validated, in our case the "add (single) item" button.
337                 It is a bit tricky, but necessary in the sake of UI correctness.
338     -->
339     <span id="addsingle">
340         <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
341         <input type="submit" name="add_duplicate_submit" value="Add &amp; duplicate" onclick="return Check(this.form)" />
342     </span>
343     <span id="addmultiple">
344         <input type="button" name="add_multiple_copies" id="add_multiple_copies" value="Add multiple copies of this item" />
345     </span>
346     <fieldset id="add_multiple_copies_span">
347         <label for="number_of_copies">Number of copies of this item to add: </label>
348         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
349         <input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) && CheckMultipleAdd(this.form.number_of_copies.value);" /> <a href="#" id="cancel_add_multiple" class="cancel">Cancel</a>
350         <div class="hint"><p>The barcode you enter will be incremented for each additional item.</p></div>
351     </fieldset>
352
353     [% ELSE %]
354     <input type="hidden" name="tag" value="[% itemtagfield %]" />
355     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
356     <input type="hidden" name="field_value" value="[% itemnumber %]" />
357     <input type="submit" value="Save changes" onclick="return Check(this.form)" />
358     [% END %]</fieldset>
359     
360     [%# Fields for fast cataloging %]
361     <input type="hidden" name="circborrowernumber" value="[% circborrowernumber %]" />
362     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
363     <input type="hidden" name="barcode" value="[% barcode %]" />
364     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
365     [%# End fields for fast cataloging %]
366
367
368     </form>
369 </div>
370 </div><!-- /yui-u -->
371 </div><!-- /yui-gf -->
372
373 </div>
374 </div>
375 [% INCLUDE 'intranet-bottom.inc' %]