From fc250be5385f9bac3e0c92034102e43e7073ce15 Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Thu, 7 Nov 2013 20:16:40 +0100 Subject: [PATCH] Bug 9807 : Make it possible to view a basket group without reopening it This patch make possible to view an individual closed basket group without reopening it. - It adds a new "View" button on closed basket group list - It creates a view for closed basket groups, with 3 buttons (reopen, print, export) - It adds a "delete" button on standard "edit" view (for open basket groups) To test : 1/ regression test : - create some empty basket groups - create some basket groups by closing baskets - in the list of basket groups closed and opened, check you can use the buttons that existed before the patch (close and print, delete, export, print, reopen) - click on "Edit" to edit a opened basket group : check everything is like before : -- change the billing and delivery places, -- add a note, -- put some new baskets in the bg, -- remove baskets from it -- save it without checking "close" box => it should be saved but kept open -- edit it again, and make other some changes (define a freetext delivery place for example) -- save it with checking "close" => it should be saved but closed 2/ new feature test - click on "view" button on top right column of some closed basket group - check all the displayed informations are correct (places, free place, note, list of baskets) - check you can not change anything - click on "print" button => check a pdf is created - click on "export" button => check a csv is created - click on "reopen" button => you should stay on the same basket group, but it is now open and you can make some changes - go back to the basket group list of the vendor. Check the reopened bg is in "open" tab - click on "edit" - click on new "delete" button => the bg should be deleted, and you are redirected to the bg list of the vendor. Signed-off-by: cedric.vita@dracenie.com Signed-off-by: Kyle M Hall Passes koha-qa.pl, t and xt. Works as advertised. Signed-off-by: Galen Charlton --- acqui/basketgroup.pl | 92 +++++++++++++------ .../prog/en/modules/acqui/basketgroup.tt | 92 ++++++++++++++++--- 2 files changed, 143 insertions(+), 41 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 6fe4db2a1f..c9db3b379a 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -29,7 +29,7 @@ basketgroup.pl =head1 DESCRIPTION This script lets the user group (closed) baskets into basket groups for easier order management. Note that the grouped baskets have to be from the same bookseller and - have to be closed. + have to be closed to be printed or exported. =head1 CGI PARAMETERS @@ -294,11 +294,29 @@ sub printbasketgrouppdf{ } 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 +# - validate : FIXME dead code +# - 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 +# - 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 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 +# if(! $booksellerid){ +# Unknown bookseller +# FIXME : ungroupedlist does not seem to be used in this file nor in template $template->param( ungroupedlist => 1); my @booksellers = GetBookSeller(''); for (my $i=0; $i < scalar @booksellers; $i++) { @@ -315,6 +333,7 @@ if ( $op eq "add" ) { } } } else { +# Known bookseller my $basketgroupid = $input->param('basketgroupid'); my $billingplace; my $deliveryplace; @@ -338,8 +357,10 @@ if ( $op eq "add" ) { $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'}; @@ -349,23 +370,27 @@ if ( $op eq "add" ) { $template->param( billingplaceloop => $branches ); $branches = C4::Branch::GetBranchesLoop( $deliveryplace ); $template->param( deliveryplaceloop => $branches ); - $template->param( booksellerid => $booksellerid ); } + # the template will display a unique basketgroup $template->param(grouping => 1); my $basketgroups = &GetBasketgroups($booksellerid); my $bookseller = &GetBookSellerFromId($booksellerid); my $baskets = &GetBasketsByBookseller($booksellerid); - displaybasketgroups($basketgroups, $bookseller, $baskets); } elsif ($op eq 'mod_basket') { -#we want to modify an individual basket's group +# +# edit an individual basket contained in this basketgroup +# my $basketno=$input->param('basketno'); my $basketgroupid=$input->param('basketgroupid'); ModBasket( { basketno => $basketno, basketgroupid => $basketgroupid } ); print $input->redirect("basket.pl?basketno=" . $basketno); } elsif ($op eq 'validate') { +# +# FIXME dead code +# if(! $booksellerid){ $template->param( booksellererror => 1); } else { @@ -374,7 +399,7 @@ if ( $op eq "add" ) { my $baskets = parseinputbaskets($booksellerid); my ($basketgroups, $newbasketgroups) = parseinputbasketgroups($booksellerid, $baskets); foreach my $nbgid (keys %$newbasketgroups){ -#javascript just picks an ID that's higher than anything else, the ID might not be correct..chenge it and change all the basket's basketgroupid as well +#javascript just picks an ID that's higher than anything else, the ID might not be correct..change it and change all the basket's basketgroupid as well my $bgid = NewBasketgroup($newbasketgroups->{$nbgid}); ${$newbasketgroups->{$nbgid}}->{'id'} = $bgid; ${$newbasketgroups->{$nbgid}}->{'oldid'} = $nbgid; @@ -400,21 +425,28 @@ if ( $op eq "add" ) { $basketgroups = &GetBasketgroups($booksellerid); my $bookseller = &GetBookSellerFromId($booksellerid); $baskets = &GetBasketsByBookseller($booksellerid); + # keep ungroupedbaskets displaybasketgroups($basketgroups, $bookseller, $baskets); } elsif ( $op eq 'closeandprint') { +# +# close an open basketgroup and generates a pdf +# my $basketgroupid = $input->param('basketgroupid'); - CloseBasketgroup($basketgroupid); - printbasketgrouppdf($basketgroupid); exit; }elsif ($op eq 'print'){ +# +# print a closed basketgroup +# my $basketgroupid = $input->param('basketgroupid'); - printbasketgrouppdf($basketgroupid); exit; }elsif ( $op eq "export" ) { +# +# export a closed basketgroup in csv +# my $basketgroupid = $input->param('basketgroupid'); print $input->header( -type => 'text/csv', @@ -423,20 +455,25 @@ if ( $op eq "add" ) { print GetBasketGroupAsCSV( $basketgroupid, $input ); exit; }elsif( $op eq "delete"){ +# +# delete an closed basketgroup +# my $basketgroupid = $input->param('basketgroupid'); DelBasketgroup($basketgroupid); - print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid); - + print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&listclosed=1'); }elsif ( $op eq 'reopen'){ +# +# reopen a closed basketgroup +# my $basketgroupid = $input->param('basketgroupid'); my $booksellerid = $input->param('booksellerid'); - ReOpenBasketgroup($basketgroupid); - - print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid . '#closed'); - + 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'; + print $input->redirect($redirectpath); } elsif ( $op eq 'attachbasket') { - +# +# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page +# # Getting parameters my $basketgroup = {}; my @baskets = $input->param('basket'); @@ -447,9 +484,9 @@ 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; - # If we got a basketgroupname, we create a basketgroup + my $closedbg = $input->param('closedbg') ? 1 : 0; if ($basketgroupid) { + # If we have a basketgroupid we edit the basketgroup $basketgroup = { name => $basketgroupname, id => $basketgroupid, @@ -458,13 +495,14 @@ if ( $op eq "add" ) { deliveryplace => $deliveryplace, freedeliveryplace => $freedeliveryplace, deliverycomment => $deliverycomment, - closed => $close, + closed => $closedbg, }; ModBasketgroup($basketgroup); - if($close){ - + if($closedbg){ +# FIXME } }else{ + # we create a new basketgroup (whith a closed basket) $basketgroup = { name => $basketgroupname, booksellerid => $booksellerid, @@ -473,22 +511,22 @@ if ( $op eq "add" ) { deliveryplace => $deliveryplace, freedeliveryplace => $freedeliveryplace, deliverycomment => $deliverycomment, - closed => $close, + closed => $closedbg, }; $basketgroupid = NewBasketgroup($basketgroup); } - - my $url = '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid; - $url .= "&closed=1" if ($input->param("closed")); - print $input->redirect($url); + 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 ); }else{ +# no param : display the list of all basketgroups for a given vendor my $basketgroups = &GetBasketgroups($booksellerid); my $bookseller = &GetBookSellerFromId($booksellerid); my $baskets = &GetBasketsByBookseller($booksellerid); displaybasketgroups($basketgroups, $bookseller, $baskets); } -$template->param(closed => $input->param("closed")); +$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 output_html_with_http_headers $input, $cookie, $template->output; 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 f256ec3716..03520713a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -140,10 +140,25 @@ function submitForm(form) {
[% IF ( grouping ) %] + [% IF (closedbg) %] + + [% ELSE %] + + [% END %] + [% IF (name && closedgb) %] +

Basket group [% name %] ([% basketgroupid %]) for [% booksellername |html %]

+ [% ELSIF (name) %] +

Edit basket group [% name %] ([% basketgroupid %]) for [% booksellername |html %]

+ [% ELSE %]

Add basket group for [% booksellername |html %]

+ [% END %]
+ [% UNLESS (closedbg) %]
-
@@ -170,39 +185,82 @@ function submitForm(form) {
-
- + [% END %]
    + [% UNLESS (closedbg) %]
  1. -
  2. + [% ELSE %] + + [% END %] +
  3. + [% UNLESS (closedbg) %] +
  4. -
  5. + + [% ELSE %] + Billing place: + [% FOREACH billingplaceloo IN billingplaceloop %] + [% IF ( billingplaceloo.selected ) %] + [% billingplaceloo.branchname %] + [% END %] + [% END %] + [% END %] +
  6. + [% UNLESS (closedbg) %] +
  7. +
  8. + -
  9. - + [% ELSE %] +
  10. + Delivery place: + [% IF (freedeliveryplace) %] + [% freedeliveryplace %] + + [% ELSE %] + [% FOREACH deliveryplaceloo IN deliveryplaceloop %] + [% IF ( deliveryplaceloo.selected ) %] + [% deliveryplaceloo.branchname %] + [% END %] + [% END %] + + [% END %] +
  11. + [% END %] +
  12. + [% UNLESS (closedbg) %] + + + [% ELSE %] + Delivery comment:[% deliverycomment %] + + [% END %]
  13. Baskets in this group: + [% UNLESS (closedbg) %]
- + [% UNLESS (closedbg) %]
[% IF ( basketgroupid ) %] @@ -229,6 +291,7 @@ function submitForm(form) { Cancel
+ [% END %]
@@ -241,9 +304,9 @@ function submitForm(form) {
    - [% UNLESS ( closed ) %]
  • Open
  • + [% UNLESS ( listclosed) %]
  • Open
  • [% ELSE%]
  • Open
  • [% END %] - [% IF ( closed ) %]
  • Closed
  • + [% IF ( listclosed) %]
  • Closed
  • [% ELSE %]
  • Closed
  • [% END %]
@@ -273,7 +336,7 @@ function submitForm(form) { [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %] [% basketgroup.basketsqty %] - +
@@ -311,6 +374,7 @@ function submitForm(form) { [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %] [% basketgroup.basketsqty %] +
-- 2.39.5