|
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-179
Link Here
|
| 173 |
var onOption = function () { |
177 |
var onOption = function () { |
| 174 |
return Check(); |
178 |
return Check(); |
| 175 |
} |
179 |
} |
| 176 |
[% END %] |
180 |
[% END %] |
| 177 |
|
181 |
|
| 178 |
function confirmnotdup(redirect){ |
182 |
function confirmnotdup(redirect){ |
| 179 |
$("#confirm_not_duplicate").attr("value","1"); |
183 |
$("#confirm_not_duplicate").attr("value","1"); |
|
Lines 196-201
Link Here
|
| 196 |
} |
200 |
} |
| 197 |
} |
201 |
} |
| 198 |
|
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 |
} |
| 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 |
|
| 199 |
function PopupMARCFieldDoc(field) { |
401 |
function PopupMARCFieldDoc(field) { |
| 200 |
[% IF Koha.Preference('marcfielddocurl') %] |
402 |
[% IF Koha.Preference('marcfielddocurl') %] |
| 201 |
var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; |
403 |
var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; |
|
Lines 585-590
Link Here
|
| 585 |
[% ELSE %] |
787 |
[% 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> |
788 |
<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 %] |
789 |
[% END %] |
|
|
790 |
[% IF ( CAN_user_editauthorities ) %] |
| 791 |
<div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div> |
| 792 |
[% END %] |
| 588 |
[% END %] |
793 |
[% END %] |
| 589 |
|
794 |
|
| 590 |
<div class="btn-group"> |
795 |
<div class="btn-group"> |