+
+
+sub edi_close_and_order {
+ my $confirm = $query->param('confirm') || $confirm_pref eq '2';
+ if ($confirm) {
+ my $edi_params = {
+ basketno => $basketno,
+ ean => $ean,
+ };
+ if ( $basket->{branch} ) {
+ $edi_params->{branchcode} = $basket->{branch};
+ }
+ if ( create_edi_order($edi_params) ) {
+ #$template->param( edifile => 1 );
+ }
+ CloseBasket($basketno);
+
+ # if requested, create basket group, close it and attach the basket
+ if ( $query->param('createbasketgroup') ) {
+ my $branchcode;
+ if ( C4::Context->userenv
+ and C4::Context->userenv->{'branch'}
+ and C4::Context->userenv->{'branch'} ne "NO_LIBRARY_SET" )
+ {
+ $branchcode = C4::Context->userenv->{'branch'};
+ }
+ my $basketgroupid = NewBasketgroup(
+ {
+ name => $basket->{basketname},
+ booksellerid => $booksellerid,
+ deliveryplace => $branchcode,
+ billingplace => $branchcode,
+ closed => 1,
+ }
+ );
+ ModBasket(
+ {
+ basketno => $basketno,
+ basketgroupid => $basketgroupid
+ }
+ );
+ print $query->redirect(
+"/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=$booksellerid&closed=1"
+ );
+ }
+ else {
+ print $query->redirect(
+ "/cgi-bin/koha/acqui/booksellers.pl?booksellerid=$booksellerid"
+ );
+ }
+ exit;
+ }
+ else {
+ $template->param(
+ edi_confirm => 1,
+ booksellerid => $booksellerid,
+ basketno => $basket->{basketno},
+ basketname => $basket->{basketname},
+ basketgroupname => $basket->{basketname},
+ );
+ if ($ean) {
+ $template->param( ean => $ean );
+ }
+
+ }
+ return;
+}