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