Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / bin / mozilla / todo.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 ######################################################################
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 # MA 02110-1335, USA.
29 #######################################################################
30
31 use SL::TODO;
32
33 use strict;
34
35 sub create_todo_list {
36   $main::lxdebug->enter_sub();
37
38   $main::auth->assert('productivity');
39
40   my $form     = $main::form;
41
42   my %params   = @_;
43   my $postfix  = $params{login_screen} ? '_login' : '';
44
45   my %todo_cfg = TODO->get_user_config('login' => $::myconfig{login});
46
47   if ($params{login_screen} && !$todo_cfg{show_after_login}) {
48     $main::lxdebug->leave_sub();
49     return '';
50   }
51
52   my (@todo_items, $todo_list);
53
54   push @todo_items, todo_list_follow_ups()               if ($todo_cfg{"show_follow_ups${postfix}"});
55   push @todo_items, todo_list_overdue_sales_quotations() if ($todo_cfg{"show_overdue_sales_quotations${postfix}"});
56
57   @todo_items = grep { $_ } @todo_items;
58   $todo_list  = join("", @todo_items);
59
60   $main::lxdebug->leave_sub();
61
62   return $todo_list;
63 }
64
65 sub show_todo_list {
66   $main::lxdebug->enter_sub();
67
68   $main::auth->assert('productivity');
69
70   my $form     = $main::form;
71   my $locale   = $main::locale;
72
73   $form->{todo_list} = create_todo_list();
74   $form->{title}     = $locale->text('TODO list');
75
76   $form->header();
77   print $form->parse_html_template('todo/show_todo_list');
78
79   $main::lxdebug->leave_sub();
80 }
81
82 sub todo_list_follow_ups {
83   $main::lxdebug->enter_sub();
84
85   $main::auth->assert('productivity');
86
87   require "bin/mozilla/fu.pl";
88
89   my $content = report_for_todo_list();
90
91   $main::lxdebug->leave_sub();
92
93   return $content;
94 }
95
96 sub todo_list_overdue_sales_quotations {
97   $main::lxdebug->enter_sub();
98
99   $main::auth->assert('productivity');
100
101   require "bin/mozilla/oe.pl";
102
103   my $content = report_for_todo_list();
104
105   $main::lxdebug->leave_sub();
106
107   return $content;
108 }
109
110 1;