1 # TODO list helper functions
10 $main::lxdebug->enter_sub();
15 my $myconfig = \%main::myconfig;
16 my $form = $main::form;
18 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
20 $form->error('Need params: id or login') if (!$params{id} && !$params{login});
23 ($params{id}) = selectfirst_array_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $params{login});
26 $main::lxdebug->leave_sub();
31 ($params{login}) = selectfirst_array_query($form, $dbh, qq|SELECT login FROM employee WHERE id = ?|, conv_i($params{id}));
34 my $cfg = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM todo_user_config WHERE employee_id = ?|, conv_i($params{id}));
37 # Standard configuration: enable all
39 $cfg = { map { $_ => 1 } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login) };
42 if (! $main::auth->check_right($params{login}, 'sales_quotation_edit')) {
43 map { delete $cfg->{$_} } qw(show_overdue_sales_quotations show_overdue_sales_quotations_login);
46 $main::lxdebug->leave_sub();
51 sub save_user_config {
52 $main::lxdebug->enter_sub();
57 Common::check_params(\%params, qw(login));
59 my $myconfig = \%main::myconfig;
60 my $form = $main::form;
62 my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
64 my $query = qq|SELECT id FROM employee WHERE login = ?|;
66 my ($id) = selectfirst_array_query($form, $dbh, $query, $params{login});
69 $main::lxdebug->leave_sub();
74 qq|SELECT show_after_login
76 WHERE employee_id = ?|;
78 if (! selectfirst_hashref_query($form, $dbh, $query, $id)) {
79 do_query($form, $dbh, qq|INSERT INTO todo_user_config (employee_id) VALUES (?)|, $id);
83 qq|UPDATE todo_user_config SET
86 show_follow_ups_login = ?,
87 show_overdue_sales_quotations = ?,
88 show_overdue_sales_quotations_login = ?
90 WHERE employee_id = ?|;
92 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);
95 do_query($form, $dbh, $query, @values);
99 $main::lxdebug->leave_sub();