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