Fix for Bug 4946 - hold warning needs rewording
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / merge.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <style type="text/css">
5 div.record ul, div.record li { float:none; display:block; }
6 div#result { margin-top: 1em; }
7 /* We use this style "against" the li ui-tabs-nav style automatically applied */
8 </style>
9 <script type="text/javascript">
10 //<![CDATA[
11
12     // When submiting the form
13     function mergeformsubmit() {
14             $("ul#ulrecord1").remove();
15             $("ul#ulrecord2").remove();
16 }
17
18
19 $(document).ready(function(){
20     // Creating tabs
21     $("#tabs > ul").tabs();
22
23     // Getting marc structure via ajax
24     tagslib = [];
25     $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "<!-- TMPL_VAR name="framework" -->" }, function(json) {
26         tagslib = json;
27     });
28
29
30     // Toggle a field / subfield
31     function toggleField(pField) {
32
33         // Getting the key of the clicked checkbox
34         var ckid   = $(pField).attr("id");
35         var tab    = ckid.split('_');
36         var source = tab[1]; // From which record the click came from
37         var key    = tab[2];
38         var type   = $(pField).attr("class");
39
40         // Getting field/subfield
41         var field;
42         var subfield;
43         if (type == "subfieldpick") {
44
45                     field = $(pField).parent().parent().parent().find("span.field").text();
46                     subfield = $(pField).parent().find("span.subfield").text();
47         } else {
48
49                     field = $(pField).parent().find("span.field").text();
50         }
51
52         // If the field has just been checked
53         if (pField.checked) {
54
55             // We check for repeatability
56             var canbeadded = true;
57             if (type == "subfieldpick") {
58                 var repeatable = 1;
59                 var alreadyexists = 0;
60                 if (tagslib[field] && tagslib[field][subfield]) {
61                     repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number 
62                     // TODO : Checking for subfields
63                 }
64             } else {
65                 if (tagslib[field]) {
66                     repeatable = tagslib[field].repeatable;
67                     alreadyexists = $("#resultul span.field:contains(" + field + ")");
68                     if (repeatable == 0 && alreadyexists.length != 0) {
69                         canbeadded = false;
70                     }
71                 }
72             }
73             // If the field is not repeatable, we check if it already exists in the result table
74             if (canbeadded == false) {
75                 alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
76                 pField.checked = 0;
77             } else {
78
79                 // Cloning the field or subfield we picked
80                 var clone = $(pField).parent().clone();
81
82                 // Removing the checkboxes from it
83                 $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
84                     $(this).remove();
85                 });
86
87
88                 // If we are a subfield
89                 if (type == "subfieldpick") {
90                     // then we need to find who is our parent field...
91                     fieldkey = $(pField).parent().parent().parent().attr("id");
92
93                     // Find where to add the subfield
94
95                     // First, check if the field is not already in the destination record
96                     if ($("#resultul li#" + fieldkey).length > 0) { 
97                         // If so, we add our field to it
98                         $("#resultul li#" + fieldkey + " ul").append(clone);
99                     } else {
100                         // If not, we add the subfield to the first matching field
101                         var where = 0;
102                         $("#resultul li span.field").each(function() {
103                             if (where == 0 && $(this).text() == field) {
104                                 where = this;
105                             }
106                         });
107
108                         // If there is no matching field in the destination record
109                         if (where == 0) {
110
111                             // TODO: 
112                             // We select the whole field and removing non-selected subfields, instead of...
113
114                             // Alerting the user 
115                             alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
116                             pField.checked = false;
117
118                         } else {
119                             $(where).nextAll("ul").append(clone);
120                         }
121
122                     }
123
124                     
125                     
126                 } else {
127                     // If we are a field
128                     var where = 0;
129                     // Find where to add the field
130                     $("#resultul li span.field").each(function() {
131                         if (where == 0 && $(this).text() > field) {
132                             where = this;
133                         }
134                     });
135
136                     $(where).parent().before(clone);
137                 }
138             }
139         } else {
140
141             // Else, we remove it from the results tab
142             $("ul#resultul li#k" + key).remove();
143         }
144 }
145
146
147     // When a field is checked / unchecked 
148     $('input.fieldpick').click(function() {
149         toggleField(this);
150         // (un)check all subfields
151         var ischecked = this.checked;
152         $(this).parent().find("input.subfieldpick").each(function() {
153             this.checked = ischecked;
154         });
155     });
156
157     // When a field or subfield is checked / unchecked
158     $("input.subfieldpick").click(function() {
159         toggleField(this);
160     });
161
162 });
163
164 //]]>
165 </script>
166 </head>
167 <body>
168 <!-- TMPL_INCLUDE NAME="header.inc" -->
169 <!-- TMPL_INCLUDE NAME="cataloging-search.inc" -->
170 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>  &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Editing <em><!-- TMPL_VAR NAME="title" escape="html" --></em> (Record Number <!-- TMPL_VAR name="biblionumber" -->)<!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></div>
171
172 <div id="doc" class="yui-t7">
173
174 <div id="bd">
175         <div id="yui-main">
176
177
178 <h1>Merging records</h1>
179 <!-- TMPL_IF name="result" -->
180     <!-- TMPL_IF name="errors" -->
181         <!-- TMPL_LOOP name="errors" -->
182             <div class="dialog alert"><!-- TMPL_VAR name="error" -->.<br />Therefore, the record to be merged has not been deleted.</div>
183         <!-- /TMPL_LOOP -->
184
185         <!-- TMPL_ELSE -->
186         <script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->"</script>      
187         <p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->">Click here to see the merged record.</a></p>
188         <!-- /TMPL_IF -->
189
190 <!-- TMPL_ELSE -->
191
192 <!-- TMPL_IF NAME="choosereference" -->
193 <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>
194 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
195     <fieldset class="rows">
196         <legend>Merge reference</legend>
197         <ol>
198         <li class="radio"><input type="radio" value="<!-- TMPL_VAR NAME="biblio1" -->" checked="checked" id="mergereference1" name="mergereference" /><label for="mergereference1"><!-- TMPL_VAR NAME="title1" --> (<!-- TMPL_VAR NAME="biblio1" -->)</label></li>
199         <li class="radio"><input type="radio" value="<!-- TMPL_VAR NAME="biblio2" -->" id="mergereference2" name="mergereference" /><label for="mergereference2"><!-- TMPL_VAR NAME="title2" --> (<!-- TMPL_VAR NAME="biblio2" -->)</label></li>
200 </ol>
201         <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio1" -->" />
202         <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio2" -->" />
203         <fieldset class="action"><input type="submit" value="Next" /></fieldset>
204     </fieldset>
205 </form>
206 <!-- TMPL_ELSE -->
207 <!-- TMPL_IF name="errors" -->
208     <!-- TMPL_LOOP name="errors" -->
209         <div class="error"><!-- TMPL_VAR name="error" --></div>
210     <!-- /TMPL_LOOP -->
211 <!-- TMPL_ELSE -->
212 <form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
213
214 <div class="yui-g">
215 <div class="yui-u first">
216 <div id="tabs" class="toptabs">
217 <h2>Source records</h2>
218     <ul>
219         <li><a href="#tabrecord1"><!-- TMPL_VAR name="biblio1" --></a></li>
220         <li><a href="#tabrecord2"><!-- TMPL_VAR name="biblio2" --></a></li>
221     </ul>
222     <div id="tabrecord1">
223         <!-- TMPL_IF name="record1" -->
224
225             <div class="record">
226                 <ul id="ulrecord1">
227                 <!-- TMPL_LOOP NAME="record1" -->
228                         <!-- TMPL_LOOP NAME="field" -->
229                         <li id="k<!-- TMPL_VAR name="key" -->">
230                             <input type="checkbox" checked="checked" class="fieldpick" id="rec_1_<!-- TMPL_VAR name="key" -->" /> 
231                             <span class="field"><!-- TMPL_VAR NAME="tag" --></span>
232
233                             <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
234                             <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
235                             <!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
236                                 <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
237                                 <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
238                             <!-- /TMPL_IF -->
239
240                             <!-- TMPL_IF NAME="subfield" -->
241                                 <ul>
242                                     <!-- TMPL_LOOP NAME="subfield" -->
243                                         <li id="k<!-- TMPL_VAR name="subkey" -->">
244                                             <input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_<!-- TMPL_VAR name="subkey" -->" /> 
245                                             <span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
246                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
247                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
248                                         </li>
249                                     <!-- /TMPL_LOOP -->
250                                 </ul>
251                             <!-- /TMPL_IF -->
252                     <!-- /TMPL_LOOP -->
253                     </li>
254                 <!-- /TMPL_LOOP -->
255                 </ul>
256             </div><!-- /div.record -->
257     </div><!-- /div#tabrecord1 -->
258     <div id="tabrecord2">
259         <!-- TMPL_IF name="record2" -->
260
261            <div class="record">
262                 <ul id="ulrecord2">
263                 <!-- TMPL_LOOP NAME="record2" -->
264                     <!-- TMPL_LOOP NAME="field" -->
265                     <li id="k<!-- TMPL_VAR name="key" -->">
266                         <input type="checkbox" class="fieldpick" id="rec_2_<!-- TMPL_VAR name="key" -->" /> 
267                         <span class="field"><!-- TMPL_VAR NAME="tag" --></span>
268
269                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
270                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
271                         <!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
272                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
273                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
274                         <!-- /TMPL_IF -->
275
276                         <!-- TMPL_IF NAME="subfield" -->
277                             <ul>
278                                 <!-- TMPL_LOOP NAME="subfield" -->
279                                     <li id="k<!-- TMPL_VAR name="subkey" -->">
280                                         <input type="checkbox" class="subfieldpick" id="rec_2_<!-- TMPL_VAR name="subkey" -->" />
281                                         <span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
282                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
283                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
284                                     </li>
285                                 <!-- /TMPL_LOOP -->
286                             </ul>
287                         <!-- /TMPL_IF -->
288                     <!-- /TMPL_LOOP -->
289                     </li>
290                 <!-- /TMPL_LOOP -->
291                 </ul>
292             </div>
293             <!-- /div.record -->
294
295
296
297
298         <!-- /TMPL_IF -->
299     </div><!-- /div#tabrecord2 -->
300 </div> <!-- // #tabs -->
301 </div>
302 <div class="yui-u">
303 <div id="result">
304     <h2>Destination record</h2>
305     <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
306             <ul id="resultul">
307         <!-- TMPL_LOOP NAME="record1" -->
308                     <!-- TMPL_LOOP NAME="field" --><li id="k<!-- TMPL_VAR name="key" -->"><span class="field"><!-- TMPL_VAR NAME="tag" --></span>  
309                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
310                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
311                     <!-- TMPL_IF NAME="value" --> /
312                         <!-- TMPL_VAR NAME="value" -->
313                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
314                         <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
315                     <!-- /TMPL_IF -->
316                         
317                     <!-- TMPL_IF NAME="subfield" -->
318                         <ul>
319                             <!-- TMPL_LOOP NAME="subfield" -->
320                                 <li id="k<!-- TMPL_VAR name="subkey" -->">
321                                     <span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
322                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
323                                     <input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
324                                 </li>
325                             <!-- /TMPL_LOOP -->
326                         </ul>
327                     <!-- /TMPL_IF -->
328
329                     <!-- /TMPL_LOOP -->
330                     </li>
331                 <!-- /TMPL_LOOP -->
332
333             </ul>
334
335 <input type="hidden" name="biblio1" value="<!-- TMPL_VAR name="biblio1" -->" />
336 <input type="hidden" name="biblio2" value="<!-- TMPL_VAR name="biblio2" -->" />
337 <input type="hidden" name="mergereference" value="<!-- TMPL_VAR name="mergereference" -->" />
338
339 </div>
340 </div> <!-- // #result -->
341 </div> <!-- .yui-u -->
342 <fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
343 </div>
344 </form>
345 <!-- /TMPL_IF -->
346 <!-- /TMPL_IF -->
347 <!-- /TMPL_IF -->
348
349 </div>
350 </div>
351 </div>
352
353 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->