|
Lines 33-39
Link Here
|
| 33 |
<a href="#" aria-current="page"> |
33 |
<a href="#" aria-current="page"> |
| 34 |
Receive items from : [% name | html %] [% IF ( invoice ) %] |
34 |
Receive items from : [% name | html %] [% IF ( invoice ) %] |
| 35 |
[[% invoice | html %]] |
35 |
[[% invoice | html %]] |
| 36 |
[% END %] (order #[% order.ordernumber | html %]) |
36 |
[% END %] (order #[% order.ordernumber || multiple_orders | html %]) |
| 37 |
</a> |
37 |
</a> |
| 38 |
</li> |
38 |
</li> |
| 39 |
</ol> |
39 |
</ol> |
|
Lines 42-54
Link Here
|
| 42 |
|
42 |
|
| 43 |
<div class="main container-fluid"> |
43 |
<div class="main container-fluid"> |
| 44 |
<div class="row"> |
44 |
<div class="row"> |
| 45 |
[% AcqCreateItem = order.basket.effective_create_items %] |
|
|
| 46 |
<div class="col-sm-10 col-sm-push-2"> |
45 |
<div class="col-sm-10 col-sm-push-2"> |
| 47 |
<main> |
46 |
<main> |
| 48 |
|
47 |
|
| 49 |
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber | html %])</h1> |
48 |
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber || multiple_orders | html %])</h1> |
| 50 |
|
49 |
|
| 51 |
[% IF ( order ) %] |
50 |
[% IF ( order ) %] |
|
|
51 |
[% AcqCreateItem = order.basket.effective_create_items %] |
| 52 |
<form id="f" action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);"> |
52 |
<form id="f" action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);"> |
| 53 |
<div class="row"> |
53 |
<div class="row"> |
| 54 |
<div class="col-sm-6"> |
54 |
<div class="col-sm-6"> |
|
Lines 459-464
Link Here
|
| 459 |
<input type="submit" value="Save" class="btn btn-primary" accesskey="w" /> |
459 |
<input type="submit" value="Save" class="btn btn-primary" accesskey="w" /> |
| 460 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a> |
460 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a> |
| 461 |
</fieldset></div> </form> |
461 |
</fieldset></div> </form> |
|
|
462 |
[% ELSIF multiple_orders %] |
| 463 |
<table id="multiple_orders" class="table table-bordered table-striped"> |
| 464 |
<thead> |
| 465 |
<tr> |
| 466 |
<th>Order</td> |
| 467 |
<th>Title</th> |
| 468 |
<th>Author</th> |
| 469 |
<th>ISBN</th> |
| 470 |
<th>Date received</th> |
| 471 |
<th>Fund</th> |
| 472 |
<th>Quantity</th> |
| 473 |
<th> </th> |
| 474 |
</tr> |
| 475 |
</thead> |
| 476 |
</table> |
| 477 |
|
| 478 |
<div class="col"> |
| 479 |
<div id="jobfailed" class="dialog alert"></div> |
| 480 |
<fieldset class="action"> |
| 481 |
<button class="save">Save</button> |
| 482 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Return</a> |
| 483 |
</fieldset> |
| 484 |
<div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> |
| 485 |
</div> |
| 486 |
|
| 487 |
<div class="modal fade" id="order_edit" tabindex="-1" role="dialog" aria-labelledby="Order edit"> |
| 488 |
<div class="modal-dialog" role="document"> |
| 489 |
<div class="modal-content modal-lg"> |
| 490 |
<div class="modal-header row"> |
| 491 |
<h4 class="col-md-11 modal-title"></h4> |
| 492 |
<button type="button" class="close col-md-1" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 493 |
</div> |
| 494 |
<div class="modal-body"> |
| 495 |
<div class="hide" id="loading">Loading ...</div> |
| 496 |
<div id="modal-order-main"> |
| 497 |
<ul> |
| 498 |
<li><a href="#info-panel">Info</a></li> |
| 499 |
<li><a href="#accounting-panel">Accounting</a></li> |
| 500 |
<li><a href="#history-panel">Receipt history</a></li> |
| 501 |
<li><a href="#items-panel">Items</a></li> |
| 502 |
</ul> |
| 503 |
|
| 504 |
|
| 505 |
<div id="info-panel"> |
| 506 |
<div> |
| 507 |
<h4>Catalog details</h4> |
| 508 |
|
| 509 |
<div class="row"> <span class="lbl col-sm-4">Title: </span><span class="col-sm-8" id="biblio_title"></span></div> |
| 510 |
<div class="row"> <span class="lbl col-sm-4">Author: </span><span class="col-sm-8" id="biblio_author"></span></div> |
| 511 |
<div class="row"> <span class="lbl col-sm-4">Copyright: </span><span class="col-sm-8" id="biblio_copyright_date"></span></div> |
| 512 |
<div class="row"> <span class="lbl col-sm-4">ISBN: </span><span class="col-sm-8" id="biblio_isbn"></span></div> |
| 513 |
<div class="row"> <span class="lbl col-sm-4">Series: </span><span class="col-sm-8" id="biblio_series_title"></span></div> |
| 514 |
|
| 515 |
</div> |
| 516 |
<div id="suggestion_fieldset"> |
| 517 |
<h4>Suggestion</h4> |
| 518 |
<div class="row"> |
| 519 |
<span class="lbl col-sm-4">Suggested by: </span> <span class="col-sm-8" id="biblio_suggestion_suggester"></span> |
| 520 |
</div> |
| 521 |
<div class="row" id="suggestion_reason"> |
| 522 |
<span class="lbl col-sm-4">Reason:</span> |
| 523 |
<div class="col-sm-8"> |
| 524 |
[% SET suggestion_reasons = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %] |
| 525 |
<select class="select-reason" id="reason" name="reason"> |
| 526 |
<option value=""> -- Choose a reason -- </option> |
| 527 |
[% FOREACH reason IN suggestion_reasons %] |
| 528 |
<option value="[% reason.lib | html %]">[% reason.lib | html %]</option> |
| 529 |
[% END %] |
| 530 |
<option value="other">Others...</option> |
| 531 |
</select> |
| 532 |
|
| 533 |
<span id="other_reason" name="other_reason"> |
| 534 |
<input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." /> |
| 535 |
<a href="#back">Cancel</a> |
| 536 |
</span> |
| 537 |
</div> |
| 538 |
</div> |
| 539 |
</div> |
| 540 |
</div> |
| 541 |
<div id="history-panel"> |
| 542 |
<div id="child_orders"> |
| 543 |
<h4>Receipt history for this subscription</h4> |
| 544 |
<table id="child_orders_table"> |
| 545 |
<thead> |
| 546 |
<tr> |
| 547 |
<th>Invoice</th> |
| 548 |
<th>Order number</th> |
| 549 |
<th>Creation date</th> |
| 550 |
<th>Receive date</th> |
| 551 |
<th>Quantity received</th> |
| 552 |
<th>Status</th> |
| 553 |
<th title="Actual cost tax exc. / Actual cost tax inc.">Spent</th> |
| 554 |
<th>Internal note</th> |
| 555 |
</tr> |
| 556 |
</thead> |
| 557 |
</table> |
| 558 |
</div> |
| 559 |
</div> |
| 560 |
<div id="items-panel"> |
| 561 |
<div id="acq-create-receiving"> |
| 562 |
<div id="items_list" style="display: none"> |
| 563 |
<h4>Items list</h4> |
| 564 |
<div style="width:100%;overflow:auto;"> |
| 565 |
<table> |
| 566 |
<thead> |
| 567 |
<tr> |
| 568 |
<th>Actions</th> |
| 569 |
<th>Barcode</th> |
| 570 |
<th>Home library</th> |
| 571 |
<th>Holding library</th> |
| 572 |
<th>Not for loan</th> |
| 573 |
<th>Restricted</th> |
| 574 |
<th>Location</th> |
| 575 |
<th>Call number</th> |
| 576 |
<th>Copy number</th> |
| 577 |
<th>Inventory number</th> |
| 578 |
<th>Collection</th> |
| 579 |
<th>Item type</th> |
| 580 |
<th>Materials</th> |
| 581 |
<th>Notes</th> |
| 582 |
</tr> |
| 583 |
</thead> |
| 584 |
<tbody> |
| 585 |
</tbody> |
| 586 |
</table> |
| 587 |
</div> |
| 588 |
</div> |
| 589 |
|
| 590 |
<div id="itemfieldset"> |
| 591 |
<h4>Item</h4> |
| 592 |
[% IF ( NoACQframework ) %] |
| 593 |
<p class="required"> |
| 594 |
No ACQ framework, using default. You should create a |
| 595 |
framework with code ACQ, the items framework would be |
| 596 |
used |
| 597 |
</p> |
| 598 |
[% END %] |
| 599 |
<div id="outeritemblock"></div> |
| 600 |
</div> |
| 601 |
</div> |
| 602 |
<div id="acq-create-ordering"> |
| 603 |
<h4>Items</h4> |
| 604 |
<div style="width:100%;overflow:auto"> |
| 605 |
<table> |
| 606 |
<thead> |
| 607 |
<tr> |
| 608 |
<th>Receive?</th> |
| 609 |
<th> </th> |
| 610 |
<th>Barcode</th> |
| 611 |
<th>Home library</th> |
| 612 |
<th>Current library</th> |
| 613 |
<th>Not for loan</th> |
| 614 |
<th>Restricted</th> |
| 615 |
<th>Location</th> |
| 616 |
<th>Call number</th> |
| 617 |
<th>Copy number</th> |
| 618 |
<th>Inventory number</th> |
| 619 |
<th>Collection</th> |
| 620 |
<th>Item type</th> |
| 621 |
<th>Materials</th> |
| 622 |
<th>Notes</th> |
| 623 |
</tr> |
| 624 |
</thead> |
| 625 |
<tbody> |
| 626 |
</tbody> |
| 627 |
</table> |
| 628 |
</div> |
| 629 |
</div> |
| 630 |
</div> |
| 631 |
<div id="accounting-panel"> |
| 632 |
<h4>Accounting details</h4> |
| 633 |
<ol> |
| 634 |
<li> |
| 635 |
<label for="datereceived">Date received: </label> |
| 636 |
<input type="text" size="10" id="datereceived" name="datereceived" class="datepicker" /> |
| 637 |
</li> |
| 638 |
<li> |
| 639 |
<label for="bookfund">Fund: </label> |
| 640 |
<select id="bookfund" name="bookfund"> |
| 641 |
<option value=""></option> |
| 642 |
[% FOREACH period IN budget_loop %] |
| 643 |
<optgroup label="[% period.description | html %]"> |
| 644 |
[% FOREACH fund IN period.funds %] |
| 645 |
<option value="[% fund.b_id | html %]">[% fund.b_txt | html %]</option> |
| 646 |
[% END %] |
| 647 |
</optgroup> |
| 648 |
[% END %] |
| 649 |
</select> |
| 650 |
</li> |
| 651 |
<li> |
| 652 |
<label> </label> |
| 653 |
<span id="current-fund"></span> |
| 654 |
</li> |
| 655 |
<li> |
| 656 |
<label for="creator">Ordered by: </label> |
| 657 |
<span id="creator"></span> |
| 658 |
</li> |
| 659 |
<li> |
| 660 |
<label for="quantity_to_receive">Quantity ordered: </label> |
| 661 |
<input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" /> |
| 662 |
</li> |
| 663 |
<li> |
| 664 |
<label for="quantity">Quantity received: </label> |
| 665 |
<input type="text" size="20" name="quantityrec" id="quantity" /> |
| 666 |
<div id="qtyrecerror" style="display:none"> |
| 667 |
<p class="error">Warning, you have entered more items than expected. |
| 668 |
Items will not be created.</p> |
| 669 |
</div> |
| 670 |
</li> |
| 671 |
|
| 672 |
[% IF ( gst_values ) %] |
| 673 |
<li> |
| 674 |
<label for="tax_rate">Tax rate: </label> |
| 675 |
<select name="tax_rate" id="tax_rate"> |
| 676 |
[% FOREACH gst IN gst_values %] |
| 677 |
<option value="[% gst.option | html %]">[% gst.option * 100 | html %]%</option> |
| 678 |
[% END %] |
| 679 |
</select> |
| 680 |
</li> |
| 681 |
[% END %] |
| 682 |
|
| 683 |
<li> |
| 684 |
<label for="rrp">Retail price: </label> |
| 685 |
<span id="rrp"></span> |
| 686 |
<li> |
| 687 |
<label for="replacementprice">Replacement price:</label> |
| 688 |
<input type="text" size="20" name="replacementprice" id="replacementprice" /> |
| 689 |
</li> |
| 690 |
<li> |
| 691 |
<label for="ecost">Budgeted cost: </label> |
| 692 |
<span id="ecost"></span> |
| 693 |
</li> |
| 694 |
<li> |
| 695 |
<label for="unitprice">Actual cost:</label> |
| 696 |
<input type="text" size="20" name="unitprice" id="unitprice" /> |
| 697 |
<span id="unitprice_hint" class="hint"></span> |
| 698 |
<label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> |
| 699 |
</li> |
| 700 |
<li id="select_currency"> |
| 701 |
<label for="unitprice_currency"></label> |
| 702 |
<input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" /> |
| 703 |
[% IF currencies.count %] |
| 704 |
<select name="currency"> |
| 705 |
<option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> |
| 706 |
[% FOR currency IN currencies %] |
| 707 |
<option value="[% currency.rate | html %]">[% currency.currency | html %] ([% currency.symbol | html %])</option> |
| 708 |
[% END %] |
| 709 |
</select> |
| 710 |
[% END %] |
| 711 |
</li> |
| 712 |
<li> |
| 713 |
<label for="order_internalnote">Internal note: </label> |
| 714 |
<textarea name="order_internalnote" id="order_internalnote" width="40" rows="8" ></textarea> |
| 715 |
</li> |
| 716 |
<li> |
| 717 |
<label for="order_vendornote">Vendor note: </label> |
| 718 |
<span id="order_vendornote"></span> |
| 719 |
</li> |
| 720 |
</ol> |
| 721 |
</div> |
| 722 |
</div> |
| 723 |
</div> |
| 724 |
<div class="modal-footer"> |
| 725 |
<button type="button" class="btn btn-defualt modal-prev">Previous</button> |
| 726 |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
| 727 |
<button type="button" class="btn btn-primary modal-save">Save changes</button> |
| 728 |
<button type="button" class="btn btn-defualt modal-next">Next</button> |
| 729 |
</div> |
| 730 |
</div> |
| 731 |
</div> |
| 732 |
</div> |
| 462 |
[% ELSE %] |
733 |
[% ELSE %] |
| 463 |
This ordernumber does not exist. |
734 |
This ordernumber does not exist. |
| 464 |
[% END %] |
735 |
[% END %] |
|
Lines 474-484
Link Here
|
| 474 |
</div> <!-- /.row --> |
745 |
</div> <!-- /.row --> |
| 475 |
[% MACRO jsinclude BLOCK %] |
746 |
[% MACRO jsinclude BLOCK %] |
| 476 |
[% Asset.js("js/acquisitions-menu.js") | $raw %] |
747 |
[% Asset.js("js/acquisitions-menu.js") | $raw %] |
| 477 |
[% INCLUDE 'calendar.inc' %] |
748 |
[% INCLUDE 'calendar.inc' %] |
| 478 |
[% Asset.js("js/additem.js") | $raw %] |
749 |
[% Asset.js("js/additem.js") | $raw %] |
| 479 |
[% Asset.js("js/cataloging.js") | $raw %] |
750 |
[% Asset.js("js/cataloging.js") | $raw %] |
| 480 |
[% INCLUDE 'select2.inc' %] |
751 |
[% INCLUDE 'select2.inc' %] |
|
|
752 |
[% INCLUDE 'datatables.inc' %] |
| 753 |
[% INCLUDE 'js-date-format.inc' %] |
| 754 |
[% INCLUDE 'format_price.inc' %] |
| 755 |
[% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %] |
| 756 |
<style> |
| 757 |
.lbl { |
| 758 |
font-weight: 700; |
| 759 |
text-align: right; |
| 760 |
} |
| 761 |
.modal-body ol { |
| 762 |
list-style-type: none; |
| 763 |
} |
| 764 |
|
| 765 |
.modal-body ol li { |
| 766 |
list-style-type: none; |
| 767 |
padding-bottom: 1em; |
| 768 |
width: 100%; |
| 769 |
} |
| 770 |
|
| 771 |
.modal-body h4 { |
| 772 |
margin-left: 1em; |
| 773 |
padding: .2em .5em; |
| 774 |
margin-bottom: 17px; |
| 775 |
} |
| 776 |
|
| 777 |
.modal-body label { |
| 778 |
margin-right: 1em; |
| 779 |
text-align: right; |
| 780 |
width: 11em; |
| 781 |
display: inline-block; |
| 782 |
font-weight: 700; |
| 783 |
} |
| 784 |
|
| 785 |
.modal-body textarea { |
| 786 |
vertical-align: text-top; |
| 787 |
} |
| 788 |
</style> |
| 481 |
<script> |
789 |
<script> |
|
|
790 |
[% IF order %] |
| 482 |
function Check(form) { |
791 |
function Check(form) { |
| 483 |
[% IF (AcqCreateItem == 'receiving') %] |
792 |
[% IF (AcqCreateItem == 'receiving') %] |
| 484 |
var total_errors = CheckMandatorySubfields(form); |
793 |
var total_errors = CheckMandatorySubfields(form); |
|
Lines 651-656
Link Here
|
| 651 |
}); |
960 |
}); |
| 652 |
|
961 |
|
| 653 |
}); |
962 |
}); |
|
|
963 |
[% ELSIF multiple_orders %] |
| 964 |
|
| 965 |
var _build_item = function(item, tr) { |
| 966 |
var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />') |
| 967 |
.prop('checked', item._checked) |
| 968 |
.change(function() { |
| 969 |
item._checked = $(this).prop('checked'); |
| 970 |
}); |
| 971 |
tr.append($('<td style="text-align:center"></td>').append(chb)); |
| 972 |
tr.append('<td><a style="cursor:pointer" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>'); |
| 973 |
tr.append('<td>'+(item.external_id||'')+'</td>'); |
| 974 |
tr.append('<td>'+(item.home_branch && item.home_branch.name||'')+'</td>'); |
| 975 |
tr.append('<td>'+(item.holding_branch && item.holding_branch.name||'')+'</td>'); |
| 976 |
tr.append('<td>'+(item._authorised_values.not_for_loan_status && item._authorised_values.not_for_loan_status.lib||'')+'</td>'); |
| 977 |
tr.append('<td>'+(item._authorised_values.restricted_status && item._authorised_values.restricted_status.lib||'')+'</td>'); |
| 978 |
tr.append('<td><span class="shelvingloc">'+(item._authorised_values.location && item._authorised_values.location.lib||'')+'</span></td>'); |
| 979 |
tr.append('<td>'+(item.callnumber||'')+'</td>'); |
| 980 |
tr.append('<td>'+(item.copy_number||'')+'</td>'); |
| 981 |
tr.append('<td>'+(item.inventory_number||'')+'</td>'); |
| 982 |
tr.append('<td>'+(item._authorised_values.collection_code && item._authorised_values.collection_code.lib||'')+'</td>'); |
| 983 |
tr.append('<td>'+(item.itemtype && item.itemtype.description || '')+'</td>'); |
| 984 |
tr.append('<td>'+(item._authorised_values.materials_notes && item._authorised_values.materials_notes.lib||'')+'</td>') |
| 985 |
tr.append('<td>'+(item.public_notes||'')+'</td>'); |
| 986 |
}; |
| 987 |
|
| 988 |
var items_columns = [null, null, 'external_id', 'home_library_id', |
| 989 |
'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location', |
| 990 |
'callnumber', 'copy_number', 'inventory_number', 'collection_code', |
| 991 |
'item_type', 'materials_notes', 'public_notes']; |
| 992 |
|
| 993 |
function PopupEditPage(biblionumber, itemnumber) { |
| 994 |
var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" |
| 995 |
+ biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; |
| 996 |
var w = window.open(url); |
| 997 |
var watchClose = setInterval(function() { |
| 998 |
if (w.closed) { |
| 999 |
clearTimeout(watchClose); |
| 1000 |
$.ajax({ |
| 1001 |
dataType: "json", |
| 1002 |
headers: { |
| 1003 |
"x-koha-embed": "home_branch,holding_branch,itemtype", |
| 1004 |
"x-koha-av": "1" |
| 1005 |
}, |
| 1006 |
url: '/api/v1/items/'+itemnumber, |
| 1007 |
success: function(item) { |
| 1008 |
var tr = $("#item_"+itemnumber); |
| 1009 |
tr.html(''); |
| 1010 |
_build_item(item, tr); |
| 1011 |
} |
| 1012 |
}); |
| 1013 |
} |
| 1014 |
}, 500); |
| 1015 |
} |
| 1016 |
|
| 1017 |
var periods={}; |
| 1018 |
var funds={}; |
| 1019 |
var funds_tree = []; |
| 1020 |
|
| 1021 |
var QTY_TOTAL = _("Receiving %0$s out of %1$s"); |
| 1022 |
var EDIT = _("edit"); |
| 1023 |
var MOD_TITLE = _("Edit %s"); |
| 1024 |
var SUGGESTION = _("suggestion #%s"); |
| 1025 |
var FUND_KEEP = _("Keep current (%0$s - %1$s)"); |
| 1026 |
var FUNC_CUR = _("(Current: %0$s - %1$s)"); |
| 1027 |
var ADJ_TAX_INC = _("(adjusted for %s, tax inclusive)"); |
| 1028 |
var ADJ_TAX_EXC = _("(adjusted for %s, tax exclusive)"); |
| 1029 |
var TAX_INC = _("(tax inclusive)"); |
| 1030 |
var TAX_EXC = _("(tax exclusive)"); |
| 1031 |
var SAVE_WARNING = _("Order %s: Warning, you have entered more items than expected. Items will not be created."); |
| 1032 |
var SAVE_WARNING_NO_ITEMS = _("Order %s: No quantity to receive set. No items will be created."); |
| 1033 |
var SAVE_ERROR = _("Order %s: An error occurred while saving"); |
| 1034 |
|
| 1035 |
|
| 1036 |
var CAN_user_acquisition = "[% CAN_user_acquisition | html %]"; |
| 1037 |
var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]"; |
| 1038 |
var edit_mode = "[% edit | html %]"; |
| 1039 |
var invoiceincgst = "[% invoiceincgst | html %]"; |
| 1040 |
var active_currency = "[% active_currency.currency | html %]"; |
| 1041 |
var invoice_id = "[% invoiceid | html %]"; |
| 1042 |
|
| 1043 |
$(document).ready(function(){ |
| 1044 |
var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}}; |
| 1045 |
var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; |
| 1046 |
var options = { |
| 1047 |
"ajax": { |
| 1048 |
"url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)), |
| 1049 |
"headers": { |
| 1050 |
'x-koha-av': '1' |
| 1051 |
} |
| 1052 |
}, |
| 1053 |
"header_filter": true, |
| 1054 |
"embed": [ |
| 1055 |
"basket", |
| 1056 |
"biblio.suggestions.suggester", |
| 1057 |
"fund.budget", |
| 1058 |
"items.home_branch", |
| 1059 |
"items.holding_branch", |
| 1060 |
"items.itemtype", |
| 1061 |
"creator" |
| 1062 |
], |
| 1063 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
| 1064 |
"columns": [ |
| 1065 |
{ |
| 1066 |
"data": "order_id", |
| 1067 |
"searchable": true, |
| 1068 |
"orderable": true |
| 1069 |
}, |
| 1070 |
{ |
| 1071 |
"data": "biblio.title", |
| 1072 |
"searchable": true, |
| 1073 |
"orderable": true, |
| 1074 |
"render": function(data, type, row, meta) { |
| 1075 |
if ( data == null ) { |
| 1076 |
return ""; |
| 1077 |
} |
| 1078 |
else { |
| 1079 |
return data; |
| 1080 |
} |
| 1081 |
} |
| 1082 |
}, |
| 1083 |
{ |
| 1084 |
"data": "biblio.author", |
| 1085 |
"searchable": true, |
| 1086 |
"orderable": true, |
| 1087 |
"render": function(data, type, row, meta) { |
| 1088 |
if ( data == null ) { |
| 1089 |
return ""; |
| 1090 |
} |
| 1091 |
else { |
| 1092 |
return data; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
}, |
| 1096 |
{ |
| 1097 |
"data": "biblio.isbn", |
| 1098 |
"searchable": true, |
| 1099 |
"orderable": true, |
| 1100 |
"render": function(data, type, row, meta) { |
| 1101 |
if ( data == null ) { |
| 1102 |
return ""; |
| 1103 |
} |
| 1104 |
else { |
| 1105 |
return data; |
| 1106 |
} |
| 1107 |
} |
| 1108 |
}, |
| 1109 |
{ |
| 1110 |
"searchable": false, |
| 1111 |
"orderable": false, |
| 1112 |
"data": function(row, type, val, meta) { |
| 1113 |
return $date(row.date_received||new Date().toISOString()); |
| 1114 |
} |
| 1115 |
}, |
| 1116 |
{ |
| 1117 |
"data": "fund.name", |
| 1118 |
"searchable": true, |
| 1119 |
"orderable": false, |
| 1120 |
"render": function(data, type, row, meta) { |
| 1121 |
return row.fund.budget.budget_period_description+" - "+row.fund.name; |
| 1122 |
} |
| 1123 |
}, |
| 1124 |
{ |
| 1125 |
"searchable": false, |
| 1126 |
"orderable": true, |
| 1127 |
"data": "quantity_received", |
| 1128 |
"render": function(data, type, row, meta) { |
| 1129 |
var data = $("#order_edit").data(); |
| 1130 |
return QTY_TOTAL.format(row.subscription_id&&(!data.saved||!data.saved.hasOwnProperty(row.order_id))?row.quantity:row.quantity_received, row.quantity); |
| 1131 |
} |
| 1132 |
}, |
| 1133 |
{ |
| 1134 |
"searchable": false, |
| 1135 |
"orderable": false, |
| 1136 |
"render": function(data, type, row, meta) { |
| 1137 |
return '<a data-toggle="modal" href="#order_edit" data-row="'+meta.row+'" class="order_edit_toggle">'+EDIT+'</a>'; |
| 1138 |
} |
| 1139 |
} |
| 1140 |
] |
| 1141 |
}; |
| 1142 |
var orders_table = $("#multiple_orders").kohaTable(options); |
| 1143 |
var api = orders_table.api(); |
| 1144 |
|
| 1145 |
api.on('preDraw', function() { |
| 1146 |
var saved = $("#order_edit").data('saved'); |
| 1147 |
if(saved) { |
| 1148 |
var data = api.data(); |
| 1149 |
for(var i = 0; i<data.length; i++) { |
| 1150 |
var row = data[i]; |
| 1151 |
var srow = saved[row.order_id]; |
| 1152 |
if(srow) { |
| 1153 |
if(row.fund_id != srow.fund_id) { |
| 1154 |
row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label'); |
| 1155 |
row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html(); |
| 1156 |
} |
| 1157 |
row.date_received = srow.date_received; |
| 1158 |
row.quantity = srow.quantity; |
| 1159 |
row.quantity_received = srow.quantity_received; |
| 1160 |
} |
| 1161 |
} |
| 1162 |
} |
| 1163 |
}); |
| 1164 |
|
| 1165 |
var _doSave = function(params) { |
| 1166 |
$.ajax($.extend({ |
| 1167 |
method: 'POST', |
| 1168 |
url: '/cgi-bin/koha/acqui/finishreceive.pl' |
| 1169 |
}, params)); |
| 1170 |
}; |
| 1171 |
|
| 1172 |
var _set_error = function(error) { |
| 1173 |
if($('#jobfailed').html() == '') $('#jobfailed').append('<ul/>'); |
| 1174 |
$('#jobfailed').show(); |
| 1175 |
$('#jobfailed ul').append('<li>'+error+'</li>'); |
| 1176 |
}; |
| 1177 |
|
| 1178 |
var _transform_row = function(row, origrec) { |
| 1179 |
var params = {}; |
| 1180 |
params['biblionumber'] = row.biblio_id; |
| 1181 |
params['invoiceid'] = invoice_id; |
| 1182 |
params['ordernumber'] = row.order_id; |
| 1183 |
params['booksellerid'] = row.basket.vendor_id; |
| 1184 |
|
| 1185 |
if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { |
| 1186 |
params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; |
| 1187 |
if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { |
| 1188 |
params['reason'] = row.biblio.suggestions[0].reason; |
| 1189 |
} else { |
| 1190 |
params['reason'] = 'other'; |
| 1191 |
params['other_reason'] = row.biblio.suggestions[0].reason; |
| 1192 |
} |
| 1193 |
} |
| 1194 |
params['datereceived'] = row.date_received; |
| 1195 |
params['bookfund'] = row.fund_id; |
| 1196 |
params['quantity'] = row.quantity; |
| 1197 |
params['quantityrec'] = row.quantity_received; |
| 1198 |
params['origquantityrec'] = origrec; |
| 1199 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
| 1200 |
params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering; |
| 1201 |
params['replacementprice'] = row.replacement_price; |
| 1202 |
params['unitprice'] = invoiceincgst=="1"?row.unit_price_tax_included:row.unit_price_tax_excluded; |
| 1203 |
params['order_internalnote'] = row.internal_note; |
| 1204 |
if(effective_create_items == 'receiving') { |
| 1205 |
Object.keys(row.items).forEach(function(key) { |
| 1206 |
var item = row.items[key]; |
| 1207 |
Object.keys(item).forEach(function(key) { |
| 1208 |
var field = item[key]; |
| 1209 |
Object.keys(field).forEach(function(key) { |
| 1210 |
if(!params[key]) params[key] = []; |
| 1211 |
params[key].push(item[key]); |
| 1212 |
}); |
| 1213 |
}); |
| 1214 |
}); |
| 1215 |
} else if(effective_create_items == 'ordering') { |
| 1216 |
params['items_to_receive'] = (row.items||[]) |
| 1217 |
.filter(function(item) { |
| 1218 |
return item._checked |
| 1219 |
}) |
| 1220 |
.map(function(item) { |
| 1221 |
item.item_id; |
| 1222 |
}) |
| 1223 |
} |
| 1224 |
return params; |
| 1225 |
}; |
| 1226 |
|
| 1227 |
$('.save').click(function() { |
| 1228 |
var data = $("#order_edit").data(); |
| 1229 |
var rows = api.rows().data(); |
| 1230 |
$('this').prop('disabled', true); |
| 1231 |
var redirect = true; |
| 1232 |
if(rows.length) { |
| 1233 |
$('#jobpanel, #jobstatus').show(); |
| 1234 |
|
| 1235 |
var loopRows = function(i) { |
| 1236 |
var row = rows[i]; |
| 1237 |
if(!row) { |
| 1238 |
if(redirect) { |
| 1239 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id |
| 1240 |
} |
| 1241 |
return; |
| 1242 |
} |
| 1243 |
if(data.saved && data.saved[row.order_id]) { |
| 1244 |
row = data.saved[row.order_id]; |
| 1245 |
var origrec = data.origrec[row.order_id]; |
| 1246 |
} else { |
| 1247 |
var origrec = row.quantity_received; |
| 1248 |
} |
| 1249 |
var _set_percentage = function() { |
| 1250 |
var percentage = Math.round(( (i+1) / rows.length) * 100); |
| 1251 |
var bgproperty = (parseInt(percentage*2)-300)+"px 0px"; |
| 1252 |
$("#jobprogress").css("background-position",bgproperty); |
| 1253 |
$("#jobprogresspercent").text(percentage); |
| 1254 |
} |
| 1255 |
if(row.quantity_received > row.quantity) { |
| 1256 |
redirect = false; |
| 1257 |
_set_error(SAVE_WARNING.format(row.order_id)); |
| 1258 |
row.quantity_received = row.quantity; |
| 1259 |
} |
| 1260 |
if(row.quantity_received == '0') { |
| 1261 |
redirect = false; |
| 1262 |
_set_error(SAVE_WARNING_NO_ITEMS.format(row.order_id)); |
| 1263 |
} |
| 1264 |
_doSave({ |
| 1265 |
data: _transform_row(row, origrec), |
| 1266 |
success: function() { |
| 1267 |
_set_percentage(); |
| 1268 |
loopRows(i+1); |
| 1269 |
}, |
| 1270 |
error: function() { |
| 1271 |
_set_percentage() |
| 1272 |
_set_error(SAVE_ERROR.format(row.order_id)); |
| 1273 |
redirect = false; |
| 1274 |
loopRows(i+1); |
| 1275 |
} |
| 1276 |
}); |
| 1277 |
}; |
| 1278 |
loopRows(0) |
| 1279 |
} |
| 1280 |
}); |
| 1281 |
|
| 1282 |
$("#order_edit").on("change", "#reason", function() { |
| 1283 |
var val = $(this).val(); |
| 1284 |
var row = $("#order_edit").data('row'); |
| 1285 |
if(val == 'other') { |
| 1286 |
$("#other_reason").show(); |
| 1287 |
$(this).hide(); |
| 1288 |
} else { |
| 1289 |
row.biblio.suggestions[0].reason = val; |
| 1290 |
} |
| 1291 |
}); |
| 1292 |
|
| 1293 |
$("#order_edit").on("change", "#select-other_reason", function() { |
| 1294 |
var val = $(this).val(); |
| 1295 |
var row = $("#order_edit").data('row'); |
| 1296 |
row.biblio.suggestions[0].reason = val; |
| 1297 |
}); |
| 1298 |
|
| 1299 |
$("#order_edit").on("click", "#other_reason a", function() { |
| 1300 |
$("#other_reason").hide(); |
| 1301 |
$("#reason").val(null).show(); |
| 1302 |
}); |
| 1303 |
|
| 1304 |
$("#order_edit").on("change", "#datereceived", function() { |
| 1305 |
var val = $(this).val(); |
| 1306 |
var row = $("#order_edit").data('row'); |
| 1307 |
row.date_received = val; |
| 1308 |
}); |
| 1309 |
|
| 1310 |
$("#order_edit").on("change", "#bookfund", function() { |
| 1311 |
var val = $(this).val(); |
| 1312 |
var row = $("#order_edit").data('row'); |
| 1313 |
row.fund_id = val; |
| 1314 |
}); |
| 1315 |
|
| 1316 |
$("#order_edit").on("change", "#quantity_to_receive", function() { |
| 1317 |
var val = $(this).val(); |
| 1318 |
var row = $("#order_edit").data('row'); |
| 1319 |
row.quantity = val; |
| 1320 |
if(row.subscription_id) { |
| 1321 |
$("#quantity").val(val).change(); |
| 1322 |
} |
| 1323 |
}); |
| 1324 |
|
| 1325 |
$("#order_edit").on("change", "#quantity", function() { |
| 1326 |
var val = $(this).val(); |
| 1327 |
var row = $("#order_edit").data('row'); |
| 1328 |
row.quantity_received = val; |
| 1329 |
var qtyto = parseInt($("#quantity_to_receive").val()); |
| 1330 |
if(parseInt(val) > qtyto) { |
| 1331 |
$("#qtyrecerror").show(); |
| 1332 |
} else { |
| 1333 |
$("#qtyrecerror").hide(); |
| 1334 |
} |
| 1335 |
$("input[name='items_to_receive']").each(function() { |
| 1336 |
$(this).prop('checked', false).change(); |
| 1337 |
}); |
| 1338 |
$("input[name='items_to_receive']:lt("+val+")").each(function () { |
| 1339 |
$(this).prop('checked', true).change(); |
| 1340 |
}); |
| 1341 |
}); |
| 1342 |
|
| 1343 |
$("#order_edit").on("change", "input[name='items_to_receive']", function() { |
| 1344 |
var qty = $("input[name='items_to_receive']:checked").length; |
| 1345 |
$("#quantity").val(qty); |
| 1346 |
var row = $("#order_edit").data('row'); |
| 1347 |
row.quantity_received = qty; |
| 1348 |
}) |
| 1349 |
|
| 1350 |
$("#order_edit").on("change", "#tax_rate", function() { |
| 1351 |
var val = $(this).val(); |
| 1352 |
if(val === null) $(this).val($('option:first-child', this).attr('value')); |
| 1353 |
val = $(this).val(); |
| 1354 |
var row = $("#order_edit").data('row'); |
| 1355 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
| 1356 |
if(effective_create_items == 'receiving') { |
| 1357 |
row.tax_rate_on_receiving = val; |
| 1358 |
} else { |
| 1359 |
row.tax_rate_on_ordering = val; |
| 1360 |
} |
| 1361 |
|
| 1362 |
}); |
| 1363 |
|
| 1364 |
$("#order_edit").on("change", "#unitprice", function() { |
| 1365 |
var val = $(this).val(); |
| 1366 |
var row = $("#order_edit").data('row'); |
| 1367 |
if(invoiceincgst == "1") { |
| 1368 |
row.unit_price_tax_included = val; |
| 1369 |
} else { |
| 1370 |
row.unit_price_tax_excluded = val; |
| 1371 |
} |
| 1372 |
|
| 1373 |
}); |
| 1374 |
|
| 1375 |
$("#order_edit").on("change", "input[name='change_currency']", function(){ |
| 1376 |
if ( $(this).is(":checked") ) { |
| 1377 |
$("#select_currency").show(); |
| 1378 |
$("#unitprice").prop("readonly", "true"); |
| 1379 |
} else { |
| 1380 |
$("#select_currency").hide(); |
| 1381 |
$("#unitprice").prop("readonly", ""); |
| 1382 |
} |
| 1383 |
}); |
| 1384 |
|
| 1385 |
function _update_unitprice() { |
| 1386 |
var rate = Number($("select[name='currency'] option:selected").val()); |
| 1387 |
var unitprice = $("#unitprice_currency").val(); |
| 1388 |
var new_unitprice = Number( unitprice * rate ).toFixed(2); |
| 1389 |
$("#unitprice").val(new_unitprice).change(); |
| 1390 |
} |
| 1391 |
$("#order_edit").on("change", "select[name='currency']", _update_unitprice ); |
| 1392 |
$("#order_edit").on("change", "#unitprice_currency", _update_unitprice ); |
| 1393 |
|
| 1394 |
$("#order_edit").on("change", "#replacementprice", function() { |
| 1395 |
var val = $(this).val(); |
| 1396 |
var row = $("#order_edit").data('row'); |
| 1397 |
row.replacement_price = val; |
| 1398 |
}); |
| 1399 |
|
| 1400 |
$("#order_edit").on("change", "#order_internalnote", function() { |
| 1401 |
var val = $(this).val(); |
| 1402 |
var row = $("#order_edit").data('row'); |
| 1403 |
row.internal_note = val; |
| 1404 |
|
| 1405 |
}); |
| 1406 |
|
| 1407 |
var keep_row = function() { |
| 1408 |
var row = $("#order_edit").data('row'); |
| 1409 |
var kept = $("#order_edit").data('kept')||{}; |
| 1410 |
if($('#items_list tbody tr').length) { |
| 1411 |
row.items = []; |
| 1412 |
$('#items_list tbody tr').each(function() { |
| 1413 |
var item = {}; |
| 1414 |
$('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() { |
| 1415 |
var kf = $(this).val(); |
| 1416 |
var obj = {}; |
| 1417 |
$(this).parent().find('*[name]').each(function() { |
| 1418 |
obj[$(this).prop('name')] = $(this).val(); |
| 1419 |
}); |
| 1420 |
item[kf] = obj; |
| 1421 |
}); |
| 1422 |
row.items.push(item); |
| 1423 |
}); |
| 1424 |
} |
| 1425 |
kept[row.order_id] = row; |
| 1426 |
$("#order_edit").data('kept', kept); |
| 1427 |
}; |
| 1428 |
|
| 1429 |
var save_row = function() { |
| 1430 |
keep_row(); |
| 1431 |
var saved = $("#order_edit").data('saved')||{}; |
| 1432 |
var kept = $("#order_edit").data('kept'); |
| 1433 |
$("#order_edit").data('saved', $.extend(saved, kept)); |
| 1434 |
api.draw(); |
| 1435 |
} |
| 1436 |
|
| 1437 |
var set_modal_buttons = function() { |
| 1438 |
var n = $("#order_edit").data('n'); |
| 1439 |
var info = api.page.info(); |
| 1440 |
|
| 1441 |
$('.modal-prev').prop('disabled', info.page == 0 && n == 0); |
| 1442 |
$('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n); |
| 1443 |
}; |
| 1444 |
|
| 1445 |
var show_subs = function(row) { |
| 1446 |
//$("#child_orders").show(); |
| 1447 |
var had_rows = false; |
| 1448 |
var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}}; |
| 1449 |
var pending_orders_url = "/api/v1/acquisitions/orders"; |
| 1450 |
var options = { |
| 1451 |
"ajax": { |
| 1452 |
"url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)) |
| 1453 |
}, |
| 1454 |
"header_filter": true, |
| 1455 |
"embed": [ |
| 1456 |
"invoice", |
| 1457 |
"basket" |
| 1458 |
], |
| 1459 |
"order": [[1, 'asc']], |
| 1460 |
'dom': 'C<"top pager"ilpfB>tr<"bottom pager"ip>', |
| 1461 |
"columns": [ |
| 1462 |
{ |
| 1463 |
"searchable": false, |
| 1464 |
"orderable": false, |
| 1465 |
"data": function(row, type, val, meta) { |
| 1466 |
if(row.invoice) { |
| 1467 |
if(CAN_user_acquisition) { |
| 1468 |
return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; |
| 1469 |
} |
| 1470 |
return row.invoice.invoice_number; |
| 1471 |
} |
| 1472 |
} |
| 1473 |
}, |
| 1474 |
{ |
| 1475 |
"data": "order_id", |
| 1476 |
"searchable": false, |
| 1477 |
"orderable": false |
| 1478 |
}, |
| 1479 |
{ |
| 1480 |
"searchable": false, |
| 1481 |
"orderable": false, |
| 1482 |
"data": "basket.creation_date", |
| 1483 |
"render": function(data, type, row, meta) { |
| 1484 |
return $date(row.basket.creation_date); |
| 1485 |
} |
| 1486 |
}, |
| 1487 |
{ |
| 1488 |
"searchable": false, |
| 1489 |
"orderable": false, |
| 1490 |
"data": function(row, type, val, meta) { |
| 1491 |
return $date(row.date_received); |
| 1492 |
} |
| 1493 |
}, |
| 1494 |
{ |
| 1495 |
"searchable": false, |
| 1496 |
"orderable": false, |
| 1497 |
"data": function(row, type, val, meta) { |
| 1498 |
return row.quantity_received; |
| 1499 |
} |
| 1500 |
}, |
| 1501 |
{ |
| 1502 |
"searchable": false, |
| 1503 |
"orderable": true, |
| 1504 |
"data": function(row, type, val, meta) { |
| 1505 |
if(!row.status) return; |
| 1506 |
var first_letter = row.status[0].toUpperCase(); |
| 1507 |
return first_letter+row.status.substr(1).toLowerCase(); |
| 1508 |
} |
| 1509 |
}, |
| 1510 |
{ |
| 1511 |
"searchable": false, |
| 1512 |
"orderable": false, |
| 1513 |
"data": function(row, type, val, meta) { |
| 1514 |
if(!row.date_received) return; |
| 1515 |
return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price() |
| 1516 |
} |
| 1517 |
}, |
| 1518 |
{ |
| 1519 |
"searchable": false, |
| 1520 |
"orderable": false, |
| 1521 |
"data": function(row, type, val, meta) { |
| 1522 |
return row.internal_note; |
| 1523 |
} |
| 1524 |
} |
| 1525 |
] |
| 1526 |
}; |
| 1527 |
var child_orders_table = $("#child_orders_table").api(options); |
| 1528 |
var child_api = child_orders_table.api(); |
| 1529 |
child_api.on('preDraw', function() { |
| 1530 |
if(!child_api.data().length && !had_rows) return; |
| 1531 |
$("#child_orders").show(); |
| 1532 |
had_rows = true; |
| 1533 |
}); |
| 1534 |
}; |
| 1535 |
|
| 1536 |
var set_editor = function() { |
| 1537 |
var modal = $("#order_edit"); |
| 1538 |
var row = modal.data('row'); |
| 1539 |
var origrec = $("#order_edit").data('origrec')||{}; |
| 1540 |
if(!origrec.hasOwnProperty(row.order_id)) { |
| 1541 |
origrec[row.order_id] = row.quantity_received; |
| 1542 |
$("#order_edit").data('origrec', origrec); |
| 1543 |
} |
| 1544 |
if(row.subscription_id) { |
| 1545 |
row.quantity_received = row.quantity; |
| 1546 |
} |
| 1547 |
var keep = $("#order_edit").data('kept'); |
| 1548 |
if(keep && keep[row.order_id]) { |
| 1549 |
row = keep[row.order_id]; |
| 1550 |
modal.data('row', row); |
| 1551 |
} |
| 1552 |
$('input, select, textarea', '.modal-body').val(null) |
| 1553 |
modal.find(".modal-title").text(MOD_TITLE.format(row.biblio.title)); |
| 1554 |
["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){ |
| 1555 |
var o = modal.find(".modal-body #biblio_"+key); |
| 1556 |
if(row.biblio[key] !== null) { |
| 1557 |
o.parent().show(); |
| 1558 |
o.html(row.biblio[key]); |
| 1559 |
} else { |
| 1560 |
o.parent().hide(); |
| 1561 |
} |
| 1562 |
}); |
| 1563 |
if(row.biblio.suggestions.length) { |
| 1564 |
$("#suggestion_fieldset").show(); |
| 1565 |
if(row.biblio.suggestions[0].suggester) { |
| 1566 |
$("#biblio_suggestion_suggester").parent().show(); |
| 1567 |
$("#biblio_suggestion_suggester") |
| 1568 |
.html( |
| 1569 |
[row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] |
| 1570 |
.filter(function(name){ |
| 1571 |
return name |
| 1572 |
}) |
| 1573 |
.join(', ')+' (<a href="http://localhost:8081/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestionid+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestionid)+'</a>)' |
| 1574 |
); |
| 1575 |
} else { |
| 1576 |
$("#biblio_suggestion_suggester").parent().hide(); |
| 1577 |
} |
| 1578 |
if(row.biblio.suggestions[0].reason) { |
| 1579 |
$("#suggestion_reason").show(); |
| 1580 |
if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { |
| 1581 |
$("#other_reason a").click(); |
| 1582 |
$("#reason").val(row.biblio.suggestions[0].reason); |
| 1583 |
$("#select-other_reason").val(null); |
| 1584 |
} else { |
| 1585 |
$("#reason").val("other").change(); |
| 1586 |
$("#select-other_reason").val(row.biblio.suggestions[0].reason); |
| 1587 |
} |
| 1588 |
|
| 1589 |
} else { |
| 1590 |
$("#suggestion_reason").hide(); |
| 1591 |
} |
| 1592 |
} else { |
| 1593 |
$("#suggestion_fieldset").hide(); |
| 1594 |
} |
| 1595 |
|
| 1596 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
| 1597 |
$("#datereceived").val(row.date_received||$date(new Date().toISOString())).change(); |
| 1598 |
$("#bookfund option[value='']").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)); |
| 1599 |
if(row.fund_id != row.fund.fund_id) { |
| 1600 |
$("#bookfund").val(row.fund_id); |
| 1601 |
} |
| 1602 |
$("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); |
| 1603 |
$("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')') |
| 1604 |
$("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id); |
| 1605 |
$("#quantity").val(row.quantity_received).prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); |
| 1606 |
$('#qtyrecerror').hide(); |
| 1607 |
var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; |
| 1608 |
$("#tax_rate").val(tax_rate).change(); |
| 1609 |
var rrp_txt; |
| 1610 |
var ecost_txt; |
| 1611 |
if(invoiceincgst == "1") { |
| 1612 |
rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint">'+ADJ_TAX_INC.format(active_currency)+"</span>"; |
| 1613 |
ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint">'+TAX_INC+"</span>"; |
| 1614 |
$("#unitprice").val(row.unit_price_tax_included); |
| 1615 |
$("#unitprice_hint").html(TAX_INC); |
| 1616 |
} else { |
| 1617 |
rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint">'+ADJ_TAX_EXC.format(active_currency)+"</span>"; |
| 1618 |
ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint">'+TAX_EXC+"</span>"; |
| 1619 |
$("#unitprice").val(row.unit_price_tax_excluded); |
| 1620 |
$("#unitprice_hint").html(TAX_EXC); |
| 1621 |
} |
| 1622 |
$("#rrp").html(rrp_txt); |
| 1623 |
$("#replacementprice").val(row.replacement_price); |
| 1624 |
$("#ecost").html(ecost_txt); |
| 1625 |
$("#order_internalnote").val(row.internal_note); |
| 1626 |
if(row.vendor_note) { |
| 1627 |
$("#order_vendornote").html(row.vendor_note); |
| 1628 |
$("#order_vendornote").parent().show(); |
| 1629 |
} else { |
| 1630 |
$("#order_vendornote").parent().hide(); |
| 1631 |
} |
| 1632 |
|
| 1633 |
|
| 1634 |
$("#child_orders").hide(); |
| 1635 |
|
| 1636 |
$('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove(); |
| 1637 |
$('#items_list').hide(); |
| 1638 |
if(row.subscription_id) { |
| 1639 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
| 1640 |
$('#modal-order-main').tabs("enable", "#history-panel"); |
| 1641 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
| 1642 |
$('#modal-order-main').tabs( "option", "active", 0); |
| 1643 |
} |
| 1644 |
} else { |
| 1645 |
$('#modal-order-main').tabs("enable", "#items-panel"); |
| 1646 |
$('#modal-order-main').tabs("disable", "#history-panel"); |
| 1647 |
if($('#modal-order-main').tabs( "option", "active" ) == 2) { |
| 1648 |
$('#modal-order-main').tabs( "option", "active", 0); |
| 1649 |
} |
| 1650 |
if(effective_create_items == 'receiving') { |
| 1651 |
$("#acq-create-receiving").show(); |
| 1652 |
$("#acq-create-ordering").hide(); |
| 1653 |
if(row.items && row.items.length) { |
| 1654 |
row.items.forEach(function(item, index) { |
| 1655 |
cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) { |
| 1656 |
var block = $('#'+block_id).hide(); |
| 1657 |
Object.keys(item).forEach(function(key) { |
| 1658 |
block |
| 1659 |
.find('*[name=kohafield][value="'+key+'"]') |
| 1660 |
.parent() |
| 1661 |
.find('*[name=field_value]') |
| 1662 |
.val(item[key].field_value); |
| 1663 |
}); |
| 1664 |
addItemInList(block_id, '[% UniqueItemFields | html %]'); |
| 1665 |
block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
| 1666 |
block.find("input[name='buttonPlusMulti']").remove(); |
| 1667 |
block.find("input[name='multiValue']").remove(); |
| 1668 |
}); |
| 1669 |
}); |
| 1670 |
} |
| 1671 |
cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]'); |
| 1672 |
} else if (effective_create_items == 'ordering') { |
| 1673 |
$("#acq-create-receiving").hide(); |
| 1674 |
$("#acq-create-ordering").show(); |
| 1675 |
if(row.items.length) { |
| 1676 |
$("#acq-create-ordering tbody").append( |
| 1677 |
row.items.map(function(item) { |
| 1678 |
var tr = $('<tr id="item_'+item.item_id+'"/>'); |
| 1679 |
_build_item(item, tr); |
| 1680 |
return tr; |
| 1681 |
}) |
| 1682 |
); |
| 1683 |
} |
| 1684 |
} else { |
| 1685 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
| 1686 |
$('#modal-order-main').tabs( "option", "active", 0); |
| 1687 |
} |
| 1688 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
| 1689 |
} |
| 1690 |
} |
| 1691 |
$("#select_currency").hide(); |
| 1692 |
$("#unitprice").prop("readonly", ""); |
| 1693 |
$("input[name='change_currency']").prop('checked', false); |
| 1694 |
set_modal_buttons(); |
| 1695 |
}; |
| 1696 |
|
| 1697 |
$('.modal-prev').click(function() { |
| 1698 |
var modal = $("#order_edit"); |
| 1699 |
keep_row(); |
| 1700 |
var n = modal.data('n'); |
| 1701 |
if(n > 0) { |
| 1702 |
n--; |
| 1703 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1704 |
modal.data('n', n); |
| 1705 |
set_editor(); |
| 1706 |
} else { |
| 1707 |
$('.modal-next, .modal-prev').prop('disabled', true); |
| 1708 |
orders_table.one('draw.dt', function() { |
| 1709 |
var info = api.page.info(); |
| 1710 |
n = info.end - info.start - 1; |
| 1711 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1712 |
modal.data('n', n); |
| 1713 |
set_editor(); |
| 1714 |
}); |
| 1715 |
api.page('previous').draw( 'page' ); |
| 1716 |
} |
| 1717 |
}); |
| 1718 |
|
| 1719 |
$('.modal-next').click(function() { |
| 1720 |
var modal = $("#order_edit"); |
| 1721 |
keep_row(); |
| 1722 |
var n = modal.data('n'); |
| 1723 |
var info = api.page.info(); |
| 1724 |
if(n < info.end - info.start - 1) { |
| 1725 |
n++; |
| 1726 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1727 |
modal.data('n', n); |
| 1728 |
set_editor(); |
| 1729 |
} else { |
| 1730 |
$('.modal-next, .modal-prev').prop('disabled', true); |
| 1731 |
orders_table.one('draw.dt', function() { |
| 1732 |
var info = api.page.info(); |
| 1733 |
n = 0; |
| 1734 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
| 1735 |
modal.data('n', n); |
| 1736 |
set_editor(); |
| 1737 |
}); |
| 1738 |
api.page('next').draw( 'page' ); |
| 1739 |
} |
| 1740 |
}); |
| 1741 |
|
| 1742 |
$('.modal-save').click(function() { |
| 1743 |
save_row(); |
| 1744 |
$("#order_edit").modal('hide'); |
| 1745 |
}) |
| 1746 |
|
| 1747 |
$('#modal-order-main').tabs({ |
| 1748 |
activate: function(event, ui) { |
| 1749 |
var active = ui.newPanel.attr('id') |
| 1750 |
if(active == 'history-panel') { |
| 1751 |
show_subs($("#order_edit").data('row')); |
| 1752 |
} |
| 1753 |
} |
| 1754 |
}); |
| 1755 |
|
| 1756 |
$("#order_edit").on("show.bs.modal", function (event) { |
| 1757 |
var anchor = $(event.relatedTarget); |
| 1758 |
var n = anchor.data("row"); |
| 1759 |
var row = api.row(n).data(); |
| 1760 |
|
| 1761 |
var modal = $(this); |
| 1762 |
modal.data('row', JSON.parse(JSON.stringify(row))); |
| 1763 |
modal.data('n', n); |
| 1764 |
modal.data('keep', modal.data('saved')||{}); |
| 1765 |
$('#modal-order-main').tabs("option", "active", 0); |
| 1766 |
set_editor(); |
| 1767 |
}); |
| 1768 |
/* $("#order_edit").on("shown.bs.modal", function() { |
| 1769 |
var modal = $(this); |
| 1770 |
|
| 1771 |
if(modal.data('show_subs')) show_subs(modal.data('row')); |
| 1772 |
});*/ |
| 1773 |
$("#order_edit").on("hide.bs.modal", function() { |
| 1774 |
$("#child_orders_table").DataTable().off('preDraw').destroy(); |
| 1775 |
}); |
| 1776 |
}); |
| 1777 |
[% END %] |
| 654 |
</script> |
1778 |
</script> |
| 655 |
[% END %] |
1779 |
[% END %] |
| 656 |
|
1780 |
|