Bug 7670 - make required fields red
[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">
5 //<![CDATA[
6 $(document).ready(function(){
7                 $("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
8                 /* Inline edit/delete links */
9                 var biblionumber = $("input[name='biblionumber']").attr("value");
10                 $("td").click(function(event){
11                         var $tgt = $(event.target);
12                         if($tgt.is("a")||$tgt.is(":first-child")||$tgt.is(":nth-child(2)")){ return true; } else {
13                         var rowid = $(this).parent().attr("id");
14                         num_rowid = rowid.replace("row","");
15                         $(".linktools").remove();
16                         $(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>");
17                 }
18                 });
19 });
20 function active(numlayer)
21 {
22     for (i=10; i < 11 ; i++ ) {
23         ong = i+"XX";
24             link = "link"+i;
25         if (numlayer==i) {
26             document.getElementById(ong).style.visibility="visible";
27             document.getElementById(link).style.backgroundColor="#11AA11";
28             document.getElementById(link).style.backgroundImage="url([% themelang %]/images/background-mem.gif)";
29         } else {
30             document.getElementById(ong).style.visibility="hidden";
31             document.getElementById(link).style.backgroundColor="#FFFFFF";
32             document.getElementById(link).style.backgroundImage="";
33         }
34     }
35 }
36 function Check(f) {
37     var total_errors=0;
38     $("input[name='mandatory'],select[name='mandatory']").each(function(i){
39         if($(this).val() == 1){
40             var mandatory_field = $("input[name='field_value'],select[name='field_value']").eq(i);
41             if(mandatory_field.val() == ''){
42                 mandatory_field.css("background-color","#FFFFCC");
43                 total_errors++;
44             }
45         }
46     });
47
48     var alertString2;
49     if (total_errors==0) {
50         return true;
51     } else {
52         alertString2  = _("Form not submitted because of the following problem(s)");
53         alertString2 += "\n------------------------------------------------------------------------------------\n";
54         alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)");
55         alert(alertString2);
56         return false;
57     }
58 }
59 function CheckMultipleAdd(f) {
60
61     if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
62         alert(_("Please enter a number of items to create."));
63         return false;
64     }
65 }
66 function Dopop(link,i) {
67     defaultvalue=document.forms[0].field_value[i].value;
68     newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
69 }
70
71 function confirm_deletion(biblionumber,itemnumber) {
72         var original = $("#row"+itemnumber).attr("class");
73         $("#row"+itemnumber).attr("class","confirm");
74     var is_confirmed = confirm(_("Are you sure you want to delete this item?"));
75     if (is_confirmed) {
76     window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber;
77         } else {
78         $("#row"+itemnumber).attr("class","");
79     }
80 }
81
82 function CloneSubfield(index){
83     var original = document.getElementById(index); //original <div>
84     var clone = original.cloneNode(true);
85     var new_key = CreateKey();
86     var old_id =  original.getAttribute('id');
87     old_id=old_id.substr(12);
88     var new_id  = old_id+new_key;
89
90     // set the attribute for the new 'div' subfields
91     var inputs     = clone.getElementsByTagName('input');
92     var selects    = clone.getElementsByTagName('select');
93     var textareas  = clone.getElementsByTagName('textarea');
94
95     // input
96     var id_input = "";
97     for(var i=0,len=inputs.length; i<len ; i++ ){
98         id_input = inputs[i].getAttribute('id')+new_key;
99         inputs[i].setAttribute('id',id_input);
100         inputs[i].setAttribute('name',inputs[i].getAttribute('name'));
101     }
102
103     // select
104     for(var i=0,len=selects.length; i<len ; i++ ){
105         id_input = selects[i].getAttribute('id')+new_key;
106         selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
107         selects[i].setAttribute('name',selects[i].getAttribute('name'));
108     }
109
110     // textarea
111     for(var i=0,len=textareas.length; i<len ; i++ ){
112         id_input = textareas[i].getAttribute('id')+new_key;
113         textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
114         textareas[i].setAttribute('name',textareas[i].getAttribute('name'));
115     }
116
117     [% UNLESS ( advancedMARCEditor ) %]
118     // when cloning a subfield, reset its label too.
119     var label = clone.getElementsByTagName('label')[0];
120     label.setAttribute('for',id_input);
121     [% END %]
122
123     // setting a new if for the parent div
124     clone.setAttribute('id',new_id);
125
126     var CloneButtonPlus;
127     try {
128       var spans = clone.getElementsByTagName('span');
129       if(spans.length){
130           for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
131             if(spans[i].getAttribute('class') == 'buttonPlus'){
132                     CloneButtonPlus = spans[i];
133                     CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
134                     var buttonUp = clone.getElementsByTagName('img')[0];
135                     buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
136                 }
137             }
138         }
139     }
140     catch(e){
141         // do nothing if ButtonPlus & CloneButtonPlus don't exist.
142     }
143     // insert this line on the page
144     original.parentNode.insertBefore(clone,original.nextSibling);
145 }
146
147 /**
148  * This function creates a random number
149  */
150 function CreateKey(){
151     return parseInt(Math.random() * 100000);
152 }
153
154 $(document).ready(function() {
155     $("#cataloguing_additem_itemlist  tr").hover(
156         function () {$(this).attr("class","highlight");},
157         function () {$(this).attr("class",""         );}
158     );
159 });
160
161 function set_to_today(id, force) {
162     if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
163     if ($("#" + id).val() == '' || $("#" + id).val() == '0000-00-00' || force) {
164         $("#" + id).val("[% today_iso %]");
165     }
166 }
167 //]]>
168 </script>
169 <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
170 </head>
171 <body>
172 [% INCLUDE 'header.inc' %]
173 <div id="breadcrumbs">
174           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
175  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
176  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</a>
177  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
178 </div>
179
180 <div id="doc3" class="yui-t7">
181
182    <div id="bd">
183         <div id="yui-main">
184
185 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</h1>
186
187 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
188 [% 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 %]
189 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div>[% END %]
190 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div>[% END %]
191 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: The items do not belong to your branch.</div>[% END %]
192 [% 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 %]
193
194 <div id="cataloguing_additem_itemlist">
195     [% IF ( item_loop ) %]
196         <div>
197         <table>
198             <tr>
199                 <th colspan="2">&nbsp;</th>
200                 [% FOREACH item_header_loo IN item_header_loop %]
201                     <th>
202                         [% item_header_loo.header_value %]
203                     </th>
204                 [% END %]
205             </tr>
206                 [% FOREACH item_loo IN item_loop %]
207                 <tr id="row[% item_loo.itemnumber %]">
208                     [% 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>
209 <td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]">Delink</a></td>
210 [% ELSE %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a></td>
211                     <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 %]
212                 [% FOREACH item_valu IN item_loo.item_value %]
213                     <td>[% item_valu.field |html %]</td>
214                 [% END %]
215                 </tr>
216                 [% END %]
217         </table>
218         </div>
219     [% END %]
220 </div>
221 <div class="yui-gf">
222 <div class="yui-u first">
223 [% INCLUDE 'biblio-view-menu.inc' %]
224 </div>
225 <div class="yui-u">
226 <div id="cataloguing_additem_newitem">
227     <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
228     <input type="hidden" name="op" value="[% op %]" />
229     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
230     [% IF ( opisadd ) %]
231         <h2 id="additema">Add Item</h2>
232     [% ELSE %]
233         <h2 id="edititem">Edit Item #[% itemnumber %]</h2>
234     [% END %]
235         <fieldset class="rows">
236         <ol>
237         [% FOREACH ite IN item %]
238                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
239                 [% IF ( ite.mandatory ) %]
240                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
241                [% ELSE %]
242                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
243                [% END %]
244                 [% ite.marc_value %]
245                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
246                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
247                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
248                 [% IF ( ite.repeatable ) %]
249                     <span class="buttonPlus" onclick="CloneSubfield('subfield[% ite.tag %][% ite.subfield %][% ite.random %]')">+</span>
250                 [% END %]
251                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
252             </div></li>
253         [% END %]
254     </ol>
255     </fieldset>
256     <input type="hidden" name="indicator" value=" " />
257     <input type="hidden" name="indicator" value=" " />
258     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
259
260 <fieldset class="action">    [% IF ( opisadd ) %]
261     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
262     <!-- 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 copies
263                 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.
264                 It is a bit tricky, but necessary in the sake of UI correctness.
265     -->
266
267     <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
268     <input type="submit" name="add_duplicate_submit" value="Add &amp; Duplicate" onclick="return Check(this.form)" />
269     <input type="submit" name="add_multiple_copies" value="Add Multiple Copies" onclick="javascript:this.nextSibling.style.visibility='visible';document.f.number_of_copies.focus(); return false;" /><span id="add_multiple_copies_span" style="visibility:hidden">
270         <label for="number_of_copies">Number of copies to add : </label>
271         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
272         <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);" />
273     </span>
274
275     [% ELSE %]
276     <input type="hidden" name="tag" value="[% itemtagfield %]" />
277     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
278     <input type="hidden" name="field_value" value="[% itemnumber %]" />
279     <input type="submit" value="Save Changes" onclick="return Check(this.form)" />
280     [% END %]</fieldset>
281     
282     <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
283     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
284     <input type="hidden" name="barcode" value="[% barcode %]" />
285     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
286
287
288     </form>
289 </div>
290 </div><!-- /yui-u -->
291 </div><!-- /yui-gf -->
292
293 </div>
294 </div>
295 [% INCLUDE 'intranet-bottom.inc' %]