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