3 # Copyright 2011,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.
27 my $input = CGI->new();
29 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31 template_name => 'admin/edi_accounts.tt',
35 flagsrequired => { acquisition => 'edi_manage' },
39 my $op = $input->param('op');
41 my $schema = Koha::Database->new()->schema();
43 if ( $op eq 'acct_form' ) {
45 $template->param( acct_form => 1 );
46 my @vendors = $schema->resultset('Aqbookseller')->search(
49 columns => [ 'name', 'id' ],
50 order_by => { -asc => 'name' }
53 $template->param( vendors => \@vendors );
58 description => 'EAN International',
62 description => 'US SAN Agency',
66 description => 'Assigned by supplier',
70 description => 'Assigned by buyer',
76 elsif ( $op eq 'delete_confirm' ) {
78 $template->param( delete_confirm => 1 );
81 if ( $op eq 'save' ) {
84 my $id = $input->param('id');
86 description => $input->param('description'),
87 host => $input->param('host'),
88 username => $input->param('username'),
89 password => $input->param('password'),
90 vendor_id => $input->param('vendor_id'),
91 upload_directory => $input->param('upload_directory'),
92 download_directory => $input->param('download_directory'),
93 san => $input->param('san'),
94 transport => $input->param('transport'),
95 quotes_enabled => defined $input->param('quotes_enabled'),
96 invoices_enabled => defined $input->param('invoices_enabled'),
97 orders_enabled => defined $input->param('orders_enabled'),
98 responses_enabled => defined $input->param('responses_enabled'),
99 auto_orders => defined $input->param('auto_orders'),
100 id_code_qualifier => $input->param('id_code_qualifier'),
104 $schema->resultset('VendorEdiAccount')->search(
108 )->update_all($fields);
111 $schema->resultset('VendorEdiAccount')->create($fields);
114 elsif ( $op eq 'delete_confirmed' ) {
116 $schema->resultset('VendorEdiAccount')
117 ->search( { id => $input->param('id'), } )->delete_all;
120 # we do a default dispaly after deletes and saves
121 # as well as when thats all you want
122 $template->param( display => 1 );
123 my @ediaccounts = $schema->resultset('VendorEdiAccount')->search(
129 $template->param( ediaccounts => \@ediaccounts );
132 output_html_with_http_headers( $input, $cookie, $template->output );
137 my $account = $schema->resultset('VendorEdiAccount')->find($id);
142 # passing undef will default to add
147 my $acct_id = $input->param('id');
149 my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
151 $template->param( account => $acct );