From 9a3bf98b8e6d02ce5469966b84323becf32a4ed2 Mon Sep 17 00:00:00 2001 From: John Soros Date: Thu, 9 Jul 2009 16:03:01 +0200 Subject: [PATCH] Fixes for basket closing: - I user has basket grouping permissions, don't display javascript popup for confirmation - if user has basket grouping permissions, after closing the basket redirect him to a page which asks which basketgroup to affect the basket to (with possibility to create a new basketgroup) - when done with this, redirect him to basketgrouping.pl to be able to print the basketgroup at once - factor out basket closing code from booksellers.pl (what was it doing there anyways?) --- acqui/basket.pl | 35 ++ acqui/basketgroup.pl | 32 ++ acqui/booksellers.pl | 10 - .../prog/en/modules/acqui/basket.tmpl | 492 +++++++++--------- .../prog/en/modules/acqui/basketgroup.tmpl | 33 +- 5 files changed, 347 insertions(+), 255 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index 07aec1d4ca..811702c58c 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -153,6 +153,41 @@ if ( $op eq 'delete_confirm' ) { address4 => $bookseller->{'address4'}, count => $count, ); +} elsif ($op eq 'attachbasket' && $template->{'param_map'}->{'CAN_user_acquisition_group_manage'} == 1) { + my $basketgroups = GetBasketgroups($basket->{booksellerid}); + for (my $i=0; $i < scalar(@$basketgroups); $i++) { + if (@$basketgroups[$i]->{closed}) { + splice(@$basketgroups, $i, 1); + $i--; + } elsif ($basket->{basketgroupid} == @$basketgroups[$i]->{id}){ + @$basketgroups[$i]->{default} = 1; + } + } + $template->param( + basketgroups => $basketgroups, + booksellerid => $booksellerid, + basketno => $basket->{'basketno'}, + basketname => $basket->{'basketname'}, + name => $bookseller->{'name'}, + selectbasketg => "1" + ); + # check if we have to "close" a basket before building page +} elsif ($op eq 'close') { + my $basket = $query->param('basketno'); + $basket =~ /^\d+$/ and CloseBasket($basket); + if ($template->{'param_map'}->{'CAN_user_acquisition_group_manage'} == 1){ + print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket.'&op=attachbasket'); + exit; + } else { + print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?supplierid='.$booksellerid); + exit; + } +} elsif ($query->param('op') eq 'reopen') { + my $basket; + $basket->{basketno} = $query->param('basketno'); + $basket->{closedate} = undef; + ModBasket($basket); + print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'}) } else { # get librarian branch... if ( C4::Context->preference("IndependantBranches") ) { diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index e8027a811c..56526e7042 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -298,6 +298,38 @@ if (! $op ) { my $pdf = printpdf($basketgroup, $bookseller, $baskets, $branch, \%orders, $bookseller->{gstrate} || C4::Context->preference("gist")) || die "pdf generation failed"; print $pdf; exit; +} elsif ( $op eq 'attachbasket') { + # TODO: create basketgroup and attach basket to it? + my $basketgroup = {}; + $basketgroup->{'name'} = $input->param('basketgroupname'); + $basketgroup->{'booksellerid'} = $input->param('booksellerid'); + my $basketgroupid; + my $basketno = $input->param('basketno'); + warn "basketgroupname", $basketgroup->{'name'}; + if ($basketgroup->{'name'}) { + $basketgroupid = NewBasketgroup($basketgroup); + } else { + $basketgroupid = $input->param('basketgroupid'); + } + if ($input->param('closebasketgroup')){ + #we override $basketgroup on purpose here + my $basketgroup= {}; + $basketgroup->{'closed'} = 1; + $basketgroup->{'id'} = $basketgroupid; + ModBasketgroup($basketgroup) + } + my $basket = {}; + $basket->{'basketno'} = $basketno; + $basket->{'basketgroupid'} = $basketgroupid; + ModBasket($basket); + $basketgroup = GetBasketgroup($basketgroupid); + my $baskets = GetBasketsByBasketgroup($basketgroupid); + my $bookseller = &GetBookSellerFromId($booksellerid); + my @basketgroups; + push(@basketgroups, $basketgroup); + $template->param(displayclosedbgs => 1, + booksellerid => $booksellerid); + displaybasketgroups(\@basketgroups, $bookseller, $baskets); } #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/acqui/booksellers.pl b/acqui/booksellers.pl index 0d534f43af..ad0bf0be27 100755 --- a/acqui/booksellers.pl +++ b/acqui/booksellers.pl @@ -92,16 +92,6 @@ if ($count == 1){ id => $suppliers[0]->{'id'} ); } -# check if we have to "close" a basket before building page -if ($query->param('op') eq 'close') { - my $basket = $query->param('basketno'); - $basket =~ /^\d+$/ and CloseBasket($basket); -} elsif ($query->param('op') eq 'reopen') { - my $basket; - $basket->{basketno} = $query->param('basketno'); - $basket->{closedate} = undef; - ModBasket($basket); -} #build result page my @loop_suppliers; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl index a1a9acb7b5..52141e9b8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl @@ -7,7 +7,7 @@ function confirm_close() { var is_confirmed = confirm(_('Are you sure you want to close this basket?')); if (is_confirmed) { - window.location = "/cgi-bin/koha/acqui/booksellers.pl?op=close&basketno=&supplierid="; + window.location = "?op=close&basketno="; } } //]]> @@ -19,7 +19,7 @@ function confirm_reopen() { var is_confirmed = confirm(_('Are you sure you want to reopen this basket?')); if (is_confirmed) { - window.location = "/cgi-bin/koha/acqui/booksellers.pl?op=reopen&basketno=&supplierid="; + window.location = "?op=reopen&basketno="; } } //]]> @@ -42,252 +42,278 @@
- - -
- - +
+ + +
+ + +
+ + + + +

Supplier Not Found

+ + +

Basket deleted

+ + +

New DeleteBasket for ">

+ +

+ + + ?op=delete_confirm&basketno=&booksellerid=" class="yui-link-button">Yes, delete this basket! + + + + + ?basketno=" class="yui-link-button">Cancel + + +

-

Number of orders:

-
- - -
-

Order Details

- - - -
ERROR: Illegal sort requested by "". -
Please use valid sort criteria. ">Return to default results.
- -
Sorted by "".
- - - - - - - - - - - - - - - - - - - - +
+

Basket Details

+

Basket number:

+

Basket name:

+

Internal note:

+

Bookseller note:

+ +

Contract number:

+

Contract name: ">

+ +

Managed by:

+

Open on:

+

For vendor ID:

+

Invoice number:

+ +
+

Closed On:

+ +

basketgroup: + " name="basketno" /> + + " /> + +

+ + + +

Number of orders:

+
+ + +
+

Order Details

+ + + +
ERROR: Illegal sort requested by "". +
Please use valid sort criteria. ">Return to default results.
+ +
Sorted by "".
-
- - - - - - - - - - - + + + +
OrderTitleISBN&order=biblioitems.publishercode">PublisherRRPEst.Qty.TotalBudgetModifyDelete
- (rcvd) -

- ">

-

-

-

-
+ + + + + + + + + + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - -
OrderTitleISBN&order=biblioitems.publishercode">PublisherRRPEst.Qty.TotalBudget - &booksellerid=&basketno=">Modify - - &basketno=&quantity=0&biblionumber=">Delete - ModifyDelete
- " /> - " /> - SubTotal -->  
+ (rcvd) +

+ ">

+

+

+

+
+ &booksellerid=&basketno=">Modify + + &basketno=&quantity=0&biblionumber=">Delete +
GST () --> **
TOTAL () 
+ + + + + " /> + " /> + + SubTotal + + --> + + + + +   + +   + + + + + GST () + + + --> +   + - - -
Basket empty
- - ** Vendor's listings already include GST. - -
-
- -
- Add To Order -
- " /> - " /> - -
-
- + ** + + + TOTAL () + +   + + + + + + + +
Basket empty
+ + ** Vendor's listings already include GST. + +
+
+ +
+ Add To Order +
+ " /> + " /> + +
+
+ + + +
+
+ Assign basket to basketgroup +

+ +

+

+ + +

+

+ + +

+ " name="basketno" /> + + " /> + +
+
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl index b64c693748..d3379205c7 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl @@ -207,24 +207,33 @@ fieldset.various li { - -