From 2201f70a4d4861ab6f45785e3321f198ac18ba98 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi 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 | 239 +++++++++++++++++- 1 file changed, 232 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..cb9d714fce 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 @@ [% END %] +

Pending orders (api)

+ + + + + + + + + + + + + + + + + +
BasketBasket groupOrder lineSummaryMoreReplacement priceQuantityUnit costOrder costFund  
+ [% UNLESS no_orders_to_display %]

Invoice number: [% invoice | html %] Received by: [% logged_in_user.userid | html %] On: [% datereceived | $KohaDates %]

@@ -181,26 +201,26 @@ Transfer - [% IF ( loop_order.left_holds_on_order ) %] + [% IF ( loop_order.left_holds_on_order ) %] [%# DONE %] Can't cancel order
- [% ELSE %] + [% ELSE %] [%# DONE %] Cancel order
- [% END %] + [% END %] [%# DONE %] [% IF ( loop_order.can_del_bib ) %] Cancel order and catalog record
[% ELSE %] Can't cancel order and delete catalog record
[% END %] - [% IF ( loop_order.left_item ) %] + [% IF ( loop_order.left_item ) %] [%# DONE %] [% loop_order.items | html %] item(s) left
[% END %] - [% IF ( loop_order.left_biblio ) %] + [% IF ( loop_order.left_biblio ) %] [%# DONE %] [% loop_order.biblios | html %] order(s) left
[% END %] - [% IF ( loop_order.left_subscription ) %] + [% IF ( loop_order.left_subscription ) %] [%# DONE %] [% loop_order.subscriptions | html %] subscription(s) left
[% END %] - [% IF ( loop_order.left_holds ) %] + [% IF ( loop_order.left_holds ) %] [%# DONE %] [% loop_order.holds | html %] hold(s) left [% END %] @@ -533,6 +553,211 @@ })); } + var pendig_orders_tb = $("#pending_orders").api({ + "ajax": { + "url": "/api/v1/acquisitions/orders" + }, + "embed": [ + "basket.basket_group", + "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 "" + row.basket.name + " (" + data + ")"; + } + }, + { "data": function(row, type, val, meta) { + if ( type != 'display' ) return row.basket.basket_group_id; + if ( row.basket.basket_group_id == null ) { + return _("No basket group"); + } + else { + return "" + + row.basket.basket_group.name + " (" + row.basket.basket_group_id + ")"; + } + } + }, + { "data": "order_id", + "render": function(data, type, row, meta) { + if (type != 'display') return data; + return ""+data+""; + } + }, + { "data": function(row, type, val, meta) { + var result = ""+row.biblio.title+""; + 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 += "
" + _("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 += "
" + _("Suggested by: ") + + '' + + suggested_by.join(", ") + + " (#" + suggestions[0].suggestionid + ")"; + } + } + + var internal_note = row.internal_note; + if ( internal_note != '' ) { + result += '

' + + _("Internal note: ") + + '' + internal_note + + ' [' + _("Change internal note") + ']

'; + } + else { + result += ' [' + _("Add internal note") + ']'; + } + + var vendor_note = row.vendor_note; + if ( vendor_note != '' ) { + result += '

' + + _("Vendor note: ") + + '' + vendor_note + '

'; + } + else { + result += ' [' + _("Add vendor note") + ']'; + } + + return result; + } + }, + { "data": function( row, type, val, meta) { + if (type != 'display') return data; + var result = '' + _('Order') + '
' + + '' + _("MARC") + '
' + + '' + _("Card") + ''; + 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 '' + + _("Receive") + '
' + + '' + + _("Transfer") + ''; + } + }, + { + "data": function( row, type, val, meta ) { + var result = ""; + + if ( row.holds_count > 0 ) { + result += '' + + _("Can't cancel order") + '
'; + } + else { + result += '' + + _("Cancel order") + '
'; + } + + 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 += '' + + _("Can't cancel order and delete catalog record") + '
'; + } + else { + result += '' + + _("Cancel order and catalog record") + '
'; + } + + if ( row.items.length > 0 ) { + result += '' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '
'; + } + + if ( row.biblio.active_orders_count > 1 ) { + result += '' + + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '
'; + } + + if ( row.biblio.subscriptions_count > 0 ) { + result += '' + + _("%s subscription(s) left").format(row.biblio.subscriptions_count) + + '
'; + } + + if ( row.biblio.holds_count > 0 ) { + result += '' + + _("%s hold(s) left").format(row.bibio.holds_count) + ''; + } + + 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