12 $main::lxdebug->enter_sub();
17 my $myconfig = \%main::myconfig;
18 my $form = $main::form;
20 SL::DB->client->with_transaction(sub {
21 my $dbh = $params{dbh} || SL::DB->client->dbh;
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};
31 $query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|;
34 push @values, $params{subject}, $params{body}, conv_i($params{id});
36 do_query($form, $dbh, $query, @values);
38 }) or do { die SL::DB->client->error };
40 $main::lxdebug->leave_sub();
46 $main::lxdebug->enter_sub();
51 Common::check_params(\%params, qw(id));
53 my $myconfig = \%main::myconfig;
54 my $form = $main::form;
56 my $dbh = $form->get_standard_dbh($myconfig);
58 my $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM notes WHERE id = ?|, conv_i($params{id}));
60 $main::lxdebug->leave_sub();
66 $main::lxdebug->enter_sub();
71 Common::check_params(\%params, qw(id));
73 my $myconfig = \%main::myconfig;
74 my $form = $main::form;
76 SL::DB->client->with_transaction(sub {
77 my $dbh = $params{dbh} || SL::DB->client->dbh;
78 my $id = conv_i($params{id});
80 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);
81 do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id);
82 do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id);
84 }) or do { die SL::DB->client->error };
86 $main::lxdebug->leave_sub();