Bug 19952: Update popup window templates to use Bootstrap grid: UNIMARC cataloging...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / merge.tt
index 745680c..c94d88d 100644 (file)
+[% USE Asset %]
+[% SET footerjs = 1 %]
+[% PROCESS 'merge-record.inc' %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
-[% INCLUDE 'greybox.inc' %]
 [% INCLUDE 'doc-head-close.inc' %]
 <style type="text/css">
 div.record ul, div.record li { float:none; display:block; }
 div#result { margin-top: 1em; }
 /* We use this style "against" the li ui-tabs-nav style automatically applied */
+#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }
 </style>
-<script type="text/javascript">
-//<![CDATA[
-
-    // When submiting the form
-    function mergeformsubmit() {
-           $("ul#ulrecord1").remove();
-           $("ul#ulrecord2").remove();
-}
-
-
-$(document).ready(function(){
-    // Creating tabs
-    $("#tabs > ul").tabs();
-
-    // Getting marc structure via ajax
-    tagslib = [];
-    $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
-       tagslib = json;
-    });
-
-
-    // Toggle a field / subfield
-    function toggleField(pField) {
-
-       // Getting the key of the clicked checkbox
-       var ckid   = $(pField).attr("id");
-       var tab    = ckid.split('_');
-       var source = tab[1]; // From which record the click came from
-       var key    = tab[2];
-       var type   = $(pField).attr("class");
-
-       // Getting field/subfield
-       var field;
-       var subfield;
-       if (type == "subfieldpick") {
-
-                   field = $(pField).parent().parent().parent().find("span.field").text();
-                   subfield = $(pField).parent().find("span.subfield").text();
-       } else {
-
-                   field = $(pField).parent().find("span.field").text();
-       }
-
-       // If the field has just been checked
-       if (pField.checked) {
-
-           // We check for repeatability
-           var canbeadded = true;
-           if (type == "subfieldpick") {
-               var repeatable = 1;
-               var alreadyexists = 0;
-               if (tagslib[field] && tagslib[field][subfield]) {
-                   repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number 
-                   // TODO : Checking for subfields
-               }
-           } else {
-               if (tagslib[field]) {
-                   repeatable = tagslib[field].repeatable;
-                   alreadyexists = $("#resultul span.field:contains(" + field + ")");
-                   if (repeatable == 0 && alreadyexists.length != 0) {
-                       canbeadded = false;
-                   }
-               }
-           }
-           // If the field is not repeatable, we check if it already exists in the result table
-           if (canbeadded == false) {
-               alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
-               pField.checked = 0;
-           } else {
-
-               // Cloning the field or subfield we picked
-               var clone = $(pField).parent().clone();
-
-               // Removing the checkboxes from it
-               $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
-                   $(this).remove();
-               });
-
-
-               // If we are a subfield
-               if (type == "subfieldpick") {
-                   // then we need to find who is our parent field...
-                   fieldkey = $(pField).parent().parent().parent().attr("id");
-
-                   // Find where to add the subfield
-
-                   // First, check if the field is not already in the destination record
-                   if ($("#resultul li#" + fieldkey).length > 0) { 
-                       // If so, we add our field to it
-                       $("#resultul li#" + fieldkey + " ul").append(clone);
-                   } else {
-                       // If not, we add the subfield to the first matching field
-                       var where = 0;
-                       $("#resultul li span.field").each(function() {
-                           if (where == 0 && $(this).text() == field) {
-                               where = this;
-                           }
-                       });
-
-                       // If there is no matching field in the destination record
-                       if (where == 0) {
-
-                           // TODO: 
-                           // We select the whole field and removing non-selected subfields, instead of...
-
-                           // Alerting the user 
-                           alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
-                           pField.checked = false;
-
-                       } else {
-                           $(where).nextAll("ul").append(clone);
-                       }
-
-                   }
-
-                   
-                   
-               } else {
-                   // If we are a field
-                   var where = 0;
-                   // Find where to add the field
-                   $("#resultul li span.field").each(function() {
-                       if (where == 0 && $(this).text() > field) {
-                           where = this;
-                       }
-                   });
-
-                   $(where).parent().before(clone);
-               }
-           }
-       } else {
-
-           // Else, we remove it from the results tab
-           $("ul#resultul li#k" + key).remove();
-       }
-}
-
-
-    // When a field is checked / unchecked 
-    $('input.fieldpick').click(function() {
-       toggleField(this);
-       // (un)check all subfields
-       var ischecked = this.checked;
-       $(this).parent().find("input.subfieldpick").each(function() {
-           this.checked = ischecked;
-       });
-    });
-
-    // When a field or subfield is checked / unchecked
-    $("input.subfieldpick").click(function() {
-       toggleField(this);
-    });
-
-});
-
-function changeFramework(fw) {
-    $("#Frameworks").val(fw);
-}
-
-//]]>
-</script>
 </head>
+
 <body id="cat_merge" class="cat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cataloging-search.inc' %]
@@ -182,15 +26,63 @@ function changeFramework(fw) {
 
 <h1>Merging records</h1>
 [% IF ( result ) %]
-    [% IF ( errors ) %]
-       [% FOREACH error IN errors %]
-           <div class="dialog alert">[% error.error %].<br />Therefore, the record to be merged has not been deleted.</div>
-       [% END %]
-
-       [% ELSE %]
-       <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]"</script> 
-       <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% biblio1 %]">Click here to see the merged record.</a></p>
-       [% END %]
+    [% IF ( errors.size ) %]
+       [% FOREACH error IN errors %]
+           <div class="dialog alert">
+                [% IF error.code == 'CANNOT_MOVE' %]
+                    The following items could not be moved from the old record to the new one: [% error.value %]
+                [% ELSE %]
+                    [% error %]
+                [% END %]
+                <br />
+                Therefore, the record to be merged has not been deleted.
+            </div>
+       [% END %]
+
+    [% ELSE %]
+        <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber %]">Click here to see the merged record.</a></p>
+        <h3>Report</h3>
+        <table>
+            <thead>
+                <tr>
+                    <th>Biblionumber</th>
+                    [% FOREACH key IN report_header.keys.sort %]
+                        [% tag = key.substr(0, 3) %]
+                        [% code = key.substr(3, 1) %]
+                        [% IF code == '@' %]
+                            [% header = tag %]
+                        [% ELSE %]
+                            [% header = tag _ '$' _ code %]
+                        [% END %]
+                        <th>[% header %]</th>
+                    [% END %]
+                </tr>
+            </thead>
+            <tbody>
+                [% FOREACH record IN report_records %]
+                    <tr>
+                        <td>
+                            [% record.biblionumber %]
+                            [% IF loop.first %]
+                                (record kept)
+                            [% END %]
+                        </td>
+                        [% FOREACH key IN report_header.keys.sort %]
+                            <td>
+                                [% values = record.fields.$key %]
+                                [% IF values %]
+                                    [% FOREACH value IN record.fields.$key %]
+                                        [% value %]
+                                        [% UNLESS loop.last %]<br />[% END %]
+                                    [% END %]
+                                [% END %]
+                            </td>
+                        [% END %]
+                    </tr>
+                [% END %]
+            </tbody>
+        </table>
+    [% END %]
 
 [% ELSE %]
 
@@ -198,172 +90,92 @@ function changeFramework(fw) {
 <p>Please choose which record will be the reference for the merge. The record chosen as reference will be kept, and the other will be deleted.</p>
 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
     <fieldset class="rows">
-       <legend>Merge reference</legend>
-       <ol>
-       <li class="radio"><input type="radio" value="[% biblio1 %]" checked="checked" id="mergereference1" name="mergereference" onclick="changeFramework('[% frameworkcode1 %]')" /><label for="mergereference1">[% title1 %] [% FOREACH subtitl1 IN subtitle1 %] [% subtitl1.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblio1 %]" title="MARC" rel="gb_page_center[600,500]">[% biblio1 %]</a>)</label></li>
-       <li class="radio"><input type="radio" value="[% biblio2 %]" id="mergereference2" name="mergereference" onclick="changeFramework('[% frameworkcode2 %]')" /><label for="mergereference2">[% title2 %] [% FOREACH subtitl2 IN subtitle2 %] [% subtitl2.subfield %][% END %] (<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblio2 %]" title="MARC" rel="gb_page_center[600,500]">[% biblio2 %]</a>)</label></li>
-
-    [% IF frameworkselect %]
-          <li><label for="frameworkcode">Using framework:</label>
-                      <select name="frameworkcode" id="frameworkcode">
-                                      <option value="Default">Default</option>
-                                      [% FOREACH frameworkcodeloo IN frameworkselect %]
-                                          [% IF ( frameworkcodeloo.selected ) %]
-                                              <option value="[% frameworkcodeloo.value %]" selected="selected">
-                                          [% ELSE %]
-                                              <option value="[% frameworkcodeloo.value %]">
-                                          [% END %]
-                                           [% frameworkcodeloo.frameworktext %]
-                                           </option>
-                                      [% END %]
-                      </select></li>
+    <legend>Merge reference</legend>
+    <ol>
+        [% FOREACH record IN records %]
+            <li class="radio">
+                [% IF loop.first %]
+                    <input type="radio" value="[% record.biblionumber %]" checked="checked" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
+                [% ELSE %]
+                    <input type="radio" value="[% record.biblionumber %]" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
+                [% END %]
+                <label for="ref_biblionumber[% record.biblionumber %]">
+                    [% record.data.title %]
+                    [% FOREACH subtitle IN record.subtitles %]
+                        [% subtitle.subfield %]
+                    [% END %]
+                    ([% record.biblionumber %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber %]" class="previewData">View MARC</a>
+                </label>
+            </li>
+        [% END %]
+
+            <li>
+                <label for="frameworkcode">Using framework:</label>
+                <select name="frameworkcode" id="frameworkcode">
+                    <option value="">Default</option>
+                    [% FOREACH framework IN frameworks %]
+                        <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
+                    [% END %]
+                </select>
+            </li>
+    </ol>
+
+    [% FOREACH record IN records %]
+        <input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
     [% END %]
-</ol>
-
-       <input type="hidden" name="biblionumber" value="[% biblio1 %]" />
-       <input type="hidden" name="biblionumber" value="[% biblio2 %]" />
-       <fieldset class="action"><input type="submit" value="Next" /></fieldset>
+    <fieldset class="action">
+        <input type="submit" value="Next" />
+    </fieldset>
     </fieldset>
 </form>
+
+<div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
+    <div class="modal-dialog">
+    <div class="modal-content">
+    <div class="modal-header">
+        <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
+        <h3 id="dataPreviewLabel">Preview</h3>
+    </div>
+    <div class="modal-body">
+        <div id="loading"> <img src="[% interface %]/[% theme %]/img/spinner-small.gif" alt="" /> Loading </div>
+    </div>
+    <div class="modal-footer">
+        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
+    </div>
+    </div>
+    </div>
+</div>
+
 [% ELSE %]
-[% IF ( errors ) %]
-    [% FOREACH error IN errors %]
-       <div class="error">[% error.error %]</div>
-    [% END %]
+[% IF ( errors.size ) %]
+    <div class="dialog alert">
+        [% FOREACH error IN errors %]
+            <p>[% error %]</p>
+        [% END %]
+    </div>
 [% ELSE %]
 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
 
 <div class="yui-g">
 <div class="yui-u first">
-<div id="tabs" class="toptabs">
-<h2>Source records</h2>
-    <ul>
-       <li><a href="#tabrecord1">[% biblio1 %]</a></li>
-       <li><a href="#tabrecord2">[% biblio2 %]</a></li>
-    </ul>
-    <div id="tabrecord1">
-       [% IF ( record1 ) %]
-
-           <div class="record">
-               <ul id="ulrecord1">
-               [% FOREACH record IN record1 %]
-                       [% FOREACH fiel IN record.field %]
-                       <li id="k[% fiel.key %]">
-                           <input type="checkbox" checked="checked" class="fieldpick" id="rec_1_[% fiel.key %]" /> 
-                           <span class="field">[% fiel.tag %]</span>
-
-                           <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
-                           <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
-                           [% IF ( fiel.value ) %] / [% fiel.value %]
-                               <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
-                               <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
-                           [% END %]
-
-                           [% IF ( fiel.subfield ) %]
-                               <ul>
-                                   [% FOREACH subfiel IN fiel.subfield %]
-                                       <li id="k[% subfiel.subkey %]">
-                                           <input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_[% subfiel.subkey %]" /> 
-                                           <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
-                                       </li>
-                                   [% END %]
-                               </ul>
-                           [% END %]
-                   [% END %]
-                   </li>
-               [% END %]
-               </ul>
-           </div><!-- /div.record -->
-[% END %]
-    </div><!-- /div#tabrecord1 -->
-    <div id="tabrecord2">
-       [% IF ( record2 ) %]
-
-          <div class="record">
-               <ul id="ulrecord2">
-               [% FOREACH record IN record2 %]
-                   [% FOREACH fiel IN record.field %]
-                   <li id="k[% fiel.key %]">
-                       <input type="checkbox" class="fieldpick" id="rec_2_[% fiel.key %]" /> 
-                       <span class="field">[% fiel.tag %]</span>
-
-                       <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
-                       <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
-                       [% IF ( fiel.value ) %] / [% fiel.value %]
-                       <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
-                       <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
-                       [% END %]
-
-                       [% IF ( fiel.subfield ) %]
-                           <ul>
-                               [% FOREACH subfiel IN fiel.subfield %]
-                                   <li id="k[% subfiel.subkey %]">
-                                       <input type="checkbox" class="subfieldpick" id="rec_2_[% subfiel.subkey %]" />
-                                       <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
-                                   </li>
-                               [% END %]
-                           </ul>
-                       [% END %]
-                   [% END %]
-                   </li>
-               [% END %]
-               </ul>
-           </div>
-           <!-- /div.record -->
-
-
-
-
-       [% END %]
-    </div><!-- /div#tabrecord2 -->
-</div> <!-- // #tabs -->
+[% PROCESS mergesource sourcerecords=records %]
 </div>
 <div class="yui-u">
-<div id="result">
-    <h2>Destination record</h2>
-    <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
-           <ul id="resultul">
-       [% FOREACH record IN record1 %]
-                   [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]"><span class="field">[% fiel.tag %]</span>  
-                       <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
-                       <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
-                   [% IF ( fiel.value ) %] /
-                       [% fiel.value %]
-                       <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
-                       <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
-                   [% END %]
-                       
-                   [% IF ( fiel.subfield ) %]
-                       <ul>
-                           [% FOREACH subfiel IN fiel.subfield %]
-                               <li id="k[% subfiel.subkey %]">
-                                   <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
-                                   <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
-                               </li>
-                           [% END %]
-                       </ul>
-                   [% END %]
-
-                   [% END %]
-                   </li>
-               [% END %]
-
-           </ul>
-</div>
-</div> <!-- // #result -->
+[% PROCESS mergetarget %]
 </div> <!-- .yui-u -->
 
-<input type="hidden" name="biblio1" value="[% biblio1 %]" />
-<input type="hidden" name="biblio2" value="[% biblio2 %]" />
-<input type="hidden" name="mergereference" value="[% mergereference %]" />
+<input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber %]" />
+[% FOREACH record IN records %]
+    <input type="hidden" name="biblionumber" value="[% record.recordid %]" />
+[% END %]
 <input type="hidden" name="frameworkcode" value="[% framework %]" />
 
-<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
+<fieldset class="action">
+    <input type="submit" name="merge" value="Merge" />
+    <label for="report_fields">Fields to display in report:</label>
+    <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields %]" />
+    <span class="hint">(Example: "001,245ab,600")
+</fieldset>
 </div>
 </form>
 [% END %]
@@ -374,4 +186,118 @@ function changeFramework(fw) {
 </div>
 </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("js/merge-record.js") %]
+    [% INCLUDE 'merge-record-strings.inc' %]
+    <script type="text/javascript">
+        [% UNLESS (result) %]
+          [% IF (choosereference) %]
+            function changeFramework(fw) {
+                $("#frameworkcode").val(fw);
+            }
+            $(document).ready(function(){
+                    $(".previewData").on("click", function(e){
+                    e.preventDefault();
+                    var ltitle = $(this).text();
+                    var page = $(this).attr("href");
+                    $("#dataPreviewLabel").text(ltitle);
+                    $("#dataPreview .modal-body").load(page + " div");
+                    $('#dataPreview').modal({show:true});
+                });
+                $("#dataPreview").on("hidden", function(){
+                    $("#dataPreviewLabel").html("");
+                    $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+                });
+            });
+          [% ELSE %]
+            function check_mandatory () {
+                var missing = {
+                    'fields': [],
+                    'subfields': []
+                };
+                for (tag in tagslib) {
+                    if (tag == '000' || tag == '001')
+                        continue;
+                    if (tagslib[tag].mandatory == 1) {
+                        if ($("#resultul span.field:contains("+ tag +")").length == 0) {
+                            missing.fields.push(tag);
+                        }
+                    }
+                    for (subfieldcode in tagslib[tag]) {
+                        if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
+                        || subfieldcode == 'repeatable' || subfieldcode == 'tab'
+                        || subfieldcode == '@') {
+                            continue;
+                        }
+                        if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
+                            var fields = $("#resultul span.field:contains("+ tag +")");
+                            $(fields).each(function() {
+                                var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
+                                if (subfields.length == 0) {
+                                    missing.subfields.push( {
+                                        'tag': tag,
+                                        'subfieldcode': subfieldcode
+                                    } );
+                                }
+                            });
+                        }
+                    }
+                }
+                return missing;
+            }
+
+            // When submiting the form
+            function mergeformsubmit() {
+                var missing = check_mandatory();
+                var alert_msg = '';
+                var error = 0;
+                if (missing.fields.length > 0) {
+                    alert_msg += _("Following required fields are missing:") + "\n";
+                    for (var i in missing.fields) {
+                        alert_msg += "\t- " + missing.fields[i] + "\n";
+                        error ++;
+                    }
+                    alert_msg += "\n";
+                }
+                if (missing.subfields.length > 0) {
+                    alert_msg += _("Following required subfields are missing:") + "\n";
+                    for (var i in missing.subfields) {
+                        var subfield = missing.subfields[i];
+                        alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
+                        error ++;
+                    }
+                }
+
+                if (error != 0) {
+                    alert(alert_msg);
+                    return false;
+                } else {
+                    $("#tabs").remove();
+                }
+            }
+
+        $(document).ready(function(){
+            tagslib = [];
+            $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
+              tagslib = json;
+              rebuild_target($("#tabs"), $("#resultul"));
+            });
+
+            // Creating tabs
+            $("#tabs").tabs();
+
+            // Check all checkboxes in first tab, and uncheck all others to avoid
+            // inconsistencies from a page refresh.
+            $('#tabs div#tabrecord[% ref_biblionumber %]').find('input[type="checkbox"]').prop('checked', true);
+            $('#tabs > div:not("#tabrecord[% ref_biblionumber %]")').find('input[type="checkbox"]').prop('checked', false);
+
+            //Set focus to cataloging search
+            $("input[name=q]:eq(0)").focus();
+        });
+
+          [% END %]
+        [% END %]
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]