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