Bug 14267: How active is active?
[koha.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 $(document).ready(function() {
94     $("#cataloguing_additem_itemlist  tr").hover(
95         function () {$(this).addClass("highlight");},
96         function () {$(this).removeClass("highlight");}
97     );
98 });
99 //]]>
100 </script>
101 <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
102 [% IF ( bidi ) %]
103    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />
104 [% END %]
105 </head>
106 <body id="cat_additem" class="cat">
107 [% INCLUDE 'header.inc' %]
108 [% INCLUDE 'cataloging-search.inc' %]
109
110 <div id="breadcrumbs">
111           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
112  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
113  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</a>
114  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
115 </div>
116
117 <div id="doc3" class="yui-t7">
118
119    <div id="bd">
120         <div id="yui-main">
121
122 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</h1>
123
124 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
125 [% 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 %]
126 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
127 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
128 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %]
129 [% 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 %]
130
131 <div id="cataloguing_additem_itemlist">
132     [% IF ( item_loop ) %]
133         <div>
134         <table id="itemst">
135           <thead>
136             <tr>
137                 <th>&nbsp;</th>
138                 [% FOREACH item_header_loo IN item_header_loop %]
139                     <th>
140                         [% item_header_loo.header_value %]
141                     </th>
142                 [% END %]
143             </tr>
144           </thead>
145           <tbody>
146                 [% FOREACH item_loo IN item_loop %]
147                     [% IF ( item_loo.itemnumber == itemnumber) %]
148                         [% IF item_loo.nomod %]
149                            <tr id="row[% item_loo.itemnumber %]" class="active">
150                         [% ELSE %]
151                             <tr id="row[% item_loo.itemnumber %]" class="active editable">
152                         [% END %]
153                     [% ELSE %]
154                         [% IF item_loo.nomod %]
155                            <tr id="row[% item_loo.itemnumber %]">
156                         [% ELSE %]
157                             <tr id="row[% item_loo.itemnumber %]" class="editable">
158                         [% END %]
159                     [% END %]
160                     [% IF ( item_loo.nomod ) %]
161                       <td>&nbsp;</td>
162                     [% ELSE %]
163                       <td>
164                         [% IF ( item_loo.hostitemflag ) %]
165                           <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>
166                         [% ELSE %]
167                           <a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a>
168                           [% IF ( item_loo.countanalytics ) %]
169                             <a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=% item_loo.itemnumber %]">View analytics</a>
170                           [% ELSE %]
171                             <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>
172                           [% END %]
173                         [% END %]
174                       </td>
175                     [% END %]
176                 [% FOREACH item_valu IN item_loo.item_value %]
177                     <td>[% item_valu.field |html %]</td>
178                 [% END %]
179                 </tr>
180                 [% END %]
181           </tbody>
182         </table>
183         </div>
184     [% END %]
185 </div>
186 <div class="yui-gf">
187 <div class="yui-u first">
188 [% INCLUDE 'biblio-view-menu.inc' %]
189 </div>
190 <div class="yui-u">
191 <div id="cataloguing_additem_newitem">
192     <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
193     <input type="hidden" name="op" value="[% op %]" />
194     [% IF (popup) %]
195         <input type="hidden" name="popup" value="1" />
196     [% END %]
197     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
198     [% IF ( opisadd ) %]
199         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
200     [% ELSE %]
201         <h2 id="edititem">Edit Item #[% itemnumber %][% IF ( barcode ) %] / Barcode [% barcode %][% END %]</h2>
202     [% END %]
203         <fieldset class="rows">
204         <ol>
205         [% FOREACH ite IN item %]
206                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
207                 [% IF ( ite.mandatory ) %]
208                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
209                [% ELSE %]
210                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
211                [% END %]
212
213                 [% SET mv = ite.marc_value %]
214                 [% IF ( mv.type == 'hidden' ) %]
215                     <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]">
216                 [% ELSIF ( mv.type == 'select' ) %]
217                     [% IF ( mv.readonlyselect ) %]
218                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
219                     [% ELSE %]
220                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor">
221                     [% END %]
222                     [% FOREACH aval IN mv.values %]
223                         [% IF aval == mv.default %]
224                         <option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
225                         [% ELSE %]
226                         <option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
227                         [% END %]
228                     [% END %]
229                     </select>
230                 [% ELSIF ( mv.type == 'text_auth' ) %]
231                     <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
232                     [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
233                     <a href="#" class="buttonDot"  onclick="[%- dopop -%]; return false;" title="Tag editor">...</a>
234                 [% ELSIF ( mv.type == 'text_plugin' ) %]
235                     <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
236                     [% IF ( mv.nopopup ) %]
237                         <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="No popup">...</a>
238                     [% ELSE  %]
239                         <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="Tag editor">...</a>
240                     [% END %]
241                     [%- mv.javascript -%]
242                 [% ELSIF ( mv.type == 'text' ) %]
243                     <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
244                 [% ELSIF ( mv.type == 'textarea' ) %]
245                     <textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value %]</textarea>
246                 [% END %]
247
248                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
249                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
250                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
251                 [% IF ( ite.repeatable ) %]
252                     <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;">
253                         <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
254                     </a>
255                 [% END %]
256                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
257             </div></li>
258         [% END %]
259     </ol>
260     </fieldset>
261     <input type="hidden" name="indicator" value=" " />
262     <input type="hidden" name="indicator" value=" " />
263     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
264
265 <fieldset class="action">    [% IF ( opisadd ) %]
266     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
267     <!-- 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
268                 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.
269                 It is a bit tricky, but necessary in the sake of UI correctness.
270     -->
271
272     <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
273     <input type="submit" name="add_duplicate_submit" value="Add &amp; duplicate" onclick="return Check(this.form)" />
274     <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">
275     <label for="number_of_copies">Number of items to add : </label>
276     <input type="text" id="number_of_copies" name="number_of_copies" value="" />
277         <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);" />
278     </span>
279
280     [% ELSE %]
281     <input type="hidden" name="tag" value="[% itemtagfield %]" />
282     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
283     <input type="hidden" name="field_value" value="[% itemnumber %]" />
284     <input type="submit" value="Save changes" onclick="return Check(this.form)" />
285     [% END %]</fieldset>
286     
287     [%# Fields for fast cataloging %]
288     <input type="hidden" name="circborrowernumber" value="[% circborrowernumber %]" />
289     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
290     <input type="hidden" name="barcode" value="[% barcode %]" />
291     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
292     [%# End fields for fast cataloging %]
293
294
295     </form>
296 </div>
297 </div><!-- /yui-u -->
298 </div><!-- /yui-gf -->
299
300 </div>
301 </div>
302 [% INCLUDE 'intranet-bottom.inc' %]