From b7765f86c9548377e23a82644c14fbef143eae68 Mon Sep 17 00:00:00 2001 From: Julian Maurice <julian.maurice@biblibre.com> Date: Tue, 6 Sep 2016 18:56:17 +0200 Subject: [PATCH] Bug 11708: New page for basket groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> --- 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 | 208 +++++------ 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, 800 insertions(+), 419 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 0000000000..4703101a50 --- /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 0000000000..e624a35b0b --- /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 0000000000..1dbc6d1e74 --- /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 0000000000..badd91ab5b --- /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 0000000000..1979f6207d --- /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 0000000000..fb689c7a95 --- /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 0000000000..7ab7ed11e5 --- /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 0000000000..49f616b12a --- /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 92fae60a0a..1b306bdee8 100755 --- a/acqui/basket.pl +++ b/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 { diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 93c33288ca..270402df05 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -90,9 +90,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; @@ -126,29 +124,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 "<h1>Invalid PDF Format set</h1>"; - print "Please go to the systempreferences and set a valid pdfformat"; - exit; + print $input->header; + print $input->start_html; # FIXME Should do a nicer page + print "<h1>Invalid PDF Format set</h1>"; + print "Please go to the systempreferences and set a valid pdfformat"; + exit; } - + my $basketgroup = GetBasketgroup($basketgroupid); my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} ); my $baskets = GetBasketsByBasketgroup($basketgroupid); - + my %orders; for my $basket (@$baskets) { my @ba_orders; @@ -211,7 +211,6 @@ sub printbasketgrouppdf{ ); my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed"; print $pdf; - } sub generate_edifact_orders { @@ -225,70 +224,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 $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set - $billingplace = $billingplace || $patron->branchcode; - $deliveryplace = $deliveryplace || $patron->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 # @@ -329,7 +283,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 @@ -337,8 +292,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 @@ -384,45 +346,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 = Koha::Patrons->find( $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 0000000000..debe80db1b --- /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 <http://www.gnu.org/licenses>. + +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 42412604e9..9421bac20e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc @@ -4,7 +4,7 @@ <ul> <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li> [% IF ( CAN_user_acquisition_group_manage ) %] - <li><a href="/cgi-bin/koha/acqui/basketgroup.pl">Basket groups</a></li> + <li><a href="/cgi-bin/koha/acqui/basketgroups.pl">Basket groups</a></li> [% END %] <li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li> [% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc index 3a79dacb5a..d2648b52a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc @@ -20,6 +20,8 @@ var MSG_DT_SEARCH = _("Search:"); var MSG_DT_ZERO_RECORDS = _("No matching records found"); var MSG_DT_ALL = _("All"); + var MSG_DT_SORT_ASC = _(": activate to sort column ascending"); + var MSG_DT_SORT_DESC = _(": activate to sort column descending"); var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the"); //]]> </script> diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc index 106221e203..724b43c610 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc @@ -2,7 +2,7 @@ <div id="menu"> <ul> [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid %]">Baskets</a></li>[% END %] - [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]">Basket groups</a></li>[% END %] + [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid %]">Basket groups</a></li>[% END %] [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a></li>[% END %] <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid %]&op=do_search">Invoices</a></li> [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt index 528be3f347..3fb2aed4c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -16,7 +16,6 @@ [% Asset.js("lib/yui/container/container_core-min.js") %] [% Asset.js("lib/yui/menu/menu-min.js") %] [% Asset.js("js/basketgroup.js") %] -[% IF ( grouping ) %] [% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") %] [% Asset.js("lib/yui/animation/animation-min.js") %] [% Asset.js("lib/yui/dragdrop/dragdrop-min.js") %] @@ -92,7 +91,6 @@ fieldset.various li { } </style> - [% END %] <script type="text/javascript"> //<![CDATA[ YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true); @@ -155,304 +153,166 @@ function submitForm(form) { [% 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> › -[% IF ( grouping ) %] - <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> › <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]">Basket groups</a> › Add basket group for [% booksellername |html %] -[% ELSE %] - [% IF (booksellerid) %] - <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> › - [% END %] - Basket groups -[% END %] + <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> + › + <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid %]">Basket groups</a> + › + Add basket group for [% booksellername |html %] </div> <div id="doc3" class="yui-t2"> <div id="bd"> <div id="yui-main"> <div class="yui-b"> - [% IF ( grouping ) %] - [% IF (closedbg) %] - <div id="toolbar" class="btn-toolbar"> - <div class="btn-group"><a href="[% script_name %]?op=reopen&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]&mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div> - <div class="btn-group"><a href="[% script_name %]?op=export&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div> - <div class="btn-group"><a href="[% script_name %]?op=print&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div> - <div class="btn-group"><a href="[% script_name %]?op=ediprint&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div> + [% IF (closedbg) %] + <div id="toolbar" class="btn-toolbar"> + <div class="btn-group"><a href="[% script_name %]?op=reopen&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]&mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div> + <div class="btn-group"><a href="[% script_name %]?op=export&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div> + <div class="btn-group"><a href="[% script_name %]?op=print&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div> + <div class="btn-group"><a href="[% script_name %]?op=ediprint&basketgroupid=[% basketgroupid %]&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div> + </div> + [% END %] + [% IF (name && closedbg) %] + <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> + [% ELSIF (name) %] + <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> + [% ELSE %] + <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> + [% END %] + <div id="basketgroupcolumns" class="yui-g"> + [% UNLESS (closedbg) %] + <div class="yui-u"> + <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups"> + <div id="groups"> + <fieldset class="brief"> + <div class="workarea_alt" > + <h3>Ungrouped baskets</h3> + <ul id="ungrouped" class="draglist_alt"> + [% IF ( baskets ) %] + [% FOREACH basket IN baskets %] + <li class="ungrouped" id="b-[% basket.basketno %]" > + <a href="basket.pl?basketno=[% basket.basketno %]"> + [% IF ( basket.basketname ) %] + [% basket.basketname %] + [% ELSE %] + No name, basketnumber: [% basket.basketno %] + [% END %] + </a>, <br /> + Total: [% basket.total %] + <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" /> + </li> + [% END %] + [% END %] + </ul> + </div> + </fieldset> + </div> + </form> </div> [% END %] - [% IF (name && closedbg) %] - <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> - [% ELSIF (name) %] - <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> - [% ELSE %] - <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1> - [% END %] - <div id="basketgroupcolumns" class="yui-g"> - [% UNLESS (closedbg) %] - <div class="yui-u"> - <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups"> - <div id="groups"> - <fieldset class="brief"> - <div class="workarea_alt" > - <h3>Ungrouped baskets</h3> - <ul id="ungrouped" class="draglist_alt"> - [% IF ( baskets ) %] - [% FOREACH basket IN baskets %] - <li class="ungrouped" id="b-[% basket.basketno %]" > - <a href="basket.pl?basketno=[% basket.basketno %]"> - [% IF ( basket.basketname ) %] - [% basket.basketname %] - [% ELSE %] - No name, basketnumber: [% basket.basketno %] - [% END %] - </a>, <br /> - Total: [% basket.total %] - <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" /> - </li> - [% END %] - [% END %] - </ul> - </div> - </fieldset> - </div> - </form> - </div> - [% END %] - <div class="yui-u first"> - <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)"> - <fieldset id="various" class="brief"> - <ol> + <div class="yui-u first"> + <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)"> + <fieldset id="various" class="brief"> + <ol> + [% UNLESS (closedbg) %] + <li> + <label for="basketgroupname">Basket group name:</label> + <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" /> + </li> + [% ELSE %] + <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" /> + [% END %] + <li> [% UNLESS (closedbg) %] - <li> - <label for="basketgroupname">Basket group name:</label> - <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" /> - </li> + <label for="billingplace">Billing place:</label> + <select name="billingplace" id="billingplace" style="width:13em;"> + <option value="">--</option> + [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %] + </select> [% ELSE %] - <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" /> + <span class="label">Billing place:</span> + <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %] [% END %] + </li> + [% UNLESS (closedbg) %] <li> - [% UNLESS (closedbg) %] - <label for="billingplace">Billing place:</label> - <select name="billingplace" id="billingplace" style="width:13em;"> - <option value="">--</option> - [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %] - </select> - [% ELSE %] - <span class="label">Billing place:</span> - <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %] - [% END %] + <label for="deliveryplace">Delivery place:</label> + <select name="deliveryplace" id="deliveryplace" style="width:13em;"> + <option value="">--</option> + [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %] + <select> </li> - [% UNLESS (closedbg) %] - <li> - <label for="deliveryplace">Delivery place:</label> - <select name="deliveryplace" id="deliveryplace" style="width:13em;"> - <option value="">--</option> - [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %] - <select> - </li> - <li><p>or</p></li> - <li> - <label for="freedeliveryplace">Delivery place:</label> - <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea> - </li> - [% ELSE %] - <li> - <span class="label">Delivery place:</span> - [% IF (freedeliveryplace) %] - <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %] - <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" /> - [% ELSE %] - <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %] - <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" /> - [% END %] - </li> - [% END %] + <li><p>or</p></li> + <li> + <label for="freedeliveryplace">Delivery place:</label> + <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea> + </li> + [% ELSE %] <li> - [% UNLESS (closedbg) %] - <label for="deliverycomment">Delivery comment:</label> - <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea> + <span class="label">Delivery place:</span> + [% IF (freedeliveryplace) %] + <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %] + <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" /> [% ELSE %] - <span class="label">Delivery comment:</span>[% deliverycomment %] - <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" /> + <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %] + <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" /> [% END %] </li> - <li> - <span class="label">Baskets in this group:</span> - [% UNLESS (closedbg) %] - <ul class="draglist" id="bg"> - [% ELSE %] - <ul> - [% END %] - [% FOREACH selectedbasket IN selectedbaskets %] - <li class="grouped" id="b-[% selectedbasket.basketno %]" > - <a href="basket.pl?basketno=[% selectedbasket.basketno %]"> - [% IF ( selectedbasket.basketname ) %] - [% selectedbasket.basketname %] - [% ELSE %] - No name, basketnumber: [% selectedbasket.basketno %] - [% END %] - </a>, <br /> - Total: [% selectedbasket.total %] - <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" /> - </li> - [% END %] - </ul> + [% END %] + <li> + [% UNLESS (closedbg) %] + <label for="deliverycomment">Delivery comment:</label> + <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea> + [% ELSE %] + <span class="label">Delivery comment:</span>[% deliverycomment %] + <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" /> + [% END %] </li> + <li> + <span class="label">Baskets in this group:</span> [% UNLESS (closedbg) %] - <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li> + <ul class="draglist" id="bg"> [% ELSE %] - <input type="hidden" id="closedbg" name="closedbg" value ="1"/> + <ul> [% END %] - </ol> - </fieldset> - [% UNLESS (closedbg) %] - <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" /> - [% IF ( basketgroupid ) %] - <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" /> + [% FOREACH selectedbasket IN selectedbaskets %] + <li class="grouped" id="b-[% selectedbasket.basketno %]" > + <a href="basket.pl?basketno=[% selectedbasket.basketno %]"> + [% IF ( selectedbasket.basketname ) %] + [% selectedbasket.basketname %] + [% ELSE %] + No name, basketnumber: [% selectedbasket.basketno %] + [% END %] + </a>, <br /> + Total: [% selectedbasket.total %] + <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" /> + </li> + [% END %] + </ul> + </li> + [% UNLESS (closedbg) %] + <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li> + [% ELSE %] + <input type="hidden" id="closedbg" name="closedbg" value ="1"/> [% END %] - <input type="hidden" name="op" value="attachbasket" /> - <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a> - </fieldset> - [% END %] - </form> - </div> + </ol> + </fieldset> + [% UNLESS (closedbg) %] + <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" /> + [% IF ( basketgroupid ) %] + <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" /> + [% END %] + <input type="hidden" name="op" value="attachbasket" /> + <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a> + </fieldset> + [% END %] + </form> </div> - [% ELSE %] - [% IF booksellerid %] - <div id="toolbar" class="btn-toolbar"> - <div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a></div> - </div> - [% END %] - - [% FOREACH bookseller IN booksellers %] - [% IF bookseller.basketgroups.size > 0 %] - <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a></h1> - <div class="basket_groups toptabs"> - <ul class="ui-tabs-nav"> - [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened[% bookseller.id %]">Open</a></li> - [% ELSE%]<li><a href="#opened[% bookseller.id %]">Open</a></li>[% END %] - [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed[% bookseller.id %]">Closed</a></li> - [% ELSE %]<li><a href="#closed[% bookseller.id %]">Closed</a></li>[% END %] - </ul> - <div id="opened[% bookseller.id %]"> - <table id="basket_group_opened"> - <thead> - <tr> - <th>Search name</th> - <th>Search no.</th> - <th>Search billing place</th> - <th>Search delivery place</th> - <th>Search no. of baskets</th> - <th>Search no. of ordered titles</th> - <th>Search no. of received titles</th> - <th></th> - </tr> - <tr> - <th>Name</th> - <th>No.</th> - <th>Billing place</th> - <th>Delivery place</th> - <th>No. of baskets</th> - <th>No. of ordered titles</th> - <th>No. of received titles</th> - <th>Action</th> - </tr> - </thead> - <tbody> - [% FOREACH basketgroup IN bookseller.basketgroups %] - [% UNLESS ( basketgroup.closed ) %] - <tr> - <td> - [% IF ( basketgroup.name ) %] - [% basketgroup.name %] - [% ELSE %] - Basket group no. [% basketgroup.id %] - [% END %] - </td> - <td>[% basketgroup.id %]</td> - <td>[% Branches.GetName(basketgroup.billingplace) %]</td> - <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td> - <td>[% basketgroup.basketsqty %]</td> - <td>[% basketgroup.ordered_titles_count %]</td> - <td>[% basketgroup.received_titles_count %]</td> - <td> - <input type="button" onclick="closeandprint('[% basketgroup.id %]');" value="Close and export as PDF" /> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Edit" /></form> - [% UNLESS basketgroup.basketsqty %] - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="delete" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Delete" /></form> - [% END %] - </td> - </tr> - [% END %] - [% END %] - </tbody> - </table> - </div> - <div id="closed[% bookseller.id %]"> - <table class="basket_group_closed"> - <thead> - <tr> - <th>Search name</th> - <th>Search no.</th> - <th>Search date closed</th> - <th>Search billing place</th> - <th>Search delivery place</th> - <th>Search no. of baskets</th> - <th>Search no. of ordered titles</th> - <th>Search no. of received titles</th> - <th></th> - </tr> - <tr> - <th>Name</th> - <th>No.</th> - <th>Date closed</th> - <th>Billing place</th> - <th>Delivery place</th> - <th>No. of baskets</th> - <th>No. of ordered titles</th> - <th>No. of received titles</th> - <th>Action</th> - </tr> - </thead> - <tbody> - [% FOREACH basketgroup IN bookseller.basketgroups %] - [% IF ( basketgroup.closed ) %] - <tr> - <td> - [% IF ( basketgroup.name ) %] - [% basketgroup.name %] - [% ELSE %] - Basket group no. [% basketgroup.id %] - [% END %] - </td> - <td>[% basketgroup.id %]</td> - <td>[% basketgroup.closeddate |$KohaDates %]</td> - <td>[% Branches.GetName(basketgroup.billingplace) %]</td> - <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td> - <td>[% basketgroup.basketsqty %]</td> - <td>[% basketgroup.ordered_titles_count %]</td> - <td>[% basketgroup.received_titles_count %]</td> - <td> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="View" /></form> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="reopen" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Reopen" /></form> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="print" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Export as PDF" /></form> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="export" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Export as CSV" /></form> - <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="ediprint" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Generate EDIFACT order" /></form> - </td> - </tr> - [% END %] - [% END %] - </tbody> - </table> - </div> - </div> - [% END %] - [% END %] - [% END %] + </div> </div> </div> <div class="yui-b"> - [% IF ( booksellerid ) %] - [% INCLUDE 'vendor-menu.inc' %] - [% END %] + [% INCLUDE 'vendor-menu.inc' %] [% INCLUDE 'acquisitions-menu.inc' %] </div> </div> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt new file mode 100644 index 0000000000..d764c54519 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt @@ -0,0 +1,162 @@ +[% USE Branches %] +[% USE KohaDates %] + +[% INCLUDE 'doc-head-open.inc' %] + [% IF bookseller %] + <title>Koha › Basket groups for [% bookseller.name |html %]</title> + [% ELSE %] + <title>Koha › Basket groups</title> + [% END %] + + <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> + [% INCLUDE 'doc-head-close.inc' %] + [% INCLUDE 'datatables.inc' %] + <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script> + <script type="text/javascript"> + $(document).ready(function() { + var options = { + "paging": false, + "autoWidth": false, + "columnDefs": [ + { "visible": false, "targets": 1 }, + { "orderable": false, "targets": -1 } + ], + "orderFixed": [[ 1, 'asc' ]] + }; + [% UNLESS bookseller %] + options.drawCallback = function(settings) { + var api = this.api(); + var rows = api.rows({page: 'current'}).nodes(); + var last = null; + + api.column(1, {page: 'current'}).data().each(function(group, i) { + if (last !== group) { + $(rows).eq(i).before( + '<tr><td class="group" colspan="8">' + group + '</td></tr>' + ); + last = group; + } + }); + }; + [% END %] + $("#basketgroups-table").kohaDataTable(options); + + $('#basketgroups-table').on('click', '.closeandprint', function(e) { + e.preventDefault(); + var w = window.open($(this).attr('href')); + var timer = setInterval(function() { + if (w.closed === true) { + clearInterval(timer); + window.location.reload(true); + } + }, 1000); + }); + $('#basketgroups-table').on('click', '.delete', function() { + return confirm(_("Are you sure you want to delete this basketgroup ?")); + }); + }); + </script> +</head> +<body id="acq_basketgroup" class="acq"> + [% 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> + › + [% IF (bookseller) %] + <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a> + › + [% END %] + Basket groups + </div> + + <div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% IF bookseller %] + <div id="toolbar" class="btn-toolbar"> + <div class="btn-group"> + <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% bookseller.id %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a> + </div> + </div> + + <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a></h1> + [% END %] + + [% IF basketgroups.size > 0 %] + <table id="basketgroups-table" class="group"> + <thead> + <tr> + <th>Name</th> + <th>Bookseller</th> + <th>Billing place</th> + <th>Delivery place</th> + <th>No. of baskets</th> + <th>No. of ordered titles</th> + <th>No. of received titles</th> + <th>Date closed</th> + <th>Action</th> + </tr> + </thead> + <tbody> + [% FOREACH basketgroup IN basketgroups %] + <tr> + <td> + [% IF ( basketgroup.name ) %] + [% basketgroup.name %] + [% ELSE %] + Basket group no. [% basketgroup.id %] + [% END %] + </td> + <td>[% basketgroup.bookseller.name %]</td> + <td>[% Branches.GetName(basketgroup.billingplace) %]</td> + <td> + [% IF (basketgroup.freedeliveryplace) %] + [% basketgroup.freedeliveryplace %] + [% ELSE %] + [% Branches.GetName(basketgroup.deliveryplace) %] + [% END %] + </td> + <td>[% basketgroup.baskets_count %]</td> + <td>[% basketgroup.ordered_titles_count %]</td> + <td>[% basketgroup.received_titles_count %]</td> + <td>[% basketgroup.closeddate | $KohaDates %]</td> + <td> + <div class="dropdown"> + <a class="btn btn-default btn-xs dropdown-toggle" id="actions-[% basketgroup.id %]" role="button" data-toggle="dropdown">Actions <b class="caret"></b></a> + <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="actions-[% basketgroup.id %]"> + [% IF basketgroup.closeddate %] + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-eye"></i> View</a></li> + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-folder-open"></i> Reopen</a></li> + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=print&basketgroupid=[% basketgroup.id %]"><i class="fa fa-print"></i> Export as PDF</a></li> + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=export&basketgroupid=[% basketgroup.id %]"><i class="fa fa-file-text"></i> Export as CSV</a></li> + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=ediprint&baskegroupid=[% basketgroup.id %]">Generate EDIFACT Order</a></li> + [% ELSE %] + <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-pencil"></i> Edit</a></li> + <li><a class="closeandprint" href="/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=[% basketgroup.id %]"><i class="fa fa-print"></i> Close and export as PDF</a></li> + [% UNLESS basketgroup.baskets_count %] + <li><a class="delete" href="/cgi-bin/koha/acqui/basketgroup.pl?op=delete&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-trash"></i> Delete</a></li> + [% END %] + [% END %] + </ul> + </div> + </td> + </tr> + [% END %] + </tbody> + </table> + [% END %] + </div> + </div> + <div class="yui-b"> + [% IF bookseller %] + [% INCLUDE 'vendor-menu.inc' booksellerid = bookseller.id %] + [% END %] + [% INCLUDE 'acquisitions-menu.inc' %] + </div> + </div> + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/basketgroup.js b/koha-tmpl/intranet-tmpl/prog/js/basketgroup.js index 0d8a525a46..daf0a15d23 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/basketgroup.js +++ b/koha-tmpl/intranet-tmpl/prog/js/basketgroup.js @@ -233,14 +233,6 @@ function closebasketgroup(bgid) { div.appendChild(unclosegroup); } -function closeandprint(bg){ - if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=' + bg ){ - setTimeout("window.location.reload();",3000); - }else{ - alert(MSG_FILE_DOWNLOAD_ERROR); - } -} - //function that lets the user unclose a basketgroup //as long as they haven't submitted the changes to the page. function unclosegroup(bgid){ diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 99aec8396e..c447c86132 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -1,34 +1,73 @@ // These default options are for translation but can be used // for any other datatables settings // MSG_DT_* variables comes from datatables.inc -// To use it, write: -// $("#table_id").dataTable($.extend(true, {}, dataTableDefaults, { -// // other settings -// } ) ); +// Since version 1.10, DataTables has a new API while still providing the older +// one. +// You can use the new API with these defaults by writing: +// +// $('#table_id').kohaDataTable({ ... }); +// +// To use the older API, write: +// +// $("#table_id").dataTable($.extend(true, {}, dataTablesDefaults, { ... }); + +var DataTableDefaults = { + "language": { + "emptyTable": window.MSG_DT_EMPTY_TABLE || "No data available in table", + "info": window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries", + "infoEmpty": window.MSG_DT_INFO_EMPTY || "No entries to show", + "infoFiltered": window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)", + "lengthMenu": window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries", + "loadingRecords": window.MSG_DT_LOADING_RECORDS || "Loading...", + "processing": window.MSG_DT_PROCESSING || "Processing...", + "search": window.MSG_DT_SEARCH || "Search:", + "zeroRecords": window.MSG_DT_ZERO_RECORDS || "No matching records found", + "paginate": { + "first": window.MSG_DT_FIRST || "First", + "last": window.MSG_DT_LAST || "Last", + "next": window.MSG_DT_NEXT || "Next", + "previous": window.MSG_DT_PREVIOUS || "Previous" + }, + "aria": { + "sortAscending": window.MSG_DT_SORT_ASC || ": activate to sort column ascending", + "sortDescending": window.MSG_DT_SORT_DESC || ": activate to sort column descending" + } + }, + "dom": '<"top pager"ilpf>tr<"bottom pager"ip>', + "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]], + "pageLength": 20 +}; + var dataTablesDefaults = { "oLanguage": { "oPaginate": { - "sFirst" : window.MSG_DT_FIRST || "First", - "sLast" : window.MSG_DT_LAST || "Last", - "sNext" : window.MSG_DT_NEXT || "Next", - "sPrevious" : window.MSG_DT_PREVIOUS || "Previous" + "sFirst" : DataTableDefaults.language.paginate.first, + "sLast" : DataTableDefaults.language.paginate.last, + "sNext" : DataTableDefaults.language.paginate.next, + "sPrevious" : DataTableDefaults.language.paginate.previous, }, - "sEmptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table", - "sInfo" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries", - "sInfoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show", - "sInfoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)", - "sLengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries", - "sLoadingRecords" : window.MSG_DT_LOADING_RECORDS || "Loading...", - "sProcessing" : window.MSG_DT_PROCESSING || "Processing...", - "sSearch" : window.MSG_DT_SEARCH || "Search:", - "sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found" + "sEmptyTable" : DataTableDefaults.language.emptyTable, + "sInfo" : DataTableDefaults.language.info, + "sInfoEmpty" : DataTableDefaults.language.infoEmpty, + "sInfoFiltered" : DataTableDefaults.language.infoFiltered, + "sLengthMenu" : DataTableDefaults.language.lengthMenu, + "sLoadingRecords" : DataTableDefaults.language.loadingRecords, + "sProcessing" : DataTableDefaults.language.processing, + "sSearch" : DataTableDefaults.language.search, + "sZeroRecords" : DataTableDefaults.language.zeroRecords, }, "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>', "buttons": [], - "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]], - "iDisplayLength": 20 + "aLengthMenu": DataTableDefaults.lengthMenu, + "iDisplayLength": DataTableDefaults.pageLength }; +(function($) { + $.fn.kohaDataTable = function(options) { + return this.DataTable($.extend(true, {}, DataTableDefaults, options)); + }; +})(jQuery); + // Return an array of string containing the values of a particular column $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { -- 2.14.2