Bugzilla – Attachment 112646 Details for
Bug 8179
Receiving multiple order lines at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8179: Receive multiple orders
Bug-8179-Receive-multiple-orders.patch (text/plain), 106.88 KB, created by
Agustín Moyano
on 2020-10-28 14:47:04 UTC
(
hide
)
Description:
Bug 8179: Receive multiple orders
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-10-28 14:47:04 UTC
Size:
106.88 KB
patch
obsolete
>From abaa9692f8c37513980b90794134c77a85896f76 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 9 Oct 2020 13:38:46 -0300 >Subject: [PATCH] Bug 8179: Receive multiple orders > >This patch implements the code to allow a patron to receive multiple >orders at the same time in /cgi-bin/koha/acqui/orderreceive.pl page > >To test: >1. apply all patches >2. updatedatabase >3. Go to system preferences and allow AcqReceiveMultipleOrderLines >4. In acquisitions module, create a vendor if you don't have one and add > 3 baskets.. one with create items on ordering, one with create items > on receiving and finally one with create items when cataloguing >5. Fill baskets with orders (There should be at least 15 orders in total). There should be a mix of orders created by suggestions, others by subscriptions and others by neither of those methods. >6. Close all baskets and receive shipment. >CHECK => in /cgi-bin/koha/acqui/parcel.pl page, in top table there is a column with checkboxes, and a button that says "Receive selected" >7. If all orders from all baskets are shown in the table, set the rows per page to 10, so table has more than one page >8. Check some of the checkboxes >CHECK => "Receive selected" button shows how many rows are selected >9. Go to the next page and select some more rows >CHECK => Changing page does not modify how many rows where selected >10. Go back to previous page >CHECK => Previously selected rows are still selected >11. Reload the page to deselect all rows >12. Select only one row and click on "Receive selected" button >CHECK => the page /cgi-bin/koha/acqui/orderreceive.pl behaves just the same as if the "receive" link in the selected row would have been clicked. >13. Click on cancel to go back to parcel.pl page >14. Select all rows (even the ones from the next page of the table) and > click on "Receive selected" >CHECH => In orderreceive.pl page there is a table with all selected rows >15. Ensure table has more than one page, as in step 7 >16. Click on the "edit" link in the last row of the current page >CHECK => A modal window is displayed with 4 tabs within: Info, >Accounting, Receipt history and Items >CHECK => Modal has 4 buttons at the bottom, 'Previous' to go to previos >order, 'Cancel' to close the modal without keeping modifications, 'Save' >to close modal keeping modifications and 'Next' to go to the next order >CHECK => Even that we are at the end of the current page, 'Next' button >is still available >17. Click on 'Next' button >CHECK => The table behind the modal now displays the next page, and the modal was not closed >18. Click on 'Previous' >CHECK => The table behind the modal went back to the first page, and the modal was not closed >19. Click on 'Previous' button till you reach the first row of the first > page >CHECK => Only when you reach the first row of the first page 'Previous' >button gets disabled >20. Click on 'Next' button till you reach the last row of the last page >CHECK => Only when you reach the last button of the last page 'Next' >button gets disabled >21. Check that behaviour for the different types of order are still the > same > a. For orders that where created through suggestion, check that the >suggestion info is present in Info tab. If when suggestion was accepted >you set a reason, a dropdown to change the reason shoul display also. > b. For orders that where created through subscriptions, check that >the Items tab is disabled, and the Receipt history is enabled. On >accounting tab you should be able to change quantity ordered. If there >were less items received than ordered, the next time you receive this >order the child order generated from this one shoul appear in receipt >history. > c. For orders that don't come from subscription and creates there items on ordering, Receipt history >should be disabled, and a table with prefilled items shold appear in the >Items tab. You can edit them and the changes should appear in the item's >row. > d. For orders that don't come from subscription and creates there >items on receiving, Receipt history should be disabled, and a form to >create the items should appear in Items tab. When you add an item a >table should appear. > e. For orders that don't come from subscription and creates there >ites on cataloguing, Receipt history and Items tabs should be disabled. > f. Any changes made in quantity (received or ordered) or funds in the modal should be >reflected in the table if you click save from the modal. >22. Once you've done all you checking and verifications click save >23. While saving a progress bar should appear >24. If no error was detected, you should be redirected back to parcel.pl > page >25. If an error or warning was detected (like there is an order with 0 > items to receive) the save button should be disabled and warnings >are dispayed. >26. prove t/db_dependent/Koha/Acquisition/Fund.t t/db_dependent/Koha/Acquisitoin/Order.t t/db_dependent/Koha/Item.t >--- > Koha/Acquisition/Fund.pm | 15 + > Koha/Acquisition/Order.pm | 15 + > Koha/Item.pm | 27 + > Koha/REST/V1/Acquisitions/Orders.pm | 2 +- > Koha/REST/V1/Items.pm | 7 +- > Koha/Schema/Result/Aqorder.pm | 20 + > acqui/finishreceive.pl | 2 + > acqui/orderreceive.pl | 98 +- > api/v1/swagger/definitions/item.json | 12 + > api/v1/swagger/definitions/order.json | 9 + > api/v1/swagger/paths/acquisitions_orders.json | 7 +- > api/v1/swagger/paths/items.json | 7 +- > .../lib/datatables/dataTables.select.min.js | 38 + > .../lib/datatables/select.dataTables.min.css | 1 + > .../prog/en/includes/datatables.inc | 1 + > .../prog/en/includes/doc-head-close.inc | 1 + > .../prog/en/modules/acqui/orderreceive.tt | 1129 ++++++++++++++++- > .../prog/en/modules/acqui/parcel.tt | 145 ++- > 18 files changed, 1452 insertions(+), 84 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js > create mode 100644 koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css > >diff --git a/Koha/Acquisition/Fund.pm b/Koha/Acquisition/Fund.pm >index d32f46af6b..b1ff6fb3aa 100644 >--- a/Koha/Acquisition/Fund.pm >+++ b/Koha/Acquisition/Fund.pm >@@ -18,6 +18,7 @@ package Koha::Acquisition::Fund; > use Modern::Perl; > > use Koha::Database; >+use Koha::Acquisition::Budget; > > use base qw(Koha::Object); > >@@ -29,6 +30,20 @@ Koha::Acquisition::Fund object class > > =head2 Class methods > >+=head3 budget >+ >+ my $budget = $fund->budget; >+ >+Returns budget this fund belongs to >+ >+=cut >+ >+sub budget { >+ my ( $self ) = @_; >+ my $budget_rs = $self->_result->budget; >+ return Koha::Acquisition::Budget->_new_from_dbic( $budget_rs ); >+} >+ > =head3 to_api > > my $json = $fund->to_api; >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 07dea68939..f07629c265 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -32,6 +32,7 @@ use Koha::Exceptions::Object; > use Koha::Biblios; > use Koha::Holds; > use Koha::Items; >+use Koha::Patron; > use Koha::Subscriptions; > > use base qw(Koha::Object); >@@ -394,6 +395,20 @@ sub claimed_date { > return $last_claim->claimed_on; > } > >+=head3 creator >+ >+my $creator = $order->creator; >+ >+Retrieves patron that created this order. >+ >+=cut >+ >+sub creator { >+ my ( $self ) = @_; >+ my $creator_rs = $self->_result->creator; >+ return Koha::Patron->_new_from_dbic( $creator_rs ); >+} >+ > =head3 duplicate_to > > my $duplicated_order = $order->duplicate_to($basket, [$default_values]); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index bedf4d1856..29e6c69dca 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -45,6 +45,8 @@ use Koha::Plugins; > use Koha::Libraries; > use Koha::StockRotationItem; > use Koha::StockRotationRotas; >+use Koha::MarcSubfieldStructures; >+use Koha::AuthorisedValues; > > use base qw(Koha::Object); > >@@ -1006,6 +1008,31 @@ sub _after_item_action_hooks { > ); > } > >+=head3 _fetch_authorised_values >+ >+Retrieves for each column name the unblessed authorised value. >+ >+=cut >+ >+sub _fetch_authorised_values { >+ my ($self, $av_expand) = @_; >+ >+ my $columns_info = $self->_result->result_source->columns_info; >+ my $framworkcode = $self->biblio->frameworkcode; >+ # Handle not null and default values for integers and dates >+ my $avs = {}; >+ foreach my $col ( keys %{$columns_info} ) { >+ next unless defined $self->$col; >+ my $field = $self->_result->result_source->name.'.'.$col; >+ my $mss = Koha::MarcSubfieldStructures->find({frameworkcode => $framworkcode, kohafield => $field}); >+ if ($mss && $mss->authorised_value) { >+ my $av = Koha::AuthorisedValues->find({category => $mss->authorised_value, authorised_value => $self->$col}); >+ $avs->{$col} = $av->unblessed if $av; >+ }; >+ } >+ return $avs; >+} >+ > =head3 _type > > =cut >diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm >index 3fb9b28b22..a553fa4544 100644 >--- a/Koha/REST/V1/Acquisitions/Orders.pm >+++ b/Koha/REST/V1/Acquisitions/Orders.pm >@@ -159,7 +159,7 @@ sub list { > > return $c->render( > status => 200, >- openapi => $orders->to_api({ embed => $embed }) >+ openapi => $orders->to_api({ embed => $embed, av_expand => $c->req->headers->header('x-koha-av') }) > ); > } > catch { >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 4781024b36..1fb0738adf 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -66,16 +66,19 @@ sub get { > my $c = shift->openapi->valid_input or return; > > try { >- my $item = Koha::Items->find($c->validation->param('item_id')); >+ my $items_set = Koha::Items->new; >+ my $id = $c->validation->param('item_id'); >+ my $item = $c->objects->find( $items_set, $id ); > unless ( $item ) { > return $c->render( > status => 404, > openapi => { error => 'Item not found'} > ); > } >- return $c->render( status => 200, openapi => $item->to_api ); >+ return $c->render( status => 200, openapi => $item ); > } > catch { >+ print $_->message; > $c->unhandled_exception($_); > }; > } >diff --git a/Koha/Schema/Result/Aqorder.pm b/Koha/Schema/Result/Aqorder.pm >index f873aa6da3..b567e5338d 100644 >--- a/Koha/Schema/Result/Aqorder.pm >+++ b/Koha/Schema/Result/Aqorder.pm >@@ -706,6 +706,26 @@ __PACKAGE__->belongs_to( > }, > ); > >+=head2 creator >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Borrower> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "creator", >+ "Koha::Schema::Result::Borrower", >+ { borrowernumber => "created_by" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "SET NULL", >+ on_update => "CASCADE", >+ }, >+); >+ > __PACKAGE__->belongs_to( > "subscription", > "Koha::Schema::Result::Subscription", >diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl >index 0ed88506c7..d77520a4b3 100755 >--- a/acqui/finishreceive.pl >+++ b/acqui/finishreceive.pl >@@ -73,6 +73,7 @@ if (C4::Context->preference("CurrencyFormat") eq 'FR') { > $unitprice = Koha::Number::Price->new( $unitprice )->unformat(); > $replacementprice = Koha::Number::Price->new( $replacementprice )->unformat(); > my $order_obj = Koha::Acquisition::Orders->find( $ordernumber ); >+ > my $basket = $order_obj->basket; > > #need old receivedate if we update the order, parcel.pl only shows the right parcel this way FIXME >@@ -116,6 +117,7 @@ if ($quantityrec > $origquantityrec ) { > # Quantity can only be modified if linked to a subscription > $order->{quantity} = $quantity; # quantityrec will be deduced from this value in ModReceiveOrder > } >+ > ( $datereceived, $new_ordernumber ) = ModReceiveOrder( > { > biblionumber => $biblionumber, >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index d3902de3bd..017834679a 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -87,6 +87,7 @@ my $invoice = GetInvoice($invoiceid); > my $booksellerid = $invoice->{booksellerid}; > my $freight = $invoice->{shipmentcost}; > my $ordernumber = $input->param('ordernumber'); >+my $multiple_orders = $input->param('multiple_orders'); > > my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); > my $order = Koha::Acquisition::Orders->find( $ordernumber ); >@@ -101,13 +102,61 @@ my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( > } > ); > >-unless ( $order ) { >+unless ( $order || $multiple_orders ) { > output_html_with_http_headers $input, $cookie, $template->output; > exit; > } > >-# prepare the form for receiving >-my $basket = $order->basket; >+my $budget; >+if( $order ) { >+ # prepare the form for receiving >+ my $creator = Koha::Patrons->find( $order->created_by ); >+ >+ $budget = GetBudget( $order->budget_id ); >+ >+ my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string; >+ >+ my $order_internalnote = $order->order_internalnote; >+ my $order_vendornote = $order->order_vendornote; >+ if ( $order->subscriptionid ) { >+ # Order from a subscription, we will display an history of what has been received >+ my $orders = Koha::Acquisition::Orders->search( >+ { >+ subscriptionid => $order->subscriptionid, >+ parent_ordernumber => $order->ordernumber, >+ ordernumber => { '!=' => $order->ordernumber } >+ } >+ ); >+ if ( $order->parent_ordernumber != $order->ordernumber ) { >+ my $parent_order = Koha::Acquisition::Orders->find($order->parent_ordernumber); >+ $order_internalnote = $parent_order->order_internalnote; >+ $order_vendornote = $parent_order->order_vendornote; >+ } >+ $template->param( >+ orders => $orders, >+ ); >+ } >+ >+ my $suggestion = GetSuggestionInfoFromBiblionumber($order->biblionumber); >+ >+ if ( $suggestion ) { >+ $template->param( suggestion => $suggestion ); >+ } >+ >+ $template->param( >+ order => $order, >+ creator => $creator, >+ bookfund => $budget->{budget_name}, >+ datereceived => $datereceived, >+ order_internalnote => $order_internalnote, >+ order_vendornote => $order_vendornote, >+ ); >+} >+ >+if( $multiple_orders ) { >+ $template->param(multiple_orders => $multiple_orders); >+} >+ > my $currencies = Koha::Acquisition::Currencies->search; > my $active_currency = $currencies->get_active; > >@@ -117,66 +166,27 @@ unless($acq_fw) { > $template->param('NoACQframework' => 1); > } > >- >-my $creator = Koha::Patrons->find( $order->created_by ); >- >-my $budget = GetBudget( $order->budget_id ); >- >-my $datereceived = $order->datereceived ? dt_from_string( $order->datereceived ) : dt_from_string; >- > # get option values for gist syspref > my @gst_values = map { > option => $_ + 0.0 > }, split( '\|', C4::Context->preference("gist") ); > >-my $order_internalnote = $order->order_internalnote; >-my $order_vendornote = $order->order_vendornote; >-if ( $order->subscriptionid ) { >- # Order from a subscription, we will display an history of what has been received >- my $orders = Koha::Acquisition::Orders->search( >- { >- subscriptionid => $order->subscriptionid, >- parent_ordernumber => $order->ordernumber, >- ordernumber => { '!=' => $order->ordernumber } >- } >- ); >- if ( $order->parent_ordernumber != $order->ordernumber ) { >- my $parent_order = Koha::Acquisition::Orders->find($order->parent_ordernumber); >- $order_internalnote = $parent_order->order_internalnote; >- $order_vendornote = $parent_order->order_vendornote; >- } >- $template->param( >- orders => $orders, >- ); >-} >- > $template->param( >- order => $order, > freight => $freight, > name => $bookseller->name, > active_currency => $active_currency, > currencies => scalar $currencies->search({ rate => { '!=' => 1 } }), > invoiceincgst => $bookseller->invoiceincgst, >- bookfund => $budget->{budget_name}, >- creator => $creator, > invoiceid => $invoice->{invoiceid}, > invoice => $invoice->{invoicenumber}, >- datereceived => $datereceived, >- order_internalnote => $order_internalnote, >- order_vendornote => $order_vendornote, > gst_values => \@gst_values, > ); > >-my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); >-if ( $suggestion ) { >- $template->param( suggestion => $suggestion ); >-} >- > my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; > my @budget_loop; > my $periods = GetBudgetPeriods( ); > foreach my $period (@$periods) { >- if ($period->{'budget_period_id'} == $budget->{'budget_period_id'}) { >+ if ($budget && $period->{'budget_period_id'} == $budget->{'budget_period_id'}) { > $template->{'VARS'}->{'budget_period_description'} = $period->{'budget_period_description'}; > } > next if $period->{'budget_period_locked'} || !$period->{'budget_period_description'}; >@@ -191,7 +201,7 @@ foreach my $period (@$periods) { > { > b_id => $r->{budget_id}, > b_txt => $r->{budget_name}, >- b_sel => ( $r->{budget_id} == $order->{budget_id} ) ? 1 : 0, >+ b_sel => ( $order && $r->{budget_id} == $order->{budget_id} ) ? 1 : 0, > }; > } > >diff --git a/api/v1/swagger/definitions/item.json b/api/v1/swagger/definitions/item.json >index 14c110714e..53111bb9bd 100644 >--- a/api/v1/swagger/definitions/item.json >+++ b/api/v1/swagger/definitions/item.json >@@ -180,6 +180,18 @@ > "exclude_from_local_holds_priority": { > "type": "boolean", > "description": "Exclude this item from local holds priority." >+ }, >+ "home_branch": { >+ "type": ["object", "null"] >+ }, >+ "holding_branch": { >+ "type": ["object", "null"] >+ }, >+ "itemtype": { >+ "type": ["object", "null"] >+ }, >+ "_authorised_values": { >+ "type": ["object", "null"] > } > }, > "additionalProperties": false, >diff --git a/api/v1/swagger/definitions/order.json b/api/v1/swagger/definitions/order.json >index 482decb1f1..f5fa90e62f 100644 >--- a/api/v1/swagger/definitions/order.json >+++ b/api/v1/swagger/definitions/order.json >@@ -329,6 +329,15 @@ > "object", > "null" > ] >+ }, >+ "creator": { >+ "type": [ >+ "object", >+ "null" >+ ] >+ }, >+ "_authorised_values": { >+ "type": "object" > } > }, > "additionalProperties": false >diff --git a/api/v1/swagger/paths/acquisitions_orders.json b/api/v1/swagger/paths/acquisitions_orders.json >index 3812f2cf66..95858d7763 100644 >--- a/api/v1/swagger/paths/acquisitions_orders.json >+++ b/api/v1/swagger/paths/acquisitions_orders.json >@@ -124,10 +124,15 @@ > "biblio.items+count", > "biblio.suggestions.suggester", > "fund", >+ "fund.budget", > "current_item_level_holds+count", > "invoice", > "items", >- "subscription" >+ "items.home_branch", >+ "items.holding_branch", >+ "items.itemtype", >+ "subscription", >+ "creator" > ] > }, > "post": { >diff --git a/api/v1/swagger/paths/items.json b/api/v1/swagger/paths/items.json >index 86197eadf1..2f3569d01b 100644 >--- a/api/v1/swagger/paths/items.json >+++ b/api/v1/swagger/paths/items.json >@@ -122,7 +122,12 @@ > "permissions": { > "catalogue": "1" > } >- } >+ }, >+ "x-koha-embed": [ >+ "itemtype", >+ "home_branch", >+ "holding_branch" >+ ] > } > } > } >diff --git a/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js b/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js >new file mode 100644 >index 0000000000..3765f6ce5d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js >@@ -0,0 +1,38 @@ >+/*! >+ Copyright 2015-2019 SpryMedia Ltd. >+ >+ This source file is free software, available under the following license: >+ MIT license - http://datatables.net/license/mit >+ >+ This source file is distributed in the hope that it will be useful, but >+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY >+ or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. >+ >+ For details please refer to: http://www.datatables.net/extensions/select >+ Select for DataTables 1.3.1 >+ 2015-2019 SpryMedia Ltd - datatables.net/license/mit >+*/ >+(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(k){return f(k,window,document)}):"object"===typeof exports?module.exports=function(k,p){k||(k=window);p&&p.fn.dataTable||(p=require("datatables.net")(k,p).$);return f(p,k,k.document)}:f(jQuery,window,document)})(function(f,k,p,h){function z(a,b,c){var d=function(c,b){if(c>b){var d=b;b=c;c=d}var e=!1;return a.columns(":visible").indexes().filter(function(a){a===c&&(e=!0);return a===b?(e=!1,!0):e})};var e= >+function(c,b){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(c)>d.indexOf(b)){var e=b;b=c;c=e}var f=!1;return d.filter(function(a){a===c&&(f=!0);return a===b?(f=!1,!0):f})};a.cells({selected:!0}).any()||c?(d=d(c.column,b.column),c=e(c.row,b.row)):(d=d(0,b.column),c=e(0,b.row));c=a.cells(c,d).flatten();a.cells(b,{selected:!0}).any()?a.cells(c).deselect():a.cells(c).select()}function v(a){var b=a.settings()[0]._select.selector;f(a.table().container()).off("mousedown.dtSelect",b).off("mouseup.dtSelect", >+b).off("click.dtSelect",b);f("body").off("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"))}function A(a){var b=f(a.table().container()),c=a.settings()[0],d=c._select.selector,e;b.on("mousedown.dtSelect",d,function(a){if(a.shiftKey||a.metaKey||a.ctrlKey)b.css("-moz-user-select","none").one("selectstart.dtSelect",d,function(){return!1});k.getSelection&&(e=k.getSelection())}).on("mouseup.dtSelect",d,function(){b.css("-moz-user-select","")}).on("click.dtSelect",d,function(c){var b= >+a.select.items();if(e){var d=k.getSelection();if((!d.anchorNode||f(d.anchorNode).closest("table")[0]===a.table().node())&&d!==e)return}d=a.settings()[0];var l=f.trim(a.settings()[0].oClasses.sWrapper).replace(/ +/g,".");if(f(c.target).closest("div."+l)[0]==a.table().container()&&(l=a.cell(f(c.target).closest("td, th")),l.any())){var g=f.Event("user-select.dt");m(a,g,[b,l,c]);g.isDefaultPrevented()||(g=l.index(),"row"===b?(b=g.row,w(c,a,d,"row",b)):"column"===b?(b=l.index().column,w(c,a,d,"column", >+b)):"cell"===b&&(b=l.index(),w(c,a,d,"cell",b)),d._select_lastCell=g)}});f("body").on("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"),function(b){!c._select.blurable||f(b.target).parents().filter(a.table().container()).length||0===f(b.target).parents("html").length||f(b.target).parents("div.DTE").length||r(c,!0)})}function m(a,b,c,d){if(!d||a.flatten().length)"string"===typeof b&&(b+=".dt"),c.unshift(a),f(a.table().node()).trigger(b,c)}function B(a){var b=a.settings()[0];if(b._select.info&& >+b.aanFeatures.i&&"api"!==a.select.style()){var c=a.rows({selected:!0}).flatten().length,d=a.columns({selected:!0}).flatten().length,e=a.cells({selected:!0}).flatten().length,l=function(b,c,d){b.append(f('<span class="select-item"/>').append(a.i18n("select."+c+"s",{_:"%d "+c+"s selected",0:"",1:"1 "+c+" selected"},d)))};f.each(b.aanFeatures.i,function(b,a){a=f(a);b=f('<span class="select-info"/>');l(b,"row",c);l(b,"column",d);l(b,"cell",e);var g=a.children("span.select-info");g.length&&g.remove(); >+""!==b.text()&&a.append(b)})}}function D(a){var b=new g.Api(a);a.aoRowCreatedCallback.push({fn:function(b,d,e){d=a.aoData[e];d._select_selected&&f(b).addClass(a._select.className);b=0;for(e=a.aoColumns.length;b<e;b++)(a.aoColumns[b]._select_selected||d._selected_cells&&d._selected_cells[b])&&f(d.anCells[b]).addClass(a._select.className)},sName:"select-deferRender"});b.on("preXhr.dt.dtSelect",function(){var a=b.rows({selected:!0}).ids(!0).filter(function(b){return b!==h}),d=b.cells({selected:!0}).eq(0).map(function(a){var c= >+b.row(a.row).id(!0);return c?{row:c,column:a.column}:h}).filter(function(b){return b!==h});b.one("draw.dt.dtSelect",function(){b.rows(a).select();d.any()&&d.each(function(a){b.cells(a.row,a.column).select()})})});b.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt",function(){B(b)});b.on("destroy.dtSelect",function(){v(b);b.off(".dtSelect")})}function C(a,b,c,d){var e=a[b+"s"]({search:"applied"}).indexes();d=f.inArray(d,e);var g=f.inArray(c,e);if(a[b+"s"]({selected:!0}).any()|| >+-1!==d){if(d>g){var u=g;g=d;d=u}e.splice(g+1,e.length);e.splice(0,d)}else e.splice(f.inArray(c,e)+1,e.length);a[b](c,{selected:!0}).any()?(e.splice(f.inArray(c,e),1),a[b+"s"](e).deselect()):a[b+"s"](e).select()}function r(a,b){if(b||"single"===a._select.style)a=new g.Api(a),a.rows({selected:!0}).deselect(),a.columns({selected:!0}).deselect(),a.cells({selected:!0}).deselect()}function w(a,b,c,d,e){var f=b.select.style(),g=b.select.toggleable(),h=b[d](e,{selected:!0}).any();if(!h||g)"os"===f?a.ctrlKey|| >+a.metaKey?b[d](e).select(!h):a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):(a=b[d+"s"]({selected:!0}),h&&1===a.flatten().length?b[d](e).deselect():(a.deselect(),b[d](e).select())):"multi+shift"==f?a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):b[d](e).select(!h):b[d](e).select(!h)}function t(a,b){return function(c){return c.i18n("buttons."+a,b)}}function x(a){a=a._eventNamespace; >+return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}function E(a,b){return-1!==f.inArray("rows",b.limitTo)&&a.rows({selected:!0}).any()||-1!==f.inArray("columns",b.limitTo)&&a.columns({selected:!0}).any()||-1!==f.inArray("cells",b.limitTo)&&a.cells({selected:!0}).any()?!0:!1}var g=f.fn.dataTable;g.select={};g.select.version="1.3.1";g.select.init=function(a){var b=a.settings()[0],c=b.oInit.select,d=g.defaults.select;c=c===h?d:c;d="row";var e="api",l=!1,u=!0,k=!0,m="td, th",p="selected",n=!1; >+b._select={};!0===c?(e="os",n=!0):"string"===typeof c?(e=c,n=!0):f.isPlainObject(c)&&(c.blurable!==h&&(l=c.blurable),c.toggleable!==h&&(u=c.toggleable),c.info!==h&&(k=c.info),c.items!==h&&(d=c.items),e=c.style!==h?c.style:"os",n=!0,c.selector!==h&&(m=c.selector),c.className!==h&&(p=c.className));a.select.selector(m);a.select.items(d);a.select.style(e);a.select.blurable(l);a.select.toggleable(u);a.select.info(k);b._select.className=p;f.fn.dataTable.ext.order["select-checkbox"]=function(b,a){return this.api().column(a, >+{order:"index"}).nodes().map(function(a){return"row"===b._select.items?f(a).parent().hasClass(b._select.className):"cell"===b._select.items?f(a).hasClass(b._select.className):!1})};!n&&f(a.table().node()).hasClass("selectable")&&a.select.style("os")};f.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,b){g.ext.selector[b.type].push(function(a,d,e){d=d.selected;var c=[];if(!0!==d&&!1!==d)return e;for(var f=0,g=e.length;f<g;f++){var h=a[b.prop][e[f]];(!0===d&&!0===h._select_selected|| >+!1===d&&!h._select_selected)&&c.push(e[f])}return c})});g.ext.selector.cell.push(function(a,b,c){b=b.selected;var d=[];if(b===h)return c;for(var e=0,f=c.length;e<f;e++){var g=a.aoData[c[e].row];(!0===b&&g._selected_cells&&!0===g._selected_cells[c[e].column]||!(!1!==b||g._selected_cells&&g._selected_cells[c[e].column]))&&d.push(c[e])}return d});var n=g.Api.register,q=g.Api.registerPlural;n("select()",function(){return this.iterator("table",function(a){g.select.init(new g.Api(a))})});n("select.blurable()", >+function(a){return a===h?this.context[0]._select.blurable:this.iterator("table",function(b){b._select.blurable=a})});n("select.toggleable()",function(a){return a===h?this.context[0]._select.toggleable:this.iterator("table",function(b){b._select.toggleable=a})});n("select.info()",function(a){return B===h?this.context[0]._select.info:this.iterator("table",function(b){b._select.info=a})});n("select.items()",function(a){return a===h?this.context[0]._select.items:this.iterator("table",function(b){b._select.items= >+a;m(new g.Api(b),"selectItems",[a])})});n("select.style()",function(a){return a===h?this.context[0]._select.style:this.iterator("table",function(b){b._select.style=a;b._select_init||D(b);var c=new g.Api(b);v(c);"api"!==a&&A(c);m(new g.Api(b),"selectStyle",[a])})});n("select.selector()",function(a){return a===h?this.context[0]._select.selector:this.iterator("table",function(b){v(new g.Api(b));b._select.selector=a;"api"!==b._select.style&&A(new g.Api(b))})});q("rows().select()","row().select()",function(a){var b= >+this;if(!1===a)return this.deselect();this.iterator("row",function(b,a){r(b);b.aoData[a]._select_selected=!0;f(b.aoData[a].nTr).addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["row",b[d]],!0)});return this});q("columns().select()","column().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("column",function(b,a){r(b);b.aoColumns[a]._select_selected=!0;a=(new g.Api(b)).column(a);f(a.header()).addClass(b._select.className);f(a.footer()).addClass(b._select.className); >+a.nodes().to$().addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["column",b[d]],!0)});return this});q("cells().select()","cell().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("cell",function(b,a,e){r(b);a=b.aoData[a];a._selected_cells===h&&(a._selected_cells=[]);a._selected_cells[e]=!0;a.anCells&&f(a.anCells[e]).addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["cell",b[d]],!0)});return this});q("rows().deselect()", >+"row().deselect()",function(){var a=this;this.iterator("row",function(a,c){a.aoData[c]._select_selected=!1;f(a.aoData[c].nTr).removeClass(a._select.className)});this.iterator("table",function(b,c){m(a,"deselect",["row",a[c]],!0)});return this});q("columns().deselect()","column().deselect()",function(){var a=this;this.iterator("column",function(a,c){a.aoColumns[c]._select_selected=!1;var b=new g.Api(a),e=b.column(c);f(e.header()).removeClass(a._select.className);f(e.footer()).removeClass(a._select.className); >+b.cells(null,c).indexes().each(function(b){var c=a.aoData[b.row],d=c._selected_cells;!c.anCells||d&&d[b.column]||f(c.anCells[b.column]).removeClass(a._select.className)})});this.iterator("table",function(b,c){m(a,"deselect",["column",a[c]],!0)});return this});q("cells().deselect()","cell().deselect()",function(){var a=this;this.iterator("cell",function(a,c,d){c=a.aoData[c];c._selected_cells[d]=!1;c.anCells&&!a.aoColumns[d]._select_selected&&f(c.anCells[d]).removeClass(a._select.className)});this.iterator("table", >+function(b,c){m(a,"deselect",["cell",a[c]],!0)});return this});var y=0;f.extend(g.ext.buttons,{selected:{text:t("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(a,b,c){var d=this;c._eventNamespace=".select"+y++;a.on(x(c),function(){d.enable(E(a,c))});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectedSingle:{text:t("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(a,b,c){var d=this;c._eventNamespace= >+".select"+y++;a.on(x(c),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(1===b)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectAll:{text:t("selectAll","Select all"),className:"buttons-select-all",action:function(){this[this.select.items()+"s"]().select()}},selectNone:{text:t("selectNone","Deselect all"),className:"buttons-select-none",action:function(){r(this.settings()[0], >+!0)},init:function(a,b,c){var d=this;c._eventNamespace=".select"+y++;a.on(x(c),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(0<b)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}}});f.each(["Row","Column","Cell"],function(a,b){var c=b.toLowerCase();g.ext.buttons["select"+b+"s"]={text:t("select"+b+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)}, >+init:function(a){var b=this;a.on("selectItems.dt.DT",function(a,d,e){b.active(e===c)})}}});f(p).on("preInit.dt.dtSelect",function(a,b){"dt"===a.namespace&&g.select.init(new g.Api(b))});return g.select}); >diff --git a/koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css b/koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css >new file mode 100644 >index 0000000000..2f5623a9b0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css >@@ -0,0 +1 @@ >+table.dataTable tbody>tr.selected,table.dataTable tbody>tr>.selected{background-color:#B0BED9}table.dataTable.stripe tbody>tr.odd.selected,table.dataTable.stripe tbody>tr.odd>.selected,table.dataTable.display tbody>tr.odd.selected,table.dataTable.display tbody>tr.odd>.selected{background-color:#acbad4}table.dataTable.hover tbody>tr.selected:hover,table.dataTable.hover tbody>tr>.selected:hover,table.dataTable.display tbody>tr.selected:hover,table.dataTable.display tbody>tr>.selected:hover{background-color:#aab7d1}table.dataTable.order-column tbody>tr.selected>.sorting_1,table.dataTable.order-column tbody>tr.selected>.sorting_2,table.dataTable.order-column tbody>tr.selected>.sorting_3,table.dataTable.order-column tbody>tr>.selected,table.dataTable.display tbody>tr.selected>.sorting_1,table.dataTable.display tbody>tr.selected>.sorting_2,table.dataTable.display tbody>tr.selected>.sorting_3,table.dataTable.display tbody>tr>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody>tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody>tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody>tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody>tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody>tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody>tr.odd>.selected,table.dataTable.order-column.stripe tbody>tr.odd>.selected{background-color:#a6b4cd}table.dataTable.display tbody>tr.even>.selected,table.dataTable.order-column.stripe tbody>tr.even>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.selected:hover>.sorting_1,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody>tr.selected:hover>.sorting_2,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody>tr.selected:hover>.sorting_3,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_3{background-color:#a5b2cb}table.dataTable.display tbody>tr:hover>.selected,table.dataTable.display tbody>tr>.selected:hover,table.dataTable.order-column.hover tbody>tr:hover>.selected,table.dataTable.order-column.hover tbody>tr>.selected:hover{background-color:#a2aec7}table.dataTable tbody td.select-checkbox,table.dataTable tbody th.select-checkbox{position:relative}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody td.select-checkbox:after,table.dataTable tbody th.select-checkbox:before,table.dataTable tbody th.select-checkbox:after{display:block;position:absolute;top:1.2em;left:50%;width:12px;height:12px;box-sizing:border-box}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody th.select-checkbox:before{content:' ';margin-top:-6px;margin-left:-6px;border:1px solid black;border-radius:3px}table.dataTable tr.selected td.select-checkbox:after,table.dataTable tr.selected th.select-checkbox:after{content:'\2714';margin-top:-11px;margin-left:-4px;text-align:center;text-shadow:1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9}div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0.5em}@media screen and (max-width: 640px){div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0;display:block}} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >index a545868ce7..b411a7b60e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >@@ -2,4 +2,5 @@ > [% USE Asset %] > [% INCLUDE 'format_price.inc' %] > [% Asset.js("lib/datatables/datatables.min.js") | $raw %] >+[% Asset.js("lib/datatables/dataTables.select.min.js") | $raw %] > [% Asset.js("js/datatables.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index c2833e3009..4e03000b0a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -18,6 +18,7 @@ > [% Asset.css("lib/bootstrap/bootstrap-theme.min.css") | $raw %] > [% Asset.css("lib/font-awesome/css/font-awesome.min.css") | $raw %] > [% Asset.css("lib/datatables/datatables.min.css") | $raw %] >+[% Asset.css("lib/datatables/select.dataTables.min.css") | $raw %] > [% Asset.css("css/print.css", { media = "print" }) | $raw %] > [% INCLUDE intranetstylesheet.inc %] > [% IF ( bidi ) %][% Asset.css("css/right-to-left.css") | $raw %][% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 578a08ae65..894b538fdf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -15,17 +15,17 @@ > [% INCLUDE 'header.inc' %] > [% INCLUDE 'acquisitions-search.inc' %] > >-<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> >+<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> > > <div class="main container-fluid"> > <div class="row"> >- [% AcqCreateItem = order.basket.effective_create_items %] > <div class="col-sm-10 col-sm-push-2"> > <main> > >-<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber | html %])</h1> >+<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber || multiple_orders | html %])</h1> > > [% IF ( order ) %] >+ [% AcqCreateItem = order.basket.effective_create_items %] > <form action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);"> > <div class="row"> > <div class="col-sm-6"> >@@ -289,7 +289,7 @@ > [% IF ( order.items.count ) %] > <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" /> > [% ELSE %] >- <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived + 1 | html %]" /> >+ <input type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" /> > [% END %] > <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" /> > [% END %] >@@ -350,7 +350,7 @@ > </li> > <li id="select_currency"> > <label for="unitprice_currency"></label> >- <input type="text" size="20" name="unitprice" id="unitprice_currency" value="" /> >+ <input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" /> > [% IF currencies.count %] > <select name="currency"> > <option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> >@@ -372,6 +372,277 @@ > <input type="submit" value="Save" class="button" accesskey="w" /> > <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Cancel</a> > </fieldset></div> </form> >+[% ELSIF multiple_orders %] >+ <table id="multiple_orders" class="table table-bordered table-striped"> >+ <thead> >+ <tr> >+ <th>Order</td> >+ <th>Title</th> >+ <th>Author</th> >+ <th>ISBN</th> >+ <th>Date received</th> >+ <th>Fund</th> >+ <th>Quantity</th> >+ <th> </th> >+ </tr> >+ </thead> >+ </table> >+ >+ <div class="col"> >+ <fieldset class="action"> >+ <button class="save">Save</button> >+ <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Return</a> >+ </fieldset> >+ <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> >+ <div id="jobfailed"></div> >+ </div> >+ >+ <div class="modal fade" id="order_edit" tabindex="-1" role="dialog" aria-labelledby="Order edit"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content modal-lg"> >+ <div class="modal-header row"> >+ <h4 class="col-md-11 modal-title"></h4> >+ <button type="button" class="close col-md-1" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> >+ </div> >+ <div class="modal-body"> >+ <div class="hide" id="loading">Loading ...</div> >+ <div id="modal-order-main"> >+ <ul> >+ <li><a href="#info-panel">Info</a></li> >+ <li><a href="#accounting-panel">Accounting</a></li> >+ <li><a href="#history-panel">Receipt history</a></li> >+ <li><a href="#items-panel">Items</a></li> >+ </ul> >+ >+ >+ <div id="info-panel"> >+ <div> >+ <h4>Catalog details</h4> >+ >+ <div class="row"> <span class="lbl col-sm-4">Title: </span><span class="col-sm-8" id="biblio_title"></span></div> >+ <div class="row"> <span class="lbl col-sm-4">Author: </span><span class="col-sm-8" id="biblio_author"></span></div> >+ <div class="row"> <span class="lbl col-sm-4">Copyright: </span><span class="col-sm-8" id="biblio_copyright_date"></span></div> >+ <div class="row"> <span class="lbl col-sm-4">ISBN: </span><span class="col-sm-8" id="biblio_isbn"></span></div> >+ <div class="row"> <span class="lbl col-sm-4">Series: </span><span class="col-sm-8" id="biblio_series_title"></span></div> >+ >+ </div> >+ <div id="suggestion_fieldset"> >+ <h4>Suggestion</h4> >+ <div class="row"> >+ <span class="lbl col-sm-4">Suggested by: </span> <span class="col-sm-8" id="biblio_suggestion_suggester"></span> >+ </div> >+ <div class="row" id="suggestion_reason"> >+ <span class="lbl col-sm-4">Reason:</span> >+ <div class="col-sm-8"> >+ [% SET suggestion_reasons = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %] >+ <select class="select-reason" id="reason" name="reason"> >+ <option value=""> -- Choose a reason -- </option> >+ [% FOREACH reason IN suggestion_reasons %] >+ <option value="[% reason.lib | html %]">[% reason.lib | html %]</option> >+ [% END %] >+ <option value="other">Others...</option> >+ </select> >+ >+ <span id="other_reason" name="other_reason"> >+ <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." /> >+ <a href="#back">Cancel</a> >+ </span> >+ </div> >+ </div> >+ </div> >+ </div> >+ <div id="history-panel"> >+ <div id="child_orders"> >+ <h4>Receipt history for this subscription</h4> >+ <table id="child_orders_table"> >+ <thead> >+ <tr> >+ <th>Invoice</th> >+ <th>Order number</th> >+ <th class="title-string">Creation date</th> >+ <th class="title-string">Receive date</th> >+ <th>Quantity received</th> >+ <th class="title-string">Status</th> >+ <th title="Actual cost tax exc. / Actual cost tax inc.">Spent</th> >+ <th>Internal note</th> >+ </tr> >+ </thead> >+ </table> >+ </div> >+ </div> >+ <div id="items-panel"> >+ <div id="acq-create-receiving"> >+ <div id="items_list" style="display: none"> >+ <h4>Items list</h4> >+ <div style="width:100%;overflow:auto;"> >+ <table> >+ <thead> >+ <tr> >+ <th>Actions</th> >+ <th>Barcode</th> >+ <th>Home library</th> >+ <th>Holding library</th> >+ <th>Not for loan</th> >+ <th>Restricted</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th>Copy number</th> >+ <th>Inventory number</th> >+ <th>Collection</th> >+ <th>Item type</th> >+ <th>Materials</th> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ <tbody> >+ </tbody> >+ </table> >+ </div> >+ </div> >+ >+ <div id="itemfieldset"> >+ <h4>Item</h4> >+ [% IF ( NoACQframework ) %] >+ <p class="required"> >+ No ACQ framework, using default. You should create a >+ framework with code ACQ, the items framework would be >+ used >+ </p> >+ [% END %] >+ <div id="outeritemblock"></div> >+ </div> >+ </div> >+ <div id="acq-create-ordering"> >+ <h4>Items</h4> >+ <div style="width:100%;overflow:auto"> >+ <table> >+ <thead> >+ <tr> >+ <th>Receive?</th> >+ <th> </th> >+ <th>Barcode</th> >+ <th>Home library</th> >+ <th>Current library</th> >+ <th>Not for loan</th> >+ <th>Restricted</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th>Copy number</th> >+ <th>Inventory number</th> >+ <th>Collection</th> >+ <th>Item type</th> >+ <th>Materials</th> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ <tbody> >+ </tbody> >+ </table> >+ </div> >+ </div> >+ </div> >+ <div id="accounting-panel"> >+ <h4>Accounting details</h4> >+ <ol> >+ <li> >+ <label for="datereceived">Date received: </label> >+ <input type="text" size="10" id="datereceived" name="datereceived" class="datepicker" /> >+ </li> >+ <li> >+ <label for="bookfund">Fund: </label> >+ <select id="bookfund" name="bookfund"> >+ <option value=""></option> >+ [% FOREACH period IN budget_loop %] >+ <optgroup label="[% period.description | html %]"> >+ [% FOREACH fund IN period.funds %] >+ <option value="[% fund.b_id | html %]">[% fund.b_txt | html %]</option> >+ [% END %] >+ </optgroup> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label> </label> >+ <span id="current-fund"></span> >+ </li> >+ <li> >+ <label for="creator">Ordered by: </label> >+ <span id="creator"></span> >+ </li> >+ <li> >+ <label for="quantity_to_receive">Quantity ordered: </label> >+ <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" /> >+ </li> >+ <li> >+ <label for="quantity">Quantity received: </label> >+ <input type="text" size="20" name="quantityrec" id="quantity" /> >+ <div id="qtyrecerror" style="display:none"> >+ <p class="error">Warning, you have entered more items than expected. >+ Items will not be created.</p> >+ </div> >+ </li> >+ >+ [% IF ( gst_values ) %] >+ <li> >+ <label for="tax_rate">Tax rate: </label> >+ <select name="tax_rate" id="tax_rate"> >+ [% FOREACH gst IN gst_values %] >+ <option value="[% gst.option | html %]">[% gst.option * 100 | html %]%</option> >+ [% END %] >+ </select> >+ </li> >+ [% END %] >+ >+ <li> >+ <label for="rrp">Retail price: </label> >+ <span id="rrp"></span> >+ <li> >+ <label for="replacementprice">Replacement price:</label> >+ <input type="text" size="20" name="replacementprice" id="replacementprice" /> >+ </li> >+ <li> >+ <label for="ecost">Budgeted cost: </label> >+ <span id="ecost"></span> >+ </li> >+ <li> >+ <label for="unitprice">Actual cost:</label> >+ <input type="text" size="20" name="unitprice" id="unitprice" /> >+ <span id="unitprice_hint" class="hint"></span> >+ <label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> >+ </li> >+ <li id="select_currency"> >+ <label for="unitprice_currency"></label> >+ <input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" /> >+ [% IF currencies.count %] >+ <select name="currency"> >+ <option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option> >+ [% FOR currency IN currencies %] >+ <option value="[% currency.rate | html %]">[% currency.currency | html %] ([% currency.symbol | html %])</option> >+ [% END %] >+ </select> >+ [% END %] >+ </li> >+ <li> >+ <label for="order_internalnote">Internal note: </label> >+ <textarea name="order_internalnote" id="order_internalnote" width="40" rows="8" ></textarea> >+ </li> >+ <li> >+ <label for="order_vendornote">Vendor note: </label> >+ <span id="order_vendornote"></span> >+ </li> >+ </ol> >+ </div> >+ </div> >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-defualt modal-prev">Previous</button> >+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> >+ <button type="button" class="btn btn-primary modal-save">Save changes</button> >+ <button type="button" class="btn btn-defualt modal-next">Next</button> >+ </div> >+ </div> >+ </div> >+ </div> > [% ELSE %] > This ordernumber does not exist. > [% END %] >@@ -387,10 +658,48 @@ > </div> <!-- /.row --> > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/acquisitions-menu.js") | $raw %] >-[% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'calendar.inc' %] > [% Asset.js("js/additem.js") | $raw %] > [% Asset.js("js/cataloging.js") | $raw %] >+ [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'js-date-format.inc' %] >+ [% INCLUDE 'format_price.inc' %] >+ [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %] >+ <style> >+ .lbl { >+ font-weight: 700; >+ text-align: right; >+ } >+ .modal-body ol { >+ list-style-type: none; >+ } >+ >+ .modal-body ol li { >+ list-style-type: none; >+ padding-bottom: 1em; >+ width: 100%; >+ } >+ >+ .modal-body h4 { >+ margin-left: 1em; >+ padding: .2em .5em; >+ margin-bottom: 17px; >+ } >+ >+ .modal-body label { >+ margin-right: 1em; >+ text-align: right; >+ width: 11em; >+ display: inline-block; >+ font-weight: 700; >+ } >+ >+ .modal-body textarea { >+ vertical-align: text-top; >+ } >+ </style> > <script> >+ [% IF order %] > function Check(form) { > [% IF (AcqCreateItem == 'receiving') %] > var total_errors = CheckMandatorySubfields(form); >@@ -541,6 +850,814 @@ > }); > > }); >+ [% ELSIF multiple_orders %] >+ >+ var _build_item = function(item, tr) { >+ var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />') >+ .prop('checked', item._checked) >+ .change(function() { >+ item._checked = $(this).prop('checked'); >+ }); >+ tr.append($('<td style="text-align:center"></td>').append(chb)); >+ tr.append('<td><a style="cursor:pointer" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>'); >+ tr.append('<td>'+(item.external_id||'')+'</td>'); >+ tr.append('<td>'+(item.home_branch && item.home_branch.name||'')+'</td>'); >+ tr.append('<td>'+(item.holding_branch && item.holding_branch.name||'')+'</td>'); >+ tr.append('<td>'+(item._authorised_values.not_for_loan_status && item._authorised_values.not_for_loan_status.lib||'')+'</td>'); >+ tr.append('<td>'+(item._authorised_values.restricted_status && item._authorised_values.restricted_status.lib||'')+'</td>'); >+ tr.append('<td><span class="shelvingloc">'+(item._authorised_values.location && item._authorised_values.location.lib||'')+'</span></td>'); >+ tr.append('<td>'+(item.callnumber||'')+'</td>'); >+ tr.append('<td>'+(item.copy_number||'')+'</td>'); >+ tr.append('<td>'+(item.inventory_number||'')+'</td>'); >+ tr.append('<td>'+(item._authorised_values.collection_code && item._authorised_values.collection_code.lib||'')+'</td>'); >+ tr.append('<td>'+(item.itemtype && item.itemtype.description || '')+'</td>'); >+ tr.append('<td>'+(item._authorised_values.materials_notes && item._authorised_values.materials_notes.lib||'')+'</td>') >+ tr.append('<td>'+(item.public_notes||'')+'</td>'); >+ }; >+ >+ var items_columns = [null, null, 'external_id', 'home_library_id', >+ 'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location', >+ 'callnumber', 'copy_number', 'inventory_number', 'collection_code', >+ 'item_type', 'materials_notes', 'public_notes']; >+ >+ function PopupEditPage(biblionumber, itemnumber) { >+ var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" >+ + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; >+ var w = window.open(url); >+ var watchClose = setInterval(function() { >+ if (w.closed) { >+ clearTimeout(watchClose); >+ $.ajax({ >+ dataType: "json", >+ headers: { >+ "x-koha-embed": "home_branch,holding_branch,itemtype", >+ "x-koha-av": "1" >+ }, >+ url: '/api/v1/items/'+itemnumber, >+ success: function(item) { >+ var tr = $("#item_"+itemnumber); >+ tr.html(''); >+ _build_item(item, tr); >+ } >+ }); >+ } >+ }, 500); >+ } >+ >+ var periods={}; >+ var funds={}; >+ var funds_tree = []; >+ >+ var QTY_TOTAL = _("Receiving %0$s out of %1$s"); >+ var EDIT = _("edit"); >+ var MOD_TITLE = _("Edit %s"); >+ var SUGGESTION = _("suggestion #%s"); >+ var FUND_KEEP = _("Keep current (%0$s - %1$s)"); >+ var FUNC_CUR = _("(Current: %0$s - %1$s)"); >+ var ADJ_TAX_INC = _("(adjusted for %s, tax inclusive)"); >+ var ADJ_TAX_EXC = _("(adjusted for %s, tax exclusive)"); >+ var TAX_INC = _("(tax inclusive)"); >+ var TAX_EXC = _("(tax exclusive)"); >+ var SAVE_WARNING = _("Order %s: Warning, you have entered more items than expected. Items will not be created."); >+ var SAVE_WARNING_NO_ITEMS = _("Order %s: No quantity to receive setted. No items will be created."); >+ var SAVE_ERROR = _("Order %s: An error cocurred while saving"); >+ >+ >+ var CAN_user_acquisition = "[% CAN_user_acquisition | html %]"; >+ var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]"; >+ var edit_mode = "[% edit | html %]"; >+ var invoiceincgst = "[% invoiceincgst | html %]"; >+ var active_currency = "[% active_currency.currency | html %]"; >+ var invoice_id = "[% invoiceid | html %]"; >+ >+ $(document).ready(function(){ >+ var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}}; >+ var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; >+ var options = { >+ "ajax": { >+ "url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)), >+ "headers": { >+ 'x-koha-av': '1' >+ } >+ }, >+ "header_filter": true, >+ "embed": [ >+ "basket", >+ "biblio.suggestions.suggester", >+ "fund.budget", >+ "items.home_branch", >+ "items.holding_branch", >+ "items.itemtype", >+ "creator" >+ ], >+ 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', >+ "columns": [ >+ { >+ "data": "order_id", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": "biblio.title", >+ "searchable": true, >+ "orderable": true, >+ "render": function(data, type, row, meta) { >+ if ( data == null ) { >+ return ""; >+ } >+ else { >+ return data; >+ } >+ } >+ }, >+ { >+ "data": "biblio.author", >+ "searchable": true, >+ "orderable": true, >+ "render": function(data, type, row, meta) { >+ if ( data == null ) { >+ return ""; >+ } >+ else { >+ return data; >+ } >+ } >+ }, >+ { >+ "data": "biblio.isbn", >+ "searchable": true, >+ "orderable": true, >+ "render": function(data, type, row, meta) { >+ if ( data == null ) { >+ return ""; >+ } >+ else { >+ return data; >+ } >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ return $date(row.date_received||new Date().toISOString()); >+ } >+ }, >+ { >+ "data": "fund.name", >+ "searchable": true, >+ "orderable": false, >+ "render": function(data, type, row, meta) { >+ return row.fund.budget.budget_period_description+" - "+row.fund.name; >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": true, >+ "data": "quantity_received", >+ "render": function(data, type, row, meta) { >+ return QTY_TOTAL.format(row.subscription_id?row.quantity:row.quantity_received, row.quantity); >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "render": function(data, type, row, meta) { >+ return '<a data-toggle="modal" href="#order_edit" data-row="'+meta.row+'" class="order_edit_toggle">'+EDIT+'</a>'; >+ } >+ } >+ ] >+ }; >+ var orders_table = $("#multiple_orders").api(options); >+ var api = orders_table.api(); >+ >+ api.on('preDraw', function() { >+ var saved = $("#order_edit").data('saved'); >+ if(saved) { >+ var data = api.data(); >+ for(var i = 0; i<data.length; i++) { >+ var row = data[i]; >+ var srow = saved[row.order_id]; >+ if(srow) { >+ if(row.fund_id != srow.fund_id) { >+ row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label'); >+ row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html(); >+ } >+ row.date_received = srow.date_received; >+ row.quantity = srow.quantity; >+ row.quantity_received = srow.quantity_received; >+ } >+ } >+ } >+ }); >+ >+ var _doSave = function(params) { >+ $.ajax($.extend({ >+ method: 'POST', >+ url: '/cgi-bin/koha/acqui/finishreceive.pl' >+ }, params)); >+ }; >+ >+ var _set_error = function(error) { >+ if($('#jobfailed').html() == '') $('#jobfailed').append('<ul/>'); >+ $('#jobfailed ul').append('<li>'+error+'</li>'); >+ }; >+ >+ var _transform_row = function(row, origrec) { >+ var params = {}; >+ params['biblionumber'] = row.biblio_id; >+ params['invoiceid'] = invoice_id; >+ params['ordernumber'] = row.order_id; >+ params['booksellerid'] = row.basket.vendor_id; >+ >+ if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) { >+ params["suggestionid"] = row.biblio.suggestions[0].suggestion_id; >+ if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { >+ params['reason'] = row.biblio.suggestions[0].reason; >+ } else { >+ params['reason'] = 'other'; >+ params['other_reason'] = row.biblio.suggestions[0].reason; >+ } >+ } >+ params['datereceived'] = row.date_received; >+ params['bookfund'] = row.fund_id; >+ params['quantity'] = row.quantity; >+ params['quantityrec'] = row.quantity_received; >+ params['origquantityrec'] = origrec; >+ var effective_create_items = row.basket.create_items || AcqCreateItem; >+ params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering; >+ params['replacementprice'] = row.replacement_price; >+ params['unitprice'] = invoiceincgst?row.unit_price_tax_included:row.unit_price_tax_excluded; >+ params['order_internalnote'] = row.internal_note; >+ if(effective_create_items == 'receiving') { >+ Object.keys(row.items).forEach(function(key) { >+ var item = row.items[key]; >+ Object.keys(item).forEach(function(key) { >+ var field = item[key]; >+ Object.keys(field).forEach(function(key) { >+ if(!params[key]) params[key] = []; >+ params[key].push(item[key]); >+ }); >+ }); >+ }); >+ } else if(effective_create_items == 'ordering') { >+ params['items_to_receive'] = (row.items||[]) >+ .filter(function(item) { >+ return item._checked >+ }) >+ .map(function(item) { >+ item.item_id; >+ }) >+ } >+ return params; >+ }; >+ >+ $('.save').click(function() { >+ var data = $("#order_edit").data(); >+ var rows = api.rows().data(); >+ $('this').prop('disabled', true); >+ var redirect = true; >+ if(rows.length) { >+ $('#jobfailed, #jobpanel, #jobstatus').show(); >+ >+ var loopRows = function(i) { >+ var row = rows[i]; >+ if(!row) { >+ if(redirect) { >+ location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id+"&sticky_filters=1" >+ } >+ return; >+ } >+ if(data.saved && data.saved[row.order_id]) { >+ row = data.saved[row.order_id]; >+ var origrec = data.origrec[row.order_id]; >+ } else { >+ var origrec = row.quantity_received; >+ } >+ if(row.subscription_id) row.quantity_received = row.quantity; >+ var _set_percentage = function() { >+ var percentage = ( (i+1) / rows.length) * 100; >+ var bgproperty = (parseInt(percentage*2)-300)+"px 0px"; >+ $("#jobprogress").css("background-position",bgproperty); >+ $("#jobprogresspercent").text(percentage); >+ } >+ if(row.quantity_received > row.quantity) { >+ _set_error(SAVE_WARNING.format(row.order_id)); >+ row.quantity_received = row.quantity; >+ } >+ if(row.quantity_received == '0') { >+ _set_error(SAVE_WARNING_NO_ITEMS.format(row.order_id)); >+ } >+ _doSave({ >+ data: _transform_row(row, origrec), >+ success: function() { >+ _set_percentage(); >+ loopRows(i+1); >+ }, >+ error: function() { >+ _set_percentage() >+ _set_error(SAVE_ERROR.format(row.order_id)); >+ redirect = false; >+ loopRows(i+1); >+ } >+ }); >+ }; >+ loopRows(0) >+ } >+ }); >+ >+ $("#order_edit").on("change", "#reason", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ if(val == 'other') { >+ $("#other_reason").show(); >+ $(this).hide(); >+ } else { >+ row.biblio.suggestions[0].reason = val; >+ } >+ }); >+ >+ $("#order_edit").on("change", "#select-other_reason", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.biblio.suggestions[0].reason = val; >+ }); >+ >+ $("#order_edit").on("click", "#other_reason a", function() { >+ $("#other_reason").hide(); >+ $("#reason").val(null).show(); >+ }); >+ >+ $("#order_edit").on("change", "#datereceived", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.date_received = val; >+ }); >+ >+ $("#order_edit").on("change", "#bookfund", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.fund_id = val; >+ }); >+ >+ $("#order_edit").on("change", "#quantity_to_receive", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.quantity = val; >+ if(row.subscription_id) { >+ $("#quantity").val(val).change(); >+ } >+ }); >+ >+ $("#order_edit").on("change", "#quantity", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.quantity_received = val; >+ var qtyto = parseInt($("#quantity_to_receive").val()); >+ if(parseInt(val) > qtyto) { >+ $("#qtyrecerror").show(); >+ } else { >+ $("#qtyrecerror").hide(); >+ } >+ $("input[name='items_to_receive']").each(function() { >+ $(this).prop('checked', false).change(); >+ }); >+ $("input[name='items_to_receive']:lt("+val+")").each(function () { >+ $(this).prop('checked', true).change(); >+ }); >+ }); >+ >+ $("#order_edit").on("change", "input[name='items_to_receive']", function() { >+ var qty = $("input[name='items_to_receive']:checked").length; >+ $("#quantity").val(qty); >+ var row = $("#order_edit").data('row'); >+ row.quantity_received = qty; >+ }) >+ >+ $("#order_edit").on("change", "#tax_rate", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ var effective_create_items = row.basket.create_items || AcqCreateItem; >+ if(effective_create_items == 'receiving') { >+ row.tax_rate_on_receiving = val; >+ } else { >+ row.tax_rate_on_ordering = val; >+ } >+ >+ }); >+ >+ $("#order_edit").on("change", "#unitprice", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ if(invoiceincgst) { >+ row.unit_price_tax_included = val; >+ } else { >+ row.unit_price_tax_excluded = val; >+ } >+ >+ }); >+ >+ $("#order_edit").on("change", "input[name='change_currency']", function(){ >+ if ( $(this).is(":checked") ) { >+ $("#select_currency").show(); >+ $("#unitprice").prop("readonly", "true"); >+ } else { >+ $("#select_currency").hide(); >+ $("#unitprice").prop("readonly", ""); >+ } >+ }); >+ >+ function _update_unitprice() { >+ var rate = Number($("select[name='currency'] option:selected").val()); >+ var unitprice = $("#unitprice_currency").val(); >+ var new_unitprice = Number( unitprice * rate ).toFixed(2); >+ $("#unitprice").val(new_unitprice).change(); >+ } >+ $("#order_edit").on("change", "select[name='currency']", _update_unitprice ); >+ $("#order_edit").on("change", "#unitprice_currency", _update_unitprice ); >+ >+ $("#order_edit").on("change", "#replacementprice", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.replacement_price = val; >+ }); >+ >+ $("#order_edit").on("change", "#order_internalnote", function() { >+ var val = $(this).val(); >+ var row = $("#order_edit").data('row'); >+ row.internal_note = val; >+ >+ }); >+ >+ var keep_row = function() { >+ var row = $("#order_edit").data('row'); >+ var kept = $("#order_edit").data('kept')||{}; >+ if($('#items_list tbody tr').length) { >+ row.items = []; >+ $('#items_list tbody tr').each(function() { >+ var item = {}; >+ $('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() { >+ var kf = $(this).val(); >+ var obj = {}; >+ $(this).parent().find('*[name]').each(function() { >+ obj[$(this).prop('name')] = $(this).val(); >+ }); >+ item[kf] = obj; >+ }); >+ row.items.push(item); >+ }); >+ } >+ kept[row.order_id] = row; >+ $("#order_edit").data('kept', kept); >+ }; >+ >+ var save_row = function() { >+ keep_row(); >+ var saved = $("#order_edit").data('saved')||{}; >+ var kept = $("#order_edit").data('kept'); >+ $("#order_edit").data('saved', $.extend(saved, kept)); >+ api.draw(); >+ } >+ >+ var set_modal_buttons = function() { >+ var n = $("#order_edit").data('n'); >+ var info = api.page.info(); >+ >+ $('.modal-prev').prop('disabled', info.page == 0 && n == 0); >+ $('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n); >+ }; >+ >+ var show_subs = function(row) { >+ //$("#child_orders").show(); >+ var had_rows = false; >+ var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}}; >+ var pending_orders_url = "/api/v1/acquisitions/orders"; >+ var options = { >+ "ajax": { >+ "url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)) >+ }, >+ "header_filter": true, >+ "embed": [ >+ "invoice", >+ "basket" >+ ], >+ "order": [[1, 'asc']], >+ 'dom': 'C<"top pager"ilpfB>tr<"bottom pager"ip>', >+ "columns": [ >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ if(row.invoice) { >+ if(CAN_user_acquisition) { >+ return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; >+ } >+ return row.invoice.invoice_number; >+ } >+ } >+ }, >+ { >+ "data": "order_id", >+ "searchable": false, >+ "orderable": false >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": "basket.creation_date", >+ "render": function(data, type, row, meta) { >+ return $date(row.basket.creation_date); >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ return $date(row.date_received); >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ return row.quantity_received; >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": true, >+ "data": function(row, type, val, meta) { >+ if(!row.status) return; >+ var first_letter = row.status[0].toUpperCase(); >+ return first_letter+row.status.substr(1).toLowerCase(); >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ if(!row.date_received) return; >+ return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price() >+ } >+ }, >+ { >+ "searchable": false, >+ "orderable": false, >+ "data": function(row, type, val, meta) { >+ return row.internal_note; >+ } >+ } >+ ] >+ }; >+ var child_orders_table = $("#child_orders_table").api(options); >+ var child_api = child_orders_table.api(); >+ child_api.on('preDraw', function() { >+ if(!child_api.data().length && !had_rows) return; >+ $("#child_orders").show(); >+ had_rows = true; >+ }); >+ }; >+ >+ var set_editor = function() { >+ var modal = $("#order_edit"); >+ var row = modal.data('row'); >+ var origrec = $("#order_edit").data('origrec')||{}; >+ if(!origrec.hasOwnProperty(row.order_id)) { >+ origrec[row.order_id] = row.quantity_received; >+ $("#order_edit").data('origrec', origrec); >+ } >+ if(row.subscription_id) { >+ row.quantity_received = row.quantity; >+ } >+ var keep = $("#order_edit").data('kept'); >+ if(keep && keep[row.order_id]) { >+ row = keep[row.order_id]; >+ modal.data('row', row); >+ } >+ $('input, select, textarea', '.modal-body').val(null) >+ modal.find(".modal-title").text(MOD_TITLE.format(row.biblio.title)); >+ ["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){ >+ var o = modal.find(".modal-body #biblio_"+key); >+ if(row.biblio[key] !== null) { >+ o.parent().show(); >+ o.html(row.biblio[key]); >+ } else { >+ o.parent().hide(); >+ } >+ }); >+ if(row.biblio.suggestions.length) { >+ $("#suggestion_fieldset").show(); >+ if(row.biblio.suggestions[0].suggester) { >+ $("#biblio_suggestion_suggester").parent().show(); >+ $("#biblio_suggestion_suggester") >+ .html( >+ [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname] >+ .filter(function(name){ >+ return name >+ }) >+ .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>)' >+ ); >+ } else { >+ $("#biblio_suggestion_suggester").parent().hide(); >+ } >+ if(row.biblio.suggestions[0].reason) { >+ $("#suggestion_reason").show(); >+ if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { >+ $("#other_reason a").click(); >+ $("#reason").val(row.biblio.suggestions[0].reason); >+ $("#select-other_reason").val(null); >+ } else { >+ $("#reason").val("other").change(); >+ $("#select-other_reason").val(row.biblio.suggestions[0].reason); >+ } >+ >+ } else { >+ $("#suggestion_reason").hide(); >+ } >+ } else { >+ $("#suggestion_fieldset").hide(); >+ } >+ >+ var effective_create_items = row.basket.create_items || AcqCreateItem; >+ $("#datereceived").val(row.date_received||$date(new Date().toISOString())).change(); >+ $("#bookfund option[value='']").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)); >+ if(row.fund_id != row.fund.fund_id) { >+ $("#bookfund").val(row.fund_id); >+ } >+ $("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name)); >+ $("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')') >+ $("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id); >+ $("#quantity").val(row.quantity_received).prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); >+ $('#qtyrecerror').hide(); >+ var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; >+ $("#tax_rate").val(tax_rate).change(); >+ var rrp_txt; >+ var ecost_txt; >+ if(invoiceincgst) { >+ rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint">'+ADJ_TAX_INC.format(active_currency)+"</span>"; >+ ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint">'+TAX_INC+"</span>"; >+ $("#unitprice").val(row.unit_price_tax_included); >+ $("#unitprice_hint").html(TAX_INC); >+ } else { >+ rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint">'+ADJ_TAX_EXC.format(active_currency)+"</span>"; >+ ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint">'+TAX_EXC+"</span>"; >+ $("#unitprice").val(row.unit_price_tax_excluded); >+ $("#unitprice_hint").html(TAX_EXC); >+ } >+ $("#rrp").html(rrp_txt); >+ $("#replacementprice").val(row.replacement_price); >+ $("#ecost").html(ecost_txt); >+ $("#order_internalnote").val(row.internal_note); >+ if(row.vendor_note) { >+ $("#order_vendornote").html(row.vendor_note); >+ $("#order_vendornote").parent().show(); >+ } else { >+ $("#order_vendornote").parent().hide(); >+ } >+ >+ >+ $("#child_orders").hide(); >+ >+ $('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove(); >+ $('#items_list').hide(); >+ if(row.subscription_id) { >+ $('#modal-order-main').tabs("disable", "#items-panel"); >+ $('#modal-order-main').tabs("enable", "#history-panel"); >+ if($('#modal-order-main').tabs( "option", "active" ) == 3) { >+ $('#modal-order-main').tabs( "option", "active", 0); >+ } >+ } else { >+ $('#modal-order-main').tabs("enable", "#items-panel"); >+ $('#modal-order-main').tabs("disable", "#history-panel"); >+ if($('#modal-order-main').tabs( "option", "active" ) == 2) { >+ $('#modal-order-main').tabs( "option", "active", 0); >+ } >+ if(effective_create_items == 'receiving') { >+ $("#acq-create-receiving").show(); >+ $("#acq-create-ordering").hide(); >+ if(row.items && row.items.length) { >+ row.items.forEach(function(item, index) { >+ cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) { >+ var block = $('#'+block_id).hide(); >+ Object.keys(item).forEach(function(key) { >+ block >+ .find('*[name=kohafield][value="'+key+'"]') >+ .parent() >+ .find('*[name=field_value]') >+ .val(item[key].field_value); >+ }); >+ addItemInList(block_id, '[% UniqueItemFields | html %]'); >+ block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); >+ block.find("input[name='buttonPlusMulti']").remove(); >+ block.find("input[name='multiValue']").remove(); >+ }); >+ }); >+ } >+ cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]'); >+ } else if (effective_create_items == 'ordering') { >+ $("#acq-create-receiving").hide(); >+ $("#acq-create-ordering").show(); >+ if(row.items.length) { >+ $("#acq-create-ordering tbody").append( >+ row.items.map(function(item) { >+ var tr = $('<tr id="item_'+item.item_id+'"/>'); >+ _build_item(item, tr); >+ return tr; >+ }) >+ ); >+ } >+ } else { >+ if($('#modal-order-main').tabs( "option", "active" ) == 3) { >+ $('#modal-order-main').tabs( "option", "active", 0); >+ } >+ $('#modal-order-main').tabs("disable", "#items-panel"); >+ } >+ } >+ >+ set_modal_buttons(); >+ }; >+ >+ $('.modal-prev').click(function() { >+ var modal = $("#order_edit"); >+ keep_row(); >+ var n = modal.data('n'); >+ if(n > 0) { >+ n--; >+ modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); >+ modal.data('n', n); >+ set_editor(); >+ } else { >+ $('.modal-next, .modal-prev').prop('disabled', true); >+ orders_table.one('draw.dt', function() { >+ var info = api.page.info(); >+ n = info.end - info.start - 1; >+ modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); >+ modal.data('n', n); >+ set_editor(); >+ }); >+ api.page('previous').draw( 'page' ); >+ } >+ }); >+ >+ $('.modal-next').click(function() { >+ var modal = $("#order_edit"); >+ keep_row(); >+ var n = modal.data('n'); >+ var info = api.page.info(); >+ if(n < info.end - info.start - 1) { >+ n++; >+ modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); >+ modal.data('n', n); >+ set_editor(); >+ } else { >+ $('.modal-next, .modal-prev').prop('disabled', true); >+ orders_table.one('draw.dt', function() { >+ var info = api.page.info(); >+ n = 0; >+ modal.data('row', JSON.parse(JSON.stringify(api.row(n).data()))); >+ modal.data('n', n); >+ set_editor(); >+ }); >+ api.page('next').draw( 'page' ); >+ } >+ }); >+ >+ $('.modal-save').click(function() { >+ save_row(); >+ $("#order_edit").modal('hide'); >+ }) >+ >+ $('#modal-order-main').tabs({ >+ activate: function(event, ui) { >+ var active = ui.newPanel.attr('id') >+ if(active == 'history-panel') { >+ show_subs($("#order_edit").data('row')); >+ } >+ } >+ }); >+ >+ $("#order_edit").on("show.bs.modal", function (event) { >+ var anchor = $(event.relatedTarget); >+ var n = anchor.data("row"); >+ var row = api.row(n).data(); >+ >+ var modal = $(this); >+ modal.data('row', JSON.parse(JSON.stringify(row))); >+ modal.data('n', n); >+ modal.data('keep', modal.data('saved')||{}); >+ $('#modal-order-main').tabs("option", "active", 0); >+ set_editor(); >+ }); >+/* $("#order_edit").on("shown.bs.modal", function() { >+ var modal = $(this); >+ >+ if(modal.data('show_subs')) show_subs(modal.data('row')); >+ });*/ >+ $("#order_edit").on("hide.bs.modal", function() { >+ $("#child_orders_table").DataTable().off('preDraw').destroy(); >+ }); >+ }); >+ [% END %] > </script> > [% END %] > >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 5b9b2c78a3..1595d89ff3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -102,6 +102,9 @@ > <table id="pending_orders" class="table table-bordered table-striped"> > <thead> > <tr> >+ [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %] >+ <th><!--input type="checkbox" id="selectAll"/--></th> >+ [% END %] > <th>Basket</th> > <th>Basket group</th> > <th>Order line</th> >@@ -120,6 +123,11 @@ > </tr> > </thead> > </table> >+ [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %] >+ <fieldset class="action"> >+ <button id="select_multiple"></button> >+ </fieldset> >+ [% END %] > </div> > [% ELSE %] > <p> >@@ -368,9 +376,11 @@ > [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %] > [% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %] > <style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style> >+ <style>fieldset.action { margin-bottom: 20px }</style> > <script> > dt_overwrite_html_sorting_localeCompare(); > var sticky_filters = [% sticky_filters | html %]; >+ var PENDING_MULTI_SELECTION = _("Receive selected (%s)"); > > $(document).ready(function(){ > >@@ -404,7 +414,7 @@ > > var base_query = { "basket.vendor_id": [% booksellerid | html %] }; > var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; >- var pending_orders_table = $("#pending_orders").api({ >+ var options = { > "ajax": { > "url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) > }, >@@ -420,28 +430,6 @@ > "items" > ], > 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', >- "columnDefs": [ { >- "targets": [3,4,5,9], >- "render": function (data, type, row, meta) { >- if ( data != null ) { >- return data.escapeHtml(); >- } >- else { >- return ""; >- } >- } >- }, >- { >- "targets": [8,10], >- "render": function (data, type, row, meta) { >- if ( data != null ) { >- return data.escapeHtml().format_price(); >- } >- else { >- return ""; >- } >- } >- } ], > "columns": [ > { "data": "basket.name", > "orderable": true, >@@ -483,19 +471,43 @@ > "data": "biblio.author", > "visible": false, > "searchable": true, >- "orderable": false >+ "orderable": false, >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { > "data": "biblio.title", > "visible": false, > "searchable": true, >- "orderable": false >+ "orderable": false, >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { > "data": "biblio.isbn", > "visible": false, > "searchable": true, >- "orderable": false >+ "orderable": false, >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { > "data": function(row, type, val, meta) { >@@ -580,14 +592,38 @@ > "orderable": false > }, > { >- "data": "replacement_price" >+ "data": "replacement_price", >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml().format_price(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { > "data": "quantity", >- "orderable": true >+ "orderable": true, >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { >- "data": "ecost" >+ "data": "ecost", >+ "render": function (data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml().format_price(); >+ } >+ else { >+ return ""; >+ } >+ } > }, > { > "data": function ( row, type, val, meta ) { >@@ -674,7 +710,58 @@ > "orderable": false > } > ] >+ }; >+ >+ [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %] >+ var selected_rows = {}; >+ $('#select_multiple').click(function() { >+ var ids = Object.keys(selected_rows); >+ if(!ids.length) return; >+ if(ids.length == 1) { >+ location.href = 'orderreceive.pl?ordernumber='+ids[0]+ '&invoiceid=[% invoiceid | uri %]'; >+ } else { >+ location.href = 'orderreceive.pl?multiple_orders='+ids.join(',')+ '&invoiceid=[% invoiceid | uri %]'; >+ } >+ }).html(PENDING_MULTI_SELECTION.format('0')) >+ options.select = { >+ style: 'api' >+ }; >+ options.order = [[1, 'asc']]; >+ options.columns.unshift({ >+ "data": function(row, type, val, meta) { >+ return '<input type="checkbox" class="selOrder" />'; >+ }, >+ "searchable": false, >+ "orderable": false > }); >+ [% END %] >+ >+ var pending_orders_table = $("#pending_orders").api(options); >+ >+ [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %] >+ var api = pending_orders_table.api(); >+ api.on('draw', function() { >+ api.rows().every(function() { >+ var row = this; >+ var data = row.data(); >+ $('.selOrder', row.node()).on('click', function(event) { >+ if($(this).prop('checked')) { >+ row.select(); >+ selected_rows[data.order_id] = data; >+ } else { >+ row.deselect(); >+ delete selected_rows[data.order_id]; >+ } >+ $('#select_multiple').html(PENDING_MULTI_SELECTION.format(Object.keys(selected_rows).length)); >+ }); >+ if(selected_rows[data.order_id]) { >+ row.select(); >+ $('.selOrder', row.node()).prop('checked', true); >+ } >+ }); >+ }); >+ >+ [% END %] > > $("#filterform").on("submit", function(e) { > e.preventDefault(); >-- >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 8179
:
9881
|
111437
|
111438
|
111439
|
111440
|
112554
|
112555
|
112556
|
112558
|
112588
|
112643
|
112644
|
112645
|
112646
|
112744
|
112745
|
112746
|
112747
|
114688
|
114689
|
114690
|
114691
|
116582
|
116583
|
116584
|
116585
|
116588
|
116589
|
116590
|
116591
|
116681
|
116682
|
116683
|
116684
|
116942
|
116943
|
116944
|
116945
|
119178
|
119179
|
119180
|
119181
|
120620
|
120621
|
120622
|
120623
|
148215
|
148216
|
148217
|
148218
|
148233
|
148284
|
148285
|
148286
|
148287
|
148288
|
148521
|
148522
|
148523
|
148524
|
148525
|
148526
|
148685
|
148981
|
148982
|
148983
|
148984
|
148985
|
148986
|
151026
|
151086
|
151087
|
151088
|
151089
|
151092
|
151093
|
151137
|
151138
|
151139
|
151140
|
151141
|
151142
|
151143
|
151144
|
151145
|
151163
|
151250
|
151367
|
151431