Bug 25728: Create AV when adding a new item
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / authorities / authorities.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Authorities &rsaquo; [% IF ( authid ) %]Modify authority #[% authid | html %] ([% authtypetext | html %])[% ELSE %]Adding authority ([% authtypetext | html %])[% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.js("lib/hc-sticky.js") | $raw %]
8 [% INCLUDE 'select2.inc' %]
9 [% Asset.js("js/cataloging.js") | $raw %]
10
11 <script>
12     $(window).load(function(){
13         $("#loading").hide();
14     });
15     var Sticky;
16     $(document).ready(function() {
17         var tabs = $('#authoritytabs').tabs();
18         $( "ul.sortable_field", tabs ).sortable();
19         $( "ul.sortable_subfield", tabs ).sortable();
20         Sticky = $("#toolbar");
21         Sticky.hcSticky({
22             stickTo: ".main",
23             stickyClass: "floating"
24         });
25         $("#addauth").click(function(){
26             if(Check()){
27                 $("#f").submit();
28             }
29                 });
30         $("#z3950submit").click(function(){
31             var strQuery = GetZ3950Terms();
32             if(strQuery){
33                 window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid | html %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
34             }
35             return false;
36         });
37     });
38
39 /**
40  * check if z3950 mandatories are set or not
41  */
42 function GetZ3950Terms(){
43  var strQuery="&authtypecode="+document.forms['f'].authtypecode.value;
44     var mandatories = new Array();
45     var mandatories_label = new Array();
46     [% FOREACH BIG_LOO IN BIG_LOOP %][% FOREACH innerloo IN BIG_LOO.innerloop %][% FOREACH subfield_loo IN innerloo.subfield_loop %][% IF ( subfield_loo.z3950_mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
47         mandatories_label.push("[% subfield_loo.z3950_mandatory | html %]");[% END %][% END %][% END %][% END %]
48
49     for(var i=0,len=mandatories.length; i<len ; i++){
50         var field_value = document.getElementById(mandatories[i]).value;
51         if( field_value ){
52             strQuery += "&"+mandatories_label[i]+"="+field_value;
53         }
54     }
55     return strQuery;
56 }
57
58 /**
59  * check if mandatory subfields are written
60  */
61 function AreMandatoriesNotOk(){
62     var mandatories = new Array();
63     var mandatoriesfields = new Array();
64     var   tab = new Array();
65     var label = new Array();
66     [% FOREACH BIG_LOO IN BIG_LOOP %]
67         [% FOREACH innerloo IN BIG_LOO.innerloop %]
68                         [% IF ( innerloo.mandatory ) %]
69                         mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]"));
70             [% END %]
71                 [% FOREACH subfield_loo IN innerloo.subfield_loop %]
72                         [% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
73                     tab.push("[% BIG_LOO.number | html %]");
74                     label.push("[% To.json(subfield_loo.marc_lib) | $raw %]");
75                         [% END %]
76                         [% END %]
77                 [% END %]
78         [% END %]
79     var StrAlert = "";
80     for(var i=0,len=mandatories.length; i<len ; i++){
81         var id_string = mandatories[i];
82         // alert (id_string);
83         if( ! $("#" + id_string).val() ){
84             var elt = document.getElementById(id_string);
85             if ( elt.nodeName == 'SELECT' ) {
86                 $(elt).siblings('.select2').find("span[role='combobox']").addClass('subfield_not_filled');
87             } else {
88                 $(elt).addClass('subfield_not_filled');
89             }
90
91             $(elt).focus();
92             StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n";
93         }
94     }
95     
96     /* Check for mandatories field(not subfields) */
97     for(var i=0,len=mandatoriesfields.length; i<len; i++){
98         isempty  = true;
99         arr      = mandatoriesfields[i];
100         divid    = "tag_" + arr[0] + "_" + arr[1];
101         varegexp = new RegExp("^tag_" + arr[0] + "_code_");
102
103                 if(parseInt(arr[0]) >= 10){
104                 elem = document.getElementById(divid);
105                 eleminputs = elem.getElementsByTagName('input');
106                 
107                 for(var j=0,len2=eleminputs.length; j<len2; j++){
108         
109                         if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
110                                         inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
111                                         
112                                         for( var k=0; k<len2; k++){
113                                                 if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
114                                                         isempty = false
115                                                 }
116                                         }
117                         }
118                 }
119         }else{
120                 isempty = false;
121         }
122         
123         if(isempty){
124                 flag = 1;
125                 StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
126         }
127         
128     }
129     
130     
131     if(StrAlert){
132         return _("Can't save this record because the following field aren't filled :") + "\n\n" + StrAlert;
133     }
134     return false;
135 }
136
137 function Check(){
138     var StrAlert = AreMandatoriesNotOk();
139     if( ! StrAlert ){
140         document.f.submit();
141         return true;
142     } else {
143         alert(StrAlert);
144         return false;
145     }
146 }
147
148 function AddField(field,cntrepeatfield) {
149     document.forms['f'].op.value = "addfield";
150     document.forms['f'].addfield_field.value=field;
151     document.forms['f'].repeat_field.value=cntrepeatfield;
152     document.f.submit();
153 }
154
155 function addauthority() {
156     X = document.forms[0].authtype.value;
157     window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
158 }
159 function searchauthority() {
160     X = document.forms[0].authtype2.value;
161     Y = document.forms[0].value.value;
162     window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
163 }
164 function confirmnotdup(redirect){
165     $("#confirm_not_duplicate").attr("value","1");
166     Check();
167 }
168 </script>
169 [% Asset.css("css/addbiblio.css") | $raw %]
170
171 </head>
172 <body id="auth_authorities" class="auth">
173
174 <div id="loading">
175    <div>Loading, please wait...</div>
176 </div>
177
178 [% INCLUDE 'header.inc' %]
179
180 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a> &rsaquo; [% IF ( authid ) %]Modify authority #[% authid | html %] ([% authtypetext | html %])[% ELSE %]Adding authority [% authtypetext | html %][% END %]  </div>
181
182 <div class="main container-fluid">
183     <div class="row">
184         <div class="col-md-8 col-md-offset-2">
185
186 [% IF ( authid ) %]
187 <h1>Modify authority #[% authid | html %] [% authtypetext | html %]</h1>
188 [% ELSE %]
189 <h1>Adding authority [% authtypetext | html %]</h1>
190 [% END %]
191
192 [% IF ( duplicateauthid ) %]
193         <div class="dialog alert">
194                 <h3>Duplicate record suspected</h3>
195                 <p>Is this a duplicate of <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid | uri %]" class="popup" onclick="openWindow('/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid | html %]&amp;popup=1', 'DuplicateAuthority','800','600'); return false;" class="button">[% duplicateauthvalue | html %]</a> ?</p>
196
197                 <form action="authorities.pl" method="get">
198                     <input type="hidden" name="authid" value="[% duplicateauthid | html %]" />
199                     <button type="submit" class="new"><i class="fa fa-pencil"></i> Yes: Edit existing authority</button>
200                 </form>
201                 <form action="authorities.pl" method="get">
202                     <button class="new" onclick="confirmnotdup('items'); return false;"><i class="fa fa-save"></i> No: Save as new authority</button>
203                 </form>
204         </div>
205 [% END %]
206
207 <form method="post" name="f" action="/cgi-bin/koha/authorities/authorities.pl">
208     <input type="hidden" name="op" value="add" />
209     <input type="hidden" name="addfield_field" value="" />
210     <input type="hidden" name="repeat_field" value="" />
211     <input type="hidden" name="authtypecode" value="[% authtypecode | html %]" />
212     <input type="hidden" name="authid" value="[% authid | html %]" />
213     <input type="hidden" name="index" value="[% index | html %]" />
214     <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
215
216     <div id="toolbar" class="btn-toolbar">
217         <div class="btn-group"><a href="#" id="addauth" class="btn btn-default" accesskey="w"><i class="fa fa-save"></i> Save</a></div>
218         <div class="btn-group">
219             [% IF ( authid ) %]
220                 <a class="btn btn-default" id="z3950submit" href="#"><i class="fa fa-search"></i> Replace record via Z39.50/SRU search</a>
221             [% ELSE %]
222                 <a class="btn btn-default" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50/SRU search</a>
223             [% END %]
224         </div>
225         <div class="btn-group">
226             [% IF ( authid ) %]
227                 <a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/detail.pl?authid=[% authid | url %]">Cancel</a>
228             [% ELSE %]
229                 <a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/authorities-home.pl">Cancel</a>
230             [% END %]
231         </div>
232     </div>
233
234 <div id="authoritytabs" class="toptabs numbered">
235     <ul>
236         [% FOREACH BIG_LOO IN BIG_LOOP %]
237         <li><a href="#tab[% BIG_LOO.number | uri %]XX">[% BIG_LOO.number | html %]</a></li>
238         [% END %]
239     </ul>
240
241 [% FOREACH BIG_LOO IN BIG_LOOP %]
242     <div id="tab[% BIG_LOO.number | html %]XX">
243
244     [% previous = "" %]
245     [% FOREACH innerloo IN BIG_LOO.innerloop %]
246     [% IF ( innerloo.tag ) %]
247     [% IF innerloo.tag != previous %]
248         [% IF previous != "" %]
249             </ul>
250         [% END %]
251         [% previous = innerloo.tag %]
252         <ul class="sortable_field">
253     [% END %]
254     <li class="tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
255         <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
256         [% UNLESS hide_marc %]
257             [% IF advancedMARCEditor %]
258                 <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to Expand this Tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a>
259             [% ELSE %]
260                 <span title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
261             [% END %]
262                 [% IF ( innerloo.fixedfield ) %]
263                     <input type="text"
264                         tabindex="1"
265                         class="indicator flat"
266                         style="display:none;"
267                         name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
268                         size="1"
269                         maxlength="1"
270                         value="[% innerloo.indicator1 | html %]" />
271                     <input type="text"
272                         tabindex="1"
273                         class="indicator flat"
274                         style="display:none;"
275                         name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
276                         size="1"
277                         maxlength="1"
278                         value="[% innerloo.indicator2 | html %]" />
279                 [% ELSE %]
280                     <input type="text"
281                         tabindex="1"
282                         class="indicator flat"
283                         name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
284                         size="1"
285                         maxlength="1"
286                         value="[% innerloo.indicator1 | html %]" />
287                     <input type="text"
288                         tabindex="1"
289                         class="indicator flat"
290                         name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
291                         size="1"
292                         maxlength="1"
293                         value="[% innerloo.indicator2 | html %]" />
294                 [% END %] -
295         [% ELSE %]
296                 [% IF ( innerloo.fixedfield ) %]
297                     <input type="hidden"
298                         tabindex="1"
299                         name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
300                         value="[% innerloo.indicator1 | html %]" />
301                     <input type="hidden"
302                         tabindex="1"
303                         name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
304                         value="[% innerloo.indicator2 | html %]" />
305                 [% ELSE %]
306                     <input type="hidden"
307                         tabindex="1"
308                         name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
309                         value="[% innerloo.indicator1 | html %]" />
310                     <input type="hidden"
311                         tabindex="1"
312                         name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
313                         value="[% innerloo.indicator2 | html %]" />
314                 [% END %]
315         [% END %]
316
317             [% UNLESS advancedMARCEditor %]
318                 <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to Expand this Tag">[% innerloo.tag_lib | html %]</a>
319             [% END %]
320                 <span class="field_controls">
321                 [% IF ( innerloo.repeatable ) %]
322                     <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','[% hide_marc | html %]','[% advancedMARCEditor | html %]'); return false;" title="Repeat this Tag">
323                         <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this Tag" />
324                     </a>
325                 [% END %]
326                     <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this Tag">
327                         <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this Tag" />
328                     </a>
329                 </span>
330
331         </div>
332
333         <ul class="sortable_subfield">
334         [% FOREACH subfield_loo IN innerloo.subfield_loop %]
335             <!--  One line on the marc editor -->
336             <li class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
337
338                 [% UNLESS advancedMARCEditor %]
339                     [% IF ( subfield_loo.fixedfield ) %]<label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" style="display:none;" class="labelsubfield">
340                     [% ELSE %]<label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
341                     [% END %]
342                 [% END %]
343                 
344                 [% UNLESS hide_marc %]
345                 <span class="subfieldcode">
346                         <input type="text"
347                             title="[% subfield_loo.marc_lib | $raw %]"
348                             style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
349                             name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
350                             value="[% subfield_loo.subfield | html %]"
351                             size="1"
352                             maxlength="1"
353                             class="flat"
354                             tabindex="0" />
355                 </span>
356                 [% ELSE %]
357                     <input type="hidden"
358                         name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
359                         value="[% subfield_loo.subfield | html %]" />
360                 [% END %]
361
362                 [% UNLESS advancedMARCEditor %]
363                     [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
364                         [% subfield_loo.marc_lib | $raw %]
365                         [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
366                     </span>
367                     </label>
368                 [% END %]
369                 
370                 [% SET mv = subfield_loo.marc_value %]
371                 [% IF ( mv.type == 'select' ) %]
372                      <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
373                      [% FOREACH aval IN mv.values %]
374                          [% IF aval == mv.default %]
375                          <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
376                          [% ELSE %]
377                          <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
378                          [% END %]
379                      [% END %]
380                      </select>
381                 [% ELSIF ( mv.type == 'text1' ) %]
382                     <input type="text" id="[%- mv.id | html -%]" name="[%- mv.id | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" />
383                     <a href="#" class="buttonDot" onclick="openAuth(this.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtypecode | html -%]','auth'); return false;" tabindex="1" title="Tag editor">...</a>
384                 [% ELSIF ( mv.type == 'text2' ) %]
385                     <input type="text" id="[%- mv.id | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" />
386                     [% IF mv.noclick %]
387                         <a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup">...</a>
388                     [% ELSE %]
389                         <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor" title="Tag editor">...</a>
390                     [% END %]
391                     [% mv.javascript | $raw %]
392                 [% ELSIF ( mv.type == 'text' ) %]
393                     <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]" />
394                 [% ELSIF ( mv.type == 'textarea' ) %]
395                     <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]">[%- mv.value | html -%]</textarea>
396                 [% ELSIF ( mv.type == 'hidden' ) %]
397                     <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
398                 [% ELSIF ( mv.type == 'hidden_simple' ) %]
399                     <input type="hidden" name="[%- mv.name | html -%]" />
400                 [% END %]
401
402                 <span class="subfield_controls">
403                 [% IF ( subfield_loo.repeatable ) %]
404                     <a href="#" class="buttonPlus" tabindex="1" onclick="CloneSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]','[% advancedMARCEditor | html %]'); return false;">
405                         <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
406                     </a>
407                     <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
408                         <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
409                     </a>
410                 [% END %]
411                 </span>
412                                 </li>
413                                 <!-- End of the line -->
414                             [% END %]
415                             </ul> <!-- /.sortable_subfield -->
416                         </li>
417                     [% END %]<!-- if innerloo.tag -->
418                 [% END %]<!-- BIG_LOO.innerloop -->
419                 </ul> <!-- /.sortable_field -->
420             </div>
421         [% END %]<!-- BIG_LOOP -->
422     </div><!-- tabs -->
423
424 <div name="hidden" id="hidden" class="tab">
425 [% FOREACH hidden_loo IN hidden_loop %]
426     <input type="hidden" name="tag" value="[% hidden_loo.tag | html %]" />
427     <input type="hidden" name="subfield" value="[% hidden_loo.subfield | html %]" />
428     <input type="hidden" name="mandatory" value="[% hidden_loo.mandatory | html %]" />
429     <input type="hidden" name="kohafield" value="[% hidden_loo.kohafield | html %]" />
430     <input type="hidden" name="tag_mandatory" value="[% hidden_loo.tag_mandatory | html %]" />
431 [% END %]
432 </div>
433 [% IF ( oldauthnumtagfield ) %]
434     <input type="hidden" name="tag" value="[% oldauthnumtagfield | html %]" />
435     <input type="hidden" name="subfield" value="[% oldauthnumtagsubfield | html %]" />
436     <input type="hidden" name="field_value" value="[% authid | html %]" />
437     <input type="hidden" name="mandatory" value="0" />
438     <input type="hidden" name="kohafield" value="[% kohafield | html %]" />
439     <input type="hidden" name="tag_mandatory" value="[% tag_mandatory | html %]" />
440     <input type="hidden" name="tag" value="[% oldauthtypetagfield | html %]" />
441     <input type="hidden" name="subfield" value="[% oldauthtypetagsubfield | html %]" />
442     <input type="hidden" name="field_value" value="[% authtypecode | html %]" />
443 [% END %]
444
445 </form>
446
447 </div>
448 </div>
449 </div>
450
451 [% INCLUDE 'intranet-bottom.inc' %]