1 package SL::BankAccount;
8 $main::lxdebug->enter_sub();
13 my $myconfig = \%main::myconfig;
14 my $form = $main::form;
16 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
19 ($params{id}) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('id')|);
20 do_query($form, $dbh, qq|INSERT INTO bank_accounts (id, chart_id)
21 VALUES (?, (SELECT id FROM chart LIMIT 1))|, conv_i($params{id}));
25 qq|UPDATE bank_accounts
26 SET name= ?, account_number = ?, bank_code = ?, bank = ?, iban = ?, bic = ?, chart_id = ?
28 my @values = (@params{qw(name account_number bank_code bank iban bic)}, conv_i($params{chart_id}), conv_i($params{id}));
30 do_query($form, $dbh, $query, @values);
32 $dbh->commit() unless ($params{dbh});
34 $main::lxdebug->leave_sub();
40 $main::lxdebug->enter_sub();
45 Common::check_params(\%params, qw(id));
47 my $myconfig = \%main::myconfig;
48 my $form = $main::form;
50 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
52 my $query = qq|SELECT * FROM bank_accounts WHERE id = ?|;
53 my $account = selectfirst_hashref_query($form, $dbh, $query, conv_i($params{id}));
55 $main::lxdebug->leave_sub();
61 $::lxdebug->enter_sub();
66 Common::check_params(\%params, qw(id));
68 my $dbh = $params{dbh} || $::form->get_standard_dbh(%::myconfig);
75 do_query($::form, $dbh, $query, conv_i($params{id}));
79 $::lxdebug->leave_sub();
83 $main::lxdebug->enter_sub();
88 my $myconfig = \%main::myconfig;
89 my $form = $main::form;
91 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
94 'name' => [ 'ba.name', ],
95 'account_number' => [ 'ba.account_number', ],
96 'bank_code' => [ 'ba.bank_code', 'ba.account_number', ],
97 'bank' => [ 'ba.bank', 'ba.account_number', ],
98 'iban' => [ 'ba.iban', 'ba.account_number', ],
99 'bic' => [ 'ba.bic', 'ba.account_number', ],
100 'chart_accno' => [ 'c.accno', ],
101 'chart_description' => [ 'c.description', ],
104 my %sort_spec = create_sort_spec('defs' => \%sort_columns, 'default' => 'bank', 'column' => $params{sortorder}, 'dir' => $params{sortdir});
107 qq|SELECT ba.id, ba.name, ba.account_number, ba.bank_code, ba.bank, ba.iban, ba.bic, ba.chart_id,
108 c.accno AS chart_accno, c.description AS chart_description
109 FROM bank_accounts ba
110 LEFT JOIN chart c ON (ba.chart_id = c.id)
111 ORDER BY $sort_spec{sql}|;
113 my $results = selectall_hashref_query($form, $dbh, $query);
115 $main::lxdebug->leave_sub();