From 51fc22831b82ca68e4c52b9a7d50d3e150cff8e4 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 24 Aug 2009 15:36:51 +0200 Subject: [PATCH] MT 1496 : Close basket --- acqui/basket.pl | 44 +++++--------- acqui/basketgroup.pl | 42 +++++++------ .../prog/en/modules/acqui/basket.tmpl | 60 +++++++++---------- 3 files changed, 69 insertions(+), 77 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index 1a9e8519dc..c5730351c1 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -133,33 +133,24 @@ if ( $op eq 'delete_confirm' ) { 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" - ); + print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?basketno=' . $basket->{'basketno'} . '&op=attachbasket&booksellerid=' . $booksellerid); # 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; + my $confirm = $query->param('confirm'); + if ($confirm) { + my $basketno = $query->param('basketno'); + my $booksellerid = $query->param('booksellerid'); + $basketno =~ /^\d+$/ and CloseBasket($basketno); + print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?basketno='.$basketno.'&op=attachbasket&booksellerid=' . $booksellerid); + exit; + } else { - print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?supplierid='.$booksellerid); - exit; + $template->param(confirm_close => "1", + booksellerid => $booksellerid, + basketno => $basket->{'basketno'}, + basketname => $basket->{'basketname'}, + basketgroupname => $basket->{'basketname'}); + } } elsif ($query->param('op') eq 'reopen') { my $basket; @@ -188,10 +179,7 @@ if ( $op eq 'delete_confirm' ) { if ($basket->{closedate} && haspermission({ flagsrequired => { acquisition => 'group_manage'} })) { $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}){ + if ($basket->{basketgroupid} == @$basketgroups[$i]->{id}){ @$basketgroups[$i]->{default} = 1; } } diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 12db2cf79f..86dfae9e4c 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -51,7 +51,7 @@ use C4::Output; use CGI; use C4::Bookseller qw/GetBookSellerFromId/; -use C4::Acquisition qw/GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup/; +use C4::Acquisition qw/GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket/; use C4::Bookseller qw/GetBookSellerFromId/; my $input=new CGI; @@ -311,37 +311,43 @@ if (! $op ) { print $pdf; exit; } elsif ( $op eq 'attachbasket') { - # TODO: create basketgroup and attach basket to it? + # Getting parameters my $basketgroup = {}; - $basketgroup->{'name'} = $input->param('basketgroupname'); + my $basketno = $input->param('basketno'); + my $basket = GetBasket($basketno); + $basketgroup->{'name'} = $input->param('basketgroupname') || $basket->{'basketname'}; $basketgroup->{'booksellerid'} = $input->param('booksellerid'); my $basketgroupid; - my $basketno = $input->param('basketno'); warn "basketgroupname", $basketgroup->{'name'}; + + # If we got a basketgroupname, we create a basketgroup if ($basketgroup->{'name'}) { $basketgroupid = NewBasketgroup($basketgroup); } else { + # Else, we use the basketgroupid in parameter $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 = {}; + + $basketgroup= {}; + $basketgroup->{'closed'} = 1; + $basketgroup->{'id'} = $basketgroupid; + ModBasketgroup($basketgroup); + + $basket = {}; $basket->{'basketno'} = $basketno; $basket->{'basketgroupid'} = $basketgroupid; ModBasket($basket); - $basketgroup = GetBasketgroup($basketgroupid); + + + $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); + + if ($input->param('createorder')) { + print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?op=printbgroup&bgroupid=' . $basketgroupid); + } else { + print $input->redirect('/cgi-bin/koha/acqui/booksellers.pl'); + } } #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/basket.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl index a5c05db311..d07f2ad1e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl @@ -55,6 +55,7 @@
+

Supplier Not Found

@@ -288,33 +286,33 @@ - - -
-
- Assign basket to basketgroup -

- -

-

- - -

-

- - -

- " name="basketno" /> - - " /> - -
-
+ + +
+ +
+
+ Closing basket +

Are you sure you want to close this basket ?

+

+ + +

+ " name="basketno" /> + + " /> + + " /> + + ';return false;" /> +
+
+
+ + + +
-- 2.39.5