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