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');
+ my $confirm = $query->param('confirm');
+ if ($confirm) {
+ my $basketno = $query->param('basketno');
+ my $booksellerid = $query->param('booksellerid');
+ $basketno =~ /^\d+$/ and CloseBasket($basketno);
+ # if requested, create basket group, close it and attach the basket
+ if ($query->param('createbasketgroup')) {
+ my $basketgroupid = NewBasketgroup( { name => $basket->{basketname},
+ booksellerid => $booksellerid,
+ closed => 1,
+ });
+ ModBasket( { basketno => $basketno,
+ basketgroupid => $basketgroupid } );
+ print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid='.$booksellerid);
+ } else {
+ 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;
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;
}
}
for ( my $i = 0 ; $i < $count ; $i++ ) {
my $rrp = $results[$i]->{'listprice'};
- my $qty = $results[$i]->{'quantity'};
+ my $qty = $results[$i]->{'quantity'} || 0;
my $budget = GetBudget( $results[$i]->{'budget_id'} );
$rrp = ConvertCurrency( $results[$i]->{'currency'}, $rrp );
basketbooksellernote => $basket->{booksellernote},
basketcontractno => $basket->{contractnumber},
basketcontractname => $contract->{contractname},
- creationdate => format_date( $basket->{creationdate} ),
+ creationdate => C4::Dates->new($basket->{creationdate},'iso')->output,
authorisedby => $basket->{authorisedby},
authorisedbyname => $basket->{authorisedbyname},
- closedate => format_date( $basket->{closedate} ),
+ closedate => C4::Dates->new($basket->{closedate},'iso')->output,
active => $bookseller->{'active'},
booksellerid => $bookseller->{'id'},
name => $bookseller->{'name'},
- address1 => $bookseller->{'address1'},
- address2 => $bookseller->{'address2'},
- address3 => $bookseller->{'address3'},
- address4 => $bookseller->{'address4'},
- entrydate => format_date( $results[0]->{'entrydate'} ),
+ entrydate => C4::Dates->new($results[0]->{'entrydate'},'iso')->output,
books_loop => \@books_loop,
count => $count,
gist_rate => sprintf( "%.2f", $gist * 100 ) . '%',
grouped => $basket->{basketgroupid},
);
}
+
output_html_with_http_headers $query, $cookie, $template->output;