|
Lines 468-541
Link Here
|
| 468 |
CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %], |
468 |
CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %], |
| 469 |
}); |
469 |
}); |
| 470 |
</script> |
470 |
</script> |
| 471 |
|
|
|
| 472 |
<script> |
471 |
<script> |
| 473 |
function display_string(key, strings, fallback) { |
472 |
function display_string(key, strings, fallback) { |
| 474 |
if ( strings.hasOwnProperty(key) ) { |
473 |
if (strings.hasOwnProperty(key)) { |
| 475 |
return strings[key].str && escape_str(strings[key].str) || ''; |
474 |
return (strings[key].str && escape_str(strings[key].str)) || ""; |
| 476 |
} |
475 |
} |
| 477 |
return fallback != null ? fallback : ''; |
476 |
return fallback != null ? fallback : ""; |
| 478 |
} |
477 |
} |
| 479 |
|
478 |
|
| 480 |
var _build_item = function(item, tr) { |
479 |
var _build_item = function (item, tr) { |
| 481 |
var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />') |
480 |
var chb = $('<input type="checkbox" name="items_to_receive" value="' + item.item_id + '" />') |
| 482 |
.prop('checked', item._checked) |
481 |
.prop("checked", item._checked) |
| 483 |
.change(function() { |
482 |
.change(function () { |
| 484 |
item._checked = $(this).prop('checked'); |
483 |
item._checked = $(this).prop("checked"); |
| 485 |
}); |
484 |
}); |
| 486 |
tr.append($('<td style="text-align:center"></td>').append(chb)); |
485 |
tr.append($('<td style="text-align:center"></td>').append(chb)); |
| 487 |
tr.append('<td><a style="cursor:pointer" href="#" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>'); |
486 |
tr.append('<td><a style="cursor:pointer" href="#" onclick="PopupEditPage(' + item.biblio_id + ", " + item.item_id + ');">' + EDIT[0].toUpperCase() + EDIT.substr(1).toLowerCase() + "</a></td>"); |
| 488 |
tr.append('<td>'+(item.external_id||'')+'</td>'); |
487 |
tr.append("<td>" + (item.external_id || "") + "</td>"); |
| 489 |
tr.append('<td>'+display_string( 'home_library_id', item._strings, item.home_library_id ) || ''+'</td>'); |
488 |
tr.append("<td>" + display_string("home_library_id", item._strings, item.home_library_id) || "" + "</td>"); |
| 490 |
tr.append('<td>'+display_string( 'holding_library_id', item._strings, item.holding_library_id )+'</td>'); |
489 |
tr.append("<td>" + display_string("holding_library_id", item._strings, item.holding_library_id) + "</td>"); |
| 491 |
tr.append('<td>'+display_string( 'not_for_loan_status', item._strings, item.not_for_loan_status )+'</td>'); |
490 |
tr.append("<td>" + display_string("not_for_loan_status", item._strings, item.not_for_loan_status) + "</td>"); |
| 492 |
tr.append('<td>'+display_string( 'restricted_status', item._strings, item.restricted_status )+'</td>'); |
491 |
tr.append("<td>" + display_string("restricted_status", item._strings, item.restricted_status) + "</td>"); |
| 493 |
tr.append('<td><span class="shelvingloc">'+display_string( 'location', item._strings, item.location )+'</span></td>'); |
492 |
tr.append('<td><span class="shelvingloc">' + display_string("location", item._strings, item.location) + "</span></td>"); |
| 494 |
tr.append('<td>'+(item.callnumber||'')+'</td>'); |
493 |
tr.append("<td>" + (item.callnumber || "") + "</td>"); |
| 495 |
tr.append('<td>'+(item.copy_number||'')+'</td>'); |
494 |
tr.append("<td>" + (item.copy_number || "") + "</td>"); |
| 496 |
tr.append('<td>'+(item.inventory_number||'')+'</td>'); |
495 |
tr.append("<td>" + (item.inventory_number || "") + "</td>"); |
| 497 |
tr.append('<td>'+display_string( 'collection', item._strings, item.collection )+'</td>'); |
496 |
tr.append("<td>" + display_string("collection", item._strings, item.collection) + "</td>"); |
| 498 |
tr.append('<td>'+display_string( 'item_type_id', item._strings, item.item_type_id )+'</td>'); |
497 |
tr.append("<td>" + display_string("item_type_id", item._strings, item.item_type_id) + "</td>"); |
| 499 |
tr.append('<td>'+display_string( 'materials_notes', item._strings, item.materials_notes )+'</td>'); |
498 |
tr.append("<td>" + display_string("materials_notes", item._strings, item.materials_notes) + "</td>"); |
| 500 |
tr.append('<td>'+(item.public_notes||'')+'</td>'); |
499 |
tr.append("<td>" + (item.public_notes || "") + "</td>"); |
| 501 |
}; |
500 |
}; |
| 502 |
|
501 |
|
| 503 |
var items_columns = [null, null, 'external_id', 'home_library_id', |
502 |
var items_columns = [ |
| 504 |
'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location', |
503 |
null, |
| 505 |
'callnumber', 'copy_number', 'inventory_number', 'collection_code', |
504 |
null, |
| 506 |
'item_type', 'materials_notes', 'public_notes']; |
505 |
"external_id", |
|
|
506 |
"home_library_id", |
| 507 |
"holding_library_id", |
| 508 |
"not_for_loan_status", |
| 509 |
"restricted_status", |
| 510 |
"location", |
| 511 |
"callnumber", |
| 512 |
"copy_number", |
| 513 |
"inventory_number", |
| 514 |
"collection_code", |
| 515 |
"item_type", |
| 516 |
"materials_notes", |
| 517 |
"public_notes", |
| 518 |
]; |
| 507 |
|
519 |
|
| 508 |
function PopupEditPage(biblionumber, itemnumber) { |
520 |
function PopupEditPage(biblionumber, itemnumber) { |
| 509 |
var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" |
521 |
var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; |
| 510 |
+ biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; |
|
|
| 511 |
var w = window.open(url); |
522 |
var w = window.open(url); |
| 512 |
var watchClose = setInterval(function() { |
523 |
var watchClose = setInterval(function () { |
| 513 |
if (w.closed) { |
524 |
if (w.closed) { |
| 514 |
clearTimeout(watchClose); |
525 |
clearTimeout(watchClose); |
| 515 |
$.ajax({ |
526 |
$.ajax({ |
| 516 |
dataType: "json", |
527 |
dataType: "json", |
| 517 |
headers: { |
528 |
headers: { |
| 518 |
"x-koha-embed": "+strings" |
529 |
"x-koha-embed": "+strings", |
| 519 |
}, |
530 |
}, |
| 520 |
url: '/api/v1/items/'+itemnumber, |
531 |
url: "/api/v1/items/" + itemnumber, |
| 521 |
success: function(item) { |
532 |
success: function (item) { |
| 522 |
var tr = $("#item_"+itemnumber); |
533 |
var tr = $("#item_" + itemnumber); |
| 523 |
item._checked = $(tr).find('input[type="checkbox"]').prop('checked'); |
534 |
item._checked = $(tr).find('input[type="checkbox"]').prop("checked"); |
| 524 |
tr.html(''); |
535 |
tr.html(""); |
| 525 |
_build_item(item, tr); |
536 |
_build_item(item, tr); |
| 526 |
|
537 |
|
| 527 |
var row = $("#order_edit").data('row'); |
538 |
var row = $("#order_edit").data("row"); |
| 528 |
row.items.forEach((it, i) => { if (it.item_id == itemnumber) { |
539 |
row.items.forEach((it, i) => { |
| 529 |
row.items[i] = item; |
540 |
if (it.item_id == itemnumber) { |
| 530 |
}}); |
541 |
row.items[i] = item; |
| 531 |
} |
542 |
} |
|
|
543 |
}); |
| 544 |
}, |
| 532 |
}); |
545 |
}); |
| 533 |
} |
546 |
} |
| 534 |
}, 500); |
547 |
}, 500); |
| 535 |
} |
548 |
} |
| 536 |
|
549 |
|
| 537 |
var periods={}; |
550 |
var periods = {}; |
| 538 |
var funds={}; |
551 |
var funds = {}; |
| 539 |
var funds_tree = []; |
552 |
var funds_tree = []; |
| 540 |
|
553 |
|
| 541 |
var QTY_TOTAL = _("Receiving %0$s out of %1$s"); |
554 |
var QTY_TOTAL = _("Receiving %0$s out of %1$s"); |
|
Lines 554-674
Link Here
|
| 554 |
var SAVE_WARNING_TITLE = _("Warning"); |
567 |
var SAVE_WARNING_TITLE = _("Warning"); |
| 555 |
var SAVE_ERROR_TITLE = _("Error"); |
568 |
var SAVE_ERROR_TITLE = _("Error"); |
| 556 |
|
569 |
|
| 557 |
$(document).ready(function(){ |
570 |
$(document).ready(function () { |
| 558 |
// keep a copy for re-rendering |
571 |
// keep a copy for re-rendering |
| 559 |
var $funds_tree = $('#bookfund').html(); |
572 |
var $funds_tree = $("#bookfund").html(); |
| 560 |
var base_query = { "order_id": {"-in": multiple_orders.split(',')}}; |
573 |
var base_query = { order_id: { "-in": multiple_orders.split(",") } }; |
| 561 |
var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; |
574 |
var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; |
| 562 |
var options = { |
575 |
var options = { |
| 563 |
ajax: { |
576 |
ajax: { |
| 564 |
"url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)) |
577 |
url: pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)), |
| 565 |
}, |
578 |
}, |
| 566 |
embed: [ |
579 |
embed: ["basket", "biblio.suggestions.suggester", "fund.budget", "items+strings", "creator"], |
| 567 |
"basket", |
|
|
| 568 |
"biblio.suggestions.suggester", |
| 569 |
"fund.budget", |
| 570 |
"items+strings", |
| 571 |
"creator" |
| 572 |
], |
| 573 |
dom: 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
580 |
dom: 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
| 574 |
columns: [ |
581 |
columns: [ |
| 575 |
{ |
582 |
{ |
| 576 |
data: "order_id", |
583 |
data: "order_id", |
| 577 |
searchable: true, |
584 |
searchable: true, |
| 578 |
orderable: true |
585 |
orderable: true, |
| 579 |
}, |
586 |
}, |
| 580 |
{ |
587 |
{ |
| 581 |
data: "biblio.title", |
588 |
data: "biblio.title", |
| 582 |
searchable: true, |
589 |
searchable: true, |
| 583 |
orderable: true, |
590 |
orderable: true, |
| 584 |
render: function(data, type, row, meta) { |
591 |
render: function (data, type, row, meta) { |
| 585 |
if ( data == null ) { |
592 |
if (data == null) { |
| 586 |
return ""; |
593 |
return ""; |
| 587 |
} |
594 |
} else { |
| 588 |
else { |
|
|
| 589 |
return data; |
595 |
return data; |
| 590 |
} |
596 |
} |
| 591 |
} |
597 |
}, |
| 592 |
}, |
598 |
}, |
| 593 |
{ |
599 |
{ |
| 594 |
data: "biblio.author", |
600 |
data: "biblio.author", |
| 595 |
searchable: true, |
601 |
searchable: true, |
| 596 |
orderable: true, |
602 |
orderable: true, |
| 597 |
render: function(data, type, row, meta) { |
603 |
render: function (data, type, row, meta) { |
| 598 |
if ( data == null ) { |
604 |
if (data == null) { |
| 599 |
return ""; |
605 |
return ""; |
| 600 |
} |
606 |
} else { |
| 601 |
else { |
|
|
| 602 |
return data; |
607 |
return data; |
| 603 |
} |
608 |
} |
| 604 |
} |
609 |
}, |
| 605 |
}, |
610 |
}, |
| 606 |
{ |
611 |
{ |
| 607 |
data: "biblio.isbn", |
612 |
data: "biblio.isbn", |
| 608 |
searchable: true, |
613 |
searchable: true, |
| 609 |
orderable: true, |
614 |
orderable: true, |
| 610 |
render: function(data, type, row, meta) { |
615 |
render: function (data, type, row, meta) { |
| 611 |
if ( data == null ) { |
616 |
if (data == null) { |
| 612 |
return ""; |
617 |
return ""; |
| 613 |
} |
618 |
} else { |
| 614 |
else { |
|
|
| 615 |
return data; |
619 |
return data; |
| 616 |
} |
620 |
} |
| 617 |
} |
621 |
}, |
| 618 |
}, |
622 |
}, |
| 619 |
{ |
623 |
{ |
| 620 |
searchable: false, |
624 |
searchable: false, |
| 621 |
orderable: false, |
625 |
orderable: false, |
| 622 |
data: function(row, type, val, meta) { |
626 |
data: function (row, type, val, meta) { |
| 623 |
return $date(row.date_received||new Date().toISOString()); |
627 |
return $date(row.date_received || new Date().toISOString()); |
| 624 |
} |
628 |
}, |
| 625 |
}, |
629 |
}, |
| 626 |
{ |
630 |
{ |
| 627 |
data: "fund.name", |
631 |
data: "fund.name", |
| 628 |
searchable: true, |
632 |
searchable: true, |
| 629 |
orderable: false, |
633 |
orderable: false, |
| 630 |
render: function(data, type, row, meta) { |
634 |
render: function (data, type, row, meta) { |
| 631 |
return row.fund.budget.budget_period_description+" - "+row.fund.name; |
635 |
return row.fund.budget.budget_period_description + " - " + row.fund.name; |
| 632 |
} |
636 |
}, |
| 633 |
}, |
637 |
}, |
| 634 |
{ |
638 |
{ |
| 635 |
searchable: false, |
639 |
searchable: false, |
| 636 |
orderable: true, |
640 |
orderable: true, |
| 637 |
data: "quantity_received", |
641 |
data: "quantity_received", |
| 638 |
render: function(data, type, row, meta) { |
642 |
render: function (data, type, row, meta) { |
| 639 |
var data = $("#order_edit").data(); |
643 |
var data = $("#order_edit").data(); |
| 640 |
return QTY_TOTAL.format(row.subscription_id&&(!data.saved||!data.saved.hasOwnProperty(row.order_id))?row.quantity:row.quantity_received, row.quantity); |
644 |
return QTY_TOTAL.format(row.subscription_id && (!data.saved || !data.saved.hasOwnProperty(row.order_id)) ? row.quantity : row.quantity_received, row.quantity); |
| 641 |
} |
645 |
}, |
| 642 |
}, |
646 |
}, |
| 643 |
{ |
647 |
{ |
| 644 |
searchable: false, |
648 |
searchable: false, |
| 645 |
orderable: false, |
649 |
orderable: false, |
| 646 |
render: function(data, type, row, meta) { |
650 |
render: function (data, type, row, meta) { |
| 647 |
return '<a class="btn btn-default btn-xs order_edit_toggle" data-bs-toggle="modal" href="#order_edit" data-row="'+meta.row+'" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> '+EDIT+'</a>'; |
651 |
return '<a class="btn btn-default btn-xs order_edit_toggle" data-bs-toggle="modal" href="#order_edit" data-row="' + meta.row + '" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> ' + EDIT + "</a>"; |
| 648 |
} |
652 |
}, |
| 649 |
} |
|
|
| 650 |
], |
| 651 |
...(only_one_order? |
| 652 |
{ |
| 653 |
drawCallback: function( settings ) { |
| 654 |
$("#order_edit").modal("show"); |
| 655 |
}, |
653 |
}, |
| 656 |
} : {}), |
654 |
], |
|
|
655 |
...(only_one_order |
| 656 |
? { |
| 657 |
drawCallback: function (settings) { |
| 658 |
$("#order_edit").modal("show"); |
| 659 |
}, |
| 660 |
} |
| 661 |
: {}), |
| 657 |
}; |
662 |
}; |
| 658 |
var orders_table = $("#multiple_orders").kohaTable(options); |
663 |
var orders_table = $("#multiple_orders").kohaTable(options); |
| 659 |
var api = orders_table.api(); |
664 |
var api = orders_table.api(); |
| 660 |
|
665 |
|
| 661 |
api.on('preDraw', function() { |
666 |
api.on("preDraw", function () { |
| 662 |
var saved = $("#order_edit").data('saved'); |
667 |
var saved = $("#order_edit").data("saved"); |
| 663 |
if(saved) { |
668 |
if (saved) { |
| 664 |
var data = api.data(); |
669 |
var data = api.data(); |
| 665 |
for(var i = 0; i<data.length; i++) { |
670 |
for (var i = 0; i < data.length; i++) { |
| 666 |
var row = data[i]; |
671 |
var row = data[i]; |
| 667 |
var srow = saved[row.order_id]; |
672 |
var srow = saved[row.order_id]; |
| 668 |
if(srow) { |
673 |
if (srow) { |
| 669 |
if(row.fund_id != srow.fund_id) { |
674 |
if (row.fund_id != srow.fund_id) { |
| 670 |
row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label'); |
675 |
row.fund.budget.budget_period_description = $("#bookfund option[value=" + srow.fund_id + "]") |
| 671 |
row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html(); |
676 |
.parent() |
|
|
677 |
.attr("label"); |
| 678 |
row.fund.name = $("#bookfund option[value=" + srow.fund_id + "]").html(); |
| 672 |
} |
679 |
} |
| 673 |
row.date_received = srow.date_received; |
680 |
row.date_received = srow.date_received; |
| 674 |
row.quantity = srow.quantity; |
681 |
row.quantity = srow.quantity; |
|
Lines 678-846
Link Here
|
| 678 |
} |
685 |
} |
| 679 |
}); |
686 |
}); |
| 680 |
|
687 |
|
| 681 |
if (only_one_order){ |
688 |
if (only_one_order) { |
| 682 |
$("#quantity").on('change', function() { |
689 |
$("#quantity").on("change", function () { |
| 683 |
$('.modal-save').prop('disabled', $(this).val() < 1 ); |
690 |
$(".modal-save").prop("disabled", $(this).val() < 1); |
| 684 |
}); |
691 |
}); |
| 685 |
} |
692 |
} |
| 686 |
|
693 |
|
| 687 |
var _doSave = function(params) { |
694 |
var _doSave = function (params) { |
| 688 |
params.data.csrf_token = $('meta[name="csrf-token"]').attr('content'); |
695 |
params.data.csrf_token = $('meta[name="csrf-token"]').attr("content"); |
| 689 |
$.ajax($.extend({ |
696 |
$.ajax( |
| 690 |
method: 'POST', |
697 |
$.extend( |
| 691 |
url: '/cgi-bin/koha/acqui/finishreceive.pl' |
698 |
{ |
| 692 |
}, params)); |
699 |
method: "POST", |
|
|
700 |
url: "/cgi-bin/koha/acqui/finishreceive.pl", |
| 701 |
}, |
| 702 |
params |
| 703 |
) |
| 704 |
); |
| 693 |
}; |
705 |
}; |
| 694 |
|
706 |
|
| 695 |
var _transform_row = function(row, origrec) { |
707 |
var _transform_row = function (row, origrec) { |
| 696 |
var params = {}; |
708 |
var params = {}; |
| 697 |
params['biblionumber'] = row.biblio_id; |
709 |
params["biblionumber"] = row.biblio_id; |
| 698 |
params['invoiceid'] = invoice_id; |
710 |
params["invoiceid"] = invoice_id; |
| 699 |
params['ordernumber'] = row.order_id; |
711 |
params["ordernumber"] = row.order_id; |
| 700 |
params['booksellerid'] = row.basket.vendor_id; |
712 |
params["booksellerid"] = row.basket.vendor_id; |
| 701 |
|
713 |
|
| 702 |
if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { |
714 |
if (row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { |
| 703 |
params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; |
715 |
params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; |
| 704 |
const options = Array.from(document.querySelectorAll('#reason option')); |
716 |
const options = Array.from(document.querySelectorAll("#reason option")); |
| 705 |
if (options.some(option => option.value === row.biblio.suggestions[0].reason)) { |
717 |
if (options.some(option => option.value === row.biblio.suggestions[0].reason)) { |
| 706 |
params['reason'] = row.biblio.suggestions[0].reason; |
718 |
params["reason"] = row.biblio.suggestions[0].reason; |
| 707 |
} else { |
719 |
} else { |
| 708 |
params['reason'] = 'other'; |
720 |
params["reason"] = "other"; |
| 709 |
params['other_reason'] = row.biblio.suggestions[0].reason; |
721 |
params["other_reason"] = row.biblio.suggestions[0].reason; |
| 710 |
} |
722 |
} |
| 711 |
} |
723 |
} |
| 712 |
params['datereceived'] = row.date_received; |
724 |
params["datereceived"] = row.date_received; |
| 713 |
params['bookfund'] = row.fund_id; |
725 |
params["bookfund"] = row.fund_id; |
| 714 |
params['quantity'] = row.quantity; |
726 |
params["quantity"] = row.quantity; |
| 715 |
params['quantityrec'] = row.quantity_received; |
727 |
params["quantityrec"] = row.quantity_received; |
| 716 |
params['origquantityrec'] = origrec; |
728 |
params["origquantityrec"] = origrec; |
| 717 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
729 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
| 718 |
params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering; |
730 |
params["tax_rate"] = effective_create_items == "receiving" ? row.tax_rate_on_receiving : row.tax_rate_on_ordering; |
| 719 |
params['replacementprice'] = row.replacement_price; |
731 |
params["replacementprice"] = row.replacement_price; |
| 720 |
params['unitprice'] = ( invoiceincgst=="1" ) ? ( row.unit_price_tax_included || row.ecost_tax_included ) : ( row.unit_price_tax_excluded || row.ecost_tax_excluded ); |
732 |
params["unitprice"] = invoiceincgst == "1" ? row.unit_price_tax_included || row.ecost_tax_included : row.unit_price_tax_excluded || row.ecost_tax_excluded; |
| 721 |
params['order_internalnote'] = row.internal_note; |
733 |
params["order_internalnote"] = row.internal_note; |
| 722 |
if (effective_create_items == 'receiving') { |
734 |
if (effective_create_items == "receiving") { |
| 723 |
row.items.forEach(function(item){ |
735 |
row.items.forEach(function (item) { |
| 724 |
Object.keys(item).forEach(function(item_field){ |
736 |
Object.keys(item).forEach(function (item_field) { |
| 725 |
Object.keys(item[item_field]).forEach(function(key){ |
737 |
Object.keys(item[item_field]).forEach(function (key) { |
| 726 |
if (!params[key]) params[key] = []; |
738 |
if (!params[key]) params[key] = []; |
| 727 |
params[key].push(item[item_field][key]); |
739 |
params[key].push(item[item_field][key]); |
| 728 |
}); |
740 |
}); |
| 729 |
}); |
741 |
}); |
| 730 |
}); |
742 |
}); |
| 731 |
} else if(effective_create_items == 'ordering') { |
743 |
} else if (effective_create_items == "ordering") { |
| 732 |
params['items_to_receive[]'] = (row.items||[]) |
744 |
params["items_to_receive[]"] = (row.items || []) |
| 733 |
.filter(function(item) { |
745 |
.filter(function (item) { |
| 734 |
return item._checked |
746 |
return item._checked; |
| 735 |
}) |
747 |
}) |
| 736 |
.map(function(item) { |
748 |
.map(function (item) { |
| 737 |
return item.item_id; |
749 |
return item.item_id; |
| 738 |
}) |
750 |
}); |
| 739 |
} |
751 |
} |
| 740 |
params['invoice_currency'] = row.invoice_currency; |
752 |
params["invoice_currency"] = row.invoice_currency; |
| 741 |
params['invoice_unitprice'] = row.invoice_unit_price; |
753 |
params["invoice_unitprice"] = row.invoice_unit_price; |
| 742 |
return params; |
754 |
return params; |
| 743 |
}; |
755 |
}; |
| 744 |
|
756 |
|
| 745 |
var save_rows = function(rows, data) { |
757 |
var save_rows = function (rows, data) { |
| 746 |
if(rows.length) { |
758 |
if (rows.length) { |
| 747 |
$('#jobpanel, #jobstatus').show(); |
759 |
$("#jobpanel, #jobstatus").show(); |
| 748 |
errors = [] |
760 |
errors = []; |
| 749 |
var loopRows = function(i) { |
761 |
var loopRows = function (i) { |
| 750 |
var row = rows[i]; |
762 |
var row = rows[i]; |
| 751 |
if(!row) { |
763 |
if (!row) { |
| 752 |
if(!errors.length) { |
764 |
if (!errors.length) { |
| 753 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id |
765 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid=" + invoice_id; |
| 754 |
} else { |
766 |
} else { |
| 755 |
$('#modal_messages .modal-header h1').html(SAVE_ERROR_TITLE); |
767 |
$("#modal_messages .modal-header h1").html(SAVE_ERROR_TITLE); |
| 756 |
$('#modal_messages .modal-body ul').html(''); |
768 |
$("#modal_messages .modal-body ul").html(""); |
| 757 |
errors.forEach(function(error) { |
769 |
errors.forEach(function (error) { |
| 758 |
$('#modal_messages .modal-body ul').append('<li>'+error+'</li>'); |
770 |
$("#modal_messages .modal-body ul").append("<li>" + error + "</li>"); |
| 759 |
}); |
771 |
}); |
| 760 |
$('#modal_messages .modal-footer .cancel').hide(); |
772 |
$("#modal_messages .modal-footer .cancel").hide(); |
| 761 |
$('#modal_messages .modal-footer .accept').html(_("Accept")); |
773 |
$("#modal_messages .modal-footer .accept").html(_("Accept")); |
| 762 |
$('#modal_messages .modal-footer .accept').one('click', function() { |
774 |
$("#modal_messages .modal-footer .accept").one("click", function () { |
| 763 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id |
775 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid=" + invoice_id; |
| 764 |
}); |
776 |
}); |
| 765 |
$('#modal_messages').modal('show'); |
777 |
$("#modal_messages").modal("show"); |
| 766 |
} |
778 |
} |
| 767 |
return; |
779 |
return; |
| 768 |
} |
780 |
} |
| 769 |
if(data.saved && data.saved[row.order_id]) { |
781 |
if (data.saved && data.saved[row.order_id]) { |
| 770 |
row = data.saved[row.order_id]; |
782 |
row = data.saved[row.order_id]; |
| 771 |
var origrec = data.origrec[row.order_id]; |
783 |
var origrec = data.origrec[row.order_id]; |
| 772 |
} else { |
784 |
} else { |
| 773 |
var origrec = row.quantity_received; |
785 |
var origrec = row.quantity_received; |
| 774 |
} |
786 |
} |
| 775 |
var _set_percentage = function() { |
787 |
var _set_percentage = function () { |
| 776 |
var percentage = Math.round(( (i+1) / rows.length) * 100); |
788 |
var percentage = Math.round(((i + 1) / rows.length) * 100); |
| 777 |
var bgproperty = (parseInt(percentage*2)-300)+"px 0px"; |
789 |
var bgproperty = parseInt(percentage * 2) - 300 + "px 0px"; |
| 778 |
$("#jobprogress").css("background-position",bgproperty); |
790 |
$("#jobprogress").css("background-position", bgproperty); |
| 779 |
$("#jobprogresspercent").text(percentage); |
791 |
$("#jobprogresspercent").text(percentage); |
| 780 |
} |
792 |
}; |
| 781 |
_doSave({ |
793 |
_doSave({ |
| 782 |
data: _transform_row(row, origrec), |
794 |
data: _transform_row(row, origrec), |
| 783 |
success: function() { |
795 |
success: function () { |
| 784 |
_set_percentage(); |
796 |
_set_percentage(); |
| 785 |
loopRows(i+1); |
797 |
loopRows(i + 1); |
| 786 |
}, |
798 |
}, |
| 787 |
error: function() { |
799 |
error: function () { |
| 788 |
_set_percentage() |
800 |
_set_percentage(); |
| 789 |
errors.push(SAVE_ERROR.format(row.order_id)); |
801 |
errors.push(SAVE_ERROR.format(row.order_id)); |
| 790 |
loopRows(i+1); |
802 |
loopRows(i + 1); |
| 791 |
} |
803 |
}, |
| 792 |
}); |
804 |
}); |
| 793 |
}; |
805 |
}; |
| 794 |
loopRows(0) |
806 |
loopRows(0); |
| 795 |
} |
807 |
} |
| 796 |
}; |
808 |
}; |
| 797 |
|
809 |
|
| 798 |
var get_warnings = function(rows) { |
810 |
var get_warnings = function (rows) { |
| 799 |
var warnings = []; |
811 |
var warnings = []; |
| 800 |
rows.forEach(function(row) { |
812 |
rows.forEach(function (row) { |
| 801 |
if(row.quantity_received > row.quantity) { |
813 |
if (row.quantity_received > row.quantity) { |
| 802 |
warnings.push(SAVE_WARNING.format(row.order_id)); |
814 |
warnings.push(SAVE_WARNING.format(row.order_id)); |
| 803 |
row.quantity_received = row.quantity; |
815 |
row.quantity_received = row.quantity; |
| 804 |
} |
816 |
} |
| 805 |
if(row.quantity_received == '0') { |
817 |
if (row.quantity_received == "0") { |
| 806 |
warnings.push(SAVE_WARNING_NO_ITEMS.format(row.order_id)); |
818 |
warnings.push(SAVE_WARNING_NO_ITEMS.format(row.order_id)); |
| 807 |
} |
819 |
} |
| 808 |
}) |
820 |
}); |
| 809 |
return warnings; |
821 |
return warnings; |
| 810 |
} |
822 |
}; |
| 811 |
|
823 |
|
| 812 |
$('#modal_messages .modal-footer .cancel').on('click', function() { |
824 |
$("#modal_messages .modal-footer .cancel").on("click", function () { |
| 813 |
$('#modal_messages .modal-footer .accept').off('click'); |
825 |
$("#modal_messages .modal-footer .accept").off("click"); |
| 814 |
$('#modal_messages').modal('hide'); |
826 |
$("#modal_messages").modal("hide"); |
| 815 |
}) |
827 |
}); |
| 816 |
$('.save').click(function() { |
828 |
$(".save").click(function () { |
| 817 |
var data = $("#order_edit").data(); |
829 |
var data = $("#order_edit").data(); |
| 818 |
var rows = api.rows().data().toArray(); |
830 |
var rows = api.rows().data().toArray(); |
| 819 |
var redirect = true; |
831 |
var redirect = true; |
| 820 |
var warnings = get_warnings(rows); |
832 |
var warnings = get_warnings(rows); |
| 821 |
if(warnings.length) { |
833 |
if (warnings.length) { |
| 822 |
$('#modal_messages .modal-header h1').html(SAVE_WARNING_TITLE); |
834 |
$("#modal_messages .modal-header h1").html(SAVE_WARNING_TITLE); |
| 823 |
$('#modal_messages .modal-body ul').html(''); |
835 |
$("#modal_messages .modal-body ul").html(""); |
| 824 |
warnings.forEach(function(warning) { |
836 |
warnings.forEach(function (warning) { |
| 825 |
$('#modal_messages .modal-body ul').append('<li>'+warning+'</li>'); |
837 |
$("#modal_messages .modal-body ul").append("<li>" + warning + "</li>"); |
| 826 |
}); |
838 |
}); |
| 827 |
$('#modal_messages .modal-footer .cancel').show(); |
839 |
$("#modal_messages .modal-footer .cancel").show(); |
| 828 |
$('#modal_messages .modal-footer .accept').html(_("Continue")); |
840 |
$("#modal_messages .modal-footer .accept").html(_("Continue")); |
| 829 |
$('#modal_messages .modal-footer .accept').one('click', function() { |
841 |
$("#modal_messages .modal-footer .accept").one("click", function () { |
| 830 |
$('#modal_messages').modal('hide'); |
842 |
$("#modal_messages").modal("hide"); |
| 831 |
save_rows(rows, data); |
843 |
save_rows(rows, data); |
| 832 |
}); |
844 |
}); |
| 833 |
$('#modal_messages').modal('show'); |
845 |
$("#modal_messages").modal("show"); |
| 834 |
} else { |
846 |
} else { |
| 835 |
save_rows(rows, data); |
847 |
save_rows(rows, data); |
| 836 |
} |
848 |
} |
| 837 |
}); |
849 |
}); |
| 838 |
|
850 |
|
| 839 |
|
851 |
$("#order_edit").on("change", "#reason", function () { |
| 840 |
$("#order_edit").on("change", "#reason", function() { |
|
|
| 841 |
var val = $(this).val(); |
852 |
var val = $(this).val(); |
| 842 |
var row = $("#order_edit").data('row'); |
853 |
var row = $("#order_edit").data("row"); |
| 843 |
if(val == 'other') { |
854 |
if (val == "other") { |
| 844 |
$("#other_reason").show(); |
855 |
$("#other_reason").show(); |
| 845 |
$(this).hide(); |
856 |
$(this).hide(); |
| 846 |
} else { |
857 |
} else { |
|
Lines 848-953
Link Here
|
| 848 |
} |
859 |
} |
| 849 |
}); |
860 |
}); |
| 850 |
|
861 |
|
| 851 |
$("#order_edit").on("change", "#select-other_reason", function() { |
862 |
$("#order_edit").on("change", "#select-other_reason", function () { |
| 852 |
var val = $(this).val(); |
863 |
var val = $(this).val(); |
| 853 |
var row = $("#order_edit").data('row'); |
864 |
var row = $("#order_edit").data("row"); |
| 854 |
row.biblio.suggestions[0].reason = val; |
865 |
row.biblio.suggestions[0].reason = val; |
| 855 |
}); |
866 |
}); |
| 856 |
|
867 |
|
| 857 |
$("#order_edit").on("click", "#other_reason a", function() { |
868 |
$("#order_edit").on("click", "#other_reason a", function () { |
| 858 |
$("#other_reason").hide(); |
869 |
$("#other_reason").hide(); |
| 859 |
$("#reason").val(null).show(); |
870 |
$("#reason").val(null).show(); |
| 860 |
}); |
871 |
}); |
| 861 |
|
872 |
|
| 862 |
$("#order_edit").on("change", "#datereceived", function() { |
873 |
$("#order_edit").on("change", "#datereceived", function () { |
| 863 |
var val = $(this).val(); |
874 |
var val = $(this).val(); |
| 864 |
var row = $("#order_edit").data('row'); |
875 |
var row = $("#order_edit").data("row"); |
| 865 |
row.date_received = val; |
876 |
row.date_received = val; |
| 866 |
}); |
877 |
}); |
| 867 |
|
878 |
|
| 868 |
$("#order_edit").on("change", "#bookfund", function() { |
879 |
$("#order_edit").on("change", "#bookfund", function () { |
| 869 |
var val = $(this).val(); |
880 |
var val = $(this).val(); |
| 870 |
var row = $("#order_edit").data('row'); |
881 |
var row = $("#order_edit").data("row"); |
| 871 |
row.fund_id = val; |
882 |
row.fund_id = val; |
| 872 |
}); |
883 |
}); |
| 873 |
|
884 |
|
| 874 |
$("#order_edit").on("change", "#quantity_to_receive", function() { |
885 |
$("#order_edit").on("change", "#quantity_to_receive", function () { |
| 875 |
var val = $(this).val(); |
886 |
var val = $(this).val(); |
| 876 |
var row = $("#order_edit").data('row'); |
887 |
var row = $("#order_edit").data("row"); |
| 877 |
row.quantity = val; |
888 |
row.quantity = val; |
| 878 |
if(row.subscription_id) { |
889 |
if (row.subscription_id) { |
| 879 |
$("#quantity").val(val).change(); |
890 |
$("#quantity").val(val).change(); |
| 880 |
} |
891 |
} |
| 881 |
}); |
892 |
}); |
| 882 |
|
893 |
|
| 883 |
$("#order_edit").on("change", "#quantity", function() { |
894 |
$("#order_edit").on("change", "#quantity", function () { |
| 884 |
var val = $(this).val(); |
895 |
var val = $(this).val(); |
| 885 |
var row = $("#order_edit").data('row'); |
896 |
var row = $("#order_edit").data("row"); |
| 886 |
row.quantity_received = val; |
897 |
row.quantity_received = val; |
| 887 |
var qtyto = parseInt($("#quantity_to_receive").val()); |
898 |
var qtyto = parseInt($("#quantity_to_receive").val()); |
| 888 |
if(parseInt(val) > qtyto) { |
899 |
if (parseInt(val) > qtyto) { |
| 889 |
$("#qtyrecerror").show(); |
900 |
$("#qtyrecerror").show(); |
| 890 |
} else { |
901 |
} else { |
| 891 |
$("#qtyrecerror").hide(); |
902 |
$("#qtyrecerror").hide(); |
| 892 |
} |
903 |
} |
| 893 |
$("input[name='items_to_receive']").each(function() { |
904 |
$("input[name='items_to_receive']").each(function () { |
| 894 |
$(this).prop('checked', false).change(); |
905 |
$(this).prop("checked", false).change(); |
| 895 |
}); |
906 |
}); |
| 896 |
$("input[name='items_to_receive']:lt("+val+")").each(function () { |
907 |
$("input[name='items_to_receive']:lt(" + val + ")").each(function () { |
| 897 |
$(this).prop('checked', true).change(); |
908 |
$(this).prop("checked", true).change(); |
| 898 |
}); |
909 |
}); |
| 899 |
}); |
910 |
}); |
| 900 |
|
911 |
|
| 901 |
$("#order_edit").on("change", "input[name='items_to_receive']", function() { |
912 |
$("#order_edit").on("change", "input[name='items_to_receive']", function () { |
| 902 |
var qty = $("input[name='items_to_receive']:checked").length; |
913 |
var qty = $("input[name='items_to_receive']:checked").length; |
| 903 |
$("#quantity").val(qty); |
914 |
$("#quantity").val(qty); |
| 904 |
var row = $("#order_edit").data('row'); |
915 |
var row = $("#order_edit").data("row"); |
| 905 |
row.quantity_received = qty; |
916 |
row.quantity_received = qty; |
| 906 |
if (only_one_order){ |
917 |
if (only_one_order) { |
| 907 |
$('.modal-save').prop('disabled', qty < 1 ); |
918 |
$(".modal-save").prop("disabled", qty < 1); |
| 908 |
} |
919 |
} |
| 909 |
}) |
920 |
}); |
| 910 |
|
921 |
|
| 911 |
$("#order_edit").on("change", "#tax_rate", function() { |
922 |
$("#order_edit").on("change", "#tax_rate", function () { |
| 912 |
var val = $(this).val(); |
923 |
var val = $(this).val(); |
| 913 |
if(val === null) $(this).val($('option:first-child', this).attr('value')); |
924 |
if (val === null) $(this).val($("option:first-child", this).attr("value")); |
| 914 |
val = $(this).val(); |
925 |
val = $(this).val(); |
| 915 |
var row = $("#order_edit").data('row'); |
926 |
var row = $("#order_edit").data("row"); |
| 916 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
927 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
| 917 |
if(effective_create_items == 'receiving') { |
928 |
if (effective_create_items == "receiving") { |
| 918 |
row.tax_rate_on_receiving = val; |
929 |
row.tax_rate_on_receiving = val; |
| 919 |
} else { |
930 |
} else { |
| 920 |
row.tax_rate_on_ordering = val; |
931 |
row.tax_rate_on_ordering = val; |
| 921 |
} |
932 |
} |
| 922 |
|
|
|
| 923 |
}); |
933 |
}); |
| 924 |
|
934 |
|
| 925 |
$("#order_edit").on("change", "#unitprice", function() { |
935 |
$("#order_edit").on("change", "#unitprice", function () { |
| 926 |
var val = $(this).val(); |
936 |
var val = $(this).val(); |
| 927 |
var row = $("#order_edit").data('row'); |
937 |
var row = $("#order_edit").data("row"); |
| 928 |
if(invoiceincgst == "1") { |
938 |
if (invoiceincgst == "1") { |
| 929 |
row.unit_price_tax_included = val; |
939 |
row.unit_price_tax_included = val; |
| 930 |
} else { |
940 |
} else { |
| 931 |
row.unit_price_tax_excluded = val; |
941 |
row.unit_price_tax_excluded = val; |
| 932 |
} |
942 |
} |
| 933 |
|
|
|
| 934 |
}); |
943 |
}); |
| 935 |
|
944 |
|
| 936 |
function _update_unitprice() { |
945 |
function _update_unitprice() { |
| 937 |
let row = $("#order_edit").data('row'); |
946 |
let row = $("#order_edit").data("row"); |
| 938 |
|
947 |
|
| 939 |
let unitprice = $("#unitprice").val(); |
948 |
let unitprice = $("#unitprice").val(); |
| 940 |
let invoice_currency = $("#invoice_currency").val(); |
949 |
let invoice_currency = $("#invoice_currency").val(); |
| 941 |
let invoice_unitprice = $("#invoice_unitprice").val(); |
950 |
let invoice_unitprice = $("#invoice_unitprice").val(); |
| 942 |
let change_currency = $("#change_currency").is(":checked"); |
951 |
let change_currency = $("#change_currency").is(":checked"); |
| 943 |
|
952 |
|
| 944 |
if ( change_currency ) { |
953 |
if (change_currency) { |
| 945 |
$("#select_currency").show(); |
954 |
$("#select_currency").show(); |
| 946 |
if(!$("#invoice_unitprice").val()){ |
955 |
if (!$("#invoice_unitprice").val()) { |
| 947 |
invoice_unitprice = unitprice; |
956 |
invoice_unitprice = unitprice; |
| 948 |
} |
957 |
} |
| 949 |
var rate = Number($("#invoice_currency option:selected").data('rate')); |
958 |
var rate = Number($("#invoice_currency option:selected").data("rate")); |
| 950 |
unitprice = Number( invoice_unitprice * rate ).toFixed(2); |
959 |
unitprice = Number(invoice_unitprice * rate).toFixed(2); |
| 951 |
$("#unitprice").prop("readonly", "true"); |
960 |
$("#unitprice").prop("readonly", "true"); |
| 952 |
} else { |
961 |
} else { |
| 953 |
$("#select_currency").hide(); |
962 |
$("#select_currency").hide(); |
|
Lines 963-1170
Link Here
|
| 963 |
row.invoice_currency = invoice_currency; |
972 |
row.invoice_currency = invoice_currency; |
| 964 |
row.invoice_unit_price = invoice_unitprice; |
973 |
row.invoice_unit_price = invoice_unitprice; |
| 965 |
} |
974 |
} |
| 966 |
$("#order_edit").on("change", "#invoice_currency", _update_unitprice ); |
975 |
$("#order_edit").on("change", "#invoice_currency", _update_unitprice); |
| 967 |
$("#order_edit").on("change", "#invoice_unitprice", _update_unitprice ); |
976 |
$("#order_edit").on("change", "#invoice_unitprice", _update_unitprice); |
| 968 |
$("#order_edit").on("change", "#change_currency", _update_unitprice ); |
977 |
$("#order_edit").on("change", "#change_currency", _update_unitprice); |
| 969 |
|
978 |
|
| 970 |
$("#order_edit").on("change", "#replacementprice", function() { |
979 |
$("#order_edit").on("change", "#replacementprice", function () { |
| 971 |
var val = $(this).val(); |
980 |
var val = $(this).val(); |
| 972 |
var row = $("#order_edit").data('row'); |
981 |
var row = $("#order_edit").data("row"); |
| 973 |
row.replacement_price = val; |
982 |
row.replacement_price = val; |
| 974 |
}); |
983 |
}); |
| 975 |
|
984 |
|
| 976 |
$("#order_edit").on("change", "#order_internalnote", function() { |
985 |
$("#order_edit").on("change", "#order_internalnote", function () { |
| 977 |
var val = $(this).val(); |
986 |
var val = $(this).val(); |
| 978 |
var row = $("#order_edit").data('row'); |
987 |
var row = $("#order_edit").data("row"); |
| 979 |
row.internal_note = val; |
988 |
row.internal_note = val; |
| 980 |
|
|
|
| 981 |
}); |
989 |
}); |
| 982 |
|
990 |
|
| 983 |
var keep_row = function() { |
991 |
var keep_row = function () { |
| 984 |
var row = $("#order_edit").data('row'); |
992 |
var row = $("#order_edit").data("row"); |
| 985 |
var kept = $("#order_edit").data('kept')||{}; |
993 |
var kept = $("#order_edit").data("kept") || {}; |
| 986 |
if($('#items_list tbody tr').length) { |
994 |
if ($("#items_list tbody tr").length) { |
| 987 |
row.items = []; |
995 |
row.items = []; |
| 988 |
$('#items_list tbody tr').each(function() { |
996 |
$("#items_list tbody tr").each(function () { |
| 989 |
var item = {}; |
997 |
var item = {}; |
| 990 |
$('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() { |
998 |
$("#" + $(this).attr("idblock")) |
| 991 |
var kf = $(this).val(); |
999 |
.find("*[name=kohafield]") |
| 992 |
var obj = {}; |
1000 |
.each(function () { |
| 993 |
$(this).parent().find('*[name]').each(function() { |
1001 |
var kf = $(this).val(); |
| 994 |
obj[$(this).prop('name')] = $(this).val(); |
1002 |
var obj = {}; |
|
|
1003 |
$(this) |
| 1004 |
.parent() |
| 1005 |
.find("*[name]") |
| 1006 |
.each(function () { |
| 1007 |
obj[$(this).prop("name")] = $(this).val(); |
| 1008 |
}); |
| 1009 |
item[kf] = obj; |
| 995 |
}); |
1010 |
}); |
| 996 |
item[kf] = obj; |
|
|
| 997 |
}); |
| 998 |
row.items.push(item); |
1011 |
row.items.push(item); |
| 999 |
}); |
1012 |
}); |
| 1000 |
} |
1013 |
} |
| 1001 |
kept[row.order_id] = row; |
1014 |
kept[row.order_id] = row; |
| 1002 |
$("#order_edit").data('kept', kept); |
1015 |
$("#order_edit").data("kept", kept); |
| 1003 |
}; |
1016 |
}; |
| 1004 |
|
1017 |
|
| 1005 |
var save_row = function() { |
1018 |
var save_row = function () { |
| 1006 |
keep_row(); |
1019 |
keep_row(); |
| 1007 |
var saved = $("#order_edit").data('saved')||{}; |
1020 |
var saved = $("#order_edit").data("saved") || {}; |
| 1008 |
var kept = $("#order_edit").data('kept'); |
1021 |
var kept = $("#order_edit").data("kept"); |
| 1009 |
var saved_rows = $.extend(saved, kept); |
1022 |
var saved_rows = $.extend(saved, kept); |
| 1010 |
$("#order_edit").data('saved', saved_rows); |
1023 |
$("#order_edit").data("saved", saved_rows); |
| 1011 |
api.draw(); |
1024 |
api.draw(); |
| 1012 |
return saved_rows; |
1025 |
return saved_rows; |
| 1013 |
} |
1026 |
}; |
| 1014 |
|
1027 |
|
| 1015 |
var set_modal_buttons = function() { |
1028 |
var set_modal_buttons = function () { |
| 1016 |
var n = $("#order_edit").data('n'); |
1029 |
var n = $("#order_edit").data("n"); |
| 1017 |
var info = api.page.info(); |
1030 |
var info = api.page.info(); |
| 1018 |
|
1031 |
|
| 1019 |
$('.modal-prev').prop('disabled', info.page == 0 && n == 0); |
1032 |
$(".modal-prev").prop("disabled", info.page == 0 && n == 0); |
| 1020 |
$('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n); |
1033 |
$(".modal-next").prop("disabled", info.pages - 1 == info.page && info.end - info.start - 1 == n); |
| 1021 |
}; |
1034 |
}; |
| 1022 |
|
1035 |
|
| 1023 |
var show_subs = function(row) { |
1036 |
var show_subs = function (row) { |
| 1024 |
//$("#child_orders").show(); |
1037 |
//$("#child_orders").show(); |
| 1025 |
var had_rows = false; |
1038 |
var had_rows = false; |
| 1026 |
var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}}; |
1039 |
var base_query = { subscription_id: row.subscription_id, parent_order_id: row.order_id, order_id: { "!=": row.order_id } }; |
| 1027 |
var pending_orders_url = "/api/v1/acquisitions/orders"; |
1040 |
var pending_orders_url = "/api/v1/acquisitions/orders"; |
| 1028 |
var options = { |
1041 |
var options = { |
| 1029 |
ajax: { |
1042 |
ajax: { |
| 1030 |
"url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)) |
1043 |
url: pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)), |
| 1031 |
}, |
1044 |
}, |
| 1032 |
embed: [ |
1045 |
embed: ["invoice", "basket"], |
| 1033 |
"invoice", |
1046 |
order: [[1, "asc"]], |
| 1034 |
"basket" |
|
|
| 1035 |
], |
| 1036 |
order: [[1, 'asc']], |
| 1037 |
dom: 'C<"top pager"ilpfB>tr<"bottom pager"ip>', |
1047 |
dom: 'C<"top pager"ilpfB>tr<"bottom pager"ip>', |
| 1038 |
columns: [ |
1048 |
columns: [ |
| 1039 |
{ |
1049 |
{ |
| 1040 |
searchable: false, |
1050 |
searchable: false, |
| 1041 |
orderable: false, |
1051 |
orderable: false, |
| 1042 |
data: function(row, type, val, meta) { |
1052 |
data: function (row, type, val, meta) { |
| 1043 |
if(row.invoice) { |
1053 |
if (row.invoice) { |
| 1044 |
if(permissions.CAN_user_acquisition) { |
1054 |
if (permissions.CAN_user_acquisition) { |
| 1045 |
return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; |
1055 |
return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=' + row.invoice_id + '" title="Invoice detail page">' + row.invoice.invoice_number + "</a>"; |
| 1046 |
} |
1056 |
} |
| 1047 |
return row.invoice.invoice_number; |
1057 |
return row.invoice.invoice_number; |
| 1048 |
} |
1058 |
} |
| 1049 |
} |
1059 |
}, |
| 1050 |
}, |
1060 |
}, |
| 1051 |
{ |
1061 |
{ |
| 1052 |
data: "order_id", |
1062 |
data: "order_id", |
| 1053 |
searchable: false, |
1063 |
searchable: false, |
| 1054 |
orderable: false |
1064 |
orderable: false, |
| 1055 |
}, |
1065 |
}, |
| 1056 |
{ |
1066 |
{ |
| 1057 |
searchable: false, |
1067 |
searchable: false, |
| 1058 |
orderable: false, |
1068 |
orderable: false, |
| 1059 |
data: "basket.creation_date", |
1069 |
data: "basket.creation_date", |
| 1060 |
render: function(data, type, row, meta) { |
1070 |
render: function (data, type, row, meta) { |
| 1061 |
return $date(row.basket.creation_date); |
1071 |
return $date(row.basket.creation_date); |
| 1062 |
} |
1072 |
}, |
| 1063 |
}, |
1073 |
}, |
| 1064 |
{ |
1074 |
{ |
| 1065 |
searchable: false, |
1075 |
searchable: false, |
| 1066 |
orderable: false, |
1076 |
orderable: false, |
| 1067 |
data: function(row, type, val, meta) { |
1077 |
data: function (row, type, val, meta) { |
| 1068 |
return $date(row.date_received); |
1078 |
return $date(row.date_received); |
| 1069 |
} |
1079 |
}, |
| 1070 |
}, |
1080 |
}, |
| 1071 |
{ |
1081 |
{ |
| 1072 |
searchable: false, |
1082 |
searchable: false, |
| 1073 |
orderable: false, |
1083 |
orderable: false, |
| 1074 |
data: function(row, type, val, meta) { |
1084 |
data: function (row, type, val, meta) { |
| 1075 |
return row.quantity_received; |
1085 |
return row.quantity_received; |
| 1076 |
} |
1086 |
}, |
| 1077 |
}, |
1087 |
}, |
| 1078 |
{ |
1088 |
{ |
| 1079 |
searchable: false, |
1089 |
searchable: false, |
| 1080 |
orderable: true, |
1090 |
orderable: true, |
| 1081 |
data: function(row, type, val, meta) { |
1091 |
data: function (row, type, val, meta) { |
| 1082 |
if(!row.status) return; |
1092 |
if (!row.status) return; |
| 1083 |
var first_letter = row.status[0].toUpperCase(); |
1093 |
var first_letter = row.status[0].toUpperCase(); |
| 1084 |
return first_letter+row.status.substr(1).toLowerCase(); |
1094 |
return first_letter + row.status.substr(1).toLowerCase(); |
| 1085 |
} |
1095 |
}, |
| 1086 |
}, |
1096 |
}, |
| 1087 |
{ |
1097 |
{ |
| 1088 |
searchable: false, |
1098 |
searchable: false, |
| 1089 |
orderable: false, |
1099 |
orderable: false, |
| 1090 |
data: function(row, type, val, meta) { |
1100 |
data: function (row, type, val, meta) { |
| 1091 |
if(!row.date_received) return; |
1101 |
if (!row.date_received) return; |
| 1092 |
return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price() |
1102 |
return Number(row.unit_price_tax_excluded * row.quantity_received).format_price() + " / " + Number(row.unit_price_tax_included * row.quantity_received).format_price(); |
| 1093 |
} |
1103 |
}, |
| 1094 |
}, |
1104 |
}, |
| 1095 |
{ |
1105 |
{ |
| 1096 |
searchable: false, |
1106 |
searchable: false, |
| 1097 |
orderable: false, |
1107 |
orderable: false, |
| 1098 |
data: function(row, type, val, meta) { |
1108 |
data: function (row, type, val, meta) { |
| 1099 |
return row.internal_note; |
1109 |
return row.internal_note; |
| 1100 |
} |
1110 |
}, |
| 1101 |
} |
1111 |
}, |
| 1102 |
] |
1112 |
], |
| 1103 |
}; |
1113 |
}; |
| 1104 |
var child_orders_table = $("#child_orders_table").api(options); |
1114 |
var child_orders_table = $("#child_orders_table").api(options); |
| 1105 |
var child_api = child_orders_table.api(); |
1115 |
var child_api = child_orders_table.api(); |
| 1106 |
child_api.on('preDraw', function() { |
1116 |
child_api.on("preDraw", function () { |
| 1107 |
if(!child_api.data().length && !had_rows) return; |
1117 |
if (!child_api.data().length && !had_rows) return; |
| 1108 |
$("#history-panel").show(); |
1118 |
$("#history-panel").show(); |
| 1109 |
had_rows = true; |
1119 |
had_rows = true; |
| 1110 |
}); |
1120 |
}); |
| 1111 |
}; |
1121 |
}; |
| 1112 |
|
1122 |
|
| 1113 |
var set_editor = function() { |
1123 |
var set_editor = function () { |
| 1114 |
var modal = $("#order_edit"); |
1124 |
var modal = $("#order_edit"); |
| 1115 |
var row = modal.data('row'); |
1125 |
var row = modal.data("row"); |
| 1116 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
1126 |
var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; |
| 1117 |
var origrec = $("#order_edit").data('origrec')||{}; |
1127 |
var origrec = $("#order_edit").data("origrec") || {}; |
| 1118 |
if(!origrec.hasOwnProperty(row.order_id)) { |
1128 |
if (!origrec.hasOwnProperty(row.order_id)) { |
| 1119 |
origrec[row.order_id] = row.quantity_received; |
1129 |
origrec[row.order_id] = row.quantity_received; |
| 1120 |
$("#order_edit").data('origrec', origrec); |
1130 |
$("#order_edit").data("origrec", origrec); |
| 1121 |
} |
1131 |
} |
| 1122 |
if(row.subscription_id || ( row.basket.standing === true && effective_create_items == 'cataloguing') ) { |
1132 |
if (row.subscription_id || (row.basket.standing === true && effective_create_items == "cataloguing")) { |
| 1123 |
row.quantity_received = row.quantity; |
1133 |
row.quantity_received = row.quantity; |
| 1124 |
} |
1134 |
} |
| 1125 |
var keep = $("#order_edit").data('kept'); |
1135 |
var keep = $("#order_edit").data("kept"); |
| 1126 |
if(keep && keep[row.order_id]) { |
1136 |
if (keep && keep[row.order_id]) { |
| 1127 |
row = keep[row.order_id]; |
1137 |
row = keep[row.order_id]; |
| 1128 |
modal.data('row', row); |
1138 |
modal.data("row", row); |
| 1129 |
} |
1139 |
} |
| 1130 |
$('input, select, textarea', '.modal-body').val(null) |
1140 |
$("input, select, textarea", ".modal-body").val(null); |
| 1131 |
modal.find(".modal-title").text(MOD_TITLE.format(escape_str(row.order_id),escape_str(row.biblio.title))); |
1141 |
modal.find(".modal-title").text(MOD_TITLE.format(escape_str(row.order_id), escape_str(row.biblio.title))); |
| 1132 |
["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){ |
1142 |
["title", "author", "copyright_date", "isbn", "series_title"].forEach(function (key) { |
| 1133 |
var o = modal.find(".modal-body #biblio_"+key); |
1143 |
var o = modal.find(".modal-body #biblio_" + key); |
| 1134 |
if(row.biblio[key] !== null) { |
1144 |
if (row.biblio[key] !== null) { |
| 1135 |
o.parent().show(); |
1145 |
o.parent().show(); |
| 1136 |
o.html(row.biblio[key]); |
1146 |
o.html(row.biblio[key]); |
| 1137 |
} else { |
1147 |
} else { |
| 1138 |
o.parent().hide(); |
1148 |
o.parent().hide(); |
| 1139 |
} |
1149 |
} |
| 1140 |
}); |
1150 |
}); |
| 1141 |
if(row.biblio.suggestions.length) { |
1151 |
if (row.biblio.suggestions.length) { |
| 1142 |
$("#suggestion_fieldset").show(); |
1152 |
$("#suggestion_fieldset").show(); |
| 1143 |
if(row.biblio.suggestions[0].suggester) { |
1153 |
if (row.biblio.suggestions[0].suggester) { |
| 1144 |
$("#biblio_suggestion_suggester").parent().show(); |
1154 |
$("#biblio_suggestion_suggester").parent().show(); |
| 1145 |
$("#biblio_suggestion_suggester") |
1155 |
$("#biblio_suggestion_suggester").html( |
| 1146 |
.html( |
1156 |
[row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] |
| 1147 |
[row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] |
1157 |
.filter(function (name) { |
| 1148 |
.filter(function(name){ |
1158 |
return name; |
| 1149 |
return name |
1159 |
}) |
| 1150 |
}) |
1160 |
.join(", ") + |
| 1151 |
.join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestion_id+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestion_id)+'</a>)' |
1161 |
' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' + |
| 1152 |
); |
1162 |
row.biblio.suggestions[0].suggestion_id + |
|
|
1163 |
'&op=show">' + |
| 1164 |
SUGGESTION.format(row.biblio.suggestions[0].suggestion_id) + |
| 1165 |
"</a>)" |
| 1166 |
); |
| 1153 |
} else { |
1167 |
} else { |
| 1154 |
$("#biblio_suggestion_suggester").parent().hide(); |
1168 |
$("#biblio_suggestion_suggester").parent().hide(); |
| 1155 |
} |
1169 |
} |
| 1156 |
if(row.biblio.suggestions[0].reason) { |
1170 |
if (row.biblio.suggestions[0].reason) { |
| 1157 |
$("#suggestion_reason").show(); |
1171 |
$("#suggestion_reason").show(); |
| 1158 |
const options = Array.from(document.querySelectorAll('#reason option')); |
1172 |
const options = Array.from(document.querySelectorAll("#reason option")); |
| 1159 |
if (options.some(option => option.value === row.biblio.suggestions[0].reason)) { |
1173 |
if (options.some(option => option.value === row.biblio.suggestions[0].reason)) { |
| 1160 |
$("#other_reason a").click(); |
1174 |
$("#other_reason a").click(); |
| 1161 |
$("#reason").val(row.biblio.suggestions[0].reason); |
1175 |
$("#reason").val(row.biblio.suggestions[0].reason); |
| 1162 |
$("#select-other_reason").val(null); |
1176 |
$("#select-other_reason").val(null); |
| 1163 |
} else { |
1177 |
} else { |
| 1164 |
$("#reason").val("other").change(); |
1178 |
$("#reason").val("other").change(); |
| 1165 |
$("#select-other_reason").val(row.biblio.suggestions[0].reason); |
1179 |
$("#select-other_reason").val(row.biblio.suggestions[0].reason); |
| 1166 |
} |
1180 |
} |
| 1167 |
|
|
|
| 1168 |
} else { |
1181 |
} else { |
| 1169 |
$("#suggestion_reason").hide(); |
1182 |
$("#suggestion_reason").hide(); |
| 1170 |
} |
1183 |
} |
|
Lines 1173-1218
Link Here
|
| 1173 |
} |
1186 |
} |
| 1174 |
|
1187 |
|
| 1175 |
// set today if no date_received in row |
1188 |
// set today if no date_received in row |
| 1176 |
document.querySelector("#datereceived")._flatpickr.setDate(row.date_received||new Date()); |
1189 |
document.querySelector("#datereceived")._flatpickr.setDate(row.date_received || new Date()); |
| 1177 |
|
1190 |
|
| 1178 |
// restore the full tree |
1191 |
// restore the full tree |
| 1179 |
$("#bookfund").html($funds_tree); |
1192 |
$("#bookfund").html($funds_tree); |
| 1180 |
$("#selected_bookfund") |
1193 |
$("#selected_bookfund").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)).attr("data-sort1-authcat", row.fund.sort1_authcat).attr("data-sort2-authcat", row.fund.sort2_authcat); |
| 1181 |
.html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)) |
|
|
| 1182 |
.attr( 'data-sort1-authcat', row.fund.sort1_authcat ) |
| 1183 |
.attr( 'data-sort2-authcat', row.fund.sort2_authcat ); |
| 1184 |
if (row.fund_id != row.fund.fund_id) { |
1194 |
if (row.fund_id != row.fund.fund_id) { |
| 1185 |
$("#bookfund").val(row.fund_id); |
1195 |
$("#bookfund").val(row.fund_id); |
| 1186 |
} |
1196 |
} |
| 1187 |
$("#bookfund").select2({ width: '50%', dropdownParent: $('#order_edit') }); |
1197 |
$("#bookfund").select2({ width: "50%", dropdownParent: $("#order_edit") }); |
| 1188 |
$("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); |
1198 |
$("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); |
| 1189 |
if( row.creator ) { |
1199 |
if (row.creator) { |
| 1190 |
$("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')') |
1200 |
$("#creator").html( |
|
|
1201 |
[row.creator.surname, row.creator.firstname] |
| 1202 |
.filter(function (name) { |
| 1203 |
return name; |
| 1204 |
}) |
| 1205 |
.join(", ") + |
| 1206 |
" (" + |
| 1207 |
row.creator.patron_id + |
| 1208 |
")" |
| 1209 |
); |
| 1191 |
} else { |
1210 |
} else { |
| 1192 |
$("#creator").html(_("Account has been deleted")); |
1211 |
$("#creator").html(_("Account has been deleted")); |
| 1193 |
} |
1212 |
} |
| 1194 |
$("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id); |
1213 |
$("#quantity_to_receive").val(row.quantity).prop("readonly", !row.subscription_id); |
| 1195 |
if (effective_create_items == 'cataloguing' && ! row.quantity_received) { |
1214 |
if (effective_create_items == "cataloguing" && !row.quantity_received) { |
| 1196 |
row.quantity_received = 1; |
1215 |
row.quantity_received = 1; |
| 1197 |
} |
1216 |
} |
| 1198 |
$("#quantity").val( row.quantity_received ) |
1217 |
$("#quantity") |
| 1199 |
.prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); |
1218 |
.val(row.quantity_received) |
| 1200 |
if (only_one_order){ |
1219 |
.prop("readonly", !row.subscription_id && effective_create_items == "receiving"); |
| 1201 |
$(".modal-save").prop('disabled', $("#quantity").val() == 0); |
1220 |
if (only_one_order) { |
|
|
1221 |
$(".modal-save").prop("disabled", $("#quantity").val() == 0); |
| 1202 |
} |
1222 |
} |
| 1203 |
$('#qtyrecerror').hide(); |
1223 |
$("#qtyrecerror").hide(); |
| 1204 |
var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; |
1224 |
var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; |
| 1205 |
$("#tax_rate").val(tax_rate).change(); |
1225 |
$("#tax_rate").val(tax_rate).change(); |
| 1206 |
var rrp_txt; |
1226 |
var rrp_txt; |
| 1207 |
var ecost_txt; |
1227 |
var ecost_txt; |
| 1208 |
if(invoiceincgst == "1") { |
1228 |
if (invoiceincgst == "1") { |
| 1209 |
rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint"> '+ADJ_TAX_INC.format(active_currency)+"</span>"; |
1229 |
rrp_txt = Number(row.rrp_tax_included).format_price() + '<span class="hint"> ' + ADJ_TAX_INC.format(active_currency) + "</span>"; |
| 1210 |
ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint"> '+TAX_INC+"</span>"; |
1230 |
ecost_txt = Number(row.ecost_tax_included).format_price() + '<span class="hint"> ' + TAX_INC + "</span>"; |
| 1211 |
$("#unitprice").val(row.unit_price_tax_included > 0 ? Number(row.unit_price_tax_included).format_price() : Number(row.ecost_tax_included).format_price()); |
1231 |
$("#unitprice").val(row.unit_price_tax_included > 0 ? Number(row.unit_price_tax_included).format_price() : Number(row.ecost_tax_included).format_price()); |
| 1212 |
$("#unitprice_hint").html(TAX_INC); |
1232 |
$("#unitprice_hint").html(TAX_INC); |
| 1213 |
} else { |
1233 |
} else { |
| 1214 |
rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint"> '+ADJ_TAX_EXC.format(active_currency)+"</span>"; |
1234 |
rrp_txt = Number(row.rrp_tax_excluded).format_price() + '<span class="hint"> ' + ADJ_TAX_EXC.format(active_currency) + "</span>"; |
| 1215 |
ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint"> '+TAX_EXC+"</span>"; |
1235 |
ecost_txt = Number(row.ecost_tax_excluded).format_price() + '<span class="hint"> ' + TAX_EXC + "</span>"; |
| 1216 |
$("#unitprice").val(row.unit_price_tax_excluded > 0 ? Number(row.unit_price_tax_excluded).format_price() : Number(row.ecost_tax_excluded).format_price()); |
1236 |
$("#unitprice").val(row.unit_price_tax_excluded > 0 ? Number(row.unit_price_tax_excluded).format_price() : Number(row.ecost_tax_excluded).format_price()); |
| 1217 |
$("#unitprice_hint").html(TAX_EXC); |
1237 |
$("#unitprice_hint").html(TAX_EXC); |
| 1218 |
} |
1238 |
} |
|
Lines 1220-1379
Link Here
|
| 1220 |
$("#replacementprice").val(row.replacement_price); |
1240 |
$("#replacementprice").val(row.replacement_price); |
| 1221 |
$("#ecost").html(ecost_txt); |
1241 |
$("#ecost").html(ecost_txt); |
| 1222 |
$("#order_internalnote").val(row.internal_note); |
1242 |
$("#order_internalnote").val(row.internal_note); |
| 1223 |
if(row.vendor_note) { |
1243 |
if (row.vendor_note) { |
| 1224 |
$("#order_vendornote").html(row.vendor_note); |
1244 |
$("#order_vendornote").html(row.vendor_note); |
| 1225 |
$("#order_vendornote").parent().show(); |
1245 |
$("#order_vendornote").parent().show(); |
| 1226 |
} else { |
1246 |
} else { |
| 1227 |
$("#order_vendornote").parent().hide(); |
1247 |
$("#order_vendornote").parent().hide(); |
| 1228 |
} |
1248 |
} |
| 1229 |
|
1249 |
|
| 1230 |
|
|
|
| 1231 |
$("#history-panel").hide(); |
1250 |
$("#history-panel").hide(); |
| 1232 |
|
1251 |
|
| 1233 |
$('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove(); |
1252 |
$("#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr").remove(); |
| 1234 |
$('#items_list').hide(); |
1253 |
$("#items_list").hide(); |
| 1235 |
if(row.subscription_id) { |
1254 |
if (row.subscription_id) { |
| 1236 |
$('#modal-order-main #items-panel').removeClass('show').addClass('hide'); |
1255 |
$("#modal-order-main #items-panel").removeClass("show").addClass("hide"); |
| 1237 |
$('#modal-order-main #history-panel').removeClass('hide').addClass('show'); |
1256 |
$("#modal-order-main #history-panel").removeClass("hide").addClass("show"); |
| 1238 |
} else { |
1257 |
} else { |
| 1239 |
$('#modal-order-main #history-panel').removeClass('show').addClass('hide'); |
1258 |
$("#modal-order-main #history-panel").removeClass("show").addClass("hide"); |
| 1240 |
$('#modal-order-main #items-panel').removeClass('hide').addClass('show'); |
1259 |
$("#modal-order-main #items-panel").removeClass("hide").addClass("show"); |
| 1241 |
if(effective_create_items == 'receiving') { |
1260 |
if (effective_create_items == "receiving") { |
| 1242 |
$("#acq-create-receiving").show(); |
1261 |
$("#acq-create-receiving").show(); |
| 1243 |
$("#acq-create-ordering").hide(); |
1262 |
$("#acq-create-ordering").hide(); |
| 1244 |
if(row.items && row.items.length) { |
1263 |
if (row.items && row.items.length) { |
| 1245 |
row.items.forEach(function(item, index) { |
1264 |
row.items.forEach(function (item, index) { |
| 1246 |
cloneItemBlock(index, prefs.UniqueItemFields, function(block_id) { |
1265 |
cloneItemBlock(index, prefs.UniqueItemFields, function (block_id) { |
| 1247 |
var block = $('#'+block_id).hide(); |
1266 |
var block = $("#" + block_id).hide(); |
| 1248 |
Object.keys(item).forEach(function(key) { |
1267 |
Object.keys(item).forEach(function (key) { |
| 1249 |
block |
1268 |
block |
| 1250 |
.find('*[name=kohafield][value="'+key+'"]') |
1269 |
.find('*[name=kohafield][value="' + key + '"]') |
| 1251 |
.parent() |
1270 |
.parent() |
| 1252 |
.find('*[name=field_value]') |
1271 |
.find("*[name=field_value]") |
| 1253 |
.val(item[key].field_value); |
1272 |
.val(item[key].field_value); |
| 1254 |
}); |
1273 |
}); |
| 1255 |
addItemInList(block_id, prefs.UniqueItemFields); |
1274 |
addItemInList(block_id, prefs.UniqueItemFields); |
| 1256 |
block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
1275 |
block.find("input[name='buttonPlus']").val(window.MSG_ADDITEM_JS_UPDATEITEM); |
| 1257 |
block.find("input[name='buttonPlusMulti']").remove(); |
1276 |
block.find("input[name='buttonPlusMulti']").remove(); |
| 1258 |
block.find("input[name='multiValue']").remove(); |
1277 |
block.find("input[name='multiValue']").remove(); |
| 1259 |
}); |
1278 |
}); |
| 1260 |
}); |
1279 |
}); |
| 1261 |
} |
1280 |
} |
| 1262 |
cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields); |
1281 |
cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields); |
| 1263 |
} else if (effective_create_items == 'ordering') { |
1282 |
} else if (effective_create_items == "ordering") { |
| 1264 |
$("#acq-create-receiving").hide(); |
1283 |
$("#acq-create-receiving").hide(); |
| 1265 |
$("#acq-create-ordering").show(); |
1284 |
$("#acq-create-ordering").show(); |
| 1266 |
if(row.items.length) { |
1285 |
if (row.items.length) { |
| 1267 |
$("#acq-create-ordering tbody").append( |
1286 |
$("#acq-create-ordering tbody").append( |
| 1268 |
row.items.map(function(item) { |
1287 |
row.items.map(function (item) { |
| 1269 |
var tr = $('<tr id="item_'+item.item_id+'"/>'); |
1288 |
var tr = $('<tr id="item_' + item.item_id + '"/>'); |
| 1270 |
_build_item(item, tr); |
1289 |
_build_item(item, tr); |
| 1271 |
return tr; |
1290 |
return tr; |
| 1272 |
}) |
1291 |
}) |
| 1273 |
); |
1292 |
); |
| 1274 |
} |
1293 |
} |
| 1275 |
} else { |
1294 |
} else { |
| 1276 |
$('#modal-order-main #items-panel').removeClass('show').addClass('hide'); |
1295 |
$("#modal-order-main #items-panel").removeClass("show").addClass("hide"); |
| 1277 |
} |
1296 |
} |
| 1278 |
} |
1297 |
} |
| 1279 |
if(row.invoice_currency && row.invoice_currency != active_currency) { |
1298 |
if (row.invoice_currency && row.invoice_currency != active_currency) { |
| 1280 |
$("#select_currency").show(); |
1299 |
$("#select_currency").show(); |
| 1281 |
$("#unitprice").prop("readonly", true); |
1300 |
$("#unitprice").prop("readonly", true); |
| 1282 |
$("#change_currency").prop('checked', true); |
1301 |
$("#change_currency").prop("checked", true); |
| 1283 |
$("#invoice_currency").val(row.invoice_currency); |
1302 |
$("#invoice_currency").val(row.invoice_currency); |
| 1284 |
$("#invoice_unitprice").val(row.invoice_unit_price); |
1303 |
$("#invoice_unitprice").val(row.invoice_unit_price); |
| 1285 |
} else { |
1304 |
} else { |
| 1286 |
$("#select_currency").hide(); |
1305 |
$("#select_currency").hide(); |
| 1287 |
$("#unitprice").prop("readonly", ""); |
1306 |
$("#unitprice").prop("readonly", ""); |
| 1288 |
$("#change_currency").prop('checked', false); |
1307 |
$("#change_currency").prop("checked", false); |
| 1289 |
$("#invoice_currency").val(active_currency); |
1308 |
$("#invoice_currency").val(active_currency); |
| 1290 |
$("#invoice_unitprice").val(''); |
1309 |
$("#invoice_unitprice").val(""); |
| 1291 |
} |
1310 |
} |
| 1292 |
|
1311 |
|
| 1293 |
disabledBudgetsCopy = $('#bookfund').html(); |
1312 |
disabledBudgetsCopy = $("#bookfund").html(); |
| 1294 |
$('#bookfund .inactive_budget').remove(); |
1313 |
$("#bookfund .inactive_budget").remove(); |
| 1295 |
|
1314 |
|
| 1296 |
$('#showallbudgets').click(function() { |
1315 |
$("#showallbudgets").click(function () { |
| 1297 |
if ($(this).is(":checked")) { |
1316 |
if ($(this).is(":checked")) { |
| 1298 |
$('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds |
1317 |
$("#bookfund").html(disabledBudgetsCopy); //Puts back all the funds |
| 1299 |
} |
1318 |
} else { |
| 1300 |
else { |
1319 |
$("#bookfund .inactive_budget").remove(); |
| 1301 |
$('#bookfund .inactive_budget').remove(); |
|
|
| 1302 |
} |
1320 |
} |
| 1303 |
}); |
1321 |
}); |
| 1304 |
set_modal_buttons(); |
1322 |
set_modal_buttons(); |
| 1305 |
}; |
1323 |
}; |
| 1306 |
|
1324 |
|
| 1307 |
$('.modal-prev').click(function() { |
1325 |
$(".modal-prev").click(function () { |
| 1308 |
var modal = $("#order_edit"); |
1326 |
var modal = $("#order_edit"); |
| 1309 |
keep_row(); |
1327 |
keep_row(); |
| 1310 |
var n = modal.data('n'); |
1328 |
var n = modal.data("n"); |
| 1311 |
if(n > 0) { |
1329 |
if (n > 0) { |
| 1312 |
n--; |
1330 |
n--; |
| 1313 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1331 |
modal.data("row", JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1314 |
modal.data('n', n); |
1332 |
modal.data("n", n); |
| 1315 |
set_editor(); |
1333 |
set_editor(); |
| 1316 |
} else { |
1334 |
} else { |
| 1317 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1335 |
$(".modal-next, .modal-prev").prop("disabled", true); |
| 1318 |
orders_table.one('draw.dt', function() { |
1336 |
orders_table.one("draw.dt", function () { |
| 1319 |
var info = api.page.info(); |
1337 |
var info = api.page.info(); |
| 1320 |
n = info.end - info.start - 1; |
1338 |
n = info.end - info.start - 1; |
| 1321 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1339 |
modal.data("row", JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1322 |
modal.data('n', n); |
1340 |
modal.data("n", n); |
| 1323 |
set_editor(); |
1341 |
set_editor(); |
| 1324 |
}); |
1342 |
}); |
| 1325 |
api.page('previous').draw( 'page' ); |
1343 |
api.page("previous").draw("page"); |
| 1326 |
} |
1344 |
} |
| 1327 |
}); |
1345 |
}); |
| 1328 |
|
1346 |
|
| 1329 |
$('.modal-next').click(function() { |
1347 |
$(".modal-next").click(function () { |
| 1330 |
var modal = $("#order_edit"); |
1348 |
var modal = $("#order_edit"); |
| 1331 |
keep_row(); |
1349 |
keep_row(); |
| 1332 |
var n = modal.data('n'); |
1350 |
var n = modal.data("n"); |
| 1333 |
var info = api.page.info(); |
1351 |
var info = api.page.info(); |
| 1334 |
if(n < info.end - info.start - 1) { |
1352 |
if (n < info.end - info.start - 1) { |
| 1335 |
n++; |
1353 |
n++; |
| 1336 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1354 |
modal.data("row", JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1337 |
modal.data('n', n); |
1355 |
modal.data("n", n); |
| 1338 |
set_editor(); |
1356 |
set_editor(); |
| 1339 |
} else { |
1357 |
} else { |
| 1340 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1358 |
$(".modal-next, .modal-prev").prop("disabled", true); |
| 1341 |
orders_table.one('draw.dt', function() { |
1359 |
orders_table.one("draw.dt", function () { |
| 1342 |
var info = api.page.info(); |
1360 |
var info = api.page.info(); |
| 1343 |
n = 0; |
1361 |
n = 0; |
| 1344 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1362 |
modal.data("row", JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1345 |
modal.data('n', n); |
1363 |
modal.data("n", n); |
| 1346 |
set_editor(); |
1364 |
set_editor(); |
| 1347 |
}); |
1365 |
}); |
| 1348 |
api.page('next').draw( 'page' ); |
1366 |
api.page("next").draw("page"); |
| 1349 |
} |
1367 |
} |
| 1350 |
}); |
1368 |
}); |
| 1351 |
|
1369 |
|
| 1352 |
$('.modal-save').click(function() { |
1370 |
$(".modal-save").click(function () { |
| 1353 |
|
|
|
| 1354 |
//We need to validate the item forms here - if one is opened with missing subfields at |
1371 |
//We need to validate the item forms here - if one is opened with missing subfields at |
| 1355 |
//confirm, it would be submitted without this |
1372 |
//confirm, it would be submitted without this |
| 1356 |
var _alertString= _("Form not submitted because of the following problem(s)")+"\n"; |
1373 |
var _alertString = _("Form not submitted because of the following problem(s)") + "\n"; |
| 1357 |
_alertString +="-------------------------------------------------------------------\n\n"; |
1374 |
_alertString += "-------------------------------------------------------------------\n\n"; |
| 1358 |
var empty_mandatory_fields = 0; |
1375 |
var empty_mandatory_fields = 0; |
| 1359 |
$('div[id^="itemblock"]').each(function(){ |
1376 |
$('div[id^="itemblock"]').each(function () { |
| 1360 |
var item_form = $(this); |
1377 |
var item_form = $(this); |
| 1361 |
var empty_item_mandatory = CheckMandatorySubfields(item_form); |
1378 |
var empty_item_mandatory = CheckMandatorySubfields(item_form); |
| 1362 |
empty_mandatory_fields += empty_item_mandatory; |
1379 |
empty_mandatory_fields += empty_item_mandatory; |
| 1363 |
}); |
1380 |
}); |
| 1364 |
if (empty_mandatory_fields > 0) { |
1381 |
if (empty_mandatory_fields > 0) { |
| 1365 |
_alertString +="\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields); |
1382 |
_alertString += "\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields); |
| 1366 |
alert(_alertString); |
1383 |
alert(_alertString); |
| 1367 |
return false; |
1384 |
return false; |
| 1368 |
} |
1385 |
} |
| 1369 |
|
1386 |
|
| 1370 |
var saved_rows = save_row(); |
1387 |
var saved_rows = save_row(); |
| 1371 |
if(Object.keys(saved_rows).length) $('.save').prop('disabled', false); |
1388 |
if (Object.keys(saved_rows).length) $(".save").prop("disabled", false); |
| 1372 |
$("#order_edit").modal('hide'); |
1389 |
$("#order_edit").modal("hide"); |
| 1373 |
if (only_one_order){ |
1390 |
if (only_one_order) { |
| 1374 |
$(".save").click(); |
1391 |
$(".save").click(); |
| 1375 |
} |
1392 |
} |
| 1376 |
}) |
1393 |
}); |
| 1377 |
|
1394 |
|
| 1378 |
$("#order_edit").on("show.bs.modal", function (event) { |
1395 |
$("#order_edit").on("show.bs.modal", function (event) { |
| 1379 |
var anchor = $(event.relatedTarget); |
1396 |
var anchor = $(event.relatedTarget); |
|
Lines 1381-1395
Link Here
|
| 1381 |
var row = api.row(n).data(); |
1398 |
var row = api.row(n).data(); |
| 1382 |
|
1399 |
|
| 1383 |
var modal = $(this); |
1400 |
var modal = $(this); |
| 1384 |
modal.data('row', JSON.parse(JSON.stringify(row))); |
1401 |
modal.data("row", JSON.parse(JSON.stringify(row))); |
| 1385 |
modal.data('n', n); |
1402 |
modal.data("n", n); |
| 1386 |
modal.data('keep', modal.data('saved')||{}); |
1403 |
modal.data("keep", modal.data("saved") || {}); |
| 1387 |
//$('#modal-order-main').tabs("option", "active", 0); |
1404 |
//$('#modal-order-main').tabs("option", "active", 0); |
| 1388 |
set_editor(); |
1405 |
set_editor(); |
| 1389 |
}); |
1406 |
}); |
| 1390 |
|
1407 |
|
| 1391 |
$("#order_edit").on("hide.bs.modal", function() { |
1408 |
$("#order_edit").on("hide.bs.modal", function () { |
| 1392 |
$("#child_orders_table").DataTable().off('preDraw').destroy(); |
1409 |
$("#child_orders_table").DataTable().off("preDraw").destroy(); |
| 1393 |
}); |
1410 |
}); |
| 1394 |
}); |
1411 |
}); |
| 1395 |
</script> |
1412 |
</script> |