Lines 87-92
Link Here
|
87 |
PopupZ3950(); |
87 |
PopupZ3950(); |
88 |
}); |
88 |
}); |
89 |
|
89 |
|
|
|
90 |
$("#linkerbutton").click(function(){ |
91 |
AutomaticLinker(); |
92 |
}); |
93 |
|
90 |
$("#saverecord").click(function(){ |
94 |
$("#saverecord").click(function(){ |
91 |
$(".btn-group").removeClass("open"); |
95 |
$(".btn-group").removeClass("open"); |
92 |
onOption(); |
96 |
onOption(); |
Lines 173-180
Link Here
|
173 |
var onOption = function () { |
177 |
var onOption = function () { |
174 |
return Check(); |
178 |
return Check(); |
175 |
} |
179 |
} |
176 |
[% END %] |
180 |
[% END %] |
|
|
181 |
|
182 |
function confirmnotdup(redirect){ |
183 |
$("#confirm_not_duplicate").attr("value","1"); |
184 |
$("#redirect").attr("value",redirect); |
185 |
Check(); |
186 |
} |
187 |
|
188 |
function Dopop(link,i) { |
189 |
defaultvalue = document.getElementById(i).value; |
190 |
window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes'); |
191 |
} |
192 |
|
193 |
/** |
194 |
* this function open a popup to search on z3950 server. |
195 |
*/ |
196 |
function PopupZ3950() { |
197 |
var strQuery = GetZ3950Terms(); |
198 |
if(strQuery){ |
199 |
window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=[% biblionumber | html %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes'); |
200 |
} |
201 |
} |
202 |
|
203 |
/** |
204 |
* this function append button for create new authority if not found |
205 |
*/ |
206 |
|
207 |
function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) { |
208 |
var title = _("Create authority"); |
209 |
var elem = $('<a href="#" title="' + title + '"><i class="fa fa-plus-circle"></i></a>'); |
210 |
tag_subfield_line.append(elem); |
211 |
var tag_subfield_line_a = $('.subfield_line[id^=subfield' + heading.tag + 'a]').eq(tag_index); |
212 |
var subfield_a = tag_subfield_line_a.children('.input_marceditor').eq(0); |
213 |
var index = subfield_a.attr('id'); |
214 |
elem.click(function() { |
215 |
var popup = window.open("", "new_auth_popup",'fullscreen,toolbar=false,scrollbars=yes'); |
216 |
if(popup !== null) { |
217 |
// Create a new form that will be POSTed in the new window |
218 |
var form = $('<form>').attr({ |
219 |
method: 'post', |
220 |
action: "../authorities/authorities.pl", |
221 |
target: "new_auth_popup" |
222 |
}); |
223 |
//add the authtypecode |
224 |
form.append($('<input>').attr({ |
225 |
type: 'hidden', |
226 |
name: 'authtypecode', |
227 |
value: heading.auth_type |
228 |
})); |
229 |
form.append($('<input>').attr({ |
230 |
type: 'hidden', |
231 |
name: 'tagreport', |
232 |
value: heading.tag_to_report |
233 |
})); |
234 |
form.append($('<input>').attr({ |
235 |
type: 'hidden', |
236 |
name: 'tagbiblio', |
237 |
value: heading.tag |
238 |
})); |
239 |
form.append($('<input>').attr({ |
240 |
type: 'hidden', |
241 |
name: 'index', |
242 |
value: index |
243 |
})); |
244 |
$('.tag[id^=tag_' + heading.tag + '_]').eq(tag_index).find(':input').each(function(){ |
245 |
form.append($('<input>').attr({ |
246 |
type: 'hidden', |
247 |
name: this.name.split('_',4).join(''), |
248 |
value: $(this).val() |
249 |
})); |
250 |
}); |
251 |
|
252 |
$('body').append(form); |
253 |
form.submit(); |
254 |
form.remove(); |
255 |
} |
256 |
return false; |
257 |
}); |
258 |
|
259 |
} |
260 |
|
261 |
/** |
262 |
* Updates the authid for every heading field |
263 |
* Adds visual feedback for the changes made on the form. |
264 |
*/ |
265 |
function updateHeadingLinks(links) { |
266 |
var current_tag = ''; |
267 |
var tag_index = 0; |
268 |
|
269 |
// Delete the old message dialog and create a new one |
270 |
$('#autolinker_dialog').remove(); |
271 |
var message_dialog = $('<div id="autolinker_dialog" class="dialog"><strong>' + _("Automatic authority link results:") + '</strong><ul></ul></div>'); |
272 |
var message_dialog_ul = message_dialog.find('ul'); |
273 |
|
274 |
$.each(links, function(index, heading) { |
275 |
if(current_tag == heading.tag) { |
276 |
tag_index++; |
277 |
} |
278 |
else { |
279 |
current_tag = heading.tag; |
280 |
tag_index = 0; |
281 |
} |
282 |
|
283 |
// Find the $9 field to update |
284 |
var tag_subfield_line = $('.subfield_line[id^=subfield' + heading.tag + '9]').eq(tag_index); |
285 |
var subfield = tag_subfield_line.children('.input_marceditor').eq(0); |
286 |
|
287 |
// Delete the old status if one exists |
288 |
tag_subfield_line.children('.subfield_status').remove(); |
289 |
|
290 |
// If the field wasn't modified. Skip it. |
291 |
if(heading.status == 'UNCHANGED') { |
292 |
return; |
293 |
} |
294 |
|
295 |
|
296 |
// Make the subfield line visible and update its value |
297 |
tag_subfield_line.show(); |
298 |
subfield.val(heading.authid); |
299 |
|
300 |
// Add the new status |
301 |
var image = '<i class="fa fa-close no_matching_authority" </i> '; |
302 |
var message = ''; |
303 |
var field_class = 'no_matching_authority_field'; |
304 |
switch(heading.status) { |
305 |
case 'LOCAL_FOUND': |
306 |
image = '<i class="fa fa-check matching_authority"</i> '; |
307 |
message = _("A matching authority was found in the local database."); |
308 |
field_class = 'matching_authority_field'; |
309 |
break; |
310 |
case 'CREATED': |
311 |
image = '<i class="fa fa-check matching_authority"></i> '; |
312 |
message = _("No matching authority found. A new authority was created automatically."); |
313 |
field_class = 'matching_authority_field'; |
314 |
break; |
315 |
case 'MULTIPLE_MATCH': |
316 |
message = _("More than one local match found. Possibly a duplicate authority!"); |
317 |
break; |
318 |
case 'NONE_FOUND': |
319 |
message = _("No matching authority found."); |
320 |
break; |
321 |
default: |
322 |
message = heading.status; |
323 |
break; |
324 |
} |
177 |
|
325 |
|
|
|
326 |
subfield[0].classList.add(field_class); |
327 |
tag_subfield_line.find('i').each(function() { |
328 |
this.remove(); |
329 |
}); |
330 |
tag_subfield_line.append(image); |
331 |
|
332 |
// Add the message to the dialog |
333 |
message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>'); |
334 |
|
335 |
// Add a link to create a new authority if none was found |
336 |
if(heading.status == 'NONE_FOUND' && tag_subfield_line.find('i').length == 1) { |
337 |
addCreateAuthorityButton(tag_subfield_line, heading , tag_index); |
338 |
} |
339 |
}); |
340 |
|
341 |
if(message_dialog.find('li').length == 0) { |
342 |
message_dialog_ul.append("<li>" + _("No authority link was changed.") + "</li>"); |
343 |
} |
344 |
$('#addbibliotabs').before(message_dialog); |
345 |
} |
346 |
|
347 |
/** |
348 |
* Use an ajax request to automatically find authority links for the current record |
349 |
*/ |
350 |
function AutomaticLinker() { |
351 |
// Show the Loading overlay |
352 |
$("#loading").show(); |
353 |
|
354 |
// Remove fields that are completely empty |
355 |
$('#f').find('.tag').each(function() { |
356 |
var empty = true; |
357 |
$(this).find('.input_marceditor').each(function() { |
358 |
if($(this).val() != '') { |
359 |
empty = false; |
360 |
return false; |
361 |
} |
362 |
}); |
363 |
if(empty) { |
364 |
UnCloneField($(this).attr('id')); |
365 |
} |
366 |
}); |
367 |
|
368 |
// Get all the form values to post via AJAX |
369 |
var form_data = {}; |
370 |
$('#f').find(':input').each(function(){ |
371 |
form_data[this.name] = $(this).val(); |
372 |
}); |
373 |
delete form_data['']; |
374 |
|
375 |
// Send the data to automatic_linker.pl |
376 |
$.ajax({ |
377 |
url:'/cgi-bin/koha/svc/cataloguing/automatic_linker.pl', |
378 |
type:'post', |
379 |
data: form_data, |
380 |
dataType: 'json', |
381 |
error: function(xhr) { |
382 |
alert("Error : \n" + xhr.responseText); |
383 |
}, |
384 |
success: function(json) { |
385 |
switch(json.status) { |
386 |
case 'UNAUTHORIZED': |
387 |
alert(_("Error : You do not have the permissions necessary to use this functionality.")); |
388 |
break; |
389 |
case 'OK': |
390 |
updateHeadingLinks(json.links); |
391 |
break; |
392 |
} |
393 |
}, |
394 |
complete: function() { |
395 |
$("#loading").hide(); |
396 |
} |
397 |
}); |
398 |
} |
399 |
|
400 |
|
401 |
function PopupMARCFieldDoc(field) { |
402 |
[% IF Koha.Preference('marcfielddocurl') %] |
403 |
var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; |
404 |
docurl = docurl.replace("{MARC}", "[% marcflavour | html %]"); |
405 |
docurl = docurl.replace("{FIELD}", ""+field); |
406 |
docurl = docurl.replace("{LANG}", "[% lang | html %]"); |
407 |
window.open(docurl); |
408 |
[% ELSIF ( marcflavour == 'MARC21' ) %] |
409 |
_MARC21FieldDoc(field); |
410 |
[% ELSIF ( marcflavour == 'UNIMARC' ) %] |
411 |
_UNIMARCFieldDoc(field); |
412 |
[% END %] |
413 |
} |
178 |
function confirmnotdup(redirect){ |
414 |
function confirmnotdup(redirect){ |
179 |
$("#confirm_not_duplicate").attr("value","1"); |
415 |
$("#confirm_not_duplicate").attr("value","1"); |
180 |
$("#redirect").attr("value",redirect); |
416 |
$("#redirect").attr("value",redirect); |
Lines 585-590
Link Here
|
585 |
[% ELSE %] |
821 |
[% ELSE %] |
586 |
<div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div> |
822 |
<div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div> |
587 |
[% END %] |
823 |
[% END %] |
|
|
824 |
[% IF ( CAN_user_editauthorities ) %] |
825 |
<div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div> |
826 |
[% END %] |
588 |
[% END %] |
827 |
[% END %] |
589 |
|
828 |
|
590 |
<div class="btn-group"> |
829 |
<div class="btn-group"> |