Lines 15-31
Link Here
|
15 |
[% INCLUDE 'header.inc' %] |
15 |
[% INCLUDE 'header.inc' %] |
16 |
[% INCLUDE 'acquisitions-search.inc' %] |
16 |
[% INCLUDE 'acquisitions-search.inc' %] |
17 |
|
17 |
|
18 |
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> › <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.basket.booksellerid | html %]">[% name | html %]</a> › Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]][% END %] (order #[% order.ordernumber | html %])</div> |
18 |
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> › <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.basket.booksellerid | html %]">[% name | html %]</a> › Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]][% END %] (order #[% order.ordernumber || multiple_orders | html %])</div> |
19 |
|
19 |
|
20 |
<div class="main container-fluid"> |
20 |
<div class="main container-fluid"> |
21 |
<div class="row"> |
21 |
<div class="row"> |
22 |
[% AcqCreateItem = order.basket.effective_create_items %] |
|
|
23 |
<div class="col-sm-10 col-sm-push-2"> |
22 |
<div class="col-sm-10 col-sm-push-2"> |
24 |
<main> |
23 |
<main> |
25 |
|
24 |
|
26 |
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber | html %])</h1> |
25 |
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber || multiple_orders | html %])</h1> |
27 |
|
26 |
|
28 |
[% IF ( order ) %] |
27 |
[% IF ( order ) %] |
|
|
28 |
[% AcqCreateItem = order.basket.effective_create_items %] |
29 |
<form action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);"> |
29 |
<form action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);"> |
30 |
<div class="row"> |
30 |
<div class="row"> |
31 |
<div class="col-sm-6"> |
31 |
<div class="col-sm-6"> |
Lines 289-295
Link Here
|
289 |
[% IF ( order.items.count ) %] |
289 |
[% IF ( order.items.count ) %] |
290 |
<input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" /> |
290 |
<input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" /> |
291 |
[% ELSE %] |
291 |
[% ELSE %] |
292 |
<input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived + 1 | html %]" /> |
292 |
<input type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" /> |
293 |
[% END %] |
293 |
[% END %] |
294 |
<input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" /> |
294 |
<input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" /> |
295 |
[% END %] |
295 |
[% END %] |
Lines 350-356
Link Here
|
350 |
</li> |
350 |
</li> |
351 |
<li id="select_currency"> |
351 |
<li id="select_currency"> |
352 |
<label for="unitprice_currency"></label> |
352 |
<label for="unitprice_currency"></label> |
353 |
<input type="text" size="20" name="unitprice" id="unitprice_currency" value="" /> |
353 |
<input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" /> |
354 |
[% IF currencies.count %] |
354 |
[% IF currencies.count %] |
355 |
<select name="currency"> |
355 |
<select name="currency"> |
356 |
<option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> |
356 |
<option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> |
Lines 372-377
Link Here
|
372 |
<input type="submit" value="Save" class="button" accesskey="w" /> |
372 |
<input type="submit" value="Save" class="button" accesskey="w" /> |
373 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a> |
373 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a> |
374 |
</fieldset></div> </form> |
374 |
</fieldset></div> </form> |
|
|
375 |
[% ELSIF multiple_orders %] |
376 |
<table id="multiple_orders" class="table table-bordered table-striped"> |
377 |
<thead> |
378 |
<tr> |
379 |
<th>Order</td> |
380 |
<th>Title</th> |
381 |
<th>Author</th> |
382 |
<th>ISBN</th> |
383 |
<th>Date received</th> |
384 |
<th>Fund</th> |
385 |
<th>Quantity</th> |
386 |
<th> </th> |
387 |
</tr> |
388 |
</thead> |
389 |
</table> |
390 |
|
391 |
<div class="col"> |
392 |
<fieldset class="action"> |
393 |
<button class="save">Save</button> |
394 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Return</a> |
395 |
</fieldset> |
396 |
<div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> |
397 |
<div id="jobfailed"></div> |
398 |
</div> |
399 |
|
400 |
<div class="modal fade" id="order_edit" tabindex="-1" role="dialog" aria-labelledby="Order edit"> |
401 |
<div class="modal-dialog" role="document"> |
402 |
<div class="modal-content modal-lg"> |
403 |
<div class="modal-header row"> |
404 |
<h4 class="col-md-11 modal-title"></h4> |
405 |
<button type="button" class="close col-md-1" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
406 |
</div> |
407 |
<div class="modal-body"> |
408 |
<div class="hide" id="loading">Loading ...</div> |
409 |
<div id="modal-order-main"> |
410 |
<ul> |
411 |
<li><a href="#info-panel">Info</a></li> |
412 |
<li><a href="#accounting-panel">Accounting</a></li> |
413 |
<li><a href="#history-panel">Receipt history</a></li> |
414 |
<li><a href="#items-panel">Items</a></li> |
415 |
</ul> |
416 |
|
417 |
|
418 |
<div id="info-panel"> |
419 |
<div> |
420 |
<h4>Catalog details</h4> |
421 |
|
422 |
<div class="row"> <span class="lbl col-sm-4">Title: </span><span class="col-sm-8" id="biblio_title"></span></div> |
423 |
<div class="row"> <span class="lbl col-sm-4">Author: </span><span class="col-sm-8" id="biblio_author"></span></div> |
424 |
<div class="row"> <span class="lbl col-sm-4">Copyright: </span><span class="col-sm-8" id="biblio_copyright_date"></span></div> |
425 |
<div class="row"> <span class="lbl col-sm-4">ISBN: </span><span class="col-sm-8" id="biblio_isbn"></span></div> |
426 |
<div class="row"> <span class="lbl col-sm-4">Series: </span><span class="col-sm-8" id="biblio_series_title"></span></div> |
427 |
|
428 |
</div> |
429 |
<div id="suggestion_fieldset"> |
430 |
<h4>Suggestion</h4> |
431 |
<div class="row"> |
432 |
<span class="lbl col-sm-4">Suggested by: </span> <span class="col-sm-8" id="biblio_suggestion_suggester"></span> |
433 |
</div> |
434 |
<div class="row" id="suggestion_reason"> |
435 |
<span class="lbl col-sm-4">Reason:</span> |
436 |
<div class="col-sm-8"> |
437 |
[% SET suggestion_reasons = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %] |
438 |
<select class="select-reason" id="reason" name="reason"> |
439 |
<option value=""> -- Choose a reason -- </option> |
440 |
[% FOREACH reason IN suggestion_reasons %] |
441 |
<option value="[% reason.lib | html %]">[% reason.lib | html %]</option> |
442 |
[% END %] |
443 |
<option value="other">Others...</option> |
444 |
</select> |
445 |
|
446 |
<span id="other_reason" name="other_reason"> |
447 |
<input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." /> |
448 |
<a href="#back">Cancel</a> |
449 |
</span> |
450 |
</div> |
451 |
</div> |
452 |
</div> |
453 |
</div> |
454 |
<div id="history-panel"> |
455 |
<div id="child_orders"> |
456 |
<h4>Receipt history for this subscription</h4> |
457 |
<table id="child_orders_table"> |
458 |
<thead> |
459 |
<tr> |
460 |
<th>Invoice</th> |
461 |
<th>Order number</th> |
462 |
<th class="title-string">Creation date</th> |
463 |
<th class="title-string">Receive date</th> |
464 |
<th>Quantity received</th> |
465 |
<th class="title-string">Status</th> |
466 |
<th title="Actual cost tax exc. / Actual cost tax inc.">Spent</th> |
467 |
<th>Internal note</th> |
468 |
</tr> |
469 |
</thead> |
470 |
</table> |
471 |
</div> |
472 |
</div> |
473 |
<div id="items-panel"> |
474 |
<div id="acq-create-receiving"> |
475 |
<div id="items_list" style="display: none"> |
476 |
<h4>Items list</h4> |
477 |
<div style="width:100%;overflow:auto;"> |
478 |
<table> |
479 |
<thead> |
480 |
<tr> |
481 |
<th>Actions</th> |
482 |
<th>Barcode</th> |
483 |
<th>Home library</th> |
484 |
<th>Holding library</th> |
485 |
<th>Not for loan</th> |
486 |
<th>Restricted</th> |
487 |
<th>Location</th> |
488 |
<th>Call number</th> |
489 |
<th>Copy number</th> |
490 |
<th>Inventory number</th> |
491 |
<th>Collection</th> |
492 |
<th>Item type</th> |
493 |
<th>Materials</th> |
494 |
<th>Notes</th> |
495 |
</tr> |
496 |
</thead> |
497 |
<tbody> |
498 |
</tbody> |
499 |
</table> |
500 |
</div> |
501 |
</div> |
502 |
|
503 |
<div id="itemfieldset"> |
504 |
<h4>Item</h4> |
505 |
[% IF ( NoACQframework ) %] |
506 |
<p class="required"> |
507 |
No ACQ framework, using default. You should create a |
508 |
framework with code ACQ, the items framework would be |
509 |
used |
510 |
</p> |
511 |
[% END %] |
512 |
<div id="outeritemblock"></div> |
513 |
</div> |
514 |
</div> |
515 |
<div id="acq-create-ordering"> |
516 |
<h4>Items</h4> |
517 |
<div style="width:100%;overflow:auto"> |
518 |
<table> |
519 |
<thead> |
520 |
<tr> |
521 |
<th>Receive?</th> |
522 |
<th> </th> |
523 |
<th>Barcode</th> |
524 |
<th>Home library</th> |
525 |
<th>Current library</th> |
526 |
<th>Not for loan</th> |
527 |
<th>Restricted</th> |
528 |
<th>Location</th> |
529 |
<th>Call number</th> |
530 |
<th>Copy number</th> |
531 |
<th>Inventory number</th> |
532 |
<th>Collection</th> |
533 |
<th>Item type</th> |
534 |
<th>Materials</th> |
535 |
<th>Notes</th> |
536 |
</tr> |
537 |
</thead> |
538 |
<tbody> |
539 |
</tbody> |
540 |
</table> |
541 |
</div> |
542 |
</div> |
543 |
</div> |
544 |
<div id="accounting-panel"> |
545 |
<h4>Accounting details</h4> |
546 |
<ol> |
547 |
<li> |
548 |
<label for="datereceived">Date received: </label> |
549 |
<input type="text" size="10" id="datereceived" name="datereceived" class="datepicker" /> |
550 |
</li> |
551 |
<li> |
552 |
<label for="bookfund">Fund: </label> |
553 |
<select id="bookfund" name="bookfund"> |
554 |
<option value=""></option> |
555 |
[% FOREACH period IN budget_loop %] |
556 |
<optgroup label="[% period.description | html %]"> |
557 |
[% FOREACH fund IN period.funds %] |
558 |
<option value="[% fund.b_id | html %]">[% fund.b_txt | html %]</option> |
559 |
[% END %] |
560 |
</optgroup> |
561 |
[% END %] |
562 |
</select> |
563 |
</li> |
564 |
<li> |
565 |
<label> </label> |
566 |
<span id="current-fund"></span> |
567 |
</li> |
568 |
<li> |
569 |
<label for="creator">Ordered by: </label> |
570 |
<span id="creator"></span> |
571 |
</li> |
572 |
<li> |
573 |
<label for="quantity_to_receive">Quantity ordered: </label> |
574 |
<input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" /> |
575 |
</li> |
576 |
<li> |
577 |
<label for="quantity">Quantity received: </label> |
578 |
<input type="text" size="20" name="quantityrec" id="quantity" /> |
579 |
<div id="qtyrecerror" style="display:none"> |
580 |
<p class="error">Warning, you have entered more items than expected. |
581 |
Items will not be created.</p> |
582 |
</div> |
583 |
</li> |
584 |
|
585 |
[% IF ( gst_values ) %] |
586 |
<li> |
587 |
<label for="tax_rate">Tax rate: </label> |
588 |
<select name="tax_rate" id="tax_rate"> |
589 |
[% FOREACH gst IN gst_values %] |
590 |
<option value="[% gst.option | html %]">[% gst.option * 100 | html %]%</option> |
591 |
[% END %] |
592 |
</select> |
593 |
</li> |
594 |
[% END %] |
595 |
|
596 |
<li> |
597 |
<label for="rrp">Retail price: </label> |
598 |
<span id="rrp"></span> |
599 |
<li> |
600 |
<label for="replacementprice">Replacement price:</label> |
601 |
<input type="text" size="20" name="replacementprice" id="replacementprice" /> |
602 |
</li> |
603 |
<li> |
604 |
<label for="ecost">Budgeted cost: </label> |
605 |
<span id="ecost"></span> |
606 |
</li> |
607 |
<li> |
608 |
<label for="unitprice">Actual cost:</label> |
609 |
<input type="text" size="20" name="unitprice" id="unitprice" /> |
610 |
<span id="unitprice_hint" class="hint"></span> |
611 |
<label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> |
612 |
</li> |
613 |
<li id="select_currency"> |
614 |
<label for="unitprice_currency"></label> |
615 |
<input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" /> |
616 |
[% IF currencies.count %] |
617 |
<select name="currency"> |
618 |
<option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> |
619 |
[% FOR currency IN currencies %] |
620 |
<option value="[% currency.rate | html %]">[% currency.currency | html %] ([% currency.symbol | html %])</option> |
621 |
[% END %] |
622 |
</select> |
623 |
[% END %] |
624 |
</li> |
625 |
<li> |
626 |
<label for="order_internalnote">Internal note: </label> |
627 |
<textarea name="order_internalnote" id="order_internalnote" width="40" rows="8" ></textarea> |
628 |
</li> |
629 |
<li> |
630 |
<label for="order_vendornote">Vendor note: </label> |
631 |
<span id="order_vendornote"></span> |
632 |
</li> |
633 |
</ol> |
634 |
</div> |
635 |
</div> |
636 |
</div> |
637 |
<div class="modal-footer"> |
638 |
<button type="button" class="btn btn-defualt modal-prev">Previous</button> |
639 |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
640 |
<button type="button" class="btn btn-primary modal-save">Save changes</button> |
641 |
<button type="button" class="btn btn-defualt modal-next">Next</button> |
642 |
</div> |
643 |
</div> |
644 |
</div> |
645 |
</div> |
375 |
[% ELSE %] |
646 |
[% ELSE %] |
376 |
This ordernumber does not exist. |
647 |
This ordernumber does not exist. |
377 |
[% END %] |
648 |
[% END %] |
Lines 387-396
Link Here
|
387 |
</div> <!-- /.row --> |
658 |
</div> <!-- /.row --> |
388 |
[% MACRO jsinclude BLOCK %] |
659 |
[% MACRO jsinclude BLOCK %] |
389 |
[% Asset.js("js/acquisitions-menu.js") | $raw %] |
660 |
[% Asset.js("js/acquisitions-menu.js") | $raw %] |
390 |
[% INCLUDE 'calendar.inc' %] |
661 |
[% INCLUDE 'calendar.inc' %] |
391 |
[% Asset.js("js/additem.js") | $raw %] |
662 |
[% Asset.js("js/additem.js") | $raw %] |
392 |
[% Asset.js("js/cataloging.js") | $raw %] |
663 |
[% Asset.js("js/cataloging.js") | $raw %] |
|
|
664 |
[% INCLUDE 'datatables.inc' %] |
665 |
[% INCLUDE 'js-date-format.inc' %] |
666 |
[% INCLUDE 'format_price.inc' %] |
667 |
[% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %] |
668 |
<style> |
669 |
.lbl { |
670 |
font-weight: 700; |
671 |
text-align: right; |
672 |
} |
673 |
.modal-body ol { |
674 |
list-style-type: none; |
675 |
} |
676 |
|
677 |
.modal-body ol li { |
678 |
list-style-type: none; |
679 |
padding-bottom: 1em; |
680 |
width: 100%; |
681 |
} |
682 |
|
683 |
.modal-body h4 { |
684 |
margin-left: 1em; |
685 |
padding: .2em .5em; |
686 |
margin-bottom: 17px; |
687 |
} |
688 |
|
689 |
.modal-body label { |
690 |
margin-right: 1em; |
691 |
text-align: right; |
692 |
width: 11em; |
693 |
display: inline-block; |
694 |
font-weight: 700; |
695 |
} |
696 |
|
697 |
.modal-body textarea { |
698 |
vertical-align: text-top; |
699 |
} |
700 |
</style> |
393 |
<script> |
701 |
<script> |
|
|
702 |
[% IF order %] |
394 |
function Check(form) { |
703 |
function Check(form) { |
395 |
[% IF (AcqCreateItem == 'receiving') %] |
704 |
[% IF (AcqCreateItem == 'receiving') %] |
396 |
var total_errors = CheckMandatorySubfields(form); |
705 |
var total_errors = CheckMandatorySubfields(form); |
Lines 541-546
Link Here
|
541 |
}); |
850 |
}); |
542 |
|
851 |
|
543 |
}); |
852 |
}); |
|
|
853 |
[% ELSIF multiple_orders %] |
854 |
|
855 |
var _build_item = function(item, tr) { |
856 |
var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />') |
857 |
.prop('checked', item._checked) |
858 |
.change(function() { |
859 |
item._checked = $(this).prop('checked'); |
860 |
}); |
861 |
tr.append($('<td style="text-align:center"></td>').append(chb)); |
862 |
tr.append('<td><a style="cursor:pointer" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>'); |
863 |
tr.append('<td>'+(item.external_id||'')+'</td>'); |
864 |
tr.append('<td>'+(item.home_branch && item.home_branch.name||'')+'</td>'); |
865 |
tr.append('<td>'+(item.holding_branch && item.holding_branch.name||'')+'</td>'); |
866 |
tr.append('<td>'+(item._authorised_values.not_for_loan_status && item._authorised_values.not_for_loan_status.lib||'')+'</td>'); |
867 |
tr.append('<td>'+(item._authorised_values.restricted_status && item._authorised_values.restricted_status.lib||'')+'</td>'); |
868 |
tr.append('<td><span class="shelvingloc">'+(item._authorised_values.location && item._authorised_values.location.lib||'')+'</span></td>'); |
869 |
tr.append('<td>'+(item.callnumber||'')+'</td>'); |
870 |
tr.append('<td>'+(item.copy_number||'')+'</td>'); |
871 |
tr.append('<td>'+(item.inventory_number||'')+'</td>'); |
872 |
tr.append('<td>'+(item._authorised_values.collection_code && item._authorised_values.collection_code.lib||'')+'</td>'); |
873 |
tr.append('<td>'+(item.itemtype && item.itemtype.description || '')+'</td>'); |
874 |
tr.append('<td>'+(item._authorised_values.materials_notes && item._authorised_values.materials_notes.lib||'')+'</td>') |
875 |
tr.append('<td>'+(item.public_notes||'')+'</td>'); |
876 |
}; |
877 |
|
878 |
var items_columns = [null, null, 'external_id', 'home_library_id', |
879 |
'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location', |
880 |
'callnumber', 'copy_number', 'inventory_number', 'collection_code', |
881 |
'item_type', 'materials_notes', 'public_notes']; |
882 |
|
883 |
function PopupEditPage(biblionumber, itemnumber) { |
884 |
var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" |
885 |
+ biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; |
886 |
var w = window.open(url); |
887 |
var watchClose = setInterval(function() { |
888 |
if (w.closed) { |
889 |
clearTimeout(watchClose); |
890 |
$.ajax({ |
891 |
dataType: "json", |
892 |
headers: { |
893 |
"x-koha-embed": "home_branch,holding_branch,itemtype", |
894 |
"x-koha-av": "1" |
895 |
}, |
896 |
url: '/api/v1/items/'+itemnumber, |
897 |
success: function(item) { |
898 |
var tr = $("#item_"+itemnumber); |
899 |
tr.html(''); |
900 |
_build_item(item, tr); |
901 |
} |
902 |
}); |
903 |
} |
904 |
}, 500); |
905 |
} |
906 |
|
907 |
var periods={}; |
908 |
var funds={}; |
909 |
var funds_tree = []; |
910 |
|
911 |
var QTY_TOTAL = _("Receiving %0$s out of %1$s"); |
912 |
var EDIT = _("edit"); |
913 |
var MOD_TITLE = _("Edit %s"); |
914 |
var SUGGESTION = _("suggestion #%s"); |
915 |
var FUND_KEEP = _("Keep current (%0$s - %1$s)"); |
916 |
var FUNC_CUR = _("(Current: %0$s - %1$s)"); |
917 |
var ADJ_TAX_INC = _("(adjusted for %s, tax inclusive)"); |
918 |
var ADJ_TAX_EXC = _("(adjusted for %s, tax exclusive)"); |
919 |
var TAX_INC = _("(tax inclusive)"); |
920 |
var TAX_EXC = _("(tax exclusive)"); |
921 |
var SAVE_WARNING = _("Order %s: Warning, you have entered more items than expected. Items will not be created."); |
922 |
var SAVE_WARNING_NO_ITEMS = _("Order %s: No quantity to receive setted. No items will be created."); |
923 |
var SAVE_ERROR = _("Order %s: An error cocurred while saving"); |
924 |
|
925 |
|
926 |
var CAN_user_acquisition = "[% CAN_user_acquisition | html %]"; |
927 |
var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]"; |
928 |
var edit_mode = "[% edit | html %]"; |
929 |
var invoiceincgst = "[% invoiceincgst | html %]"; |
930 |
var active_currency = "[% active_currency.currency | html %]"; |
931 |
var invoice_id = "[% invoiceid | html %]"; |
932 |
|
933 |
$(document).ready(function(){ |
934 |
var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}}; |
935 |
var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; |
936 |
var options = { |
937 |
"ajax": { |
938 |
"url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)), |
939 |
"headers": { |
940 |
'x-koha-av': '1' |
941 |
} |
942 |
}, |
943 |
"header_filter": true, |
944 |
"embed": [ |
945 |
"basket", |
946 |
"biblio.suggestions.suggester", |
947 |
"fund.budget", |
948 |
"items.home_branch", |
949 |
"items.holding_branch", |
950 |
"items.itemtype", |
951 |
"creator" |
952 |
], |
953 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
954 |
"columns": [ |
955 |
{ |
956 |
"data": "order_id", |
957 |
"searchable": true, |
958 |
"orderable": true |
959 |
}, |
960 |
{ |
961 |
"data": "biblio.title", |
962 |
"searchable": true, |
963 |
"orderable": true, |
964 |
"render": function(data, type, row, meta) { |
965 |
if ( data == null ) { |
966 |
return ""; |
967 |
} |
968 |
else { |
969 |
return data; |
970 |
} |
971 |
} |
972 |
}, |
973 |
{ |
974 |
"data": "biblio.author", |
975 |
"searchable": true, |
976 |
"orderable": true, |
977 |
"render": function(data, type, row, meta) { |
978 |
if ( data == null ) { |
979 |
return ""; |
980 |
} |
981 |
else { |
982 |
return data; |
983 |
} |
984 |
} |
985 |
}, |
986 |
{ |
987 |
"data": "biblio.isbn", |
988 |
"searchable": true, |
989 |
"orderable": true, |
990 |
"render": function(data, type, row, meta) { |
991 |
if ( data == null ) { |
992 |
return ""; |
993 |
} |
994 |
else { |
995 |
return data; |
996 |
} |
997 |
} |
998 |
}, |
999 |
{ |
1000 |
"searchable": false, |
1001 |
"orderable": false, |
1002 |
"data": function(row, type, val, meta) { |
1003 |
return $date(row.date_received||new Date().toISOString()); |
1004 |
} |
1005 |
}, |
1006 |
{ |
1007 |
"data": "fund.name", |
1008 |
"searchable": true, |
1009 |
"orderable": false, |
1010 |
"render": function(data, type, row, meta) { |
1011 |
return row.fund.budget.budget_period_description+" - "+row.fund.name; |
1012 |
} |
1013 |
}, |
1014 |
{ |
1015 |
"searchable": false, |
1016 |
"orderable": true, |
1017 |
"data": "quantity_received", |
1018 |
"render": function(data, type, row, meta) { |
1019 |
return QTY_TOTAL.format(row.subscription_id?row.quantity:row.quantity_received, row.quantity); |
1020 |
} |
1021 |
}, |
1022 |
{ |
1023 |
"searchable": false, |
1024 |
"orderable": false, |
1025 |
"render": function(data, type, row, meta) { |
1026 |
return '<a data-toggle="modal" href="#order_edit" data-row="'+meta.row+'" class="order_edit_toggle">'+EDIT+'</a>'; |
1027 |
} |
1028 |
} |
1029 |
] |
1030 |
}; |
1031 |
var orders_table = $("#multiple_orders").api(options); |
1032 |
var api = orders_table.api(); |
1033 |
|
1034 |
api.on('preDraw', function() { |
1035 |
var saved = $("#order_edit").data('saved'); |
1036 |
if(saved) { |
1037 |
var data = api.data(); |
1038 |
for(var i = 0; i<data.length; i++) { |
1039 |
var row = data[i]; |
1040 |
var srow = saved[row.order_id]; |
1041 |
if(srow) { |
1042 |
if(row.fund_id != srow.fund_id) { |
1043 |
row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label'); |
1044 |
row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html(); |
1045 |
} |
1046 |
row.date_received = srow.date_received; |
1047 |
row.quantity = srow.quantity; |
1048 |
row.quantity_received = srow.quantity_received; |
1049 |
} |
1050 |
} |
1051 |
} |
1052 |
}); |
1053 |
|
1054 |
var _doSave = function(params) { |
1055 |
$.ajax($.extend({ |
1056 |
method: 'POST', |
1057 |
url: '/cgi-bin/koha/acqui/finishreceive.pl' |
1058 |
}, params)); |
1059 |
}; |
1060 |
|
1061 |
var _set_error = function(error) { |
1062 |
if($('#jobfailed').html() == '') $('#jobfailed').append('<ul/>'); |
1063 |
$('#jobfailed ul').append('<li>'+error+'</li>'); |
1064 |
}; |
1065 |
|
1066 |
var _transform_row = function(row, origrec) { |
1067 |
var params = {}; |
1068 |
params['biblionumber'] = row.biblio_id; |
1069 |
params['invoiceid'] = invoice_id; |
1070 |
params['ordernumber'] = row.order_id; |
1071 |
params['booksellerid'] = row.basket.vendor_id; |
1072 |
|
1073 |
if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { |
1074 |
params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; |
1075 |
if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { |
1076 |
params['reason'] = row.biblio.suggestions[0].reason; |
1077 |
} else { |
1078 |
params['reason'] = 'other'; |
1079 |
params['other_reason'] = row.biblio.suggestions[0].reason; |
1080 |
} |
1081 |
} |
1082 |
params['datereceived'] = row.date_received; |
1083 |
params['bookfund'] = row.fund_id; |
1084 |
params['quantity'] = row.quantity; |
1085 |
params['quantityrec'] = row.quantity_received; |
1086 |
params['origquantityrec'] = origrec; |
1087 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
1088 |
params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering; |
1089 |
params['replacementprice'] = row.replacement_price; |
1090 |
params['unitprice'] = invoiceincgst?row.unit_price_tax_included:row.unit_price_tax_excluded; |
1091 |
params['order_internalnote'] = row.internal_note; |
1092 |
if(effective_create_items == 'receiving') { |
1093 |
Object.keys(row.items).forEach(function(key) { |
1094 |
var item = row.items[key]; |
1095 |
Object.keys(item).forEach(function(key) { |
1096 |
var field = item[key]; |
1097 |
Object.keys(field).forEach(function(key) { |
1098 |
if(!params[key]) params[key] = []; |
1099 |
params[key].push(item[key]); |
1100 |
}); |
1101 |
}); |
1102 |
}); |
1103 |
} else if(effective_create_items == 'ordering') { |
1104 |
params['items_to_receive'] = (row.items||[]) |
1105 |
.filter(function(item) { |
1106 |
return item._checked |
1107 |
}) |
1108 |
.map(function(item) { |
1109 |
item.item_id; |
1110 |
}) |
1111 |
} |
1112 |
return params; |
1113 |
}; |
1114 |
|
1115 |
$('.save').click(function() { |
1116 |
var data = $("#order_edit").data(); |
1117 |
var rows = api.rows().data(); |
1118 |
$('this').prop('disabled', true); |
1119 |
var redirect = true; |
1120 |
if(rows.length) { |
1121 |
$('#jobfailed, #jobpanel, #jobstatus').show(); |
1122 |
|
1123 |
var loopRows = function(i) { |
1124 |
var row = rows[i]; |
1125 |
if(!row) { |
1126 |
if(redirect) { |
1127 |
location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id |
1128 |
} |
1129 |
return; |
1130 |
} |
1131 |
if(data.saved && data.saved[row.order_id]) { |
1132 |
row = data.saved[row.order_id]; |
1133 |
var origrec = data.origrec[row.order_id]; |
1134 |
} else { |
1135 |
var origrec = row.quantity_received; |
1136 |
} |
1137 |
if(row.subscription_id) row.quantity_received = row.quantity; |
1138 |
var _set_percentage = function() { |
1139 |
var percentage = Math.round(( (i+1) / rows.length) * 100); |
1140 |
var bgproperty = (parseInt(percentage*2)-300)+"px 0px"; |
1141 |
$("#jobprogress").css("background-position",bgproperty); |
1142 |
$("#jobprogresspercent").text(percentage); |
1143 |
} |
1144 |
if(row.quantity_received > row.quantity) { |
1145 |
_set_error(SAVE_WARNING.format(row.order_id)); |
1146 |
row.quantity_received = row.quantity; |
1147 |
} |
1148 |
if(row.quantity_received == '0') { |
1149 |
_set_error(SAVE_WARNING_NO_ITEMS.format(row.order_id)); |
1150 |
} |
1151 |
_doSave({ |
1152 |
data: _transform_row(row, origrec), |
1153 |
success: function() { |
1154 |
_set_percentage(); |
1155 |
loopRows(i+1); |
1156 |
}, |
1157 |
error: function() { |
1158 |
_set_percentage() |
1159 |
_set_error(SAVE_ERROR.format(row.order_id)); |
1160 |
redirect = false; |
1161 |
loopRows(i+1); |
1162 |
} |
1163 |
}); |
1164 |
}; |
1165 |
loopRows(0) |
1166 |
} |
1167 |
}); |
1168 |
|
1169 |
$("#order_edit").on("change", "#reason", function() { |
1170 |
var val = $(this).val(); |
1171 |
var row = $("#order_edit").data('row'); |
1172 |
if(val == 'other') { |
1173 |
$("#other_reason").show(); |
1174 |
$(this).hide(); |
1175 |
} else { |
1176 |
row.biblio.suggestions[0].reason = val; |
1177 |
} |
1178 |
}); |
1179 |
|
1180 |
$("#order_edit").on("change", "#select-other_reason", function() { |
1181 |
var val = $(this).val(); |
1182 |
var row = $("#order_edit").data('row'); |
1183 |
row.biblio.suggestions[0].reason = val; |
1184 |
}); |
1185 |
|
1186 |
$("#order_edit").on("click", "#other_reason a", function() { |
1187 |
$("#other_reason").hide(); |
1188 |
$("#reason").val(null).show(); |
1189 |
}); |
1190 |
|
1191 |
$("#order_edit").on("change", "#datereceived", function() { |
1192 |
var val = $(this).val(); |
1193 |
var row = $("#order_edit").data('row'); |
1194 |
row.date_received = val; |
1195 |
}); |
1196 |
|
1197 |
$("#order_edit").on("change", "#bookfund", function() { |
1198 |
var val = $(this).val(); |
1199 |
var row = $("#order_edit").data('row'); |
1200 |
row.fund_id = val; |
1201 |
}); |
1202 |
|
1203 |
$("#order_edit").on("change", "#quantity_to_receive", function() { |
1204 |
var val = $(this).val(); |
1205 |
var row = $("#order_edit").data('row'); |
1206 |
row.quantity = val; |
1207 |
if(row.subscription_id) { |
1208 |
$("#quantity").val(val).change(); |
1209 |
} |
1210 |
}); |
1211 |
|
1212 |
$("#order_edit").on("change", "#quantity", function() { |
1213 |
var val = $(this).val(); |
1214 |
var row = $("#order_edit").data('row'); |
1215 |
row.quantity_received = val; |
1216 |
var qtyto = parseInt($("#quantity_to_receive").val()); |
1217 |
if(parseInt(val) > qtyto) { |
1218 |
$("#qtyrecerror").show(); |
1219 |
} else { |
1220 |
$("#qtyrecerror").hide(); |
1221 |
} |
1222 |
$("input[name='items_to_receive']").each(function() { |
1223 |
$(this).prop('checked', false).change(); |
1224 |
}); |
1225 |
$("input[name='items_to_receive']:lt("+val+")").each(function () { |
1226 |
$(this).prop('checked', true).change(); |
1227 |
}); |
1228 |
}); |
1229 |
|
1230 |
$("#order_edit").on("change", "input[name='items_to_receive']", function() { |
1231 |
var qty = $("input[name='items_to_receive']:checked").length; |
1232 |
$("#quantity").val(qty); |
1233 |
var row = $("#order_edit").data('row'); |
1234 |
row.quantity_received = qty; |
1235 |
}) |
1236 |
|
1237 |
$("#order_edit").on("change", "#tax_rate", function() { |
1238 |
var val = $(this).val(); |
1239 |
if(val === null) $(this).val($('option:first-child', this).attr('value')); |
1240 |
val = $(this).val(); |
1241 |
var row = $("#order_edit").data('row'); |
1242 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
1243 |
if(effective_create_items == 'receiving') { |
1244 |
row.tax_rate_on_receiving = val; |
1245 |
} else { |
1246 |
row.tax_rate_on_ordering = val; |
1247 |
} |
1248 |
|
1249 |
}); |
1250 |
|
1251 |
$("#order_edit").on("change", "#unitprice", function() { |
1252 |
var val = $(this).val(); |
1253 |
var row = $("#order_edit").data('row'); |
1254 |
if(invoiceincgst) { |
1255 |
row.unit_price_tax_included = val; |
1256 |
} else { |
1257 |
row.unit_price_tax_excluded = val; |
1258 |
} |
1259 |
|
1260 |
}); |
1261 |
|
1262 |
$("#order_edit").on("change", "input[name='change_currency']", function(){ |
1263 |
if ( $(this).is(":checked") ) { |
1264 |
$("#select_currency").show(); |
1265 |
$("#unitprice").prop("readonly", "true"); |
1266 |
} else { |
1267 |
$("#select_currency").hide(); |
1268 |
$("#unitprice").prop("readonly", ""); |
1269 |
} |
1270 |
}); |
1271 |
|
1272 |
function _update_unitprice() { |
1273 |
var rate = Number($("select[name='currency'] option:selected").val()); |
1274 |
var unitprice = $("#unitprice_currency").val(); |
1275 |
var new_unitprice = Number( unitprice * rate ).toFixed(2); |
1276 |
$("#unitprice").val(new_unitprice).change(); |
1277 |
} |
1278 |
$("#order_edit").on("change", "select[name='currency']", _update_unitprice ); |
1279 |
$("#order_edit").on("change", "#unitprice_currency", _update_unitprice ); |
1280 |
|
1281 |
$("#order_edit").on("change", "#replacementprice", function() { |
1282 |
var val = $(this).val(); |
1283 |
var row = $("#order_edit").data('row'); |
1284 |
row.replacement_price = val; |
1285 |
}); |
1286 |
|
1287 |
$("#order_edit").on("change", "#order_internalnote", function() { |
1288 |
var val = $(this).val(); |
1289 |
var row = $("#order_edit").data('row'); |
1290 |
row.internal_note = val; |
1291 |
|
1292 |
}); |
1293 |
|
1294 |
var keep_row = function() { |
1295 |
var row = $("#order_edit").data('row'); |
1296 |
var kept = $("#order_edit").data('kept')||{}; |
1297 |
if($('#items_list tbody tr').length) { |
1298 |
row.items = []; |
1299 |
$('#items_list tbody tr').each(function() { |
1300 |
var item = {}; |
1301 |
$('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() { |
1302 |
var kf = $(this).val(); |
1303 |
var obj = {}; |
1304 |
$(this).parent().find('*[name]').each(function() { |
1305 |
obj[$(this).prop('name')] = $(this).val(); |
1306 |
}); |
1307 |
item[kf] = obj; |
1308 |
}); |
1309 |
row.items.push(item); |
1310 |
}); |
1311 |
} |
1312 |
kept[row.order_id] = row; |
1313 |
$("#order_edit").data('kept', kept); |
1314 |
}; |
1315 |
|
1316 |
var save_row = function() { |
1317 |
keep_row(); |
1318 |
var saved = $("#order_edit").data('saved')||{}; |
1319 |
var kept = $("#order_edit").data('kept'); |
1320 |
$("#order_edit").data('saved', $.extend(saved, kept)); |
1321 |
api.draw(); |
1322 |
} |
1323 |
|
1324 |
var set_modal_buttons = function() { |
1325 |
var n = $("#order_edit").data('n'); |
1326 |
var info = api.page.info(); |
1327 |
|
1328 |
$('.modal-prev').prop('disabled', info.page == 0 && n == 0); |
1329 |
$('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n); |
1330 |
}; |
1331 |
|
1332 |
var show_subs = function(row) { |
1333 |
//$("#child_orders").show(); |
1334 |
var had_rows = false; |
1335 |
var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}}; |
1336 |
var pending_orders_url = "/api/v1/acquisitions/orders"; |
1337 |
var options = { |
1338 |
"ajax": { |
1339 |
"url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)) |
1340 |
}, |
1341 |
"header_filter": true, |
1342 |
"embed": [ |
1343 |
"invoice", |
1344 |
"basket" |
1345 |
], |
1346 |
"order": [[1, 'asc']], |
1347 |
'dom': 'C<"top pager"ilpfB>tr<"bottom pager"ip>', |
1348 |
"columns": [ |
1349 |
{ |
1350 |
"searchable": false, |
1351 |
"orderable": false, |
1352 |
"data": function(row, type, val, meta) { |
1353 |
if(row.invoice) { |
1354 |
if(CAN_user_acquisition) { |
1355 |
return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; |
1356 |
} |
1357 |
return row.invoice.invoice_number; |
1358 |
} |
1359 |
} |
1360 |
}, |
1361 |
{ |
1362 |
"data": "order_id", |
1363 |
"searchable": false, |
1364 |
"orderable": false |
1365 |
}, |
1366 |
{ |
1367 |
"searchable": false, |
1368 |
"orderable": false, |
1369 |
"data": "basket.creation_date", |
1370 |
"render": function(data, type, row, meta) { |
1371 |
return $date(row.basket.creation_date); |
1372 |
} |
1373 |
}, |
1374 |
{ |
1375 |
"searchable": false, |
1376 |
"orderable": false, |
1377 |
"data": function(row, type, val, meta) { |
1378 |
return $date(row.date_received); |
1379 |
} |
1380 |
}, |
1381 |
{ |
1382 |
"searchable": false, |
1383 |
"orderable": false, |
1384 |
"data": function(row, type, val, meta) { |
1385 |
return row.quantity_received; |
1386 |
} |
1387 |
}, |
1388 |
{ |
1389 |
"searchable": false, |
1390 |
"orderable": true, |
1391 |
"data": function(row, type, val, meta) { |
1392 |
if(!row.status) return; |
1393 |
var first_letter = row.status[0].toUpperCase(); |
1394 |
return first_letter+row.status.substr(1).toLowerCase(); |
1395 |
} |
1396 |
}, |
1397 |
{ |
1398 |
"searchable": false, |
1399 |
"orderable": false, |
1400 |
"data": function(row, type, val, meta) { |
1401 |
if(!row.date_received) return; |
1402 |
return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price() |
1403 |
} |
1404 |
}, |
1405 |
{ |
1406 |
"searchable": false, |
1407 |
"orderable": false, |
1408 |
"data": function(row, type, val, meta) { |
1409 |
return row.internal_note; |
1410 |
} |
1411 |
} |
1412 |
] |
1413 |
}; |
1414 |
var child_orders_table = $("#child_orders_table").api(options); |
1415 |
var child_api = child_orders_table.api(); |
1416 |
child_api.on('preDraw', function() { |
1417 |
if(!child_api.data().length && !had_rows) return; |
1418 |
$("#child_orders").show(); |
1419 |
had_rows = true; |
1420 |
}); |
1421 |
}; |
1422 |
|
1423 |
var set_editor = function() { |
1424 |
var modal = $("#order_edit"); |
1425 |
var row = modal.data('row'); |
1426 |
var origrec = $("#order_edit").data('origrec')||{}; |
1427 |
if(!origrec.hasOwnProperty(row.order_id)) { |
1428 |
origrec[row.order_id] = row.quantity_received; |
1429 |
$("#order_edit").data('origrec', origrec); |
1430 |
} |
1431 |
if(row.subscription_id) { |
1432 |
row.quantity_received = row.quantity; |
1433 |
} |
1434 |
var keep = $("#order_edit").data('kept'); |
1435 |
if(keep && keep[row.order_id]) { |
1436 |
row = keep[row.order_id]; |
1437 |
modal.data('row', row); |
1438 |
} |
1439 |
$('input, select, textarea', '.modal-body').val(null) |
1440 |
modal.find(".modal-title").text(MOD_TITLE.format(row.biblio.title)); |
1441 |
["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){ |
1442 |
var o = modal.find(".modal-body #biblio_"+key); |
1443 |
if(row.biblio[key] !== null) { |
1444 |
o.parent().show(); |
1445 |
o.html(row.biblio[key]); |
1446 |
} else { |
1447 |
o.parent().hide(); |
1448 |
} |
1449 |
}); |
1450 |
if(row.biblio.suggestions.length) { |
1451 |
$("#suggestion_fieldset").show(); |
1452 |
if(row.biblio.suggestions[0].suggester) { |
1453 |
$("#biblio_suggestion_suggester").parent().show(); |
1454 |
$("#biblio_suggestion_suggester") |
1455 |
.html( |
1456 |
[row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] |
1457 |
.filter(function(name){ |
1458 |
return name |
1459 |
}) |
1460 |
.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>)' |
1461 |
); |
1462 |
} else { |
1463 |
$("#biblio_suggestion_suggester").parent().hide(); |
1464 |
} |
1465 |
if(row.biblio.suggestions[0].reason) { |
1466 |
$("#suggestion_reason").show(); |
1467 |
if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { |
1468 |
$("#other_reason a").click(); |
1469 |
$("#reason").val(row.biblio.suggestions[0].reason); |
1470 |
$("#select-other_reason").val(null); |
1471 |
} else { |
1472 |
$("#reason").val("other").change(); |
1473 |
$("#select-other_reason").val(row.biblio.suggestions[0].reason); |
1474 |
} |
1475 |
|
1476 |
} else { |
1477 |
$("#suggestion_reason").hide(); |
1478 |
} |
1479 |
} else { |
1480 |
$("#suggestion_fieldset").hide(); |
1481 |
} |
1482 |
|
1483 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
1484 |
$("#datereceived").val(row.date_received||$date(new Date().toISOString())).change(); |
1485 |
$("#bookfund option[value='']").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)); |
1486 |
if(row.fund_id != row.fund.fund_id) { |
1487 |
$("#bookfund").val(row.fund_id); |
1488 |
} |
1489 |
$("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); |
1490 |
$("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')') |
1491 |
$("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id); |
1492 |
$("#quantity").val(row.quantity_received).prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); |
1493 |
$('#qtyrecerror').hide(); |
1494 |
var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; |
1495 |
$("#tax_rate").val(tax_rate).change(); |
1496 |
var rrp_txt; |
1497 |
var ecost_txt; |
1498 |
if(invoiceincgst) { |
1499 |
rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint">'+ADJ_TAX_INC.format(active_currency)+"</span>"; |
1500 |
ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint">'+TAX_INC+"</span>"; |
1501 |
$("#unitprice").val(row.unit_price_tax_included); |
1502 |
$("#unitprice_hint").html(TAX_INC); |
1503 |
} else { |
1504 |
rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint">'+ADJ_TAX_EXC.format(active_currency)+"</span>"; |
1505 |
ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint">'+TAX_EXC+"</span>"; |
1506 |
$("#unitprice").val(row.unit_price_tax_excluded); |
1507 |
$("#unitprice_hint").html(TAX_EXC); |
1508 |
} |
1509 |
$("#rrp").html(rrp_txt); |
1510 |
$("#replacementprice").val(row.replacement_price); |
1511 |
$("#ecost").html(ecost_txt); |
1512 |
$("#order_internalnote").val(row.internal_note); |
1513 |
if(row.vendor_note) { |
1514 |
$("#order_vendornote").html(row.vendor_note); |
1515 |
$("#order_vendornote").parent().show(); |
1516 |
} else { |
1517 |
$("#order_vendornote").parent().hide(); |
1518 |
} |
1519 |
|
1520 |
|
1521 |
$("#child_orders").hide(); |
1522 |
|
1523 |
$('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove(); |
1524 |
$('#items_list').hide(); |
1525 |
if(row.subscription_id) { |
1526 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
1527 |
$('#modal-order-main').tabs("enable", "#history-panel"); |
1528 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
1529 |
$('#modal-order-main').tabs( "option", "active", 0); |
1530 |
} |
1531 |
} else { |
1532 |
$('#modal-order-main').tabs("enable", "#items-panel"); |
1533 |
$('#modal-order-main').tabs("disable", "#history-panel"); |
1534 |
if($('#modal-order-main').tabs( "option", "active" ) == 2) { |
1535 |
$('#modal-order-main').tabs( "option", "active", 0); |
1536 |
} |
1537 |
if(effective_create_items == 'receiving') { |
1538 |
$("#acq-create-receiving").show(); |
1539 |
$("#acq-create-ordering").hide(); |
1540 |
if(row.items && row.items.length) { |
1541 |
row.items.forEach(function(item, index) { |
1542 |
cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) { |
1543 |
var block = $('#'+block_id).hide(); |
1544 |
Object.keys(item).forEach(function(key) { |
1545 |
block |
1546 |
.find('*[name=kohafield][value="'+key+'"]') |
1547 |
.parent() |
1548 |
.find('*[name=field_value]') |
1549 |
.val(item[key].field_value); |
1550 |
}); |
1551 |
addItemInList(block_id, '[% UniqueItemFields | html %]'); |
1552 |
block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
1553 |
block.find("input[name='buttonPlusMulti']").remove(); |
1554 |
block.find("input[name='multiValue']").remove(); |
1555 |
}); |
1556 |
}); |
1557 |
} |
1558 |
cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]'); |
1559 |
} else if (effective_create_items == 'ordering') { |
1560 |
$("#acq-create-receiving").hide(); |
1561 |
$("#acq-create-ordering").show(); |
1562 |
if(row.items.length) { |
1563 |
$("#acq-create-ordering tbody").append( |
1564 |
row.items.map(function(item) { |
1565 |
var tr = $('<tr id="item_'+item.item_id+'"/>'); |
1566 |
_build_item(item, tr); |
1567 |
return tr; |
1568 |
}) |
1569 |
); |
1570 |
} |
1571 |
} else { |
1572 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
1573 |
$('#modal-order-main').tabs( "option", "active", 0); |
1574 |
} |
1575 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
1576 |
} |
1577 |
} |
1578 |
|
1579 |
set_modal_buttons(); |
1580 |
}; |
1581 |
|
1582 |
$('.modal-prev').click(function() { |
1583 |
var modal = $("#order_edit"); |
1584 |
keep_row(); |
1585 |
var n = modal.data('n'); |
1586 |
if(n > 0) { |
1587 |
n--; |
1588 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1589 |
modal.data('n', n); |
1590 |
set_editor(); |
1591 |
} else { |
1592 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1593 |
orders_table.one('draw.dt', function() { |
1594 |
var info = api.page.info(); |
1595 |
n = info.end - info.start - 1; |
1596 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1597 |
modal.data('n', n); |
1598 |
set_editor(); |
1599 |
}); |
1600 |
api.page('previous').draw( 'page' ); |
1601 |
} |
1602 |
}); |
1603 |
|
1604 |
$('.modal-next').click(function() { |
1605 |
var modal = $("#order_edit"); |
1606 |
keep_row(); |
1607 |
var n = modal.data('n'); |
1608 |
var info = api.page.info(); |
1609 |
if(n < info.end - info.start - 1) { |
1610 |
n++; |
1611 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1612 |
modal.data('n', n); |
1613 |
set_editor(); |
1614 |
} else { |
1615 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1616 |
orders_table.one('draw.dt', function() { |
1617 |
var info = api.page.info(); |
1618 |
n = 0; |
1619 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1620 |
modal.data('n', n); |
1621 |
set_editor(); |
1622 |
}); |
1623 |
api.page('next').draw( 'page' ); |
1624 |
} |
1625 |
}); |
1626 |
|
1627 |
$('.modal-save').click(function() { |
1628 |
save_row(); |
1629 |
$("#order_edit").modal('hide'); |
1630 |
}) |
1631 |
|
1632 |
$('#modal-order-main').tabs({ |
1633 |
activate: function(event, ui) { |
1634 |
var active = ui.newPanel.attr('id') |
1635 |
if(active == 'history-panel') { |
1636 |
show_subs($("#order_edit").data('row')); |
1637 |
} |
1638 |
} |
1639 |
}); |
1640 |
|
1641 |
$("#order_edit").on("show.bs.modal", function (event) { |
1642 |
var anchor = $(event.relatedTarget); |
1643 |
var n = anchor.data("row"); |
1644 |
var row = api.row(n).data(); |
1645 |
|
1646 |
var modal = $(this); |
1647 |
modal.data('row', JSON.parse(JSON.stringify(row))); |
1648 |
modal.data('n', n); |
1649 |
modal.data('keep', modal.data('saved')||{}); |
1650 |
$('#modal-order-main').tabs("option", "active", 0); |
1651 |
set_editor(); |
1652 |
}); |
1653 |
/* $("#order_edit").on("shown.bs.modal", function() { |
1654 |
var modal = $(this); |
1655 |
|
1656 |
if(modal.data('show_subs')) show_subs(modal.data('row')); |
1657 |
});*/ |
1658 |
$("#order_edit").on("hide.bs.modal", function() { |
1659 |
$("#child_orders_table").DataTable().off('preDraw').destroy(); |
1660 |
}); |
1661 |
}); |
1662 |
[% END %] |
544 |
</script> |
1663 |
</script> |
545 |
[% END %] |
1664 |
[% END %] |
546 |
|
1665 |
|