From e7ebf296bfefb690a78cb5e447ee7951d63e5abc Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Fri, 15 Mar 2013 20:27:07 +0100 Subject: [PATCH] Bug 9806 : Add new columns to basket groups lists In the list of all the open/closed basketgroups for a vendor, you just have the name of each basketgroup, and 3 action buttons. It is not sufficient for libraries using basketgroup. Warning : this patch must be tested with BZ 9771 applied. If BZ 9771 is not pushed to master when you test, apply it before. This patch adds the following columns : - number (id of basketgroup) - billingplace (name of the library) - deliveryplace (name of the library, or "free delivery place") - number of baskets in each basketgroup To test : 1) make some basketgroups with 0, 1, 2 baskets 2) make some basketgroups with different billing and deliveryplace 3) check the list of open and closed basketgroups 4) check action buttons are working like before patch --- acqui/basketgroup.pl | 43 ++++--- .../prog/en/modules/acqui/basketgroup.tt | 134 +++++++++++--------- 2 files changed, 99 insertions(+), 78 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 6b7e5bf..6d10b8f 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -55,7 +55,7 @@ use CGI; use C4::Bookseller qw/GetBookSellerFromId/; use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/; use C4::Bookseller qw/GetBookSellerFromId/; -use C4::Branch qw/GetBranches/; +use C4::Branch qw/GetBranches GetBranchName/; use C4::Members qw/GetMember/; our $input=new CGI; @@ -155,17 +155,22 @@ sub displaybasketgroups { my $baskets = shift; if (scalar @$basketgroups != 0) { foreach my $basketgroup (@$basketgroups){ + $basketgroup -> {'billingplacename'} = GetBranchName($basketgroup -> {'billingplace'}); + $basketgroup -> {'deliveryplacename'} = GetBranchName($basketgroup -> {'deliveryplace'}); my $i = 0; + my $basketsqty = 0; while($i < scalar(@$baskets)){ my $basket = @$baskets[$i]; if($basket->{'basketgroupid'} && $basket->{'basketgroupid'} == $basketgroup->{'id'}){ $basket->{total} = BasketTotal($basket->{basketno}, $bookseller); push(@{$basketgroup->{'baskets'}}, $basket); splice(@$baskets, $i, 1); + ++$basketsqty; --$i; } ++$i; } + $basketgroup -> {'basketsqty'} = $basketsqty; } $template->param(basketgroups => $basketgroups); } @@ -183,7 +188,7 @@ sub displaybasketgroups { sub printbasketgrouppdf{ my ($basketgroupid) = @_; - + my $pdfformat = C4::Context->preference("OrderPdfFormat"); if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages'){ eval { @@ -194,23 +199,23 @@ sub printbasketgrouppdf{ } } else { - print $input->header; + print $input->header; print $input->start_html; # FIXME Should do a nicer page print "

Invalid PDF Format set

"; print "Please go to the systempreferences and set a valid pdfformat"; exit; } - + my $basketgroup = GetBasketgroup($basketgroupid); my $bookseller = GetBookSellerFromId($basketgroup->{'booksellerid'}); my $baskets = GetBasketsByBasketgroup($basketgroupid); - + my %orders; for my $basket (@$baskets) { my @ba_orders; my @ords = &GetOrders($basket->{basketno}); for my $ord (@ords) { - # ba_order is filled with : + # ba_order is filled with : # 0 1 2 3 4 5 6 7 8 9 #isbn, itemtype, author, title, publishercode, quantity, listprice ecost discount gstrate my @ba_order; @@ -388,14 +393,14 @@ if ( $op eq "add" ) { displaybasketgroups($basketgroups, $bookseller, $baskets); } elsif ( $op eq 'closeandprint') { my $basketgroupid = $input->param('basketgroupid'); - + CloseBasketgroup($basketgroupid); - + printbasketgrouppdf($basketgroupid); exit; }elsif ($op eq 'print'){ my $basketgroupid = $input->param('basketgroupid'); - + printbasketgrouppdf($basketgroupid); exit; }elsif ( $op eq "export" ) { @@ -410,17 +415,16 @@ if ( $op eq "add" ) { my $basketgroupid = $input->param('basketgroupid'); DelBasketgroup($basketgroupid); print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid); - + }elsif ( $op eq 'reopen'){ my $basketgroupid = $input->param('basketgroupid'); my $booksellerid = $input->param('booksellerid'); - ReOpenBasketgroup($basketgroupid); - + print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid . '#closed'); - + } elsif ( $op eq 'attachbasket') { - + # Getting parameters my $basketgroup = {}; my @baskets = $input->param('basket'); @@ -431,7 +435,8 @@ if ( $op eq "add" ) { my $deliveryplace = $input->param('deliveryplace'); my $freedeliveryplace = $input->param('freedeliveryplace'); my $deliverycomment = $input->param('deliverycomment'); - my $close = $input->param('close') ? 1 : 0; + my $close = $input->param('closed') ? 1 : 0; + # If we got a basketgroupname, we create a basketgroup if ($basketgroupid) { $basketgroup = { @@ -446,7 +451,7 @@ if ( $op eq "add" ) { }; ModBasketgroup($basketgroup); if($close){ - + } }else{ $basketgroup = { @@ -460,11 +465,11 @@ if ( $op eq "add" ) { }; $basketgroupid = NewBasketgroup($basketgroup); } - + my $url = '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid; - $url .= "&closed=1" if ($input->param("closed")); + $url .= "&closed=1" if ($input->param("closed")); print $input->redirect($url); - + }else{ my $basketgroups = &GetBasketgroups($booksellerid); my $bookseller = &GetBookSellerFromId($booksellerid); 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 deb20e9..297cc3f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -167,9 +167,9 @@ function submitForm(form) { - - -
+
+ +
    @@ -226,17 +226,16 @@ function submitForm(form) { Cancel
-
- + + [% ELSE %] -

Basket grouping for [% booksellername |html %]

-
-
[% END %] -- 1.7.9.5