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