From ffcac846ad125534c0008291d53f094cfde6cc4b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 15 Dec 2016 11:10:38 +0000 Subject: [PATCH] Bug 17692 - Can't add library EAN under Plack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When adding a library ean under plack, there is an "internal server error" when running Plack. Tested with Koha 16.11 release. Test Plan: 1) Apply this patch 2) Enable Plack 3) Add, Edit and Delete a Library EAN Signed-off-by: Marc VĂ©ron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- admin/edi_ean_accounts.pl | 85 ++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/admin/edi_ean_accounts.pl b/admin/edi_ean_accounts.pl index f65ab9e04a..0450e2e409 100755 --- a/admin/edi_ean_accounts.pl +++ b/admin/edi_ean_accounts.pl @@ -37,12 +37,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $schema = Koha::Database->new()->schema(); -my $op = $input->param('op'); -$op ||= 'display'; + +my $id = scalar $input->param('id'); +my $op = scalar $input->param('op') || 'display'; if ( $op eq 'ean_form' ) { - show_ean(); - $template->param( ean_form => 1 ); + my $e = $schema->resultset('EdifactEan')->find($id); my @branches = $schema->resultset('Branch')->search( undef, { @@ -50,24 +50,47 @@ if ( $op eq 'ean_form' ) { order_by => 'branchname', } ); - $template->param( branches => \@branches ); + $template->param( + ean_form => 1, + branches => \@branches, + ean => $e, + ); } elsif ( $op eq 'delete_confirm' ) { - show_ean(); - $template->param( delete_confirm => 1 ); + my $e = $schema->resultset('EdifactEan')->find($id); + $template->param( + delete_confirm => 1, + ean => $e, + ); } else { if ( $op eq 'save' ) { - my $change = $input->param('id'); + my $change = $id; if ($change) { - editsubmit(); + $schema->resultset('EdifactEan')->find($id)->update( + { + branchcode => $input->param('branchcode'), + description => $input->param('description'), + ean => $input->param('ean'), + id_code_qualifier => $input->param('id_code_qualifier'), + } + ); } else { - addsubmit(); + my $new_ean = $schema->resultset('EdifactEan')->new( + { + branchcode => $input->param('branchcode'), + description => $input->param('description'), + ean => $input->param('ean'), + id_code_qualifier => $input->param('id_code_qualifier'), + } + ); + $new_ean->insert(); } } elsif ( $op eq 'delete_confirmed' ) { - delsubmit(); + my $e = $schema->resultset('EdifactEan')->find($id); + $e->delete if $e; } my @eans = $schema->resultset('EdifactEan')->search( {}, @@ -101,43 +124,3 @@ $template->param( ); output_html_with_http_headers( $input, $cookie, $template->output ); - -sub delsubmit { - my $id = $input->param('id'); - my $e = $schema->resultset('EdifactEan')->find( $id ); - $e->delete if $e; - return; -} - -sub addsubmit { - - my $new_ean = $schema->resultset('EdifactEan')->new( - { - branchcode => $input->param('branchcode'), - description => $input->param('description'), - ean => $input->param('ean'), - id_code_qualifier => $input->param('id_code_qualifier'), - } - ); - $new_ean->insert(); - return; -} - -sub editsubmit { - $schema->resultset('EdifactEan')->find( $input->param('id') )->update( - { - branchcode => $input->param('branchcode'), - description => $input->param('description'), - ean => $input->param('ean'), - id_code_qualifier => $input->param('id_code_qualifier'), - } - ); - return; -} - -sub show_ean { - my $id = $input->param('id'); - my $e = $schema->resultset('EdifactEan')->find( $id ); - $template->param( ean => $e ); - return; -}