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