Bug 10543: fix false warnings from checks of mandatory item fields
[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 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script>
5 <script type="text/javascript">
6 //<![CDATA[
7 $(document).ready(function(){
8     [% IF (popup) %]
9         [% IF (opisadd) %]
10             window.close();
11         [% END %]
12     [% END %]
13             $("fieldset.rows input").addClass("noEnterSubmit");
14                 /* Inline edit/delete links */
15                 var biblionumber = $("input[name='biblionumber']").attr("value");
16         $("tr.editable td").click(function(event){
17                         var $tgt = $(event.target);
18                         if($tgt.is("a")||$tgt.is(":first-child")||$tgt.is(":nth-child(2)")){ return true; } else {
19                         var rowid = $(this).parent().attr("id");
20                         num_rowid = rowid.replace("row","");
21                         $(".linktools").remove();
22                         $(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>");
23                 }
24                 });
25 });
26 function active(numlayer)
27 {
28     for (i=10; i < 11 ; i++ ) {
29         ong = i+"XX";
30             link = "link"+i;
31         if (numlayer==i) {
32             document.getElementById(ong).style.visibility="visible";
33             document.getElementById(link).style.backgroundColor="#11AA11";
34             document.getElementById(link).style.backgroundImage="url([% themelang %]/images/background-mem.gif)";
35         } else {
36             document.getElementById(ong).style.visibility="hidden";
37             document.getElementById(link).style.backgroundColor="#FFFFFF";
38             document.getElementById(link).style.backgroundImage="";
39         }
40     }
41 }
42 function Check(f) {
43     var total_errors = CheckMandatorySubfields(f);
44     if (total_errors > 0) {
45         var alertString2 = _("Form not submitted because of the following problem(s)");
46         alertString2 += "\n------------------------------------------------------------------------------------\n";
47         alertString2 += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)");
48         alert(alertString2);
49         return false;
50     }
51     return true;
52 }
53 function CheckMultipleAdd(f) {
54
55     if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
56         alert(_("Please enter a number of items to create."));
57         return false;
58     }
59 }
60 function Dopop(link,i) {
61     defaultvalue=document.forms[0].field_value[i].value;
62     newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
63 }
64
65 function confirm_deletion(biblionumber,itemnumber) {
66         var original = $("#row"+itemnumber).attr("class");
67         $("#row"+itemnumber).attr("class","confirm");
68     var is_confirmed = confirm(_("Are you sure you want to delete this item?"));
69     if (is_confirmed) {
70     window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber;
71         } else {
72         $("#row"+itemnumber).attr("class","");
73     }
74 }
75
76 $(document).ready(function() {
77     $("#cataloguing_additem_itemlist  tr").hover(
78         function () {$(this).addClass("highlight");},
79         function () {$(this).removeClass("highlight");}
80     );
81 });
82 //]]>
83 </script>
84 <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
85 [% IF ( bidi ) %]
86    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />
87 [% END %]
88 </head>
89 <body id="cat_additem" class="cat">
90 [% INCLUDE 'header.inc' %]
91 [% INCLUDE 'cataloging-search.inc' %]
92
93 <div id="breadcrumbs">
94           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
95  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
96  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</a>
97  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
98 </div>
99
100 <div id="doc3" class="yui-t7">
101
102    <div id="bd">
103         <div id="yui-main">
104
105 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</h1>
106
107 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
108 [% 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 %]
109 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div>[% END %]
110 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div>[% END %]
111 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: The items do not belong to your library.</div>[% END %]
112 [% 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 %]
113
114 <div id="cataloguing_additem_itemlist">
115     [% IF ( item_loop ) %]
116         <div>
117         <table>
118             <tr>
119                 <th colspan="2">&nbsp;</th>
120                 [% FOREACH item_header_loo IN item_header_loop %]
121                     <th>
122                         [% item_header_loo.header_value %]
123                     </th>
124                 [% END %]
125             </tr>
126                 [% FOREACH item_loo IN item_loop %]
127                     [% IF ( item_loo.itemnumber == itemnumber) %]
128                         [% IF item_loo.nomod %]
129                            <tr id="row[% item_loo.itemnumber %]" class="active">
130                         [% ELSE %]
131                             <tr id="row[% item_loo.itemnumber %]" class="active editable">
132                         [% END %]
133                     [% ELSE %]
134                         [% IF item_loo.nomod %]
135                            <tr id="row[% item_loo.itemnumber %]">
136                         [% ELSE %]
137                             <tr id="row[% item_loo.itemnumber %]" class="editable">
138                         [% END %]
139                     [% END %]
140                     [% IF ( item_loo.nomod ) %] <td colspan="2">&nbsp;</td>[% ELSE %][% IF ( item_loo.hostitemflag ) %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% item_loo.hostbiblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a></td>
141 <td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]">Delink</a></td>
142 [% ELSE %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a></td>
143                     <td>[% IF ( item_loo.countanalytics ) %]<a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=% item_loo.itemnumber %]">View analytics</a>[% ELSE %]<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>[% END %]</td>[% END %][% END %]
144                 [% FOREACH item_valu IN item_loo.item_value %]
145                     <td>[% item_valu.field |html %]</td>
146                 [% END %]
147                 </tr>
148                 [% END %]
149         </table>
150         </div>
151     [% END %]
152 </div>
153 <div class="yui-gf">
154 <div class="yui-u first">
155 [% INCLUDE 'biblio-view-menu.inc' %]
156 </div>
157 <div class="yui-u">
158 <div id="cataloguing_additem_newitem">
159     <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
160     <input type="hidden" name="op" value="[% op %]" />
161     [% IF (popup) %]
162         <input type="hidden" name="popup" value="1" />
163     [% END %]
164     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
165     [% IF ( opisadd ) %]
166         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
167     [% ELSE %]
168         <h2 id="edititem">Edit Item #[% itemnumber %][% IF ( barcode ) %] / Barcode [% barcode %][% END %]</h2>
169     [% END %]
170         <fieldset class="rows">
171         <ol>
172         [% FOREACH ite IN item %]
173                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
174                 [% IF ( ite.mandatory ) %]
175                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
176                [% ELSE %]
177                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
178                [% END %]
179                 [% ite.marc_value %]
180                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
181                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
182                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
183                 [% IF ( ite.repeatable ) %]
184                     <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;">
185                         <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
186                     </a>
187                 [% END %]
188                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
189             </div></li>
190         [% END %]
191     </ol>
192     </fieldset>
193     <input type="hidden" name="indicator" value=" " />
194     <input type="hidden" name="indicator" value=" " />
195     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
196
197 <fieldset class="action">    [% IF ( opisadd ) %]
198     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
199     <!-- 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
200                 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.
201                 It is a bit tricky, but necessary in the sake of UI correctness.
202     -->
203
204     <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
205     <input type="submit" name="add_duplicate_submit" value="Add &amp; duplicate" onclick="return Check(this.form)" />
206     <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">
207     <label for="number_of_copies">Number of items to add : </label>
208         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
209         <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);" />
210     </span>
211
212     [% ELSE %]
213     <input type="hidden" name="tag" value="[% itemtagfield %]" />
214     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
215     <input type="hidden" name="field_value" value="[% itemnumber %]" />
216     <input type="submit" value="Save changes" onclick="return Check(this.form)" />
217     [% END %]</fieldset>
218     
219     [%# Fields for fast cataloging %]
220     <input type="hidden" name="circborrowernumber" value="[% circborrowernumber %]" />
221     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
222     <input type="hidden" name="barcode" value="[% barcode %]" />
223     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
224     [%# End fields for fast cataloging %]
225
226
227     </form>
228 </div>
229 </div><!-- /yui-u -->
230 </div><!-- /yui-gf -->
231
232 </div>
233 </div>
234 [% INCLUDE 'intranet-bottom.inc' %]