Revision e8784e42
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/Notes.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use SL::Common; |
6 | 6 |
use SL::DBUtils; |
7 |
use SL::DB; |
|
7 | 8 |
|
8 | 9 |
use strict; |
9 | 10 |
|
... | ... | |
16 | 17 |
my $myconfig = \%main::myconfig; |
17 | 18 |
my $form = $main::form; |
18 | 19 |
|
19 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
20 |
my ($query, @values); |
|
20 |
SL::DB->client->with_transaction(sub { |
|
21 |
my $dbh = $params{dbh} || SL::DB->client->dbh; |
|
22 |
my ($query, @values); |
|
21 | 23 |
|
22 |
if (!$params{id}) { |
|
23 |
($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('note_id')|); |
|
24 |
$query = qq|INSERT INTO notes (created_by, trans_id, trans_module, subject, body, id) |
|
25 |
VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|; |
|
26 |
push @values, $::myconfig{login}, conv_i($params{trans_id}), $params{trans_module}; |
|
24 |
if (!$params{id}) {
|
|
25 |
($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('note_id')|);
|
|
26 |
$query = qq|INSERT INTO notes (created_by, trans_id, trans_module, subject, body, id)
|
|
27 |
VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|;
|
|
28 |
push @values, $::myconfig{login}, conv_i($params{trans_id}), $params{trans_module};
|
|
27 | 29 |
|
28 |
} else { |
|
29 |
$query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|; |
|
30 |
} |
|
30 |
} else {
|
|
31 |
$query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|;
|
|
32 |
}
|
|
31 | 33 |
|
32 |
push @values, $params{subject}, $params{body}, conv_i($params{id}); |
|
34 |
push @values, $params{subject}, $params{body}, conv_i($params{id});
|
|
33 | 35 |
|
34 |
do_query($form, $dbh, $query, @values); |
|
35 |
|
|
36 |
$dbh->commit() unless ($params{dbh}); |
|
36 |
do_query($form, $dbh, $query, @values); |
|
37 |
}); |
|
37 | 38 |
|
38 | 39 |
$main::lxdebug->leave_sub(); |
39 | 40 |
|
... | ... | |
71 | 72 |
my $myconfig = \%main::myconfig; |
72 | 73 |
my $form = $main::form; |
73 | 74 |
|
74 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
75 |
my $id = conv_i($params{id}); |
|
76 |
|
|
77 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id IN (SELECT DISTINCT id FROM follow_ups WHERE note_id = ?)|, $id); |
|
78 |
do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id); |
|
79 |
do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id); |
|
75 |
SL::DB->client->with_transaction(sub { |
|
76 |
my $dbh = $params{dbh} || SL::DB->client->dbh; |
|
77 |
my $id = conv_i($params{id}); |
|
80 | 78 |
|
81 |
$dbh->commit() unless ($params{dbh}); |
|
79 |
do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id IN (SELECT DISTINCT id FROM follow_ups WHERE note_id = ?)|, $id); |
|
80 |
do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id); |
|
81 |
do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id); |
|
82 |
}); |
|
82 | 83 |
|
83 | 84 |
$main::lxdebug->leave_sub(); |
84 | 85 |
} |
Auch abrufbar als: Unified diff
Notes: single-dbh