@@ -, +, @@ - No. of ordered titles - No. of received titles - Date closed on the left (Edit, Close and export as PDF, View, Reopen, Export as CSV) --- C4/Acquisition.pm | 8 +- Koha/Acquisition/Basket.pm | 22 ++ Koha/Acquisition/Basketgroup.pm | 133 +++++++ Koha/Acquisition/Basketgroups.pm | 50 +++ acqui/basket.pl | 4 +- acqui/basketgroup.pl | 187 +++++----- acqui/basketgroups.pl | 52 +++ .../prog/en/includes/acquisitions-menu.inc | 3 + .../intranet-tmpl/prog/en/includes/datatables.inc | 2 + .../intranet-tmpl/prog/en/includes/vendor-menu.inc | 2 +- .../prog/en/modules/acqui/basketgroup.tt | 382 ++++++++------------- .../prog/en/modules/acqui/basketgroups.tt | 163 +++++++++ koha-tmpl/intranet-tmpl/prog/js/basketgroup.js | 8 - koha-tmpl/intranet-tmpl/prog/js/datatables.js | 95 +++-- 14 files changed, 739 insertions(+), 372 deletions(-) create mode 100644 Koha/Acquisition/Basketgroup.pm create mode 100644 Koha/Acquisition/Basketgroups.pm create mode 100755 acqui/basketgroups.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -1510,7 +1510,9 @@ sub ModReceiveOrder { $order->{datereceived} = $datereceived; $order->{invoiceid} = $invoice->{invoiceid}; $order->{orderstatus} = 'complete'; - $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; # TODO What if the store fails? + my @columns = Koha::Acquisition::Orders->columns; + my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns; + $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber; if ($received_items) { foreach my $itemnumber (@$received_items) { @@ -2000,7 +2002,9 @@ sub TransferOrder { delete $order->{parent_ordernumber}; $order->{'basketno'} = $basketno; - my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; + my @columns = Koha::Acquisition::Orders->columns; + my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns; + my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber; $query = q{ UPDATE aqorders_items --- a/Koha/Acquisition/Basket.pm +++ a/Koha/Acquisition/Basket.pm @@ -20,6 +20,7 @@ package Koha::Acquisition::Basket; use Modern::Perl; use Koha::Database; +use Koha::Acquisition::Orders; use base qw( Koha::Object ); @@ -58,6 +59,27 @@ sub effective_create_items { return $self->create_items || C4::Context->preference('AcqCreateItem'); } +=head3 orders + +Returns basket's orders + + # As an arrayref + my $orders = $basket->orders; + + # As an array + my @orders = $basket->orders; + +=cut + +sub orders { + my ($self) = @_; + + $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno }); + + return wantarray ? $self->{_orders}->as_list : $self->{_orders}; +} + + =head2 Internal methods =head3 _type --- a/Koha/Acquisition/Basketgroup.pm +++ a/Koha/Acquisition/Basketgroup.pm @@ -0,0 +1,133 @@ +package Koha::Acquisition::Basketgroup; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha 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 GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use List::MoreUtils qw/uniq/; + +use Koha::Acquisition::Baskets; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Acquisition::Basketgroup + +=head1 API + +=head2 Methods + +=head3 bookseller + +Returns the basketgroup's bookseller (Koha::Acquisition::Bookseller) + + my $bookseller = $basketgroup->bookseller; + +=cut + +sub bookseller { + my ($self) = @_; + + return scalar Koha::Acquisition::Booksellers->find($self->booksellerid); +} + +=head3 baskets + +Returns the basketgroup's baskets + + my $baskets = $basketgroup->baskets; # Koha::Acquisition::Baskets + my @baskets = $basketgroup->baskets; # array of Koha::Acquisition::Basket + +=cut + +sub baskets { + my ($self) = @_; + + $self->{_baskets} ||= Koha::Acquisition::Baskets->search({ basketgroupid => $self->id }); + + return wantarray ? $self->{_baskets}->as_list : $self->{_baskets}; +} + +=head3 baskets_count + +Returns the number of baskets contained in a basket group + + my $count = $basketgroup->baskets_count; + +=cut + +sub baskets_count { + my ($self) = @_; + + return $self->baskets->count; +} + +=head3 ordered_titles_count + +Returns the number of ordered titles contained in a basket group + + my $count = $basketgroup->ordered_titles_count; + +=cut + +sub ordered_titles_count { + my ($self) = @_; + + my @biblionumbers; + foreach my $basket ($self->baskets) { + foreach my $order ($basket->orders) { + push @biblionumbers, $order->biblionumber; + } + } + + return scalar uniq @biblionumbers; +} + +=head3 received_titles_count + +Returns the number of received titles contained in a basket group + + my $count = $basketgroup->ordered_titles_count; + +=cut + +sub received_titles_count { + my ($self) = @_; + + my @biblionumbers; + foreach my $basket ($self->baskets) { + foreach my $order ($basket->orders) { + if ($order->datereceived) { + push @biblionumbers, $order->biblionumber; + } + } + } + + return scalar uniq @biblionumbers; +} + +=head2 Internal Methods + +=head3 _type + +=cut + +sub _type { + return 'Aqbasketgroup'; +} + +1; --- a/Koha/Acquisition/Basketgroups.pm +++ a/Koha/Acquisition/Basketgroups.pm @@ -0,0 +1,50 @@ +package Koha::Acquisition::Basketgroups; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha 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 GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Acquisition::Basketgroup; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Acquisition::Basketgroups + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'Aqbasketgroup'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Acquisition::Basketgroup'; +} + +1; --- a/acqui/basket.pl +++ a/acqui/basket.pl @@ -207,7 +207,7 @@ if ( $op eq 'delete_confirm' ) { }); ModBasket( { basketno => $basketno, basketgroupid => $basketgroupid } ); - print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid='.$booksellerid.'&closed=1'); + print $query->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid='.$booksellerid); } else { print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' . $booksellerid); } @@ -554,7 +554,7 @@ sub edi_close_and_order { } ); print $query->redirect( -"/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=$booksellerid&closed=1" + "/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=$booksellerid" ); } else { --- a/acqui/basketgroup.pl +++ a/acqui/basketgroup.pl @@ -58,6 +58,8 @@ use Koha::Acquisition::Booksellers; use Koha::ItemTypes; use Koha::Patrons; +use List::MoreUtils qw/uniq/; + our $input=new CGI; our ($template, $loggedinuser, $cookie) @@ -87,9 +89,7 @@ sub BasketTotal { #displays all basketgroups and all closed baskets (in their respective groups) sub displaybasketgroups { - my $basketgroups = shift; - my $bookseller = shift; - my $baskets = shift; + my ($basketgroups, $bookseller, $baskets, $template) = @_; if (scalar @$basketgroups != 0) { foreach my $basketgroup (@$basketgroups){ my $i = 0; @@ -123,29 +123,31 @@ sub displaybasketgroups { sub printbasketgrouppdf{ my ($basketgroupid) = @_; - + my $pdfformat = C4::Context->preference("OrderPdfFormat"); if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr' || $pdfformat eq 'pdfformat::layout2pagesde'){ - eval { - eval "require $pdfformat"; - import $pdfformat; - }; - if ($@){ - } + eval { + my $pdfformatfile = './' . ($pdfformat =~ s,::,/,gr) . '.pm'; + require $pdfformatfile; + import $pdfformat; + }; + if ($@){ + warn $@; + } } else { - print $input->header; - print $input->start_html; # FIXME Should do a nicer page - print "
Name | +Vendor | +Billing place | +Delivery place | +No. of baskets | +No. of ordered titles | +No. of received titles | +Date closed | +Action | +
---|---|---|---|---|---|---|---|---|
+ [% IF ( basketgroup.name ) %] + [% basketgroup.name %] + [% ELSE %] + Basket group no. [% basketgroup.id %] + [% END %] + | +[% basketgroup.bookseller.name %] | +[% Branches.GetName(basketgroup.billingplace) %] | ++ [% IF (basketgroup.freedeliveryplace) %] + [% basketgroup.freedeliveryplace %] + [% ELSE %] + [% Branches.GetName(basketgroup.deliveryplace) %] + [% END %] + | +[% basketgroup.baskets_count %] | +[% basketgroup.ordered_titles_count %] | +[% basketgroup.received_titles_count %] | +[% basketgroup.closeddate | $KohaDates %] | +
+
+ Actions
+
+
+ |
+