Bugzilla – Attachment 97547 Details for
Bug 20212
Improve performance of acquisitions receive page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[WIP] Bug 20212: Use the API to render orders
WIP-Bug-20212-Use-the-API-to-render-orders.patch (text/plain), 15.97 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-01-17 16:08:06 UTC
(
hide
)
Description:
[WIP] Bug 20212: Use the API to render orders
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-01-17 16:08:06 UTC
Size:
15.97 KB
patch
obsolete
>From af865e66b3a44c281243562e96d5de57f9ee97fe Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 17 Jan 2020 13:07:34 -0300 >Subject: [PATCH] [WIP] Bug 20212: Use the API to render orders > >--- > .../prog/en/modules/acqui/parcel.tt | 240 +++++++++++++++++- > 1 file changed, 233 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index 414844397c..e39adf1b67 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -87,6 +87,26 @@ > </div> > [% END %] > >+<h3>Pending orders (api)</h3> >+<table id="pending_orders" class="table table-bordered table-striped"> >+ <thead> >+ <tr> >+ <th>Basket</th> >+ <th>Basket group</th> >+ <th>Order line</th> >+ <th>Summary</th> >+ <th>More</th> >+ <th>Replacement price</th> >+ <th>Quantity</th> >+ <th>Unit cost</th> >+ <th>Order cost</th> >+ <th>Fund</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+</table> >+ > [% UNLESS no_orders_to_display %] > <div id="acqui_receive_summary"> > <p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% logged_in_user.userid | html %] <strong>On:</strong> [% datereceived | $KohaDates %]</p> >@@ -181,26 +201,26 @@ > <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber | html %]); return false;">Transfer</a> > </td> > <td> >- [% IF ( loop_order.left_holds_on_order ) %] >+ [% IF ( loop_order.left_holds_on_order ) %] [%# DONE %] > <span class="button" title="Can't cancel order, ([% loop_order.holds_on_order | html %]) holds are linked with this order. Cancel holds first">Can't cancel order</span><br> >- [% ELSE %] >+ [% ELSE %] [%# DONE %] > <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | uri %]&biblionumber=[% loop_order.biblionumber | uri %]&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order</a><br /> >- [% END %] >+ [% END %] [%# DONE %] > [% IF ( loop_order.can_del_bib ) %] > <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | uri %]&biblionumber=[% loop_order.biblionumber | uri %]&del_biblio=1&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order and catalog record</a><br /> > [% ELSE %] > <span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br> > [% END %] >- [% IF ( loop_order.left_item ) %] >+ [% IF ( loop_order.left_item ) %] [%# DONE %] > <b title="Can't delete catalog record, because of [% loop_order.items | html %] existing item(s)" >[% loop_order.items | html %] item(s) left</b><br> > [% END %] >- [% IF ( loop_order.left_biblio ) %] >+ [% IF ( loop_order.left_biblio ) %] [%# DONE %] > <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios | html %] order(s) left</b><br> > [% END %] >- [% IF ( loop_order.left_subscription ) %] >+ [% IF ( loop_order.left_subscription ) %] [%# DONE %] > <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions | html %] subscription(s) left</b><br> > [% END %] >- [% IF ( loop_order.left_holds ) %] >+ [% IF ( loop_order.left_holds ) %] [%# DONE %] > <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds | html %] hold(s) left</b> > [% END %] > </td> >@@ -533,6 +553,212 @@ > })); > } > >+ var pendig_orders_tb = $("#pending_orders").api({ >+ "ajax": { >+ "url": "/api/v1/acquisitions/orders" >+ }, >+ "embed": [ >+ "basket", >+ "biblio.active_orders_count", >+ "biblio.holds_count", >+ "biblio.items_count", >+ "biblio.suggestions.suggester", >+ "fund", >+ "holds_count", >+ "items" >+ ], >+ 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', >+ "columnDefs": [ >+ { "targets": [ "nosort" ],"sortable": false,"searchable": false }, >+ { "type": "anti-the", "targets" : [ "anti-the" ] }, >+ { "type": "title-string", "targets" : [ "title-string" ] } >+ ], >+ "columns": [ >+ { "data": "basket_id", >+ "render": function(data, type, row, meta) { >+ if (type != 'display') return data; >+ return "<a href=\"/cgi-bin/koha/acqui/basket.pl?basketno=" + data + "\">" + row.basket.name + " (" + data + ")</a>"; >+ } >+ }, >+ { "data": "basket_group_id", >+ "render": function(data, type, row, meta) { >+ if (type != 'display') return data; >+ if ( typeof data == "undefined") { >+ return _("No basket group"); >+ } >+ else { >+ return "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=" >+ + row.basket.vendor_id + "&basketgroupid=" >+ + data + "\">" >+ + "loop_order.basketgroupname " + data + ")</a>"; >+ } >+ } >+ }, >+ { "data": "order_id", >+ "render": function(data, type, row, meta) { >+ if (type != 'display') return data; >+ return "<a href=\"neworderempty.pl?ordernumber="+data+"&booksellerid="+row.basket.vendor_id+"\">"+data+"</a>"; >+ } >+ }, >+ { "data": function(row, type, val, meta) { >+ var result = "<a href=\"opac-detail.pl?biblionumber="+row.biblio_id+"\">"+row.biblio.title+"</a>"; >+ if ( row.biblio.author != null ) >+ result += _(" by ") + row.biblio.author; >+ if ( row.biblio.isbn != null ) >+ result += " – " + row.biblio.isbn; >+ if ( row.biblio.publisher != null ) { >+ result += "<br/>" + _("Publisher: ") + row.biblio.publisher; >+ if ( row.biblio.publication_year != null ) { >+ result += ", " + row.biblio.publication_year; >+ } >+ else if ( row.biblio.copyright_date != null ) { >+ result += row.biblio.copyright_date; >+ } >+ } >+ var suggestions = row.biblio.suggestions; >+ if ( suggestions != null && suggestions.length > 0 ) { >+ var suggestion = suggestions[0]; >+ if ( suggestion.suggestor != null ) { >+ var suggestor = suggestion.suggestor; >+ var suggested_by = []; >+ if ( suggestor.surname != null ) { >+ suggested_by.push(suggestor.surname); >+ } >+ if ( suggestor.firstname != null ) { >+ suggested_by.push(suggestor.firstname); >+ } >+ >+ result += "<br/>" + _("Suggested by: ") + >+ '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' >+ + suggestion.suggestionid >+ + '&op=show">' >+ + suggested_by.join(", ") >+ + " (#" + suggestions[0].suggestionid + ")</a>"; >+ } >+ } >+ >+ var internal_note = row.internal_note; >+ if ( internal_note != '' ) { >+ result += '<p class="ordernote"><strong>' >+ + _("Internal note: ") >+ + '</strong>' + internal_note >+ + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=' >+ + row.order_id + '&referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]' >+ + '&type=internal">' + _("Change internal note") + '</a>]</p>'; >+ } >+ else { >+ result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=' >+ + row.order_id + '&referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]' >+ + '&type=internal">' + _("Add internal note") + '</a>]'; >+ } >+ >+ var vendor_note = row.vendor_note; >+ if ( vendor_note != '' ) { >+ result += '<p class="ordernote"><strong>' >+ + _("Vendor note: ") >+ + '</strong>' + vendor_note + '</p>'; >+ } >+ else { >+ result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=' >+ + row.order_id + '&referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]' >+ + '&type=vendor">' + _("Add vendor note") + '</a>]'; >+ } >+ >+ return result; >+ } >+ }, >+ { "data": function( row, type, val, meta) { >+ if (type != 'display') return data; >+ var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + row.order_id + '" class="previewData">' + _('Order') + '</a><br>' >+ + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + row.biblio_id + '" class="previewData">' + _("MARC") + '</a><br>' >+ + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=' + row.biblio_id + '" class="previewData">' + _("Card") + '</a>'; >+ return result; >+ } >+ }, >+ { "data": "replacement_price" }, >+ { "data": "quantity" }, >+ { "data": "ecost" }, >+ { "data": function ( row, type, val, meta ) { >+ return row.quantity * row.ecost; >+ } >+ }, >+ { "data": "fund_id", >+ "render": function(data, type, row, meta) { >+ if (type != 'display') return data; >+ return row.fund.name; >+ } >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ return '<a href="orderreceive.pl?ordernumber=' >+ + row.order_id + '&invoiceid=[% invoiceid | uri %]' + '">' >+ + _("Receive") + '</a><br/>' >+ + '<a href="#" onclick="transfer_order_popup(' + row.order_id + '); return false;">' >+ + _("Transfer") + '</a>'; >+ } >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ var result = ""; >+ >+ if ( row.holds_count > 0 ) { >+ result += '<span class="button" title="' >+ + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( row.holds_count ) + '">' >+ + _("Can't cancel order") + '</span><br/>'; >+ } >+ else { >+ result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=' >+ + row.order_id >+ + '&biblionumber=' + row.biblio_id >+ + '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">' >+ + _("Cancel order") + '</a><br/>'; >+ } >+ >+ if ( row.items.length > 0 || >+ row.biblio.active_orders_count > 1 || >+ row.biblio.subscriptions_count > 0 || >+ row.bibio.holds_count > 0 ) { // biblio can be deleted >+ result += '<span class="button" title="' >+ + _("Can't delete catalog record, see constraints below") + '">' >+ + _("Can't cancel order and delete catalog record") + '</span><br>'; >+ } >+ else { >+ result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=' >+ + row.order_id + '&biblionumber=' + row.biblio_id >+ + '&del_biblio=1&referrer="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[$ invoiceid | uri ]">' >+ + _("Cancel order and catalog record") + '</a><br/>'; >+ } >+ >+ if ( row.items.length > 0 ) { >+ result += '<b title="' >+ + _("Can't delete catalog record, because of %s existing item(s)").format(row.items.length) >+ +'">' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '</b><br/>'; >+ } >+ >+ if ( row.biblio.active_orders_count > 1 ) { >+ result += '<b title="' >+ + _("Can't delete catalog record, delete other orders linked to it first") + '">' >+ + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '</b><br/>'; >+ } >+ >+ if ( row.biblio.subscriptions_count > 0 ) { >+ result += '<b title="' + _("Can't delete catalog record, delete subscriptions first") + '">' >+ + _("%s subscription(s) left").format(row.biblio.subscriptions_count) >+ + '</b><br>'; >+ } >+ >+ if ( row.biblio.holds_count > 0 ) { >+ result += '<b title="' + _("Can't delete catalog record or order, cancel holds first") + '">' >+ + _("%s hold(s) left").format(row.bibio.holds_count) + '</b>'; >+ } >+ >+ return result; >+ } >+ } >+ ] >+ }); >+ >+ > // Keep filters from finishreceive.pl to parcel.pl > $.cookie("filter_parcel_summary", $("#summaryfilter").val()); > $.cookie("filter_parcel_basketname", $("#basketfilter").val()); >-- >2.25.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20212
:
97545
|
97546
|
97547
|
97629
|
97630
|
97633
|
97634
|
97635
|
97745
|
98226
|
98230
|
98241
|
99724
|
99725
|
99727
|
100142
|
100475
|
100476
|
100477
|
100478
|
100552
|
100553
|
100554
|
100555
|
100600
|
100601
|
100602
|
100603
|
100605
|
100606
|
100643
|
101320
|
103684
|
103685
|
103686
|
103687
|
103688
|
109861
|
109862
|
109863
|
109864
|
109866
|
109867
|
109868
|
109869
|
109870
|
109936
|
110229
|
110234
|
110478
|
110482
|
111568
|
111569
|
112310
|
112521
|
112522
|
112523
|
112524
|
112686
|
112695
|
112698
|
112699
|
112700
|
112702
|
112703
|
112704
|
112705
|
112706
|
112868
|
112882
|
112987
|
113278
|
113279
|
114607
|
114608
|
114609
|
114610
|
114611
|
114612
|
114613
|
114614
|
114615
|
114616
|
114617
|
114942
|
114953
|
114954
|
114956
|
114959
|
114963
|
115050
|
115056
|
115057
|
115060
|
115062
|
115107
|
115108
|
115109
|
115817
|
115818
|
115819
|
115820
|
115821
|
115822
|
115886
|
115887
|
115888
|
115889
|
115890
|
115891
|
115892
|
115893
|
115894
|
115895
|
115896
|
115897
|
115898
|
115899
|
115900
|
115901
|
115902
|
115903
|
115904
|
115905
|
115906
|
115920
|
115921
|
115940
|
115941
|
115943
|
115944
|
115945
|
115946
|
115947
|
115948
|
115949
|
115950
|
115951
|
115952
|
115953
|
115954
|
115955
|
115956
|
115957
|
115958
|
115959
|
115960
|
115961
|
115962
|
115963
|
115964
|
115965
|
116139