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 %]&sticky_filters=1">Cancel</a> |
373 |
<a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">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+"&sticky_filters=1" |
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 = ( (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 |
var row = $("#order_edit").data('row'); |
1240 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
1241 |
if(effective_create_items == 'receiving') { |
1242 |
row.tax_rate_on_receiving = val; |
1243 |
} else { |
1244 |
row.tax_rate_on_ordering = val; |
1245 |
} |
1246 |
|
1247 |
}); |
1248 |
|
1249 |
$("#order_edit").on("change", "#unitprice", function() { |
1250 |
var val = $(this).val(); |
1251 |
var row = $("#order_edit").data('row'); |
1252 |
if(invoiceincgst) { |
1253 |
row.unit_price_tax_included = val; |
1254 |
} else { |
1255 |
row.unit_price_tax_excluded = val; |
1256 |
} |
1257 |
|
1258 |
}); |
1259 |
|
1260 |
$("#order_edit").on("change", "input[name='change_currency']", function(){ |
1261 |
if ( $(this).is(":checked") ) { |
1262 |
$("#select_currency").show(); |
1263 |
$("#unitprice").prop("readonly", "true"); |
1264 |
} else { |
1265 |
$("#select_currency").hide(); |
1266 |
$("#unitprice").prop("readonly", ""); |
1267 |
} |
1268 |
}); |
1269 |
|
1270 |
function _update_unitprice() { |
1271 |
var rate = Number($("select[name='currency'] option:selected").val()); |
1272 |
var unitprice = $("#unitprice_currency").val(); |
1273 |
var new_unitprice = Number( unitprice * rate ).toFixed(2); |
1274 |
$("#unitprice").val(new_unitprice).change(); |
1275 |
} |
1276 |
$("#order_edit").on("change", "select[name='currency']", _update_unitprice ); |
1277 |
$("#order_edit").on("change", "#unitprice_currency", _update_unitprice ); |
1278 |
|
1279 |
$("#order_edit").on("change", "#replacementprice", function() { |
1280 |
var val = $(this).val(); |
1281 |
var row = $("#order_edit").data('row'); |
1282 |
row.replacement_price = val; |
1283 |
}); |
1284 |
|
1285 |
$("#order_edit").on("change", "#order_internalnote", function() { |
1286 |
var val = $(this).val(); |
1287 |
var row = $("#order_edit").data('row'); |
1288 |
row.internal_note = val; |
1289 |
|
1290 |
}); |
1291 |
|
1292 |
var keep_row = function() { |
1293 |
var row = $("#order_edit").data('row'); |
1294 |
var kept = $("#order_edit").data('kept')||{}; |
1295 |
if($('#items_list tbody tr').length) { |
1296 |
row.items = []; |
1297 |
$('#items_list tbody tr').each(function() { |
1298 |
var item = {}; |
1299 |
$('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() { |
1300 |
var kf = $(this).val(); |
1301 |
var obj = {}; |
1302 |
$(this).parent().find('*[name]').each(function() { |
1303 |
obj[$(this).prop('name')] = $(this).val(); |
1304 |
}); |
1305 |
item[kf] = obj; |
1306 |
}); |
1307 |
row.items.push(item); |
1308 |
}); |
1309 |
} |
1310 |
kept[row.order_id] = row; |
1311 |
$("#order_edit").data('kept', kept); |
1312 |
}; |
1313 |
|
1314 |
var save_row = function() { |
1315 |
keep_row(); |
1316 |
var saved = $("#order_edit").data('saved')||{}; |
1317 |
var kept = $("#order_edit").data('kept'); |
1318 |
$("#order_edit").data('saved', $.extend(saved, kept)); |
1319 |
api.draw(); |
1320 |
} |
1321 |
|
1322 |
var set_modal_buttons = function() { |
1323 |
var n = $("#order_edit").data('n'); |
1324 |
var info = api.page.info(); |
1325 |
|
1326 |
$('.modal-prev').prop('disabled', info.page == 0 && n == 0); |
1327 |
$('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n); |
1328 |
}; |
1329 |
|
1330 |
var show_subs = function(row) { |
1331 |
//$("#child_orders").show(); |
1332 |
var had_rows = false; |
1333 |
var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}}; |
1334 |
var pending_orders_url = "/api/v1/acquisitions/orders"; |
1335 |
var options = { |
1336 |
"ajax": { |
1337 |
"url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)) |
1338 |
}, |
1339 |
"header_filter": true, |
1340 |
"embed": [ |
1341 |
"invoice", |
1342 |
"basket" |
1343 |
], |
1344 |
"order": [[1, 'asc']], |
1345 |
'dom': 'C<"top pager"ilpfB>tr<"bottom pager"ip>', |
1346 |
"columns": [ |
1347 |
{ |
1348 |
"searchable": false, |
1349 |
"orderable": false, |
1350 |
"data": function(row, type, val, meta) { |
1351 |
if(row.invoice) { |
1352 |
if(CAN_user_acquisition) { |
1353 |
return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; |
1354 |
} |
1355 |
return row.invoice.invoice_number; |
1356 |
} |
1357 |
} |
1358 |
}, |
1359 |
{ |
1360 |
"data": "order_id", |
1361 |
"searchable": false, |
1362 |
"orderable": false |
1363 |
}, |
1364 |
{ |
1365 |
"searchable": false, |
1366 |
"orderable": false, |
1367 |
"data": "basket.creation_date", |
1368 |
"render": function(data, type, row, meta) { |
1369 |
return $date(row.basket.creation_date); |
1370 |
} |
1371 |
}, |
1372 |
{ |
1373 |
"searchable": false, |
1374 |
"orderable": false, |
1375 |
"data": function(row, type, val, meta) { |
1376 |
return $date(row.date_received); |
1377 |
} |
1378 |
}, |
1379 |
{ |
1380 |
"searchable": false, |
1381 |
"orderable": false, |
1382 |
"data": function(row, type, val, meta) { |
1383 |
return row.quantity_received; |
1384 |
} |
1385 |
}, |
1386 |
{ |
1387 |
"searchable": false, |
1388 |
"orderable": true, |
1389 |
"data": function(row, type, val, meta) { |
1390 |
if(!row.status) return; |
1391 |
var first_letter = row.status[0].toUpperCase(); |
1392 |
return first_letter+row.status.substr(1).toLowerCase(); |
1393 |
} |
1394 |
}, |
1395 |
{ |
1396 |
"searchable": false, |
1397 |
"orderable": false, |
1398 |
"data": function(row, type, val, meta) { |
1399 |
if(!row.date_received) return; |
1400 |
return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price() |
1401 |
} |
1402 |
}, |
1403 |
{ |
1404 |
"searchable": false, |
1405 |
"orderable": false, |
1406 |
"data": function(row, type, val, meta) { |
1407 |
return row.internal_note; |
1408 |
} |
1409 |
} |
1410 |
] |
1411 |
}; |
1412 |
var child_orders_table = $("#child_orders_table").api(options); |
1413 |
var child_api = child_orders_table.api(); |
1414 |
child_api.on('preDraw', function() { |
1415 |
if(!child_api.data().length && !had_rows) return; |
1416 |
$("#child_orders").show(); |
1417 |
had_rows = true; |
1418 |
}); |
1419 |
}; |
1420 |
|
1421 |
var set_editor = function() { |
1422 |
var modal = $("#order_edit"); |
1423 |
var row = modal.data('row'); |
1424 |
var origrec = $("#order_edit").data('origrec')||{}; |
1425 |
if(!origrec.hasOwnProperty(row.order_id)) { |
1426 |
origrec[row.order_id] = row.quantity_received; |
1427 |
$("#order_edit").data('origrec', origrec); |
1428 |
} |
1429 |
if(row.subscription_id) { |
1430 |
row.quantity_received = row.quantity; |
1431 |
} |
1432 |
var keep = $("#order_edit").data('kept'); |
1433 |
if(keep && keep[row.order_id]) { |
1434 |
row = keep[row.order_id]; |
1435 |
modal.data('row', row); |
1436 |
} |
1437 |
$('input, select, textarea', '.modal-body').val(null) |
1438 |
modal.find(".modal-title").text(MOD_TITLE.format(row.biblio.title)); |
1439 |
["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){ |
1440 |
var o = modal.find(".modal-body #biblio_"+key); |
1441 |
if(row.biblio[key] !== null) { |
1442 |
o.parent().show(); |
1443 |
o.html(row.biblio[key]); |
1444 |
} else { |
1445 |
o.parent().hide(); |
1446 |
} |
1447 |
}); |
1448 |
if(row.biblio.suggestions.length) { |
1449 |
$("#suggestion_fieldset").show(); |
1450 |
if(row.biblio.suggestions[0].suggester) { |
1451 |
$("#biblio_suggestion_suggester").parent().show(); |
1452 |
$("#biblio_suggestion_suggester") |
1453 |
.html( |
1454 |
[row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] |
1455 |
.filter(function(name){ |
1456 |
return name |
1457 |
}) |
1458 |
.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>)' |
1459 |
); |
1460 |
} else { |
1461 |
$("#biblio_suggestion_suggester").parent().hide(); |
1462 |
} |
1463 |
if(row.biblio.suggestions[0].reason) { |
1464 |
$("#suggestion_reason").show(); |
1465 |
if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { |
1466 |
$("#other_reason a").click(); |
1467 |
$("#reason").val(row.biblio.suggestions[0].reason); |
1468 |
$("#select-other_reason").val(null); |
1469 |
} else { |
1470 |
$("#reason").val("other").change(); |
1471 |
$("#select-other_reason").val(row.biblio.suggestions[0].reason); |
1472 |
} |
1473 |
|
1474 |
} else { |
1475 |
$("#suggestion_reason").hide(); |
1476 |
} |
1477 |
} else { |
1478 |
$("#suggestion_fieldset").hide(); |
1479 |
} |
1480 |
|
1481 |
var effective_create_items = row.basket.create_items || AcqCreateItem; |
1482 |
$("#datereceived").val(row.date_received||$date(new Date().toISOString())).change(); |
1483 |
$("#bookfund option[value='']").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)); |
1484 |
if(row.fund_id != row.fund.fund_id) { |
1485 |
$("#bookfund").val(row.fund_id); |
1486 |
} |
1487 |
$("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); |
1488 |
$("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')') |
1489 |
$("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id); |
1490 |
$("#quantity").val(row.quantity_received).prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); |
1491 |
$('#qtyrecerror').hide(); |
1492 |
var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; |
1493 |
$("#tax_rate").val(tax_rate).change(); |
1494 |
var rrp_txt; |
1495 |
var ecost_txt; |
1496 |
if(invoiceincgst) { |
1497 |
rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint">'+ADJ_TAX_INC.format(active_currency)+"</span>"; |
1498 |
ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint">'+TAX_INC+"</span>"; |
1499 |
$("#unitprice").val(row.unit_price_tax_included); |
1500 |
$("#unitprice_hint").html(TAX_INC); |
1501 |
} else { |
1502 |
rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint">'+ADJ_TAX_EXC.format(active_currency)+"</span>"; |
1503 |
ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint">'+TAX_EXC+"</span>"; |
1504 |
$("#unitprice").val(row.unit_price_tax_excluded); |
1505 |
$("#unitprice_hint").html(TAX_EXC); |
1506 |
} |
1507 |
$("#rrp").html(rrp_txt); |
1508 |
$("#replacementprice").val(row.replacement_price); |
1509 |
$("#ecost").html(ecost_txt); |
1510 |
$("#order_internalnote").val(row.internal_note); |
1511 |
if(row.vendor_note) { |
1512 |
$("#order_vendornote").html(row.vendor_note); |
1513 |
$("#order_vendornote").parent().show(); |
1514 |
} else { |
1515 |
$("#order_vendornote").parent().hide(); |
1516 |
} |
1517 |
|
1518 |
|
1519 |
$("#child_orders").hide(); |
1520 |
|
1521 |
$('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove(); |
1522 |
$('#items_list').hide(); |
1523 |
if(row.subscription_id) { |
1524 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
1525 |
$('#modal-order-main').tabs("enable", "#history-panel"); |
1526 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
1527 |
$('#modal-order-main').tabs( "option", "active", 0); |
1528 |
} |
1529 |
} else { |
1530 |
$('#modal-order-main').tabs("enable", "#items-panel"); |
1531 |
$('#modal-order-main').tabs("disable", "#history-panel"); |
1532 |
if($('#modal-order-main').tabs( "option", "active" ) == 2) { |
1533 |
$('#modal-order-main').tabs( "option", "active", 0); |
1534 |
} |
1535 |
if(effective_create_items == 'receiving') { |
1536 |
$("#acq-create-receiving").show(); |
1537 |
$("#acq-create-ordering").hide(); |
1538 |
if(row.items && row.items.length) { |
1539 |
row.items.forEach(function(item, index) { |
1540 |
cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) { |
1541 |
var block = $('#'+block_id).hide(); |
1542 |
Object.keys(item).forEach(function(key) { |
1543 |
block |
1544 |
.find('*[name=kohafield][value="'+key+'"]') |
1545 |
.parent() |
1546 |
.find('*[name=field_value]') |
1547 |
.val(item[key].field_value); |
1548 |
}); |
1549 |
addItemInList(block_id, '[% UniqueItemFields | html %]'); |
1550 |
block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
1551 |
block.find("input[name='buttonPlusMulti']").remove(); |
1552 |
block.find("input[name='multiValue']").remove(); |
1553 |
}); |
1554 |
}); |
1555 |
} |
1556 |
cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]'); |
1557 |
} else if (effective_create_items == 'ordering') { |
1558 |
$("#acq-create-receiving").hide(); |
1559 |
$("#acq-create-ordering").show(); |
1560 |
if(row.items.length) { |
1561 |
$("#acq-create-ordering tbody").append( |
1562 |
row.items.map(function(item) { |
1563 |
var tr = $('<tr id="item_'+item.item_id+'"/>'); |
1564 |
_build_item(item, tr); |
1565 |
return tr; |
1566 |
}) |
1567 |
); |
1568 |
} |
1569 |
} else { |
1570 |
if($('#modal-order-main').tabs( "option", "active" ) == 3) { |
1571 |
$('#modal-order-main').tabs( "option", "active", 0); |
1572 |
} |
1573 |
$('#modal-order-main').tabs("disable", "#items-panel"); |
1574 |
} |
1575 |
} |
1576 |
|
1577 |
set_modal_buttons(); |
1578 |
}; |
1579 |
|
1580 |
$('.modal-prev').click(function() { |
1581 |
var modal = $("#order_edit"); |
1582 |
keep_row(); |
1583 |
var n = modal.data('n'); |
1584 |
if(n > 0) { |
1585 |
n--; |
1586 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1587 |
modal.data('n', n); |
1588 |
set_editor(); |
1589 |
} else { |
1590 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1591 |
orders_table.one('draw.dt', function() { |
1592 |
var info = api.page.info(); |
1593 |
n = info.end - info.start - 1; |
1594 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1595 |
modal.data('n', n); |
1596 |
set_editor(); |
1597 |
}); |
1598 |
api.page('previous').draw( 'page' ); |
1599 |
} |
1600 |
}); |
1601 |
|
1602 |
$('.modal-next').click(function() { |
1603 |
var modal = $("#order_edit"); |
1604 |
keep_row(); |
1605 |
var n = modal.data('n'); |
1606 |
var info = api.page.info(); |
1607 |
if(n < info.end - info.start - 1) { |
1608 |
n++; |
1609 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1610 |
modal.data('n', n); |
1611 |
set_editor(); |
1612 |
} else { |
1613 |
$('.modal-next, .modal-prev').prop('disabled', true); |
1614 |
orders_table.one('draw.dt', function() { |
1615 |
var info = api.page.info(); |
1616 |
n = 0; |
1617 |
modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); |
1618 |
modal.data('n', n); |
1619 |
set_editor(); |
1620 |
}); |
1621 |
api.page('next').draw( 'page' ); |
1622 |
} |
1623 |
}); |
1624 |
|
1625 |
$('.modal-save').click(function() { |
1626 |
save_row(); |
1627 |
$("#order_edit").modal('hide'); |
1628 |
}) |
1629 |
|
1630 |
$('#modal-order-main').tabs({ |
1631 |
activate: function(event, ui) { |
1632 |
var active = ui.newPanel.attr('id') |
1633 |
if(active == 'history-panel') { |
1634 |
show_subs($("#order_edit").data('row')); |
1635 |
} |
1636 |
} |
1637 |
}); |
1638 |
|
1639 |
$("#order_edit").on("show.bs.modal", function (event) { |
1640 |
var anchor = $(event.relatedTarget); |
1641 |
var n = anchor.data("row"); |
1642 |
var row = api.row(n).data(); |
1643 |
|
1644 |
var modal = $(this); |
1645 |
modal.data('row', JSON.parse(JSON.stringify(row))); |
1646 |
modal.data('n', n); |
1647 |
modal.data('keep', modal.data('saved')||{}); |
1648 |
$('#modal-order-main').tabs("option", "active", 0); |
1649 |
set_editor(); |
1650 |
}); |
1651 |
/* $("#order_edit").on("shown.bs.modal", function() { |
1652 |
var modal = $(this); |
1653 |
|
1654 |
if(modal.data('show_subs')) show_subs(modal.data('row')); |
1655 |
});*/ |
1656 |
$("#order_edit").on("hide.bs.modal", function() { |
1657 |
$("#child_orders_table").DataTable().off('preDraw').destroy(); |
1658 |
}); |
1659 |
}); |
1660 |
[% END %] |
544 |
</script> |
1661 |
</script> |
545 |
[% END %] |
1662 |
[% END %] |
546 |
|
1663 |
|