3 # Copyright 2012, 2014 Mark Gavillet & PTFS Europe Ltd
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 my $input = CGI->new();
28 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30 template_name => 'admin/edi_ean_accounts.tt',
33 flagsrequired => { acquisition => 'edi_manage' },
37 my $schema = Koha::Database->new()->schema();
39 my $id = scalar $input->param('id');
40 my $op = scalar $input->param('op') || 'display';
42 if ( $op eq 'ean_form' ) {
43 my $e = $schema->resultset('EdifactEan')->find($id);
44 my @branches = $schema->resultset('Branch')->search(
47 columns => [ 'branchcode', 'branchname' ],
48 order_by => 'branchname',
53 branches => \@branches,
57 elsif ( $op eq 'delete_confirm' ) {
58 my $e = $schema->resultset('EdifactEan')->find($id);
65 if ( $op eq 'save' ) {
68 $schema->resultset('EdifactEan')->find($id)->update(
70 branchcode => scalar $input->param('branchcode') || undef,
71 description => scalar $input->param('description'),
72 ean => scalar $input->param('ean'),
73 id_code_qualifier => scalar $input->param('id_code_qualifier'),
78 my $new_ean = $schema->resultset('EdifactEan')->new(
80 branchcode => scalar $input->param('branchcode') || undef,
81 description => scalar $input->param('description'),
82 ean => scalar $input->param('ean'),
83 id_code_qualifier => scalar $input->param('id_code_qualifier'),
89 elsif ( $op eq 'delete_confirmed' ) {
90 my $e = $schema->resultset('EdifactEan')->find($id);
93 my @eans = $schema->resultset('EdifactEan')->search(
99 $template->param( display => 1 );
100 $template->param( eans => \@eans );
107 description => 'EAN International',
111 description => 'US SAN Agency',
115 description => 'Assigned by supplier',
119 description => 'Assigned by buyer',
124 output_html_with_http_headers( $input, $cookie, $template->output );