9 $main::lxdebug->enter_sub();
14 my $myconfig = \%main::myconfig;
15 my $form = $main::form;
17 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
21 ($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('note_id')|);
22 $query = qq|INSERT INTO notes (created_by, trans_id, trans_module, subject, body, id)
23 VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|;
24 push @values, $form->{login}, conv_i($params{trans_id}), $params{trans_module};
27 $query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|;
30 push @values, $params{subject}, $params{body}, conv_i($params{id});
32 do_query($form, $dbh, $query, @values);
34 $dbh->commit() unless ($params{dbh});
36 $main::lxdebug->leave_sub();
42 $main::lxdebug->enter_sub();
47 Common::check_params(\%params, qw(id));
49 my $myconfig = \%main::myconfig;
50 my $form = $main::form;
52 my $dbh = $form->get_standard_dbh($myconfig);
54 my $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM notes WHERE id = ?|, conv_i($param{id}));
56 $main::lxdebug->leave_sub();
62 $main::lxdebug->enter_sub();
67 Common::check_params(\%params, qw(id));
69 my $myconfig = \%main::myconfig;
70 my $form = $main::form;
72 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
73 my $id = conv_i($params{id});
75 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);
76 do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id);
77 do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id);
79 $dbh->commit() unless ($params{dbh});
81 $main::lxdebug->leave_sub();