From c45c4a0ded76925eb4455076404d01a803b7f4f2 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 6 Sep 2016 18:56:17 +0200 Subject: [PATCH] Bug 11708: New page for basket groups This patch moves the code responsible for displaying a list of basket groups into its own Perl script (acqui/basketgroups.pl), making the code in basketgroup.pl and basketgroup.tt a little bit easier to read. basketgroups.pl displays all basket groups in a single table (as bug 13371 for vendors) where rows are grouped by bookseller. In the process, this patch adds 4 new "Koha::Object" modules: - Koha::Bookseller(s) - Koha::Basket(s) - Koha::Basketgroup(s) - Koha::Order(s) It also adds a wrapper around the new DataTable() constructor to be able to use it with the same defaults than the previous dataTable() constructor Test plan: 0. Create a bunch of booksellers and basketgroups 1. Go back to acquisitions home page and click on "Basket groups" link on the left 2. Play with the table (sort, filter) and try every possible actions (Edit, Close and export as PDF, View, Reopen, Export as CSV) 3. Go to a specific vendor page and click on "Basket groups" tab 4. Check that only the vendor's basket groups are displayed --- Koha/Basket.pm | 36 ++ Koha/Basketgroup.pm | 78 ++++ Koha/Basketgroups.pm | 32 ++ Koha/Baskets.pm | 32 ++ Koha/Bookseller.pm | 26 ++ Koha/Booksellers.pm | 32 ++ Koha/Order.pm | 26 ++ Koha/Orders.pm | 32 ++ acqui/basket.pl | 4 +- acqui/basketgroup.pl | 177 ++++----- acqui/basketgroups.pl | 52 +++ .../prog/en/includes/acquisitions-menu.inc | 2 +- .../intranet-tmpl/prog/en/includes/datatables.inc | 2 + .../intranet-tmpl/prog/en/includes/vendor-menu.inc | 2 +- .../prog/en/modules/acqui/basketgroup.tt | 408 +++++++-------------- .../prog/en/modules/acqui/basketgroups.tt | 162 ++++++++ koha-tmpl/intranet-tmpl/prog/js/basketgroup.js | 8 - koha-tmpl/intranet-tmpl/prog/js/datatables.js | 77 +++- 18 files changed, 784 insertions(+), 404 deletions(-) create mode 100644 Koha/Basket.pm create mode 100644 Koha/Basketgroup.pm create mode 100644 Koha/Basketgroups.pm create mode 100644 Koha/Baskets.pm create mode 100644 Koha/Bookseller.pm create mode 100644 Koha/Booksellers.pm create mode 100644 Koha/Order.pm create mode 100644 Koha/Orders.pm create mode 100755 acqui/basketgroups.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt diff --git a/Koha/Basket.pm b/Koha/Basket.pm new file mode 100644 index 0000000..4703101 --- /dev/null +++ b/Koha/Basket.pm @@ -0,0 +1,36 @@ +package Koha::Basket; + +# 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::Orders; + +use base qw(Koha::Object); + +sub _type { + return 'Aqbasket'; +} + +sub orders { + my ($self) = @_; + + $self->{_orders} ||= Koha::Orders->search({ basketno => $self->basketno }); + + return wantarray ? $self->{_orders}->as_list : $self->{_orders}; +} + +1; diff --git a/Koha/Basketgroup.pm b/Koha/Basketgroup.pm new file mode 100644 index 0000000..e624a35 --- /dev/null +++ b/Koha/Basketgroup.pm @@ -0,0 +1,78 @@ +package Koha::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::Baskets; + +use base qw(Koha::Object); + +sub _type { + return 'Aqbasketgroup'; +} + +sub bookseller { + my ($self) = @_; + + return Koha::Booksellers->find($self->booksellerid); +} + +sub baskets { + my ($self) = @_; + + $self->{_baskets} ||= Koha::Baskets->search({ basketgroupid => $self->id }); + + return wantarray ? $self->{_baskets}->as_list : $self->{_baskets}; +} + +sub baskets_count { + my ($self) = @_; + + return $self->baskets->count; +} + +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; +} + +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; +} + +1; diff --git a/Koha/Basketgroups.pm b/Koha/Basketgroups.pm new file mode 100644 index 0000000..1dbc6d1 --- /dev/null +++ b/Koha/Basketgroups.pm @@ -0,0 +1,32 @@ +package Koha::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::Basketgroup; + +use base qw(Koha::Objects); + +sub _type { + return 'Aqbasketgroup'; +} + +sub object_class { + return 'Koha::Basketgroup'; +} + +1; diff --git a/Koha/Baskets.pm b/Koha/Baskets.pm new file mode 100644 index 0000000..badd91a --- /dev/null +++ b/Koha/Baskets.pm @@ -0,0 +1,32 @@ +package Koha::Baskets; + +# 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::Basket; + +use base qw(Koha::Objects); + +sub _type { + return 'Aqbasket'; +} + +sub object_class { + return 'Koha::Basket'; +} + +1; diff --git a/Koha/Bookseller.pm b/Koha/Bookseller.pm new file mode 100644 index 0000000..1979f62 --- /dev/null +++ b/Koha/Bookseller.pm @@ -0,0 +1,26 @@ +package Koha::Bookseller; + +# 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 base qw(Koha::Object); + +sub _type { + return 'Aqbookseller'; +} + +1; diff --git a/Koha/Booksellers.pm b/Koha/Booksellers.pm new file mode 100644 index 0000000..fb689c7 --- /dev/null +++ b/Koha/Booksellers.pm @@ -0,0 +1,32 @@ +package Koha::Booksellers; + +# 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::Bookseller; + +use base qw(Koha::Objects); + +sub _type { + return 'Aqbookseller'; +} + +sub object_class { + return 'Koha::Bookseller'; +} + +1; diff --git a/Koha/Order.pm b/Koha/Order.pm new file mode 100644 index 0000000..7ab7ed1 --- /dev/null +++ b/Koha/Order.pm @@ -0,0 +1,26 @@ +package Koha::Order; + +# 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 base qw(Koha::Object); + +sub _type { + return 'Aqorder'; +} + +1; diff --git a/Koha/Orders.pm b/Koha/Orders.pm new file mode 100644 index 0000000..49f616b --- /dev/null +++ b/Koha/Orders.pm @@ -0,0 +1,32 @@ +package Koha::Orders; + +# 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::Order; + +use base qw(Koha::Objects); + +sub _type { + return 'Aqorder'; +} + +sub object_class { + return 'Koha::Order'; +} + +1; diff --git a/acqui/basket.pl b/acqui/basket.pl index 31b96bb..fb799ac 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -200,7 +200,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); } @@ -547,7 +547,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 { diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 3163a5a..9a17278 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -89,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; @@ -224,70 +222,25 @@ sub generate_edifact_orders { return; } -my $op = $input->param('op') || 'display'; # possible values of $op : -# - add : adds a new basketgroup, or edit an open basketgroup, or display a closed basketgroup # - mod_basket : modify an individual basket of the basketgroup -# - closeandprint : close and print an closed basketgroup in pdf. called by clicking on "Close and print" button in closed basketgroups list -# - print : print a closed basketgroup. called by clicking on "Print" button in closed basketgroups list +# - closeandprint : close and print an closed basketgroup in pdf. called by +# clicking on "Close and print" button in closed basketgroups list +# - print : print a closed basketgroup. called by clicking on "Print" button in +# closed basketgroups list # - ediprint : generate edi order messages for the baskets in the group -# - export : export in CSV a closed basketgroup. called by clicking on "Export" button in closed basketgroups list -# - delete : delete an open basketgroup. called by clicking on "Delete" button in open basketgroups list -# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button in closed basketgroup list -# - attachbasket : save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page -# - display : display the list of all basketgroups for a vendor +# - export : export in CSV a closed basketgroup. called by clicking on "Export" +# button in closed basketgroups list +# - delete : delete an open basketgroup. called by clicking on "Delete" button +# in open basketgroups list +# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button +# in closed basketgroup list +# - attachbasket : save a modified basketgroup, or creates a new basketgroup +# when a basket is closed. called from basket page +my $op = $input->param('op'); my $booksellerid = $input->param('booksellerid'); -$template->param(booksellerid => $booksellerid); -if ( $op eq "add" ) { -# -# if no param('basketgroupid') is not defined, adds a new basketgroup -# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid -# the template will know if basketgroup must be displayed or edited, depending on the value of closed key -# - my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); - my $basketgroupid = $input->param('basketgroupid'); - my $billingplace; - my $deliveryplace; - my $freedeliveryplace; - if ( $basketgroupid ) { - # Get the selected baskets in the basketgroup to display them - my $selecteds = GetBasketsByBasketgroup($basketgroupid); - foreach my $basket(@{$selecteds}){ - $basket->{total} = BasketTotal($basket->{basketno}, $bookseller); - } - $template->param(basketgroupid => $basketgroupid, - selectedbaskets => $selecteds); - - # Get general informations about the basket group to prefill the form - my $basketgroup = GetBasketgroup($basketgroupid); - $template->param( - name => $basketgroup->{name}, - deliverycomment => $basketgroup->{deliverycomment}, - freedeliveryplace => $basketgroup->{freedeliveryplace}, - ); - $billingplace = $basketgroup->{billingplace}; - $deliveryplace = $basketgroup->{deliveryplace}; - $freedeliveryplace = $basketgroup->{freedeliveryplace}; - $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0); - } else { - $template->param( closedbg => 0); - } - # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data - my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) ); - $billingplace = $billingplace || $borrower->{'branchcode'}; - $deliveryplace = $deliveryplace || $borrower->{'branchcode'}; - - $template->param( billingplace => $billingplace ); - $template->param( deliveryplace => $deliveryplace ); - $template->param( booksellerid => $booksellerid ); - - # the template will display a unique basketgroup - $template->param(grouping => 1); - my $basketgroups = &GetBasketgroups($booksellerid); - my $baskets = &GetBasketsByBookseller($booksellerid); - displaybasketgroups($basketgroups, $bookseller, $baskets); -} elsif ($op eq 'mod_basket') { +if ($op eq 'mod_basket') { # # edit an individual basket contained in this basketgroup # @@ -328,7 +281,8 @@ if ( $op eq "add" ) { # my $basketgroupid = $input->param('basketgroupid'); DelBasketgroup($basketgroupid); - print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&listclosed=1'); + print $input->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid); + exit; }elsif ( $op eq 'reopen'){ # # reopen a closed basketgroup @@ -336,8 +290,15 @@ if ( $op eq "add" ) { my $basketgroupid = $input->param('basketgroupid'); my $booksellerid = $input->param('booksellerid'); ReOpenBasketgroup($basketgroupid); - my $redirectpath = ((defined $input->param('mode'))&& ($input->param('mode') eq 'singlebg')) ?'/cgi-bin/koha/acqui/basketgroup.pl?op=add&basketgroupid='.$basketgroupid.'&booksellerid='.$booksellerid : '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' .$booksellerid.'&listclosed=1'; + my $redirectpath; + my $mode = $input->param('mode'); + if (defined $mode && $mode eq 'singlebg') { + $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&basketgroupid='.$basketgroupid.'&booksellerid='.$booksellerid; + } else { + $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' .$booksellerid; + } print $input->redirect($redirectpath); + exit; } elsif ( $op eq 'attachbasket') { # # save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page @@ -383,45 +344,63 @@ if ( $op eq "add" ) { }; $basketgroupid = NewBasketgroup($basketgroup); } - my $redirectpath = ((defined $input->param('mode')) && ($input->param('mode') eq 'singlebg')) ?'/cgi-bin/koha/acqui/basketgroup.pl?op=add&basketgroupid='.$basketgroupid.'&booksellerid='.$booksellerid : '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid; - $redirectpath .= "&listclosed=1" if $closedbg ; - print $input->redirect($redirectpath ); - + my $redirectpath; + my $mode = $input->param('mode'); + if (defined $mode && $mode eq 'singlebg') { + $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&basketgroupid='.$basketgroupid.'&booksellerid='.$booksellerid; + } else { + $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid; + } + print $input->redirect($redirectpath); + exit; } elsif ( $op eq 'ediprint') { my $basketgroupid = $input->param('basketgroupid'); generate_edifact_orders( $basketgroupid ); exit; -}else{ - my @booksellers; - if ($booksellerid) { - my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); - push @booksellers, $bookseller; - $template->param(booksellername => $booksellers[0]->{name}); - } else { - @booksellers = Koha::Acquisition::Bookseller->search; - } - foreach my $bookseller (@booksellers) { - $bookseller->{basketgroups} = GetBasketgroups($bookseller->{id}); - foreach my $basketgroup (@{ $bookseller->{basketgroups} }) { - my $baskets = GetBasketsByBasketgroup($basketgroup->{id}); - $basketgroup->{basketsqty} = 0; - my (@ordered_biblionumbers, @received_biblionumbers); - foreach my $basket (@$baskets) { - $basketgroup->{basketsqty} += 1; - my @orders = GetOrders($basket->{basketno}); - foreach my $order (@orders) { - push @ordered_biblionumbers, $order->{biblionumber}; - if ($order->{datereceived}) { - push @received_biblionumbers, $order->{biblionumber}; - } - } - } - $basketgroup->{ordered_titles_count} = uniq @ordered_biblionumbers; - $basketgroup->{received_titles_count} = uniq @received_biblionumbers; - } +} + +# if no param('basketgroupid') is not defined, adds a new basketgroup else, edit +# (if it is open) or display (if it is close) the basketgroup basketgroupid the +# template will know if basketgroup must be displayed or edited, depending on +# the value of closed key + +my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); +my $basketgroupid = $input->param('basketgroupid'); +my $billingplace; +my $deliveryplace; +my $freedeliveryplace; +if ( $basketgroupid ) { + # Get the selected baskets in the basketgroup to display them + my $selecteds = GetBasketsByBasketgroup($basketgroupid); + foreach my $basket(@{$selecteds}){ + $basket->{total} = BasketTotal($basket->{basketno}, $bookseller); } - $template->param(booksellers => \@booksellers); + $template->param(basketgroupid => $basketgroupid, + selectedbaskets => $selecteds); + + # Get general informations about the basket group to prefill the form + my $basketgroup = GetBasketgroup($basketgroupid); + $template->param( + name => $basketgroup->{name}, + billingplace => $basketgroup->{billingplace}, + deliveryplace => $basketgroup->{deliveryplace}, + deliverycomment => $basketgroup->{deliverycomment}, + freedeliveryplace => $basketgroup->{freedeliveryplace}, + closedbg => $basketgroup->{closed} ? 1 : 0 + ); +} else { + $template->param( closedbg => 0); } -$template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 ); -#prolly won't use all these, maybe just use print, the rest can be done inside validate +# determine default billing and delivery places depending on librarian homebranch and existing basketgroup data +my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) ); +$billingplace = $billingplace || $borrower->{'branchcode'}; +$deliveryplace = $deliveryplace || $borrower->{'branchcode'}; + +$template->param( booksellerid => $booksellerid ); + +# the template will display a unique basketgroup +my $basketgroups = &GetBasketgroups($booksellerid); +my $baskets = &GetBasketsByBookseller($booksellerid); +displaybasketgroups($basketgroups, $bookseller, $baskets, $template); + output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/basketgroups.pl b/acqui/basketgroups.pl new file mode 100755 index 0000000..debe80d --- /dev/null +++ b/acqui/basketgroups.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +# 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, see . + +use Modern::Perl; + +use CGI qw(-utf8); + +use C4::Auth; +use C4::Output; + +use Koha::Acquisition::Basketgroups; +use Koha::Acquisition::Booksellers; + +my $cgi = new CGI; + +my ($template, $loggedinuser, $cookie) = get_template_and_user({ + template_name => 'acqui/basketgroups.tt', + query => $cgi, + type => 'intranet', + flagsrequired => { acquisition => 'group_manage' }, +}); + +my $booksellerid = $cgi->param('booksellerid'); + +my $params = {}; +if ($booksellerid) { + $params->{booksellerid} = $booksellerid; + my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); + $template->param(bookseller => $bookseller); +} + +my @basketgroups = Koha::Acquisition::Basketgroups->search($params); + +$template->param( + basketgroups => \@basketgroups, +); + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc index f9cf6dc..c5f9ab8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc @@ -1,6 +1,6 @@