1 # TODO list helper functions
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);
18 $form->error('Need params: id or login') if (!$params{id} && !$params{login});
21 ($params{id}) = selectfirst_array_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $params{login});
24 $main::lxdebug->leave_sub();
29 ($params{login}) = selectfirst_array_query($form, $dbh, qq|SELECT login FROM employee WHERE id = ?|, conv_i($params{id}));
32 my $cfg = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM todo_user_config WHERE employee_id = ?|, conv_i($params{id}));
35 # Standard configuration: enable all
37 $cfg = { map { $_ => 1 } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login) };
40 if (! $main::auth->check_right($params{login}, 'sales_quotation_edit')) {
41 map { delete $cfg->{$_} } qw(show_overdue_sales_quotations show_overdue_sales_quotations_login);
44 $main::lxdebug->leave_sub();
49 sub save_user_config {
50 $main::lxdebug->enter_sub();
55 Common::check_params(\%params, qw(login));
57 my $myconfig = \%main::myconfig;
58 my $form = $main::form;
60 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
62 my $query = qq|SELECT id FROM employee WHERE login = ?|;
64 my ($id) = selectfirst_array_query($form, $dbh, $query, $params{login});
67 $main::lxdebug->leave_sub();
72 qq|SELECT show_after_login
74 WHERE employee_id = ?|;
76 if (! selectfirst_hashref_query($form, $dbh, $query, $id)) {
77 do_query($form, $dbh, qq|INSERT INTO todo_user_config (employee_id) VALUES (?)|, $id);
81 qq|UPDATE todo_user_config SET
84 show_follow_ups_login = ?,
85 show_overdue_sales_quotations = ?,
86 show_overdue_sales_quotations_login = ?
88 WHERE employee_id = ?|;
90 my @values = map { $params{$_} ? 't' : 'f' } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login);
93 do_query($form, $dbh, $query, @values);
97 $main::lxdebug->leave_sub();