From f13910a1f7307ea2851cab5e3f1cfa444aba3beb Mon Sep 17 00:00:00 2001 From: Jon Knight Date: Mon, 14 May 2018 15:30:55 +0000 Subject: [PATCH] Bug 16739: Show note instead of 500 error for 'Generate EDIFACT' when no EDI account is configured When a book seller (vendor) does not have EDI account information configured the basketgroup display still shows a button to generate EDIFACT output which results in 500 error when clicked. This patch fixes two aspects of this: a) it stops the button being displayed in the first place, replacing it with a message that explains there is not EDIFACT configuration for the vendor. b) if, somehow, an edifact print operation is passed to the basketgroup script it detects the lack of an EAN and redirects back to the basket group display page with a warning message. To test: 1) Create a vendor with no EDI details. 2) Create a basket with some items in, then close it and add it to a basket group for this vendor. 3) Go to that vendor's basket groups, click on the "Closed" tab and then click on the 'generate edifact order' button. You should get a 500 error. 4) Apply this patch. 5) Repeat 3, except this time you should find that the 'generate edifact order' button has been replaced with a note that there is "No EDIFACT configuration for ". Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens (cherry picked from commit 121b8105bcb00909b1e8081442148c1939c101a6) Signed-off-by: Martin Renvoize (cherry picked from commit 43b6644818f71c2d3c4bf09c6c40b36f5c0522c2) Signed-off-by: Fridolin Somers --- acqui/basketgroup.pl | 30 ++++++++++++++++--- .../prog/en/modules/acqui/basketgroup.tt | 27 ++++++++++------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 7b3aa386b6..cc24b1be34 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -222,8 +222,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; } @@ -242,6 +249,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" ) { # @@ -393,8 +406,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 1ee708331a..62615108b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -141,10 +141,12 @@ function submitForm(form) { [% IF ( grouping ) %] [% IF (closedbg) %] [% END %] [% IF (name && closedbg) %] @@ -288,7 +290,8 @@ function submitForm(form) { -

Basket grouping for [% booksellername |html %]

+

Basket grouping for [% booksellername | html %]

+ [% IF (NoEDIMessage) %]
No EDIFACT configuration for [% booksellername | html %]
[% END %]
    [% UNLESS ( listclosed) %]
  • Open
  • @@ -363,11 +366,15 @@ function submitForm(form) { [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %] [% basketgroup.basketsqty %] -
    -
    -
    -
    -
    +
    +
    +
    +
    + [% IF (ediaccount) %] +
    + [% ELSE %] +
    No EDIFACT configuration for [% booksellername | html %]
    + [% END %] [% END %] -- 2.39.5