From 713a6d703c0b2806f6a1f8fafa6bc9b6554c4087 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 16 Jan 2008 16:26:02 +0000 Subject: [PATCH] Benutzerkonfiguration um Einstellungen zur Aufgabenliste erweitert. --- SL/TODO.pm | 100 +++++++++++++++++++++++ bin/mozilla/am.pl | 4 + bin/mozilla/login.pl | 2 +- bin/mozilla/todo.pl | 16 +++- locale/de/all | 7 ++ menu.ini | 1 + sql/Pg-upgrade2/todo_user_config.sql | 14 ++++ templates/webpages/am/config_de.html | 48 +++++++++++ templates/webpages/am/config_master.html | 48 +++++++++++ 9 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 SL/TODO.pm create mode 100644 sql/Pg-upgrade2/todo_user_config.sql diff --git a/SL/TODO.pm b/SL/TODO.pm new file mode 100644 index 000000000..af881b406 --- /dev/null +++ b/SL/TODO.pm @@ -0,0 +1,100 @@ +# TODO list helper functions + +package TODO; + +use SL::DBUtils; + +sub get_user_config { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + + $form->error('Need params: id or login') if (!$params{id} && !$params{login}); + + if ($params{login}) { + ($params{id}) = selectfirst_array_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $params{login}); + + if (!$params{id}) { + $main::lxdebug->leave_sub(); + return (); + } + + } else { + ($params{login}) = selectfirst_array_query($form, $dbh, qq|SELECT login FROM employee WHERE id = ?|, conv_i($params{id})); + } + + my $cfg = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM todo_user_config WHERE employee_id = ?|, conv_i($params{id})); + + if (!$cfg) { + # Standard configuration: enable all + + $cfg = { map { $_ => 1 } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login) }; + } + + if (! $main::auth->check_right($params{login}, 'sales_quotation_edit')) { + map { delete $cfg->{$_} } qw(show_overdue_sales_quotations show_overdue_sales_quotations_login); + } + + $main::lxdebug->leave_sub(); + + return %{ $cfg }; +} + +sub save_user_config { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(login)); + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + + my $query = qq|SELECT id FROM employee WHERE login = ?|; + + my ($id) = selectfirst_array_query($form, $dbh, $query, $params{login}); + + if (!$id) { + $main::lxdebug->leave_sub(); + return; + } + + $query = + qq|SELECT show_after_login + FROM todo_user_config + WHERE employee_id = ?|; + + if (! selectfirst_hashref_query($form, $dbh, $query, $id)) { + do_query($form, $dbh, qq|INSERT INTO todo_user_config (employee_id) VALUES (?)|, $id); + } + + $query = + qq|UPDATE todo_user_config SET + show_after_login = ?, + show_follow_ups = ?, + show_follow_ups_login = ?, + show_overdue_sales_quotations = ?, + show_overdue_sales_quotations_login = ? + + WHERE employee_id = ?|; + + 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); + push @values, $id; + + do_query($form, $dbh, $query, @values); + + $dbh->commit(); + + $main::lxdebug->leave_sub(); +} + +1; diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 51f8f6981..9f7d8f557 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -38,6 +38,7 @@ use SL::Form; use SL::User; use SL::USTVA; use SL::Iconv; +use SL::TODO; use CGI::Ajax; use CGI; @@ -2491,6 +2492,7 @@ sub config { $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details})); $form->{"menustyle_$myconfig{menustyle}"} = 1; $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password(); + $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) }; $form->{title} = $locale->text('Edit Preferences for #1', $form->{login}); @@ -2505,6 +2507,8 @@ sub save_preferences { $form->{stylesheet} = $form->{usestylesheet}; + TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } }); + $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, $webdav)); $form->error($locale->text('Cannot save preferences!')); diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 309b3d1b6..7a4df5c69 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -164,7 +164,7 @@ sub company_logo { $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode}); - $form->{todo_list} = create_todo_list(); + $form->{todo_list} = create_todo_list('login_screen' => 1) if (!$form->{no_todo_list}); $form->{stylesheet} = $myconfig{stylesheet}; $form->{title} = $locale->text('About'); diff --git a/bin/mozilla/todo.pl b/bin/mozilla/todo.pl index 0f8cf3d7e..8f09fee5a 100644 --- a/bin/mozilla/todo.pl +++ b/bin/mozilla/todo.pl @@ -27,13 +27,25 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ####################################################################### +use SL::TODO; + sub create_todo_list { $lxdebug->enter_sub(); + my %params = @_; + my $postfix = '_login' if ($params{login_screen}); + + my %todo_cfg = TODO->get_user_config('login' => $form->{login}); + + if ($params{login_screen} && !$todo_cfg{show_after_login}) { + $lxdebug->leave_sub(); + return ''; + } + my (@todo_items, $todo_list); - push @todo_items, todo_list_follow_ups(); - push @todo_items, todo_list_overdue_sales_quotations(); + push @todo_items, todo_list_follow_ups() if ($todo_cfg{"show_follow_ups${postfix}"}); + push @todo_items, todo_list_overdue_sales_quotations() if ($todo_cfg{"show_overdue_sales_quotations${postfix}"}); @todo_items = grep { $_ } @todo_items; $todo_list = join("", @todo_items); diff --git a/locale/de/all b/locale/de/all index cb8c6be48..ad5e85dab 100644 --- a/locale/de/all +++ b/locale/de/all @@ -20,7 +20,9 @@ $self->{texts} = { '<%total%> -- Amount payable' => '<%total%> -- Noch zu bezahlender Betrag', '<%total_wo_skonto%> -- Amount payable less discount' => '<%total_wo_skonto%> -- Noch zu bezahlender Betrag abzüglich Skonto', '*/' => '*/', + '...after loggin in' => '...nach dem Anmelden', '...done' => '...fertig', + '...on the TODO list' => '...auf der Aufgabenliste', '1. Quarter' => '1. Quartal', '2. Quarter' => '2. Quartal', '3. Quarter' => '3. Quartal', @@ -291,6 +293,7 @@ aktualisieren wollen?', 'Company' => 'Firma', 'Company Name' => 'Firmenname', 'Compare to' => 'Gegenüberstellen zu', + 'Configuration of individual TODO items' => 'Konfiguration für die einzelnen Aufgabenlistenpunkte', 'Confirm!' => 'Bestätigen Sie!', 'Confirmation' => 'Auftragsbestätigung', 'Contact' => 'Kontakt', @@ -1165,7 +1168,10 @@ aktualisieren wollen?', 'Show TODO list' => 'Aufgabenliste anzeigen', 'Show by default' => 'Standardmäßig anzeigen', 'Show details' => 'Details anzeigen', + 'Show follow ups...' => 'Zeige Wiedervorlagen...', 'Show old dunnings' => 'Alte Mahnungen anzeigen', + 'Show overdue sales quotations...' => 'Zeige überfällige Angebote...', + 'Show your TODO list after loggin in' => 'Aufgabenliste nach dem Anmelden anzeigen', 'Signature' => 'Unterschrift', 'Skip' => 'Überspringen', 'Skonto' => 'Skonto', @@ -1197,6 +1203,7 @@ aktualisieren wollen?', 'Superuser name' => 'Datenbankadministrator', 'System' => 'System', 'TODO list' => 'Aufgabenliste', + 'TODO list options' => 'Aufgabenlistenoptionen', 'TOP100' => 'Top 100', 'Tax' => 'Steuer', 'Tax Consultant' => 'Steuerberater/-in', diff --git a/menu.ini b/menu.ini index 186216dc8..1522221e5 100644 --- a/menu.ini +++ b/menu.ini @@ -729,6 +729,7 @@ target=_top [Programm--Version] module=login.pl action=company_logo +no_todo_list=1 ################################# diff --git a/sql/Pg-upgrade2/todo_user_config.sql b/sql/Pg-upgrade2/todo_user_config.sql new file mode 100644 index 000000000..add7c02e1 --- /dev/null +++ b/sql/Pg-upgrade2/todo_user_config.sql @@ -0,0 +1,14 @@ +-- @tag: todo_config +-- @description: Benutzerkonfiguration zur Aufgabenliste +-- @depends: release_2_4_3 + +CREATE TABLE todo_user_config ( + employee_id integer NOT NULL, + show_after_login boolean DEFAULT TRUE, + show_follow_ups boolean DEFAULT TRUE, + show_follow_ups_login boolean DEFAULT TRUE, + show_overdue_sales_quotations boolean DEFAULT TRUE, + show_overdue_sales_quotations_login boolean DEFAULT TRUE, + + FOREIGN KEY (employee_id) REFERENCES employee (id) +); diff --git a/templates/webpages/am/config_de.html b/templates/webpages/am/config_de.html index 02769478d..167f0b972 100644 --- a/templates/webpages/am/config_de.html +++ b/templates/webpages/am/config_de.html @@ -8,6 +8,7 @@
  • Persönliche Einstellungen
  • Anzeigeoptionen
  • Druckoptionen
  • +
  • Aufgabenlistenoptionen
  • @@ -195,6 +196,53 @@
    + +
    + + + + + + + + + + + + + + + + + + [%- IF AUTH_RIGHTS_SALES_QUOTATION_EDIT %] + + + + + + [%- END %] +
    Aufgabenliste nach dem Anmelden anzeigen + + + + +
    Konfiguration für die einzelnen Aufgabenlistenpunkte
    Zeige Wiedervorlagen... + + + + + +
    Zeige überfällige Angebote... + + + + + +
    + +
    +

    diff --git a/templates/webpages/am/config_master.html b/templates/webpages/am/config_master.html index 2bda248a5..7e0e9f31e 100644 --- a/templates/webpages/am/config_master.html +++ b/templates/webpages/am/config_master.html @@ -8,6 +8,7 @@
  • Personal settings
  • Display options
  • Print options
  • +
  • TODO list options
  • @@ -195,6 +196,53 @@
    + +
    + + + + + + + + + + + + + + + + + + [%- IF AUTH_RIGHTS_SALES_QUOTATION_EDIT %] + + + + + + [%- END %] +
    Show your TODO list after loggin in + + + + +
    Configuration of individual TODO items
    Show follow ups... + + + + + +
    Show overdue sales quotations... + + + + + +
    + +
    +

    -- 2.20.1