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