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 account_number = ?, bank_code = ?, bank = ?, iban = ?, bic = ?, chart_id = ?
28 my @values = (@params{qw(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 $main::lxdebug->enter_sub();
66 my $myconfig = \%main::myconfig;
67 my $form = $main::form;
69 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
72 'account_number' => [ 'ba.account_number', ],
73 'bank_code' => [ 'ba.bank_code', 'ba.account_number', ],
74 'bank' => [ 'ba.bank', 'ba.account_number', ],
75 'iban' => [ 'ba.iban', 'ba.account_number', ],
76 'bic' => [ 'ba.bic', 'ba.account_number', ],
77 'chart_accno' => [ 'c.accno', ],
78 'chart_description' => [ 'c.description', ],
81 my %sort_spec = create_sort_spec('defs' => \%sort_columns, 'default' => 'bank', 'column' => $params{sortorder}, 'dir' => $params{sortdir});
84 qq|SELECT ba.id, ba.account_number, ba.bank_code, ba.bank, ba.iban, ba.bic, ba.chart_id,
85 c.accno AS chart_accno, c.description AS chart_description
87 LEFT JOIN chart c ON (ba.chart_id = c.id)
88 ORDER BY $sort_spec{sql}|;
90 my $results = selectall_hashref_query($form, $dbh, $query);
92 $main::lxdebug->leave_sub();