Bug 30735: Fix filtering by patron attribute with AV in overdues report
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / addbiblio.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>[% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %] &rsaquo; Cataloging &rsaquo; Koha</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% INCLUDE 'calendar.inc' %]
8 [% Asset.js("lib/hc-sticky.js") | $raw %]
9 [% INCLUDE 'select2.inc' %]
10 <script>
11     [% IF Koha.Preference('CreateAVFromCataloguing') && CAN_user_parameters_manage_auth_values %]
12         var auth_values_creation = 1;
13     [% ELSE %]
14         var auth_values_creation = 0;
15     [% END %]
16     $.fn.select2.defaults.set("width", "100%" );
17 </script>
18 [% Asset.js("js/cataloging.js") | $raw %]
19 [% Asset.js("js/browser.js") | $raw %]
20 <script>
21     var browser = KOHA.browser('[% searchid | html %]', parseInt('[% biblionumber | html %]', 10));
22     browser.show();
23
24     $(window).load(function(){
25         $("#loading").hide();
26     });
27     var Sticky;
28     $(document).ready(function() {
29
30         [% IF bib_doesnt_exist %]
31             $("#addbibliotabs").hide();
32             $("#toolbar").hide();
33         [% END %]
34
35         var $tabs = $('#addbibliotabs').tabs().bind('show.ui-tabs', function(e, ui) {
36             $("#"+ui.panel.id+" input:eq(0)").focus();
37         });
38         $( "ul.sortable_field", $tabs ).sortable({
39             axis: "y",
40             containment: $("#addbibliotabs")
41         });
42         $( "ul.sortable_subfield", $tabs ).sortable({
43             axis: "y",
44             containment: "parent"
45         });
46
47         [% IF tab %]
48             link = $("a[href='#[% tab | html %]']");
49             selectTab( link );
50         [% END %]
51
52         Sticky = $("#toolbar");
53         Sticky.hcSticky({
54             stickTo: "#f",
55             stickyClass: "floating"
56         });
57
58         /* check cookie to hide/show marcdocs*/
59         if( Cookies.get("marcdocs_[% borrowernumber | html %]") == 'hide'){
60             toggleMARCdocLinks(false);
61         } else {
62             toggleMARCdocLinks(true);
63         }
64
65         $("#marcDocsSelect").click(function(){
66             if( Cookies.get("marcdocs_[% borrowernumber | html %]") == 'hide'){
67                 toggleMARCdocLinks(true);
68             } else {
69                 toggleMARCdocLinks(false);
70             }
71         });
72
73         /* check cookie to hide/show marc tags*/
74         var marctags_cookie = Cookies.get("marctags_[% borrowernumber | html %]");
75         if( marctags_cookie == 'hide'){
76             toggleMARCTagLinks(false);
77         } else if( marctags_cookie == 'show'){
78             toggleMARCTagLinks(true)
79         } else {
80             [% UNLESS Koha.Preference("hide_marc") %]
81                 toggleMARCTagLinks(true)
82             [% ELSE %]
83                 toggleMARCTagLinks(false);
84             [% END %]
85         }
86
87         $("#marcTagsSelect").click(function(){
88             if( Cookies.get("marctags_[% borrowernumber | html %]") == 'hide'){
89                 toggleMARCTagLinks(true)
90             } else {
91                 toggleMARCTagLinks(false);
92             }
93         });
94
95         $("#z3950search").click(function(){
96             PopupZ3950();
97         });
98
99         $("#linkerbutton").click(function(){
100             AutomaticLinker();
101         });
102
103         $("#saverecord").click(function(){
104             $(".btn-group").removeClass("open");
105             onOption();
106             return false;
107         });
108
109         $("#saveandview").click(function(){
110             $(".btn-group").removeClass("open");
111             redirect("view");
112             return false;
113         });
114
115         $("#saveanditems").click(function(){
116             $(".btn-group").removeClass("open");
117             redirect("items");
118             return false;
119         });
120         $("#saveandcontinue").click(function(){
121             $(".btn-group").removeClass("open");
122             var tab = $("#addbibliotabs li.ui-tabs-active:first a").attr('href');
123             tab = tab.replace('#', '');
124             $("#current_tab").val(tab);
125             redirect("just_save", tab);
126             return false;
127         });
128
129         $( '#switcheditor' ).click( function() {
130             var breedingid = [% breedingid || "null" | html %];
131
132             if ( !confirm( breedingid ? _("This record cannot be transferred to the advanced editor. Continue?") : _("Any changes will not be saved. Continue?") ) ) return false;
133
134             Cookies.set( 'catalogue_editor_[% logged_in_user.borrowernumber | html %]', 'advanced', { expires: 365, path: '/', sameSite: 'Lax'  } );
135
136             var biblionumber = [% biblionumber || "null" | html %];
137
138             if ( biblionumber ) {
139                 window.location = '/cgi-bin/koha/cataloguing/editor.pl#catalog/' + biblionumber;
140             } else {
141                 window.location = '/cgi-bin/koha/cataloguing/editor.pl';
142             }
143
144             return false;
145         } );
146         $(".change-framework").on("click", function(){
147             var frameworkcode = $(this).data("frameworkcode");
148             $("#frameworkcode").val( frameworkcode );
149             Changefwk();
150         });
151
152         $(".toolbar-tabs a").on("click",function(e){
153             e.preventDefault();
154             selectTab( $(this ) );
155         });
156
157         $(".tag_anchor").on("click", function(e){
158             e.preventDefault();
159             $(".tag_anchor").removeClass("selected");
160             $(this).addClass("selected");
161             var link = this.href;
162             var linkid = link.substring( link.indexOf("#") + 1 );
163             window.scrollTo( 0, getScrollto( linkid, "toolbar" ) );
164         });
165
166         $("body").on("click", ".linkfield", function(e){
167             e.preventDefault();
168             var tab = $(this).data("tab");
169             var field = $(this).data("field");
170             var tablink = $("a[data-tabid='" + tab + "']" );
171             selectTab( tablink );
172             window.scrollTo( 0, getScrollto( field, "toolbar" ) );
173         });
174
175         $("body").on("click", ".show-errors", function(e){
176             document.getElementById("form-errors").scrollIntoView();
177         });
178
179     });
180
181     function selectTab( tablink ){
182         $(".toolbar-tabs li").removeClass("selected");
183         tablink.parent().addClass("selected");
184         var tabid = tablink.data("tabid");
185         $('#addbibliotabs').selectTabByID("#tab" + tabid + "XX");
186         $(".tag_anchors").removeClass("tab_selected").hide();
187         $(".tag_anchors_" + tabid ).addClass("tab_selected").show();
188     }
189
190     /**
191     * Returns a roughly ideal position to scroll an element into view
192     * @param {string} target - The HTML id of the element to scroll into view
193     * @param {string} elemid - The HTML id of the element which might obscure
194     *                          the view of the target element e.g. a floating toolbar
195     * @return {number} - The y-coordinate to pass to window.scrollTo()
196     */
197     function getScrollto( target, elemid ){
198         var dest = $("#" + target );
199         var yoffset = dest.offset();
200
201         if( elemid != "" ){
202             var element = $("#" + elemid );
203             var elem_height = element.outerHeight();
204         } else {
205             elem_height = 0;
206         }
207         return yoffset.top - elem_height - 20;
208     }
209
210     function redirect(dest){
211         $("#redirect").attr("value",dest);
212         return Check();
213     }
214
215     [% IF ( CAN_user_editcatalogue_edit_items ) %]
216         var onOption = function () {
217             return Check();
218         }
219     [% END %]
220
221 /**
222 * this function append button for create new authority if not found
223 */
224
225 function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) {
226     var title = _("Create authority");
227     var elem = $('<a href="#" title="' + title + '"><i class="fa fa-plus-circle"></i></a>');
228     tag_subfield_line.append(elem);
229     var tag_subfield_line_a = $('.subfield_line[id^=subfield' + heading.tag + 'a]').eq(tag_index);
230     var subfield_a = tag_subfield_line_a.find('.input_marceditor').eq(0);
231     var index = subfield_a.attr('id');
232     elem.click(function() {
233         var popup = window.open("", "new_auth_popup",'fullscreen,toolbar=false,scrollbars=yes');
234         if(popup !== null) {
235             // Create a new form that will be POSTed in the new window
236             var form = $('<form>').attr({
237             method: 'post',
238             action: "/cgi-bin/koha/authorities/authorities.pl",
239             target: "new_auth_popup"
240             });
241             //add the authtypecode
242             form.append($('<input>').attr({
243                 type: 'hidden',
244                 name: 'authtypecode',
245                 value: heading.auth_type
246             }));
247             form.append($('<input>').attr({
248                 type: 'hidden',
249                 name: 'tagreport',
250                 value: heading.tag_to_report
251             }));
252             form.append($('<input>').attr({
253                 type: 'hidden',
254                 name: 'tagbiblio',
255                 value: heading.tag
256             }));
257             form.append($('<input>').attr({
258                 type: 'hidden',
259                 name: 'index',
260                 value: index
261             }));
262             $('.tag[id^=tag_' + heading.tag + '_]').eq(tag_index).find(':input').each(function(){
263                 form.append($('<input>').attr({
264                     type: 'hidden',
265                     name: this.name.split('_',4).join(''),
266                     value: $(this).val()
267                 }));
268             });
269             $('body').append(form);
270             form.submit();
271             form.remove();
272         }
273         return false;
274     });
275
276 }
277
278 /**
279  * Updates the authid for every heading field
280  * Adds visual feedback for the changes made on the form.
281  */
282 function updateHeadingLinks(links) {
283     var current_tag = '';
284     var tag_index = 0;
285
286     // Delete the old message dialog and create a new one
287     $('#autolinker_dialog').remove();
288     var message_dialog = $('<div id="autolinker_dialog" class="dialog message"><strong>' + _("Automatic authority link results:") + '</strong><ul></ul></div>');
289     var message_dialog_ul = message_dialog.find('ul');
290
291     $.each(links, function(index, heading) {
292         if(current_tag == heading.tag) {
293             tag_index++;
294         }
295         else {
296             current_tag = heading.tag;
297             tag_index = 0;
298         }
299
300         // Find the $9 field to update
301         var tag_subfield_line = $('.subfield_line[id^=subfield' + heading.tag + '9]').eq(tag_index);
302         if( tag_subfield_line.length < 1 ){ return; }
303
304         var subfield = tag_subfield_line.find('.input_marceditor').eq(0);
305         subfield.removeClass("matching_authority_field no_matching_authority_field");
306
307         // Delete the old status if one exists
308         tag_subfield_line.children('.subfield_status').remove();
309
310         // If the field wasn't modified. Skip it.
311         if(heading.status == 'UNCHANGED') {
312             return;
313         }
314
315
316         // Make the subfield line visible and update its value
317         tag_subfield_line.show();
318         subfield.val(heading.authid);
319
320         // Add the new status
321         var image = '<i class="fa fa-close subfield_status no_matching_authority" </i> ';
322         var message = '';
323         var field_class = 'no_matching_authority_field';
324         switch(heading.status) {
325             case 'LOCAL_FOUND':
326                 image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
327                 message = _("A matching authority was found in the local database.");
328                 field_class = 'matching_authority_field';
329                 break;
330             case 'CREATED':
331                 image = '<i class="fa fa-check subfield_status matching_authority"></i> ';
332                 message = _("No matching authority found. A new authority was created automatically.");
333                 field_class = 'matching_authority_field';
334                 break;
335             case 'MULTIPLE_MATCH':
336                 message = _("More than one local match found. Possibly a duplicate authority!");
337                 break;
338             case 'NONE_FOUND':
339                 message = _("No matching authority found.");
340                 break;
341             default:
342                 message = heading.status;
343                 break;
344         }
345
346         subfield[0].classList.add(field_class);
347         tag_subfield_line.find('i').each(function() {
348             this.remove();
349         });
350         tag_subfield_line.append(image);
351
352         // Add the message to the dialog
353         message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>');
354
355         // Add a link to create a new authority if none was found
356         if(heading.status == 'NONE_FOUND' && tag_subfield_line.find('i').length == 1) {
357             addCreateAuthorityButton(tag_subfield_line, heading , tag_index);
358         }
359     });
360
361     if(message_dialog.find('li').length == 0) {
362         message_dialog_ul.append("<li>" + _("No authority link was changed.") + "</li>");
363     }
364     $('#addbibliotabs').before(message_dialog);
365 }
366
367 /**
368  * Use an ajax request to automatically find authority links for the current record
369  */
370 function AutomaticLinker() {
371     // Show the Loading overlay
372     $("#loading").show();
373
374     // Remove fields that are completely empty
375     $('#f').find('.tag').each(function() {
376         var empty = true;
377         $(this).find('.input_marceditor').each(function() {
378             if($(this).val() != '') {
379                 empty = false;
380                 return false;
381             }
382         });
383         if(empty) {
384             UnCloneField($(this).attr('id'));
385         }
386     });
387
388     // Get all the form values to post via AJAX
389     var form_data = {};
390     $('#f').find(':input').each(function(){
391         form_data[this.name] = $(this).val();
392     });
393     delete form_data[''];
394
395     // Send the data to automatic_linker.pl
396     $.ajax({
397         url:'/cgi-bin/koha/svc/cataloguing/automatic_linker.pl',
398         type:'post',
399         data: form_data,
400         dataType: 'json',
401         error: function(xhr) {
402             alert("Error : \n" + xhr.responseText);
403         },
404         success: function(json) {
405             switch(json.status) {
406                 case 'UNAUTHORIZED':
407                     alert(_("Error : You do not have the permissions necessary to use this functionality."));
408                     break;
409                 case 'OK':
410                     updateHeadingLinks(json.links);
411                     break;
412             }
413         },
414         complete: function() {
415             $("#loading").hide();
416         }
417     });
418 }
419
420
421 function PopupMARCFieldDoc(field) {
422     [% IF Koha.Preference('marcfielddocurl') %]
423         var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','&quot;') | html %]";
424         docurl = docurl.replace("{MARC}", "[% marcflavour | html %]");
425         docurl = docurl.replace("{FIELD}", ""+field);
426         docurl = docurl.replace("{LANG}", "[% lang | html %]");
427         window.open(docurl);
428     [% ELSIF ( marcflavour == 'MARC21' ) %]
429         _MARC21FieldDoc(field);
430     [% ELSIF ( marcflavour == 'UNIMARC' ) %]
431         _UNIMARCFieldDoc(field);
432     [% END %]
433 }
434     function confirmnotdup(redirect){
435         $("#confirm_not_duplicate").attr("value","1");
436         $("#redirect").attr("value",redirect);
437         Check();
438     }
439
440     function Dopop(link,i) {
441         defaultvalue = document.getElementById(i).value;
442         window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes');
443     }
444
445     /**
446      * this function open a popup to search on z3950 server.
447      */
448     function PopupZ3950() {
449         var strQuery = GetZ3950Terms();
450         if(strQuery){
451             window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=[% biblionumber | html %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
452         }
453     }
454
455     function PopupMARCFieldDoc(field) {
456         [% IF Koha.Preference('marcfielddocurl') %]
457             var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','&quot;') | html %]";
458             docurl = docurl.replace("{MARC}", "[% marcflavour | html %]");
459             docurl = docurl.replace("{FIELD}", ""+field);
460             docurl = docurl.replace("{LANG}", "[% lang | html %]");
461             window.open(docurl);
462         [% ELSIF ( marcflavour == 'MARC21' ) %]
463             _MARC21FieldDoc(field);
464         [% ELSIF ( marcflavour == 'UNIMARC' ) %]
465             _UNIMARCFieldDoc(field);
466         [% END %]
467     }
468
469     function _MARC21FieldDoc(field) {
470         if(field == 0) {
471             window.open("http://www.loc.gov/marc/bibliographic/bdleader.html");
472         } else if (field >= 90 && field <= 99 ){
473             window.open("http://www.loc.gov/marc/bibliographic/bd09x.html");
474         } else if (field >= 590 && field <= 599 ){
475             window.open("http://www.loc.gov/marc/bibliographic/bd59x.html");
476         } else if (field >= 690 && field <= 699 ){
477             window.open("http://www.loc.gov/marc/bibliographic/bd69x.html");
478         } else if (field < 900) {
479             window.open("http://www.loc.gov/marc/bibliographic/bd" + ("000"+field).slice(-3) + ".html");
480         } else {
481             window.open("http://www.loc.gov/marc/bibliographic/bd9xx.html");
482         }
483     }
484
485     function _UNIMARCFieldDoc(field) {
486         /* http://archive.ifla.org/VI/3/p1996-1/ is an outdated version of UNIMARC, but
487            seems to be the only version available that can be linked to per tag.  More recent
488            versions of the UNIMARC standard are available on the IFLA website only as
489            PDFs!
490         */
491         var url;
492         if (field == 0) {
493             url = "http://archive.ifla.org/VI/3/p1996-1/uni.htm";
494         } else {
495             var first = field.substring(0,1);
496             url = "http://archive.ifla.org/VI/3/p1996-1/uni" + first + ".htm#";
497             if (first == 0) url = url + "b";
498             url = first == 9
499                   ? "http://archive.ifla.org/VI/3/p1996-1/uni9.htm"
500                   : url + field;
501         }
502         window.open(url);
503     }
504
505     /*
506      * Functions to hide/show marc docs and tags links
507      */
508
509     function toggleMARCdocLinks(flag){
510         if( flag === true ){
511             $(".marcdocs").show();
512             Cookies.set("marcdocs_[% borrowernumber | html %]",'show', { path: "/", expires: 365, sameSite: 'Lax'  });
513             $("#marcDocsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
514         } else {
515             $(".marcdocs").hide();
516             Cookies.set("marcdocs_[% borrowernumber | html %]",'hide', { path: "/", expires: 365, sameSite: 'Lax'  });
517             $("#marcDocsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
518         }
519     }
520
521     function toggleMARCTagLinks(flag){
522         if( flag === true ){
523             $(".tagnum").show();
524             $(".subfieldcode").show();
525             Cookies.set("marctags_[% borrowernumber | html %]",'show', { path: "/", expires: 365, sameSite: 'Lax'  });
526             $("#marcTagsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
527         } else {
528             $(".tagnum").hide();
529             $(".subfieldcode").hide();
530             Cookies.set("marctags_[% borrowernumber | html %]",'hide', { path: "/", expires: 365, sameSite: 'Lax'  });
531             $("#marcTagsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
532         }
533     }
534
535     /**
536      * check if mandatory/important subfields are written
537      * @param mandatory true to check for mandatories, false for importants
538      */
539     function AreFieldsNotOk (mandatory = true) {
540         var fields = new Array();
541         var subfields = new Array();
542         var tab = new Array();
543         var label = new Array();
544         var flag = false;
545         var tabflag= new Array();
546         var StrAlert = "<div id='form-errors' class='dialog alert list'>";
547         var notFilledClass = "subfield_not_filled";
548
549         if (mandatory) {
550             [% FOREACH BIG_LOO IN BIG_LOOP %]
551                 [% FOREACH innerloo IN BIG_LOO.innerloop %]
552                     [% IF ( innerloo.mandatory ) %]
553                         fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]"));
554                     [% END %]
555                     [% FOREACH subfield_loo IN innerloo.subfield_loop %]
556                         [% IF ( subfield_loo.mandatory ) %]subfields.push("[% subfield_loo.id | html %]");
557                             tab.push("[% BIG_LOO.number | html %]");
558                             label.push("[% subfield_loo.marc_lib | $raw %]");
559                         [% END %]
560                     [% END %]
561                 [% END %]
562             [% END %]
563             StrAlert += "<h4>" + _("The following mandatory subfields aren't filled:") + "</h4>";
564         } else {
565             [% FOREACH BIG_LOO IN BIG_LOOP %]
566                 [% FOREACH innerloo IN BIG_LOO.innerloop %]
567                     [% IF ( innerloo.important ) %]
568                         fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]"));
569                     [% END %]
570                     [% FOREACH subfield_loo IN innerloo.subfield_loop %]
571                         [% IF ( subfield_loo.important ) %]subfields.push("[% subfield_loo.id | html %]");
572                             tab.push("[% BIG_LOO.number | html %]");
573                             label.push("[% subfield_loo.marc_lib | $raw %]");
574                         [% END %]
575                     [% END %]
576                 [% END %]
577             [% END %]
578             StrAlert += "<h4>" + _("The following important subfields aren’t filled:") + "</h4>";
579             notFilledClass = "important_subfield_not_filled";
580         }
581         StrAlert += "<ul>";
582         for(var i=0,len=subfields.length; i<len ; i++){
583             var tag=subfields[i].substr(4,3);
584             var subfield=subfields[i].substr(17,1);
585             var tagnumber=subfields[i].substr(19,subfields[i].lastIndexOf("_")-19);
586             if (tabflag[tag+subfield+tagnumber] ==  null) {
587                 tabflag[tag+subfield+tagnumber]=new Array();
588                 tabflag[tag+subfield+tagnumber][0]=0;
589             }
590             if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(subfields[i]) != null && ! document.getElementById(subfields[i]).value || document.getElementById(subfields[i]) == null)){
591                 tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
592
593                 var elt = document.getElementById(subfields[i]);
594                 if ( elt.nodeName == 'SELECT' ) {
595                     $(elt).siblings('.select2').find("span[role='combobox']").addClass(notFilledClass);
596                 } else {
597                     elt.setAttribute('class','input_marceditor noEnterSubmit ' + notFilledClass);
598                 }
599                 $('#' + subfields[i]).focus();
600                 tabflag[tag+subfield+tagnumber][1]=label[i];
601                 tabflag[tag+subfield+tagnumber][2]=tab[i];
602             } else {
603                 tabflag[tag+subfield+tagnumber][0] = 1;
604             }
605             tabflag[tag+subfield+tagnumber][3] = subfields[i];
606         }
607
608         for (var tagsubfieldid in tabflag){
609             if (tabflag[tagsubfieldid][0]==0){
610                 var tag=tagsubfieldid.substr(0,3);
611                 var subfield=tagsubfieldid.substr(3,1);
612                 StrAlert += "<li>"+_("Tag %s subfield %s %s in tab %s").format(tag, subfield, formatFieldName( tabflag[tagsubfieldid][1] ), tabflag[tagsubfieldid][2]) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + tabflag[tagsubfieldid][2] + '" data-field="' + tabflag[tagsubfieldid][3] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
613                 flag = true;
614             }
615         }
616         StrAlert += "</ul>";
617         /* Check for mandatories/importants field(not subfields) */
618         /* Loop over array of fields identified as mandatory or
619            important to see if at least one subfield is filled */
620         mandatoryFields = new Object();
621
622         for(var i=0,len=fields.length; i<len; i++){
623             isempty  = true;
624             arr      = fields[i];
625             divid    = "tag_" + arr[0] + "_" + arr[1];
626             varegexp = new RegExp("^tag_" + arr[0] + "_code_");
627
628             if(parseInt(arr[0]) >= 10){
629                 elem = document.getElementById(divid);
630                 eleminputs = elem.getElementsByTagName('input');
631
632                 for(var j=0,len2=eleminputs.length; j<len2; j++){
633
634                     if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
635                         inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
636
637                         for( var k=0; k<len2; k++){
638                             if( eleminputs[k].id.match(inputregexp) ){
639                                 if( eleminputs[k].value ){
640                                     isempty = false
641                                 }
642                             }
643                         }
644
645                         elemselect = elem.getElementsByTagName('select');
646                         for( var k=0; k<elemselect.length; k++){
647                             if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
648                                 isempty = false
649                             }
650                         }
651                     }
652                 }
653
654                 elemtextareas = elem.getElementsByTagName('textarea');
655                 for(var j=0,len2=elemtextareas.length; j<len2; j++){
656                     // this bit assumes that the only textareas in this context would be for subfields
657                     if (elemtextareas[j].value) {
658                         isempty = false;
659                     }
660                 }
661
662             } else {
663                 isempty = false;
664             }
665
666             if(isempty){
667                 flag = true;
668                 if (mandatory) {
669                     mandatoryFields[ arr[0] ] = {
670                         importance: "mandatory",
671                         elemid: "div_indicator_" + divid,
672                         tab: arr[3]
673                     }
674                 } else {
675                     mandatoryFields[ arr[0] ] = {
676                         importance: "important",
677                         elemid: "div_indicator_" + divid,
678                         tab: arr[3]
679                     }
680                 }
681             }
682
683         }
684
685         if( Object.entries(mandatoryFields).length > 0 ){
686             StrAlert += "<h4>" + _("The following fields aren't filled:") + "</h4>";
687             StrAlert += "<ul>";
688             for( var prop in mandatoryFields ){
689                 if( mandatoryFields[prop]["importance"] == "mandatory" ){
690                     StrAlert += "<li>" + _("Field %s is mandatory, at least one of its subfields must be filled.").format( prop ) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
691                 } else {
692                     StrAlert += "<li>" + _("Field %s is important, at least one of its subfields must be filled.").format(prop) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
693                 }
694             }
695             StrAlert += "</ul>";
696         }
697         StrAlert += "</div>";
698         if ( flag ) {
699             $("#show-errors").html('<button type="button" class="btn btn-danger show-errors"><i class="fa fa-warning"></i> ' + _("Errors") + '</span>');
700             return StrAlert;
701         } else {
702             return flag;
703         }
704     }
705
706     /**
707      * Run checks for mandatory and important fields
708      * Output errors if necessary, or submit the form
709      */
710     function Check(){
711         var StrAlert = AreFieldsNotOk();
712         var StrWarning = AreFieldsNotOk( false );
713         if( !StrAlert && StrWarning ){
714             // Check important fields
715             $("#check_errors").html( StrWarning );
716             $('html, body').animate({ scrollTop: 0 }, 'fast');
717
718             var r=confirm( _("Important fields(s) are not filled. Are you sure you want to save?" ) );
719             if (! r){
720                 return false;
721             } else {
722                 document.f.submit();
723                 return true;
724             }
725         } else if( StrAlert ){
726             var strAll = StrAlert;
727             if( StrWarning ){
728                 strAll += StrWarning;
729             }
730             $("#check_errors").html( strAll );
731             $('html, body').animate({ scrollTop: 0 }, 'fast');
732             Sticky.hcSticky('refresh');
733             return false;
734         } else if( !StrAlert && !StrWarning ){
735             document.f.submit();
736             return true;
737         }
738     }
739
740     /**
741      * check if z3950 mandatories are set or not
742      */
743     function GetZ3950Terms(){
744         var frameworkcode = document.getElementById("frameworkcode").value;
745         var strQuery = "&frameworkcode=" + encodeURIComponent(frameworkcode);
746         var mandatories = new Array();
747         var mandatories_label = new Array();
748         [% FOREACH BIG_LOO IN BIG_LOOP %]
749             [% FOREACH innerloo IN BIG_LOO.innerloop %]
750                 [% FOREACH subfield_loo IN innerloo.subfield_loop %]
751                     [% IF ( subfield_loo.z3950_mandatory ) %]
752                         mandatories.push("[% subfield_loo.id | html %]");
753                         mandatories_label.push("[% subfield_loo.z3950_mandatory | html %]");
754                     [% END %]
755                 [% END %]
756             [% END %]
757         [% END %]
758
759         for(var i=0,len=mandatories.length; i<len ; i++){
760             var field_value = document.getElementById(mandatories[i]).value;
761             if( field_value ){
762                 strQuery += "&"+encodeURIComponent(mandatories_label[i])+"="+encodeURIComponent(field_value);
763             }
764         }
765         return strQuery;
766     }
767
768     function Changefwk() {
769         var f = document.f;
770         f.op.value = "[% op | html %]";
771         f.biblionumber.value = "[% biblionumberdata | html %]";
772         f.changed_framework.value = "changed";
773         f.submit();
774     }
775
776     /* Wrap a value in HTML without putting HTML in translatable string */
777     function formatFieldName( string ){
778         return "<strong><em>" + string + "</em></strong>";
779     }
780 </script>
781 [% Asset.css("css/addbiblio.css") | $raw %]
782 </head>
783 <body id="cat_addbiblio" class="cat">
784
785    <div id="loading">
786        <div>Loading, please wait...</div>
787    </div>
788
789     [% INCLUDE 'header.inc' %]
790
791     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
792         <ol>
793             <li>
794                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
795             </li>
796             <li>
797                 <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
798             </li>
799             <li>
800                 <a href="#" aria-current="page">
801                     [% IF ( biblionumber ) %]
802                         Editing <em>[% title | html %]</em> (Record number [% biblionumber | html %])
803                     [% ELSE %]
804                         Add MARC record
805                     [% END %]
806                 </a>
807             </li>
808         </ol>
809     </nav>
810
811     <div class="main container-fluid">
812         <div class="row">
813             <div class="col-md-10 col-md-offset-1">
814
815                 <div id="check_errors"></div>
816
817                 <h1>
818                     [% IF ( biblionumber ) %]
819                         Editing <em>[% title | html %]</em> (Record number [% biblionumber | html %])
820                     [% ELSE %]
821                         Add MARC record [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]
822                     [% END %]
823                 </h1>
824
825                 [% UNLESS ( number ) %]
826                     <!-- show duplicate warning on tab 0 only -->
827                     [% IF ( duplicatebiblionumber ) %]
828                         <div class="dialog alert">
829                             <h3>Duplicate record suspected</h3>
830                             <p>Is this a duplicate of <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% duplicatebiblionumber | uri %]" onclick="openWindow('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% duplicatebiblionumber | uri %]&amp;popup=1', 'DuplicateBiblio','800','600'); return false;">[% duplicatetitle | html %] <i class="fa fa-window-restore"></i></a> ?</p>
831                             [% IF ( CAN_user_editcatalogue_edit_items ) %]
832                                 <form action="/cgi-bin/koha/cataloguing/additem.pl" method="get">
833                                     <input type="hidden" name="biblionumber" value="[% duplicatebiblionumber | html %]" />
834                                     <button type="submit" class="new"><i class="fa fa-fw fa-pencil"></i> Yes, edit existing items</button>
835                                 </form>
836                             [% ELSE %]
837                                 <form action="/cgi-bin/koha/catalogue/detail.pl" method="get">
838                                     <input type="hidden" name="biblionumber" value="[% duplicatebiblionumber | html %]" />
839                                     <input type="submit" value="Yes: View existing items" />
840                                 </form>
841                             [% END %]
842                             <form action="/cgi-bin/koha/cataloguing/addbiblio.pl" method="get">
843                                 [% IF ( CAN_user_editcatalogue_edit_items ) %]
844                                     <button type="submit" class="new" onclick="confirmnotdup('items'); return false;"><i class="fa fa-fw fa-save"></i> No, save as new record</button>
845                                 [% ELSE %]
846                                     <button type="submit" class="new" onclick="confirmnotdup('view'); return false;"><i class="fa fa-fw fa-save"></i> No, save as new record</button>
847                                 [% END %]
848                             </form>
849                         </div> <!-- /.dialog.alert -->
850                     [% END # /IF duplicatebiblionumber %]
851                 [% END # /UNLESS number %]
852
853                 [% IF ( done ) %]
854                     <script>
855                         opener.document.forms['f'].biblionumber.value=[% biblionumber | html %];
856                         opener.document.forms['f'].title.value='[% title | html %]';
857                         window.close();
858                     </script>
859                 [% ELSE %]
860                     <form method="post" name="f" id="f" action="/cgi-bin/koha/cataloguing/addbiblio.pl" onsubmit="return Check();">
861                         <input type="hidden" value="[% IF ( biblionumber ) %]view[% ELSE %]items[% END %]" id="redirect" name="redirect" />
862                         <input type="hidden" value="" id="current_tab" name="current_tab" />
863                         <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
864                 [% END %]
865
866                 <div id="toolbar" class="btn-toolbar">
867                     [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
868                         [% IF (circborrowernumber) %][%# fast cataloging must lead to items %]
869                             <!-- Action is under fast cataloging - Save button redirecting to items -->
870                             <div class="btn-group"><a href="#" id="saveanditems" class="btn btn-default"><i class="fa fa-save"></i> Save</a></div>
871                         [% ELSE %]
872                             <!-- Not using fast cataloging - Display split menu -->
873                             <div class="btn-group">
874                                 <button class="btn btn-default" id="saverecord"><i class="fa fa-save"></i> Save</button>
875                                 <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
876                                 <span class="caret"></span>
877                                 </button>
878                                 <ul class="dropdown-menu">
879                                     <li><a id="saveandview" href="#">Save and view record</a></li>
880                                     <li><a id="saveanditems" href="#">Save and edit items</a></li>
881                                     <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
882                                 </ul>
883                             </div>
884                         [% END %]
885                     [% ELSE %]
886                         <!-- User cannot edit items - single button redirecting to view -->
887                         <div class="btn-group"><a href="#" id="saveandview" class="btn btn-default"><i class="fa fa-save"></i> Save</a></div>
888                     [% END # /IF CAN_user_editcatalogue_edit_items %]
889
890                     [% UNLESS (circborrowernumber) %][%# Hide in fast cataloging %]
891                         [% IF biblionumber %]
892                             <div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Replace record via Z39.50/SRU search</a></div>
893                         [% ELSE %]
894                             <div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div>
895                         [% END %]
896                         [% IF ( CAN_user_editauthorities ) %]
897                             <div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div>
898                         [% END %]
899                     [% END %]
900
901                     <div class="btn-group">
902                         <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"></i> Settings <span class="caret"></span></button>
903                         <ul id="settings-menu" class="dropdown-menu">
904                             [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 && CAN_user_editcatalogue_advanced_editor %]
905                                 <li><a href="#" id="switcheditor">Switch to advanced editor</a></li>
906                             [% END %]
907                             [% UNLESS advancedMARCEditor %]
908                                 <li>
909                                     <a href="#" id="marcDocsSelect"><i class="fa fa-check-square-o"></i> Show MARC tag documentation links</a>
910                                 <li>
911                                     <a href="#" id="marcTagsSelect"><i class="fa fa-check-square-o"></i> Show tags</a>
912                                 </li>
913                             [% END %]
914                             <li class="dropdown-header">Change framework</li>
915                             <li>
916                                 <a href="#" class="change-framework" data-frameworkcode="">
917                                     [% IF ( frameworkcode ) %]
918                                        <i class="fa fa-fw">&nbsp;</i>
919                                     [% ELSE %]
920                                         <i class="fa fa-fw fa-check"></i>
921                                     [% END %]
922                                     Default
923                                 </a>
924                             </li>
925                             [% FOREACH framework IN frameworks%]
926                                 <li>
927                                     <a href="#" class="change-framework" data-frameworkcode="[% framework.frameworkcode | html %]">
928                                         [% IF framework.frameworkcode == frameworkcode %]
929                                             <i class="fa fa-fw fa-check"></i>
930                                         [% ELSE %]
931                                             <i class="fa fa-fw">&nbsp;</i>
932                                         [% END %]
933                                         [% framework.frameworktext | html %]
934                                     </a>
935                                 </li>
936                             [% END %]
937                         </ul> <!-- /#settings-menu -->
938                     </div> <!-- /.btn-group -->
939                     [% UNLESS (circborrowernumber) %][%# Hide in fast cataloging %]
940                         [% IF (biblionumber) %]
941                             <div class="btn-group">
942                                 <a href="[% PROCESS biblio_a_href biblionumber => biblionumber %]" class="btn btn-default" id="cancel">Cancel</a>
943                             </div>
944                         [% ELSE %]
945                             <div class="btn-group">
946                                 <a class="btn btn-default" id="cancel" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cancel</a>
947                             </div>
948                         [% END %]
949                         <div id="show-errors" class="btn-group"></div>
950                     [% END # /UNLESS circborrowernumber %]
951                     <div class="toolbar-tabs-container">
952                         [% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %]
953                             <ul class="toolbar-tabs">
954                                 [%- FOREACH BIG_LOO IN BIG_LOOP -%]
955                                     [% IF loop.first %]
956                                         <li class="selected">
957                                     [% ELSE %]
958                                         <li>
959                                     [% END %]
960                                         <a data-tabid="[% BIG_LOO.number | html %]" href="#tab[% BIG_LOO.number | html %]XX">[% BIG_LOO.number | html %]</a>
961                                     </li>
962                                 [%- END -%]
963                             </ul>
964                         [% END %]
965                         <ul class="tag_anchors_list">
966                             [% FOREACH BIG_LOO IN BIG_LOOP %]
967                                 [% IF loop.first %][% SET tab_selected = "tab_selected" %][% ELSE %][% SET tab_selected = "" %][% END %]
968                                 [% FOREACH innerloo IN BIG_LOO.innerloop %]
969                                     [% IF ( innerloo.tag ) %]
970                                         <li class="tag_anchors tag_anchors_[% BIG_LOO.number | html %] [% tab_selected | html %]">
971                                             <a class="tag_anchor" id="tag_anchor_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" title="tag_anchor_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" href="#div_indicator_tag_[% innerloo.tag | uri %]_[% innerloo.index | uri %][% innerloo.random | uri %]">[% innerloo.tag | uri %]</a>
972                                         </li>
973                                     [% END %]
974                                 [% END %]
975                             [% END %]
976                         </ul>
977                     </div>
978                 </div> <!-- /#toolbar.btn-toolbar -->
979
980                 [% IF bib_doesnt_exist %]
981                     <div class="dialog alert">
982                         The record you are trying to edit doesn't exist.<br>
983                         <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Add a new record</a> or <a href="/cgi-bin/koha/catalogue/search.pl">do a catalog search</a>.
984                     </div>
985                 [% END %]
986
987                 [% IF ( popup ) %]
988                         <input type="hidden" name="mode" value="popup" />
989                 [% END %]
990                 <input type="hidden" name="op" value="addbiblio" />
991                 <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode | html %]" />
992                 <input type="hidden" name="z3950" value="[% z3950 | html %]" />
993                 <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
994                 <input type="hidden" name="breedingid" value="[% breedingid | html %]" />
995                 <input type="hidden" name="changed_framework" value="" />
996
997                 <div id="addbibliotabs" class="toptabs numbered">
998                     <ul>
999                         [% FOREACH BIG_LOO IN BIG_LOOP %]
1000                             <li><a href="#tab[% BIG_LOO.number | uri %]XX">[% BIG_LOO.number | html %]</a></li>
1001                         [% END %]
1002                     </ul>
1003
1004                     [% FOREACH BIG_LOO IN BIG_LOOP %]
1005                         <div id="tab[% BIG_LOO.number | html %]XX">
1006
1007                             [% IF ( BIG_LOOP.size > 1 ) %]
1008                                 <h3>Section [% BIG_LOO.number | html %]</h3>
1009                             [% END %]
1010                             [% previous = "" %]
1011                             [% FOREACH innerloo IN BIG_LOO.innerloop %]
1012                                 [% IF ( innerloo.tag ) %]
1013                                 [% IF innerloo.tag != previous %]
1014                                     [% IF previous != "" %]
1015                                         </ul>
1016                                     [% END %]
1017                                     [% previous = innerloo.tag %]
1018                                     [% IF ( innerloo.repeatable ) %]
1019                                         <ul class="sortable_field">
1020                                     [% ELSE %]
1021                                         <ul>
1022                                     [% END %]
1023                                 [% END %]
1024                                     [% IF ( innerloo.repeatable ) %]
1025                                         <li class="tag sortable_tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
1026                                     [% ELSE %]
1027                                         <li class="tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
1028                                     [% END %]
1029                                         <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
1030                                             [% IF advancedMARCEditor %]
1031                                                 <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>
1032                                             [% ELSE %]
1033                                                 <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
1034                                                 <a href="#" class="marcdocs" onclick="PopupMARCFieldDoc('[% innerloo.tag | html %]'); return false;">&nbsp;?</a>
1035                                             [% END %]
1036
1037                                             [% IF ( innerloo.fixedfield ) %]
1038                                                 <input type="text"
1039                                                     tabindex="1"
1040                                                     class="indicator flat"
1041                                                     style="display:none;"
1042                                                     name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
1043                                                     size="1"
1044                                                     maxlength="1"
1045                                                     value="[% innerloo.indicator1 | html %]" />
1046                                                 <input type="text"
1047                                                     tabindex="1"
1048                                                     class="indicator flat"
1049                                                     style="display:none;"
1050                                                     name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
1051                                                     size="1"
1052                                                     maxlength="1"
1053                                                     value="[% innerloo.indicator2 | html %]" />
1054                                             [% ELSE %]
1055                                                 <input type="text"
1056                                                     tabindex="1"
1057                                                     class="indicator flat"
1058                                                     name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
1059                                                     size="1"
1060                                                     maxlength="1"
1061                                                     value="[% innerloo.indicator1 | html %]" />
1062                                                 <input type="text"
1063                                                     tabindex="1"
1064                                                     class="indicator flat"
1065                                                     name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
1066                                                     size="1"
1067                                                     maxlength="1"
1068                                                     value="[% innerloo.indicator2 | html %]" />
1069                                             [% END # /IF innerloo.fixedfield %] -
1070
1071                                             [% UNLESS advancedMARCEditor %]
1072                                                 <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>
1073                                             [% END %]
1074
1075                                             <span class="field_controls">
1076                                                 [% IF ( innerloo.repeatable ) %]
1077                                                     <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','0','[% advancedMARCEditor | html %]'); return false;" title="Repeat this Tag">
1078                                                         <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this Tag" />
1079                                                     </a>
1080                                                 [% END %]
1081                                                 <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this Tag">
1082                                                     <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this Tag" />
1083                                                 </a>
1084                                             </span> <!-- /.field_controls -->
1085                                         </div> <!-- /div.tag_title -->
1086
1087                                         <ul class="sortable_subfield">
1088                                         [% FOREACH subfield_loo IN innerloo.subfield_loop %]
1089                                             <!--  One line on the marc editor -->
1090                                             <li class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
1091                                                 <div class="subfieldcode">
1092                                                     <input type="text"
1093                                                             title="[% subfield_loo.marc_lib | $raw %]"
1094                                                             style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
1095                                                             name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
1096                                                             value="[% subfield_loo.subfield | html %]"
1097                                                             size="1"
1098                                                             maxlength="1"
1099                                                             class="flat"
1100                                                             tabindex="0" />
1101                                                 </div>
1102                                                 [% UNLESS advancedMARCEditor %]
1103                                                     [% IF ( subfield_loo.mandatory ) %]
1104                                                         <div class="subfield subfield_mandatory">
1105                                                     [% ELSIF ( subfield_loo.important ) %]
1106                                                         <div class="subfield subfield_important">
1107                                                     [% ELSE %]
1108                                                         <div class="subfield">
1109                                                     [% END %]
1110                                                         [% IF ( subfield_loo.fixedfield ) %]
1111                                                             <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">
1112                                                         [% ELSE %]
1113                                                             <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
1114                                                         [% END %]
1115                                                         [% subfield_loo.marc_lib | $raw %]
1116                                                         </label>
1117                                                     </div>
1118                                                 [% END %]
1119
1120                                                 [% SET mv = subfield_loo.marc_value %]
1121                                                 <div id="field_marceditor[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]" class="field_marceditor">
1122                                                     [% IF ( mv.type == 'text' ) %]
1123                                                         [% IF ( mv.readonly == 1 ) %]
1124                                                             <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor readonly" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" readonly="readonly" />
1125                                                         [% ELSE %]
1126                                                             <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
1127                                                         [% END %]
1128
1129                                                     [% ELSIF ( mv.type == 'text_complex' ) %]
1130                                                         <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor framework_plugin" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
1131                                                         [% mv.javascript | $raw %]
1132                                                     [% ELSIF ( mv.type == 'hidden' ) %]
1133                                                         <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
1134                                                     [% ELSIF ( mv.type == 'textarea' ) %]
1135                                                         <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
1136                                                     [% ELSIF ( mv.type == 'select' ) %]
1137                                                     [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
1138                                                         <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]">
1139                                                     [% ELSE %]
1140                                                         <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
1141                                                     [% END %]
1142                                                         [% FOREACH aval IN mv.values %]
1143                                                             [% IF aval == mv.default %]
1144                                                             <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
1145                                                             [% ELSE %]
1146                                                             <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
1147                                                             [% END %]
1148                                                         [% END %]
1149                                                         </select>
1150                                                     [% END  # /IF (mv.type...) %]
1151                                                 </div>
1152                                                 [% IF ( subfield_loo.mandatory ) %]
1153                                                     <div class="subfield_loop_mandatory">
1154                                                         <span class="required">Required</span>
1155                                                     </div>
1156                                                 [% ELSIF ( subfield_loo.important ) %]
1157                                                     <div class="subfield_loop_mandatory">
1158                                                         <span class="important">Important</span>
1159                                                     </div>
1160                                                 [% END %]
1161                                                 <div class="subfield_controls">
1162                                                     [% IF ( mv.type == 'text' ) %]
1163                                                         [% IF ( mv.authtype ) %]
1164                                                             <a href="#" class="buttonDot tag_editor" onclick="openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtype | html -%]','biblio'); return false;" tabindex="1" title="Tag editor">Tag editor</a>
1165                                                         [% END %]
1166                                                     [% ELSIF ( mv.type == 'text_complex' ) %]
1167                                                             [% IF mv.noclick %]
1168                                                                 <span class="buttonDot tag_editor disabled" tabindex="-1" title="Field autofilled by plugin"></span>
1169                                                             [% ELSE %]
1170                                                                 [% IF mv.plugin == "upload.pl" %]
1171                                                                     <a href="#" id="buttonDot_[% mv.id | html %]" class="tag_editor upload framework_plugin" tabindex="1"><i class="fa fa-upload" aria-hidden="true"></i> Upload</a>
1172                                                                 [% ELSE %]
1173                                                                     <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor framework_plugin" tabindex="1" title="Tag editor">Tag editor</a>
1174                                                                 [% END %]
1175                                                             [% END %]
1176                                                         </span>
1177                                                     [% END %]
1178                                                     [% IF ( subfield_loo.repeatable ) %]
1179                                                         <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;">
1180                                                             <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
1181                                                         </a>
1182                                                         <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
1183                                                             <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
1184                                                         </a>
1185                                                     [% END %]
1186                                                 </div>
1187                                             </li> <!-- /.subfield_line -->
1188                                             <!-- End of the line -->
1189                                         [% END # /FOREACH subfield_loop %]
1190                                         </ul> <!--  /.sortable_subfield -->
1191                                     </li> <!-- /.tag.clearfix -->
1192                                 [% END %]<!-- if innerloo.tag -->
1193                             [% END # /FOREACH BIG_LOO.innerloop %]
1194                             </ul> <!--  /.sortable_field -->
1195                         </div> <!-- /#tabXXX -->
1196                     [% END # /FOREACH BIG_LOOP %]
1197                 </div><!-- /#addbibliotabs -->
1198
1199                 [%# Fields for fast cataloging %]
1200                 <input type="hidden" name="barcode" value="[% barcode | html %]" />
1201                 <input type="hidden" name="branch" value="[% branch | html %]" />
1202                 <input type="hidden" name="circborrowernumber" value="[% circborrowernumber | html %]" />
1203                 <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
1204                 <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
1205                 [%# End of fields for fast cataloging %]
1206             </form> <!-- /name=f -->
1207
1208             [% INCLUDE 'modals/cataloguing_create_av.inc' %]
1209
1210         </div> <!-- /.col-md-10.col-md-offset-1 -->
1211     </div> <!-- /.row -->
1212
1213 [% INCLUDE 'intranet-bottom.inc' %]