From 8fa555e9270ff0e45c70a50eb7b7ec7aac219bbe Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Tue, 15 Oct 2013 22:10:01 +0200 Subject: [PATCH] Bug 9807 : Make possible to view a basketgroup without reopening it This patch make possible to view an individual closed basketgroup without reopening it. - It adds a new "View" button on closed basketgroup list - It creates a view for closed basketgroups, with 3 buttons (reopen, print, export) - It adds a "delete" button on standard "edit" view (for open basketgroup) To test : 1/ regression test : - create some empty basketgroups - create some basketgroups by closing baskets - in the list of basketgroups 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 basketgroup : 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 must be save but kept open -- edit it again, and make other some changes (define a free delivery place for example) -- save it with checking "close" => it must be saved but closed 2/ new feature test - click on "view" button on top right column of some closed basketgroup - 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 must stay on the same basketgroup, but it is now open and you can make some changes - go back to the basketgroup list of the vendor. Check the reopened bg is in "open" tab - click on "edit" - click on new "delete" button => the bg must be deleted, and you are redirected to the bg list of the vendor. Signed-off-by: cedric.vita@dracenie.com --- acqui/basketgroup.pl | 96 +++++++--- .../prog/en/modules/acqui/basketgroup.tt | 201 +++++++++++++------- 2 files changed, 198 insertions(+), 99 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 6fe4db2..aa8d745 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 open) or display (if it is close) the basketgroup basketgroupid +# the template will know if basketgroup must be displayed or edited, depending on closed value +# 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,25 @@ if ( $op eq "add" ) { $template->param( billingplaceloop => $branches ); $branches = C4::Branch::GetBranchesLoop( $deliveryplace ); $template->param( deliveryplaceloop => $branches ); - $template->param( booksellerid => $booksellerid ); } - $template->param(grouping => 1); + $template->param(grouping => 1); # the template will display a unique basketgroup 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 } ); + 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 +397,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 +423,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 +453,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 +482,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 +493,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 +509,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 b6cdc52..0619db0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -21,8 +21,8 @@ we turn them off as a foundation for YUI CSS treatments. */ body { - margin:0; - padding:0; + margin:0; + padding:0; } #basketgroupcolumns { width: 58em; @@ -144,11 +144,26 @@ function submitForm(form) {
[% IF ( grouping ) %] -

Add basket group for [% booksellername |html %]

-
-
- -
+ [% 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) %] +
+
@@ -174,65 +189,112 @@ function submitForm(form) {
- -
- -
-
-
-
    +
+ [% END %] +
+ +
+
    + [% UNLESS (closedbg) %]
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. or

  8. -
  9. -
  10. -
  11. - -
  12. -
  13. Baskets in this group: - -
  14. -
  15. -
-
- -
- [% IF ( basketgroupid ) %] - - [% END %] - - Cancel -
+ + [% ELSE %] + + [% END %] +
  • + [% UNLESS (closedbg) %] + + + [% ELSE %] + Billing place: + [% FOREACH billingplaceloo IN billingplaceloop %] + [% IF ( billingplaceloo.selected ) %] + [% billingplaceloo.branchname %] + [% END %] + [% END %] + [% END %] +
  • + [% UNLESS (closedbg) %] +
  • + + +
  • +
  • or

  • +
  • + +
  • + [% ELSE %] + Delivery place: + [% IF (freedeliveryplace) %] + [% freedeliveryplace %] + + [% ELSE %] + [% FOREACH deliveryplaceloo IN deliveryplaceloop %] + [% IF ( deliveryplaceloo.selected ) %] + [% deliveryplaceloo.branchname %] + [% END %] + [% END %] + + [% END %] + [% END %] +
  • + [% UNLESS (closedbg) %] + + + [% ELSE %] + Delivery comment:[% deliverycomment %] + + [% END %] +
  • +
  • Baskets in this group: + [% UNLESS (closedbg) %] +
  • @@ -245,9 +307,9 @@ function submitForm(form) {
      - [% UNLESS ( closed ) %]
    • Open
    • + [% UNLESS ( listclosed) %]
    • Open
    • [% ELSE%]
    • Open
    • [% END %] - [% IF ( closed ) %]
    • Closed
    • + [% IF ( listclosed) %]
    • Closed
    • [% ELSE %]
    • Closed
    • [% END %]
    @@ -277,7 +339,7 @@ function submitForm(form) { [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% basketgroup.deliveryplace | $KohaBranchName %][% END %] [% basketgroup.basketsqty %] - +
    @@ -315,7 +377,8 @@ function submitForm(form) { [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% basketgroup.deliveryplace | $KohaBranchName %][% END %] [% basketgroup.basketsqty %] -
    +
    +
    -- 1.7.2.5