diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 78514ba2ac..05c505ad54 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -220,8 +220,15 @@ sub generate_edifact_orders { my $baskets = GetBasketsByBasketgroup($basketgroupid); my $ean = get_edifact_ean(); - for my $basket ( @{$baskets} ) { - create_edi_order( { ean => $ean, basketno => $basket->{basketno}, } ); + if($ean) { + for my $basket ( @{$baskets} ) { + create_edi_order( { ean => $ean, basketno => $basket->{basketno}, } ); + } + } else { + my $booksellerid = $input->param('booksellerid') || 0; + print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . + $booksellerid . + '&message=No%20EDIFACT%20Setup'); } return; } @@ -240,6 +247,12 @@ my $op = $input->param('op') || 'display'; # - display : display the list of all basketgroups for a vendor my $booksellerid = $input->param('booksellerid'); $template->param(booksellerid => $booksellerid); +my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); + +my $schema = Koha::Database->new()->schema(); +my $rs = $schema->resultset('VendorEdiAccount')->search( + { vendor_id => $booksellerid, } ); +$template->param( ediaccount => ($rs->count > 0)); if ( $op eq "add" ) { # @@ -391,8 +404,17 @@ if ( $op eq "add" ) { } elsif ( $op eq 'ediprint') { my $basketgroupid = $input->param('basketgroupid'); - generate_edifact_orders( $basketgroupid ); - exit; + if ($template->param( 'ediaccount' )) { + generate_edifact_orders( $basketgroupid ); + exit; + } else { + $template->param('NoEDIMessage' => 1); + my $basketgroups = &GetBasketgroups($booksellerid); + my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); + my $baskets = &GetBasketsByBookseller($booksellerid); + + displaybasketgroups($basketgroups, $bookseller, $baskets); + } }else{ # no param : display the list of all basketgroups for a given vendor my $basketgroups = &GetBasketgroups($booksellerid); 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 7847ff49c9..6f4ac6d745 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -144,10 +144,12 @@ function submitForm(form) { [% IF ( grouping ) %] [% IF (closedbg) %]
-
Reopen this basket group
-
Export this basket group as CSV
-
Print this basket group in PDF
-
Generate EDIFACT order
+
Reopen this basket group
+
Export this basket group as CSV
+
Print this basket group in PDF
+ [% IF (ediaccount) %] +
Generate EDIFACT order
+ [% END %]
[% END %] [% IF (name && closedbg) %] @@ -295,7 +297,8 @@ function submitForm(form) {
New basket group
-

Basket grouping for [% booksellername | html %]

+

Basket grouping for [% booksellername | html %]

+ [% IF (NoEDIMessage) %]
No EDIFACT configuration for [% booksellername | html %]
[% END %]