Lines 1-4
Link Here
|
1 |
/* global irregularity more_than_one_serial subscriptionid tags */ |
1 |
/* global _ irregularity more_than_one_serial subscriptionid tags interface theme mana_enabled MSG_FREQUENCY_LENGTH_ERROR */ |
2 |
|
2 |
|
3 |
var globalnumpatterndata; |
3 |
var globalnumpatterndata; |
4 |
var globalfreqdata; |
4 |
var globalfreqdata; |
Lines 47-59
function Clear(id) {
Link Here
|
47 |
|
47 |
|
48 |
function Check_page1() { |
48 |
function Check_page1() { |
49 |
if ( $("#aqbooksellerid").val().length == 0) { |
49 |
if ( $("#aqbooksellerid").val().length == 0) { |
50 |
input_box = confirm(_("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor")); |
50 |
input_box = confirm( MSG_LINK_TO_VENDOR ); |
51 |
if (input_box==false) { |
51 |
if (input_box==false) { |
52 |
return false; |
52 |
return false; |
53 |
} |
53 |
} |
54 |
} |
54 |
} |
55 |
if ($("#biblionumber").val().length == 0) { |
55 |
if ($("#biblionumber").val().length == 0) { |
56 |
alert(_("You must choose or create a biblio")); |
56 |
alert( MSG_LINK_BIBLIO ); |
57 |
return false; |
57 |
return false; |
58 |
} |
58 |
} |
59 |
|
59 |
|
Lines 63-85
function Check_page1() {
Link Here
|
63 |
function Check_page2(){ |
63 |
function Check_page2(){ |
64 |
if( more_than_one_serial == "" ){ |
64 |
if( more_than_one_serial == "" ){ |
65 |
if($("#acqui_date").val().length == 0){ |
65 |
if($("#acqui_date").val().length == 0){ |
66 |
alert(_("You must choose a first publication date")); |
66 |
alert( MSG_REQUIRED_PUB_DATE ); |
67 |
return false; |
67 |
return false; |
68 |
} |
68 |
} |
69 |
} |
69 |
} |
70 |
if($("#sublength").val().length == 0 && $("input[name='enddate']").val().length == 0){ |
70 |
if($("#sublength").val().length == 0 && $("input[name='enddate']").val().length == 0){ |
71 |
alert(_("You must choose a subscription length or an end date.")); |
71 |
alert( MSG_REQUIRED_SUB_LENGTH ); |
72 |
return false; |
72 |
return false; |
73 |
} |
73 |
} |
74 |
if(advancedpatternlocked == 0){ |
74 |
if(advancedpatternlocked == 0){ |
75 |
alert(_("You have modified the advanced prediction pattern. Please save your work or cancel modifications.")); |
75 |
alert( MSG_SAVE_PREDICTION_PATTERN ); |
76 |
return false; |
76 |
return false; |
77 |
} |
77 |
} |
78 |
if(patternneedtobetested){ |
78 |
if(patternneedtobetested){ |
79 |
if( irregularity !== "" ){ |
79 |
if( irregularity !== "" ){ |
80 |
alert(_("Warning! Present pattern has planned irregularities. Click on 'Test prediction pattern' to check if it's still valid")); |
80 |
alert( MSG_PATTERN_IRREG ); |
81 |
} else { |
81 |
} else { |
82 |
alert(_("Please click on 'Test prediction pattern' before saving subscription.")); |
82 |
alert( MSG_TEST_PREDICTION ); |
83 |
} |
83 |
} |
84 |
return false; |
84 |
return false; |
85 |
} |
85 |
} |
Lines 95-101
function frequencyload(){
Link Here
|
95 |
$("input[name='unitsperissue']").val(manafreqdata.unitsperissue); |
95 |
$("input[name='unitsperissue']").val(manafreqdata.unitsperissue); |
96 |
$("input[name='issuesperunit']").val(manafreqdata.issuesperunit); |
96 |
$("input[name='issuesperunit']").val(manafreqdata.issuesperunit); |
97 |
if ($( "#numberpattern option:selected" ).val() === "mana" ) { |
97 |
if ($( "#numberpattern option:selected" ).val() === "mana" ) { |
98 |
$("input[name='mana_id']").val(manaid); |
98 |
$("#mana_id").val(manaid); |
99 |
} |
99 |
} |
100 |
} else { |
100 |
} else { |
101 |
$.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, |
101 |
$.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, |
Lines 110-116
function frequencyload(){
Link Here
|
110 |
} |
110 |
} |
111 |
} |
111 |
} |
112 |
); |
112 |
); |
113 |
$("input[name='mana_id']").val(""); |
113 |
$("#mana_id").val(""); |
114 |
} |
114 |
} |
115 |
} |
115 |
} |
116 |
|
116 |
|
Lines 119-125
function numberpatternload(){
Link Here
|
119 |
globalnumpatterndata=mananumpatterndata; |
119 |
globalnumpatterndata=mananumpatterndata; |
120 |
$("input[name='sndescription']").val(mananumpatterndata.description); |
120 |
$("input[name='sndescription']").val(mananumpatterndata.description); |
121 |
if($("#frequency option:selected" ).val() === "mana"){ |
121 |
if($("#frequency option:selected" ).val() === "mana"){ |
122 |
$("input[name='mana_id']").val(manaid); |
122 |
$("#mana_id").val(manaid); |
123 |
} |
123 |
} |
124 |
if (globalnumpatterndata==undefined){ |
124 |
if (globalnumpatterndata==undefined){ |
125 |
return false; |
125 |
return false; |
Lines 137-143
function numberpatternload(){
Link Here
|
137 |
restoreAdvancedPattern(); |
137 |
restoreAdvancedPattern(); |
138 |
} |
138 |
} |
139 |
); |
139 |
); |
140 |
$("input[name='mana_id']").val(""); |
140 |
$("#mana_id").val(""); |
141 |
} |
141 |
} |
142 |
} |
142 |
} |
143 |
|
143 |
|
Lines 260-283
function testPredictionPattern() {
Link Here
|
260 |
var error = 0; |
260 |
var error = 0; |
261 |
var error_msg = ""; |
261 |
var error_msg = ""; |
262 |
if(frequencyid == undefined || frequencyid == ""){ |
262 |
if(frequencyid == undefined || frequencyid == ""){ |
263 |
error_msg += _("- Frequency is not defined") + "\n"; |
263 |
error_msg += "- " + MSG_FREQUENCY_UNDEFINED + "\n"; |
264 |
error ++; |
264 |
error ++; |
265 |
} |
265 |
} |
266 |
acquidate = $("#acqui_date").val(); |
266 |
acquidate = $("#acqui_date").val(); |
267 |
if(acquidate == undefined || acquidate == ""){ |
267 |
if(acquidate == undefined || acquidate == ""){ |
268 |
error_msg += _("- First publication date is not defined") + "\n"; |
268 |
error_msg += "-" + MSG_PUB_DATE_UNDEFINED + "\n"; |
269 |
error ++; |
269 |
error ++; |
270 |
} |
270 |
} |
271 |
if( more_than_one_serial !== "" ){ |
271 |
if( more_than_one_serial !== "" ){ |
272 |
var nextacquidate = $("#nextacquidate").val(); |
272 |
var nextacquidate = $("#nextacquidate").val(); |
273 |
if(nextacquidate == undefined || nextacquidate == ""){ |
273 |
if(nextacquidate == undefined || nextacquidate == ""){ |
274 |
error_msg += _("- Next issue publication date is not defined") + "\n"; |
274 |
error_msg += "-" + MSG_NEXT_ISSUE_UNDEFINED + "\n"; |
275 |
error ++; |
275 |
error ++; |
276 |
} |
276 |
} |
277 |
} |
277 |
} |
278 |
|
278 |
|
279 |
if(error){ |
279 |
if(error){ |
280 |
alert(_("Cannot test prediction pattern for the following reason(s): %s").format(error_msg)); |
280 |
alert( MSG_PATTERN_TEST_FAILED.format(error_msg) ); |
281 |
return false; |
281 |
return false; |
282 |
} |
282 |
} |
283 |
|
283 |
|
Lines 326-332
function testPredictionPattern() {
Link Here
|
326 |
|
326 |
|
327 |
function saveAdvancedPattern() { |
327 |
function saveAdvancedPattern() { |
328 |
if ($("#patternname").val().length == 0) { |
328 |
if ($("#patternname").val().length == 0) { |
329 |
alert(_("Please enter a name for this pattern")); |
329 |
alert( MSG_PATTERN_NAME ); |
330 |
return false; |
330 |
return false; |
331 |
} |
331 |
} |
332 |
|
332 |
|
Lines 341-348
function saveAdvancedPattern() {
Link Here
|
341 |
}); |
341 |
}); |
342 |
var cnfrm = 1; |
342 |
var cnfrm = 1; |
343 |
if(found){ |
343 |
if(found){ |
344 |
var msg = _("This pattern name already exists. Do you want to modify it?") |
344 |
var msg = MSG_PATTERN_NAME_EXISTS |
345 |
+ "\n" + _("Warning: it will modify the pattern for all subscriptions that are using it."); |
345 |
+ "\n" + MSG_OVERWRITE_PATTERNS; |
346 |
cnfrm = confirm(msg); |
346 |
cnfrm = confirm(msg); |
347 |
} |
347 |
} |
348 |
|
348 |
|
Lines 372-378
function saveAdvancedPattern() {
Link Here
|
372 |
$("#numberpattern").val(data.numberpatternid); |
372 |
$("#numberpattern").val(data.numberpatternid); |
373 |
numberpatternload(); |
373 |
numberpatternload(); |
374 |
} else { |
374 |
} else { |
375 |
alert(_("Something went wrong. Unable to create a new numbering pattern.")); |
375 |
alert( MSG_PATTERN_CREATE_FAILED ); |
376 |
} |
376 |
} |
377 |
} |
377 |
} |
378 |
); |
378 |
); |
Lines 393-399
function show_page_2() {
Link Here
|
393 |
} |
393 |
} |
394 |
|
394 |
|
395 |
function mana_search() { |
395 |
function mana_search() { |
396 |
$("#mana_search").html("<p>" + _("Mana kb is being asked for your subscription..") + "</p>"); |
396 |
$("#mana_search").html("<p>" + MSG_MANA_SEARCHING + "... <img src='" + interface + "/" + theme + "/img/spinner-small.gif' /></p>"); |
397 |
$("#mana_search").show(); |
397 |
$("#mana_search").show(); |
398 |
|
398 |
|
399 |
$.ajax({ |
399 |
$.ajax({ |
Lines 402-434
function mana_search() {
Link Here
|
402 |
data: {id: $("#biblionumber").val(), resource: 'subscription', usecomments: 1}, |
402 |
data: {id: $("#biblionumber").val(), resource: 'subscription', usecomments: 1}, |
403 |
dataType: "html", |
403 |
dataType: "html", |
404 |
}) |
404 |
}) |
405 |
.done( function( result ) { |
405 |
.done( function( result ) { |
406 |
$("#mana_search_result .modal-body").html(result); |
406 |
$("#mana_search_result .modal-body").html(result); |
407 |
$("#mana_search_result_label").text(_("Results from Mana Knowledge Base")); |
407 |
$("#mana_search_result_label").text( MSG_MANA_RESULTS ); |
408 |
$("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { |
408 |
$("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { |
409 |
"sPaginationType": "four_button", |
409 |
"sPaginationType": "four_button", |
410 |
"order":[[4, "desc"], [5, "desc"]], |
410 |
"order":[[4, "desc"], [5, "desc"]], |
411 |
"autoWidth": false, |
411 |
"autoWidth": false, |
412 |
"columnDefs": [ |
412 |
"columnDefs": [ |
413 |
{ "width": "35%", "targets": 1 } |
413 |
{ "width": "35%", "targets": 1 } |
414 |
], |
414 |
], |
415 |
"aoColumnDefs": [ |
415 |
"aoColumnDefs": [ |
416 |
{ 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, |
416 |
{ 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, |
417 |
{ "sType": "title-string", "aTargets" : [ "title-string" ] }, |
417 |
{ "sType": "title-string", "aTargets" : [ "title-string" ] }, |
418 |
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } |
418 |
{ 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } |
419 |
] |
419 |
] |
420 |
})); |
420 |
})); |
421 |
if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){ |
421 |
if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){ |
422 |
$("#mana_search").html("<p>" + _("Subscription found on Mana Knowledge Base:") + "</p><p> <a style='cursor:pointer' data-toggle='modal' data-target='#mana_search_result'>" + _("Quick fill") + "</a></p>"); |
422 |
$("#mana_search").html("<p>" + MSG_MANA_SUBSCRIPTION_FOUND + "</p><p> <a href=\"#\" data-toggle=\"modal\" data-target=\"#mana_search_result\"><i class=\"fa fa-window-maximize\"></i> " + MSG_MANA_SHOW_DETAILS + "</a></p>"); |
423 |
} |
423 |
} |
424 |
else if ( $("#mana_results_datatable").length ){ |
424 |
else if ( $("#mana_results_datatable").length ){ |
425 |
$("#mana_search").html("<p>" + _("No subscription found on Mana Knowledge Base :(") + "</p><p>" + _(" Please feel free to share you pattern with all others librarians once you are done") + "</p>"); |
425 |
$("#mana_search").html("<p>" + MSG_MANA_NO_SUBSCRIPTION_FOUND + "</p><p>" + MSG_MANA_SHARE_PATTERN + "</p>"); |
426 |
} |
426 |
} |
427 |
else{ |
427 |
else{ |
428 |
$("#mana_search").html( result ); |
428 |
$("#mana_search").html( result ); |
429 |
} |
429 |
} |
430 |
$("#mana_search").show(); |
430 |
$("#mana_search").show(); |
431 |
}) |
431 |
}); |
432 |
} |
432 |
} |
433 |
|
433 |
|
434 |
function mana_use(mana_id){ |
434 |
function mana_use(mana_id){ |
Lines 440-509
function mana_use(mana_id){
Link Here
|
440 |
data: {id: mana_id, resource: 'subscription'}, |
440 |
data: {id: mana_id, resource: 'subscription'}, |
441 |
dataType: "json", |
441 |
dataType: "json", |
442 |
}) |
442 |
}) |
443 |
.done(function(result){ |
443 |
.done(function(result){ |
444 |
var select = document.getElementById('numberpattern'); |
444 |
var select = document.getElementById('numberpattern'); |
445 |
for(i = 0; i < select.length; i++){ |
445 |
for(i = 0; i < select.length; i++){ |
446 |
if(select[i].value === "mana"){ |
446 |
if(select[i].value === "mana"){ |
447 |
select.remove(i); |
447 |
select.remove(i); |
|
|
448 |
} |
448 |
} |
449 |
} |
449 |
} |
450 |
var optionnumpattern = document.createElement("option"); |
450 |
var optionnumpattern = document.createElement("option"); |
451 |
optionnumpattern.text = result.label + " (mana)"; |
451 |
optionnumpattern.text = result.label + " (mana)"; |
452 |
optionnumpattern.selected = true; |
452 |
optionnumpattern.selected = true; |
453 |
optionnumpattern.value="mana"; |
453 |
optionnumpattern.value="mana"; |
454 |
select.add(optionnumpattern); |
454 |
select.add(optionnumpattern); |
455 |
|
455 |
|
456 |
mananumpatterndata = { |
456 |
mananumpatterndata = { |
457 |
id:"mana", |
457 |
id:"mana", |
458 |
add1:result.add1, |
458 |
add1:result.add1, |
459 |
add2:result.add2, |
459 |
add2:result.add2, |
460 |
add3:result.add3, |
460 |
add3:result.add3, |
461 |
description:result.sndescription, |
461 |
description:result.sndescription, |
462 |
displayorder:result.displayorder, |
462 |
displayorder:result.displayorder, |
463 |
every1:result.every1, |
463 |
every1:result.every1, |
464 |
every2:result.every2, |
464 |
every2:result.every2, |
465 |
every3:result.every3, |
465 |
every3:result.every3, |
466 |
label:result.label, |
466 |
label:result.label, |
467 |
label1:result.label1, |
467 |
label1:result.label1, |
468 |
label2:result.label2, |
468 |
label2:result.label2, |
469 |
label3:result.label3, |
469 |
label3:result.label3, |
470 |
numbering1:result.numbering1, |
470 |
numbering1:result.numbering1, |
471 |
numbering2:result.numbering2, |
471 |
numbering2:result.numbering2, |
472 |
numbering3:result.numbering3, |
472 |
numbering3:result.numbering3, |
473 |
numberingmethod:result.numberingmethod, |
473 |
numberingmethod:result.numberingmethod, |
474 |
setto1:result.setto1, |
474 |
setto1:result.setto1, |
475 |
setto2:result.setto2, |
475 |
setto2:result.setto2, |
476 |
setto3:result.setto3, |
476 |
setto3:result.setto3, |
477 |
whenmorethan1:result.whenmorethan1, |
477 |
whenmorethan1:result.whenmorethan1, |
478 |
whenmorethan2:result.whenmorethan2, |
478 |
whenmorethan2:result.whenmorethan2, |
479 |
whenmorethan3:result.whenmorethan3, |
479 |
whenmorethan3:result.whenmorethan3, |
480 |
}; |
480 |
}; |
481 |
select = document.getElementById("frequency"); |
481 |
select = document.getElementById("frequency"); |
482 |
for(i = 0; i < select.length; i++){ |
482 |
for(i = 0; i < select.length; i++){ |
483 |
if(select[i].value === "mana"){ |
483 |
if(select[i].value === "mana"){ |
484 |
select.remove(i); |
484 |
select.remove(i); |
485 |
} |
485 |
} |
486 |
} |
486 |
} |
487 |
var optionfreq = document.createElement("option"); |
487 |
var optionfreq = document.createElement("option"); |
488 |
optionfreq.text = result.sfdescription + " (mana)"; |
488 |
optionfreq.text = result.sfdescription + " (mana)"; |
489 |
optionfreq.selected = true; |
489 |
optionfreq.selected = true; |
490 |
optionfreq.value="mana"; |
490 |
optionfreq.value="mana"; |
491 |
select.add(optionfreq); |
491 |
select.add(optionfreq); |
492 |
manafreqdata = { |
492 |
manafreqdata = { |
493 |
id:"mana", |
493 |
id:"mana", |
494 |
description:result.sfdescription, |
494 |
description:result.sfdescription, |
495 |
displayorder:result.displayorder, |
495 |
displayorder:result.displayorder, |
496 |
issuesperunit:result.issuesperunit, |
496 |
issuesperunit:result.issuesperunit, |
497 |
unit:result.unit, |
497 |
unit:result.unit, |
498 |
unitsperissue:result.unitsperissue, |
498 |
unitsperissue:result.unitsperissue, |
499 |
}; |
499 |
}; |
500 |
manaid = result.id; |
500 |
manaid = result.id; |
501 |
$("#mana_id").val(manaid); |
501 |
$("input[name='mana_id']").val(manaid); |
502 |
$("#mana_search_result").modal("hide"); |
502 |
$("#mana_search_result").modal("hide"); |
503 |
frequencyload(); |
503 |
frequencyload(); |
504 |
numberpatternload(); |
504 |
numberpatternload(); |
505 |
}) |
505 |
}).fail( function( result ){ |
506 |
.done( function(){ |
506 |
}); |
507 |
$("tr").removeClass("selected"); |
|
|
508 |
$(".mana-use i").attr("class","fa fa-download"); |
509 |
}) |
510 |
.fail( function( result ){ |
511 |
}); |
512 |
} |
513 |
|
514 |
function mana_comment_close(){ |
515 |
$("#selected_id").val(""); |
516 |
$("#mana-resource-id").val(""); |
517 |
$("#mana-comment").val(""); |
518 |
$("#mana_results").show(); |
519 |
$("#new_mana_comment").hide(); |
507 |
} |
520 |
} |
508 |
|
521 |
|
509 |
$(document).ready(function() { |
522 |
$(document).ready(function() { |
Lines 511-517
$(document).ready(function() {
Link Here
|
511 |
mana_search(); |
524 |
mana_search(); |
512 |
} |
525 |
} |
513 |
$("#displayexample").hide(); |
526 |
$("#displayexample").hide(); |
514 |
$("#mana_search_result").modal("hide"); |
527 |
|
|
|
528 |
// When Mana search results modal is hidden, hide comment form and any status messages |
529 |
$("#mana_search_result").on("hide.bs.modal", function(){ |
530 |
$("#mana_results").show(); |
531 |
$("#new_mana_comment").hide(); |
532 |
$(".mana_comment_status").hide(); |
533 |
}); |
534 |
|
515 |
$("#aqbooksellerid").on('keypress', function(e) { |
535 |
$("#aqbooksellerid").on('keypress', function(e) { |
516 |
if (e.keyCode == 13) { |
536 |
if (e.keyCode == 13) { |
517 |
e.preventDefault(); |
537 |
e.preventDefault(); |
Lines 652-655
$(document).ready(function() {
Link Here
|
652 |
$('#save-subscription').on("click", function(e){ |
672 |
$('#save-subscription').on("click", function(e){ |
653 |
$('select:disabled').removeAttr('disabled'); |
673 |
$('select:disabled').removeAttr('disabled'); |
654 |
}); |
674 |
}); |
|
|
675 |
|
676 |
$("body").on("click", ".mana-use", function(e) { |
677 |
e.preventDefault(); |
678 |
$(this).find("i").attr("class","fa fa-refresh fa-spin"); |
679 |
var subscription_id = $(this).data("subscription_id"); |
680 |
mana_use( subscription_id ); |
681 |
}); |
655 |
}); |
682 |
}); |