11 $main::lxdebug->enter_sub();
16 my $myconfig = \%main::myconfig;
17 my $form = $main::form;
19 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
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};
29 $query = qq|UPDATE notes SET subject = ?, body = ? WHERE id = ?|;
32 push @values, $params{subject}, $params{body}, conv_i($params{id});
34 do_query($form, $dbh, $query, @values);
36 $dbh->commit() unless ($params{dbh});
38 $main::lxdebug->leave_sub();
44 $main::lxdebug->enter_sub();
49 Common::check_params(\%params, qw(id));
51 my $myconfig = \%main::myconfig;
52 my $form = $main::form;
54 my $dbh = $form->get_standard_dbh($myconfig);
56 my $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM notes WHERE id = ?|, conv_i($params{id}));
58 $main::lxdebug->leave_sub();
64 $main::lxdebug->enter_sub();
69 Common::check_params(\%params, qw(id));
71 my $myconfig = \%main::myconfig;
72 my $form = $main::form;
74 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
75 my $id = conv_i($params{id});
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);
81 $dbh->commit() unless ($params{dbh});
83 $main::lxdebug->leave_sub();