Bug 28962: Add del-unv-selfreg to crontab
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / merge.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% PROCESS 'merge-record.inc' %]
5
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Merging records &rsaquo; Cataloging &rsaquo; Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <style>
10 div.record ul, div.record li { float:none; display:block; }
11 div#result { margin-top: 1em; }
12 /* We use this style "against" the li ui-tabs-nav style automatically applied */
13 #dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }
14 </style>
15 </head>
16
17 <body id="cat_merge" class="cat">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'cataloging-search.inc' %]
20
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
22     <ol>
23         <li>
24             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
25         </li>
26         <li>
27             <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
28         </li>
29         <li>
30             <a href="#" aria-current="page">
31                 Merging records
32             </a>
33         </li>
34 </nav>
35
36 <div class="main container-fluid">
37     <div class="row">
38         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
39
40 <h1>Merging records</h1>
41 [% IF ( result ) %]
42     [% IF ( errors.size ) %]
43        [% FOREACH error IN errors %]
44            <div class="dialog alert">
45                 [% IF error.code == 'CANNOT_MOVE' %]
46                     The following items could not be moved from the old record to the new one: [% error.value | html %]
47                 [% ELSE %]
48                     [% error | html %]
49                 [% END %]
50                 <br />
51                 Therefore, the record to be merged has not been deleted.
52             </div>
53        [% END %]
54
55     [% ELSE %]
56         <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber | uri %]">View the merged record.</a></p>
57         <h3>Report</h3>
58         <table>
59             <thead>
60                 <tr>
61                     <th>Biblionumber</th>
62                     [% FOREACH key IN report_header.keys.sort %]
63                         [% tag = key.substr(0, 3) %]
64                         [% code = key.substr(3, 1) %]
65                         [% IF code == '@' %]
66                             [% header = tag %]
67                         [% ELSE %]
68                             [% header = tag _ '$' _ code %]
69                         [% END %]
70                         <th>[% header | html %]</th>
71                     [% END %]
72                 </tr>
73             </thead>
74             <tbody>
75                 [% FOREACH record IN report_records %]
76                     <tr>
77                         <td>
78                             [% record.biblionumber | html %]
79                             [% IF loop.first %]
80                                 (record kept)
81                             [% END %]
82                         </td>
83                         [% FOREACH key IN report_header.keys.sort %]
84                             <td>
85                                 [% values = record.fields.$key %]
86                                 [% IF values %]
87                                     [% FOREACH value IN record.fields.$key %]
88                                         [% value | html %]
89                                         [% UNLESS loop.last %]<br />[% END %]
90                                     [% END %]
91                                 [% END %]
92                             </td>
93                         [% END %]
94                     </tr>
95                 [% END %]
96             </tbody>
97         </table>
98     [% END %]
99
100 [% ELSE %]
101
102 [% IF ( choosereference ) %]
103 <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>
104 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
105     <fieldset class="rows">
106     <legend>Merge reference</legend>
107     <ol>
108         [% FOREACH record IN records %]
109             <li class="radio">
110                 [% IF loop.first %]
111                     <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
112                 [% ELSE %]
113                     <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" />
114                 [% END %]
115                 <label for="ref_biblionumber[% record.biblionumber | html %]">
116                     [% INCLUDE 'biblio-title.inc' biblio=record.data %]
117                     ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a>
118                 </label>
119             </li>
120         [% END %]
121
122             <li>
123                 <label for="frameworkcode">Using framework:</label>
124                 <select name="frameworkcode" id="frameworkcode">
125                     <option value="">Default</option>
126                     [% FOREACH framework IN frameworks %]
127                         <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
128                     [% END %]
129                 </select>
130             </li>
131     </ol>
132
133     [% FOREACH record IN records %]
134         <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" />
135     [% END %]
136     <fieldset class="action">
137         <input type="submit" value="Next" />
138     </fieldset>
139     </fieldset>
140 </form>
141
142 <div id="dataPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
143     <div class="modal-dialog">
144     <div class="modal-content">
145     <div class="modal-header">
146         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
147         <h3 id="dataPreviewLabel">Preview</h3>
148     </div>
149     <div class="modal-body">
150         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
151     </div>
152     <div class="modal-footer">
153         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
154     </div>
155     </div>
156     </div>
157 </div>
158
159 [% ELSE %]
160 [% IF ( errors.size ) %]
161     <div class="dialog alert">
162         [% FOREACH error IN errors %]
163             <p>[% error | html %]</p>
164         [% END %]
165     </div>
166 [% ELSE %]
167 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
168
169 <div class="col-sm-6">
170 [% PROCESS mergesource sourcerecords=records %]
171 </div>
172 <div class="col-sm-6">
173 [% PROCESS mergetarget %]
174 </div> <!-- .col-sm-6 -->
175
176 <input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber | html %]" />
177 [% FOREACH record IN records %]
178     <input type="hidden" name="biblionumber" value="[% record.recordid | html %]" />
179 [% END %]
180 <input type="hidden" name="frameworkcode" value="[% framework | html %]" />
181
182 <fieldset class="action">
183     <input type="submit" name="merge" value="Merge" />
184     <label for="report_fields">Fields to display in report:</label>
185     <input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields | html %]" />
186     <span class="hint">(Example: "001,245ab,600")</span>
187 </fieldset>
188 </form>
189 [% END %]
190 [% END %]
191 [% END %]
192
193 </div>
194 </div>
195
196 [% MACRO jsinclude BLOCK %]
197     [% Asset.js("js/merge-record.js") | $raw %]
198     <script>
199         [% UNLESS (result) %]
200           [% IF (choosereference) %]
201             function changeFramework(fw) {
202                 $("#frameworkcode").val(fw);
203             }
204             $(document).ready(function(){
205                     $(".previewData").on("click", function(e){
206                     e.preventDefault();
207                     var ltitle = $(this).text();
208                     var page = $(this).attr("href");
209                     $("#dataPreviewLabel").text(ltitle);
210                     $("#dataPreview .modal-body").load(page + " div");
211                     $('#dataPreview').modal({show:true});
212                 });
213                 $("#dataPreview").on("hidden.bs.modal", function(){
214                     $("#dataPreviewLabel").html("");
215                     $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
216                 });
217             });
218           [% ELSE %]
219             function check_mandatory () {
220                 var missing = {
221                     'fields': [],
222                     'subfields': []
223                 };
224                 for (tag in tagslib) {
225                     if (tag == '000' || tag == '001')
226                         continue;
227                     if (tagslib[tag].mandatory == 1) {
228                         if ($("#resultul span.field:contains("+ tag +")").length == 0) {
229                             missing.fields.push(tag);
230                         }
231                     }
232                     for (subfieldcode in tagslib[tag]) {
233                         if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
234                         || subfieldcode == 'repeatable' || subfieldcode == 'tab'
235                         || subfieldcode == '@') {
236                             continue;
237                         }
238                         if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
239                             var fields = $("#resultul span.field:contains("+ tag +")");
240                             $(fields).each(function() {
241                                 var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
242                                 if (subfields.length == 0) {
243                                     missing.subfields.push( {
244                                         'tag': tag,
245                                         'subfieldcode': subfieldcode
246                                     } );
247                                 }
248                             });
249                         }
250                     }
251                 }
252                 return missing;
253             }
254
255             // When submiting the form
256             function mergeformsubmit() {
257                 var missing = check_mandatory();
258                 var alert_msg = '';
259                 var error = 0;
260                 if (missing.fields.length > 0) {
261                     alert_msg += _("Following required fields are missing:") + "\n";
262                     for (var i in missing.fields) {
263                         alert_msg += "\t- " + missing.fields[i] + "\n";
264                         error ++;
265                     }
266                     alert_msg += "\n";
267                 }
268                 if (missing.subfields.length > 0) {
269                     alert_msg += _("Following required subfields are missing:") + "\n";
270                     for (var i in missing.subfields) {
271                         var subfield = missing.subfields[i];
272                         alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
273                         error ++;
274                     }
275                 }
276
277                 if (error != 0) {
278                     alert(alert_msg);
279                     return false;
280                 } else {
281                     $("#tabs").remove();
282                 }
283             }
284
285         $(document).ready(function(){
286             tagslib = [];
287             $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework | html %]" }, function(json) {
288               tagslib = json;
289               rebuild_target($("#tabs"), $("#resultul"));
290             });
291
292             // Creating tabs
293             $("#tabs").tabs();
294
295             // Check all checkboxes in first tab, and uncheck all others to avoid
296             // inconsistencies from a page refresh.
297             $('#tabs div#tabrecord[% ref_biblionumber | html %]').find('input[type="checkbox"]').prop('checked', true);
298             $('#tabs > div:not("#tabrecord[% ref_biblionumber | html %]")').find('input[type="checkbox"]').prop('checked', false);
299
300             //Set focus to cataloging search
301             $("input[name=q]:eq(0)").focus();
302         });
303
304           [% END %]
305         [% END %]
306     </script>
307 [% END %]
308
309 [% INCLUDE 'intranet-bottom.inc' %]