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 |
subfield.css({backgroundColor:''}); |
290 |
|
291 |
// If the field wasn't modified. Skip it. |
292 |
if(heading.status == 'UNCHANGED') { |
293 |
return; |
294 |
} |
295 |
|
296 |
|
297 |
// Make the subfield line visible and update its value |
298 |
tag_subfield_line.show(); |
299 |
subfield.val(heading.authid); |
300 |
|
301 |
// Add the new status |
302 |
var image = '<i class="fa fa-close" style="color: #FFAAAA"></i> '; |
303 |
var message = ''; |
304 |
var field_color = '#FFAAAA'; |
305 |
switch(heading.status) { |
306 |
case 'LOCAL_FOUND': |
307 |
image = '<i class="fa fa-check" style="color: #99FF99"></i> '; |
308 |
message = _("A matching authority was found in the local database."); |
309 |
field_color = '#99FF99'; |
310 |
break; |
311 |
case 'CREATED': |
312 |
image = '<i class="fa fa-check" style="color: #99FF99"></i> '; |
313 |
message = _("No matching authority found. A new authority was created automatically."); |
314 |
field_color = '#99FF99'; |
315 |
break; |
316 |
case 'MULTIPLE_MATCH': |
317 |
message = _("More than one local match found. Possibly a duplicate authority!"); |
318 |
break; |
319 |
case 'NONE_FOUND': |
320 |
message = _("No matching authority found."); |
321 |
break; |
322 |
default: |
323 |
message = heading.status; |
324 |
break; |
325 |
} |
177 |
|
326 |
|
|
|
327 |
subfield.css({backgroundColor:field_color}); |
328 |
tag_subfield_line.find('i').each(function() { |
329 |
this.remove(); |
330 |
}); |
331 |
tag_subfield_line.append(image); |
332 |
|
333 |
// Add the message to the dialog |
334 |
message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>'); |
335 |
|
336 |
// Add a link to create a new authority if none was found |
337 |
if(heading.status == 'NONE_FOUND' && tag_subfield_line.find('i').length == 1) { |
338 |
addCreateAuthorityButton(tag_subfield_line, heading , tag_index); |
339 |
} |
340 |
}); |
341 |
|
342 |
if(message_dialog.find('li').length == 0) { |
343 |
message_dialog_ul.append("<li>" + _("No authority link was changed.") + "</li>"); |
344 |
} |
345 |
$('#addbibliotabs').before(message_dialog); |
346 |
} |
347 |
|
348 |
/** |
349 |
* Use an ajax request to automatically find authority links for the current record |
350 |
*/ |
351 |
function AutomaticLinker() { |
352 |
// Show the Loading overlay |
353 |
$("#loading").show(); |
354 |
|
355 |
// Remove fields that are completely empty |
356 |
$('#f').find('.tag').each(function() { |
357 |
var empty = true; |
358 |
$(this).find('.input_marceditor').each(function() { |
359 |
if($(this).val() != '') { |
360 |
empty = false; |
361 |
return false; |
362 |
} |
363 |
}); |
364 |
if(empty) { |
365 |
UnCloneField($(this).attr('id')); |
366 |
} |
367 |
}); |
368 |
|
369 |
// Get all the form values to post via AJAX |
370 |
var form_data = {}; |
371 |
$('#f').find(':input').each(function(){ |
372 |
form_data[this.name] = $(this).val(); |
373 |
}); |
374 |
delete form_data['']; |
375 |
|
376 |
// Send the data to automatic_linker.pl |
377 |
$.ajax({ |
378 |
url:'/cgi-bin/koha/cataloguing/automatic_linker.pl', |
379 |
type:'post', |
380 |
data: form_data, |
381 |
dataType: 'json', |
382 |
error: function(xhr) { |
383 |
alert("Error : \n" + xhr.responseText); |
384 |
}, |
385 |
success: function(json) { |
386 |
switch(json.status) { |
387 |
case 'UNAUTHORIZED': |
388 |
alert(_("Error : You do not have the permissions necessary to use this functionality.")); |
389 |
break; |
390 |
case 'OK': |
391 |
updateHeadingLinks(json.links); |
392 |
break; |
393 |
} |
394 |
}, |
395 |
complete: function() { |
396 |
$("#loading").hide(); |
397 |
} |
398 |
}); |
399 |
} |
400 |
|
401 |
|
402 |
function PopupMARCFieldDoc(field) { |
403 |
[% IF Koha.Preference('marcfielddocurl') %] |
404 |
var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; |
405 |
docurl = docurl.replace("{MARC}", "[% marcflavour | html %]"); |
406 |
docurl = docurl.replace("{FIELD}", ""+field); |
407 |
docurl = docurl.replace("{LANG}", "[% lang | html %]"); |
408 |
window.open(docurl); |
409 |
[% ELSIF ( marcflavour == 'MARC21' ) %] |
410 |
_MARC21FieldDoc(field); |
411 |
[% ELSIF ( marcflavour == 'UNIMARC' ) %] |
412 |
_UNIMARCFieldDoc(field); |
413 |
[% END %] |
414 |
} |
178 |
function confirmnotdup(redirect){ |
415 |
function confirmnotdup(redirect){ |
179 |
$("#confirm_not_duplicate").attr("value","1"); |
416 |
$("#confirm_not_duplicate").attr("value","1"); |
180 |
$("#redirect").attr("value",redirect); |
417 |
$("#redirect").attr("value",redirect); |
Lines 585-590
Link Here
|
585 |
[% ELSE %] |
822 |
[% 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> |
823 |
<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 %] |
824 |
[% END %] |
|
|
825 |
[% IF ( CAN_user_editauthorities ) %] |
826 |
<div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div> |
827 |
[% END %] |
588 |
[% END %] |
828 |
[% END %] |
589 |
|
829 |
|
590 |
<div class="btn-group"> |
830 |
<div class="btn-group"> |