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