From 979543127ce95408792573c99fc7eb09c30448c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 29 Oct 2012 15:32:37 +0100 Subject: [PATCH] =?utf8?q?Controller=20f=C3=BCr=20Mandantenkonfiguration.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Im Moment lässt sich hier die Änderbarkeit für Zahlungen einstellen. Es sollen demnächst auch noch anderen Konfig-Einstellungen aus der Konfig-Datei hierher wandern. --- SL/AP.pm | 6 +-- SL/AR.pm | 5 ++- SL/Controller/ClientConfig.pm | 42 +++++++++++++++++++ SL/DB/MetaSetup/Default.pm | 1 + SL/Form.pm | 1 - SL/IR.pm | 5 ++- SL/IS.pm | 5 ++- bin/mozilla/ap.pl | 5 ++- bin/mozilla/ar.pl | 5 ++- bin/mozilla/ir.pl | 5 ++- bin/mozilla/is.pl | 5 ++- config/kivitendo.conf.default | 3 -- locale/de/all | 7 ++++ locale/de_DE/all | 7 ++++ locale/en/all | 8 ++++ menu.ini | 5 +++ sql/Pg-upgrade2/defaults_posting_config.pl | 49 ++++++++++++++++++++++ templates/webpages/client_config/form.html | 25 +++++++++++ 18 files changed, 168 insertions(+), 21 deletions(-) create mode 100644 SL/Controller/ClientConfig.pm create mode 100644 sql/Pg-upgrade2/defaults_posting_config.pl create mode 100644 templates/webpages/client_config/form.html diff --git a/SL/AP.pm b/SL/AP.pm index eda1e71f4..839d40be6 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -38,7 +38,7 @@ use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::IO; use SL::MoreCommon; - +use SL::DB::Default; use Data::Dumper; use strict; @@ -251,7 +251,7 @@ sub post_transaction { # add paid transactions for my $i (1 .. $form->{paidaccounts}) { - if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + if ($form->{"acc_trans_id_$i"} && $payments_only && (SL::DB::Default->get->payments_changeable == 0)) { next; } @@ -593,7 +593,7 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - if ($::lx_office_conf{features}->{payments_changeable} != 0) { + if (SL::DB::Default->get->payments_changeable != 0) { $self->_delete_payments($form, $dbh); } diff --git a/SL/AR.pm b/SL/AR.pm index 8c72d3cf9..fcf898ea0 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -39,6 +39,7 @@ use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::IO; use SL::MoreCommon; +use SL::DB::Default; use strict; @@ -203,7 +204,7 @@ sub post_transaction { # add paid transactions for my $i (1 .. $form->{paidaccounts}) { - if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + if ($form->{"acc_trans_id_$i"} && $payments_only && (SL::DB::Default->get->payments_changeable == 0)) { next; } @@ -356,7 +357,7 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - if ($::lx_office_conf{features}->{payments_changeable} != 0) { + if (SL::DB::Default->get->payments_changeable != 0) { $self->_delete_payments($form, $dbh); } diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm new file mode 100644 index 000000000..86ae56165 --- /dev/null +++ b/SL/Controller/ClientConfig.pm @@ -0,0 +1,42 @@ +package SL::Controller::ClientConfig; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Default; +use SL::Helper::Flash; + +__PACKAGE__->run_before('check_auth'); + + +sub action_edit { + my ($self, %params) = @_; + + $self->{payment_options} = [ { title => $::locale->text("never"), value => 0 }, + { title => $::locale->text("every time"), value => 1 }, + { title => $::locale->text("on the same day"), value => 2 }, ]; + + $self->{payments_changeable} = SL::DB::Default->get->payments_changeable; + + $self->render('client_config/form', title => $::locale->text('Client Configuration')); +} + + +sub action_save { + my ($self, %params) = @_; + + SL::DB::Default->get->update_attributes('payments_changeable' => $::form->{payments_changeable}); + + flash_later('info', $::locale->text('Client Configuration saved!')); + + $self->redirect_to(action => 'edit'); +} + + +#################### private stuff ########################## + +sub check_auth { + $::auth->assert('admin'); +} + +1; diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 53ecc68e9..8488a085a 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -47,6 +47,7 @@ __PACKAGE__->meta->setup( inventory_system => { type => 'text' }, profit_determination => { type => 'text' }, language_id => { type => 'integer' }, + payments_changeable => { type => 'integer', default => '0', not_null => 1 }, ], primary_key_columns => [ 'id' ], diff --git a/SL/Form.pm b/SL/Form.pm index c14024f95..e03916f1d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -638,7 +638,6 @@ sub _prepare_html_template { $additional_params->{"conf_parts_image_css"} = $::lx_office_conf{features}->{parts_image_css}; $additional_params->{"conf_parts_listing_images"} = $::lx_office_conf{features}->{parts_listing_images}; $additional_params->{"conf_parts_show_image"} = $::lx_office_conf{features}->{parts_show_image}; - $additional_params->{"conf_payments_changeable"} = $::lx_office_conf{features}->{payments_changeable}; $additional_params->{"INSTANCE_CONF"} = $::instance_conf; if (my $debug_options = $::lx_office_conf{debug}{options}) { diff --git a/SL/IR.pm b/SL/IR.pm index 444dffceb..7be04aef2 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -44,6 +44,7 @@ use SL::DO; use SL::GenericTranslations; use SL::IO; use SL::MoreCommon; +use SL::DB::Default; use List::Util qw(min); use strict; @@ -502,7 +503,7 @@ sub post_invoice { for my $i (1 .. $form->{paidaccounts}) { if ($form->{"acc_trans_id_$i"} && $payments_only - && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + && (SL::DB::Default->get->payments_changeable == 0)) { next; } @@ -1437,7 +1438,7 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - if ($::lx_office_conf{features}->{payments_changeable} != 0) { + if (SL::DB::Default->get->payments_changeable != 0) { $self->_delete_payments($form, $dbh); } diff --git a/SL/IS.pm b/SL/IS.pm index 266e05299..8f00225be 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -48,6 +48,7 @@ use SL::MoreCommon; use SL::IC; use SL::IO; use SL::TransNumber; +use SL::DB::Default; use Data::Dumper; use strict; @@ -886,7 +887,7 @@ sub post_invoice { if ($form->{"acc_trans_id_$i"} && $payments_only - && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + && (SL::DB::Default->get->payments_changeable == 0)) { next; } @@ -1157,7 +1158,7 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - if ($::lx_office_conf{features}->{payments_changeable} != 0) { + if (SL::DB::Default->get->payments_changeable != 0) { $self->_delete_payments($form, $dbh); } diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 8c55a3d9c..821949b2a 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -40,6 +40,7 @@ use SL::IR; use SL::IS; use SL::PE; use SL::ReportGenerator; +use SL::DB::Default; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; @@ -693,11 +694,11 @@ $jsscript print qq|{"acc_trans_id_$i"}>\n|; print qq|{"gldate_$i"}>\n|; my $changeable = 1; - if ($::lx_office_conf{features}->{payments_changeable} == 0) { + if (SL::DB::Default->get->payments_changeable == 0) { # never $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1; } - if ($::lx_office_conf{features}->{payments_changeable} == 2) { + if (SL::DB::Default->get->payments_changeable == 2) { # on the same day $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"}); } diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index f164997af..1bae80b98 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -38,6 +38,7 @@ use SL::AR; use SL::FU; use SL::IS; use SL::PE; +use SL::DB::Default; use SL::ReportGenerator; require "bin/mozilla/arap.pl"; @@ -421,8 +422,8 @@ sub form_header { $payment->{changeable} = - $::lx_office_conf{features}->{payments_changeable} == 0 ? !$payment->{acc_trans_id} # never - : $::lx_office_conf{features}->{payments_changeable} == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now + SL::DB::Default->get->payments_changeable == 0 ? !$payment->{acc_trans_id} # never + : SL::DB::Default->get->payments_changeable == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now : 1; push @payments, $payment; diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 0a468615e..86910c52d 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -35,6 +35,7 @@ use SL::FU; use SL::IR; use SL::IS; use SL::PE; +use SL::DB::Default; use List::Util qw(max sum); require "bin/mozilla/io.pl"; @@ -415,10 +416,10 @@ sub form_footer { for my $i (1 .. $form->{paidaccounts}) { $form->{"changeable_$i"} = 1; - if ($::lx_office_conf{features}->{payments_changeable} == 0) { + if (SL::DB::Default->get->payments_changeable == 0) { # never $form->{"changeable_$i"} = ($form->{"acc_trans_id_$i"})? 0 : 1; - } elsif ($::lx_office_conf{features}->{payments_changeable} == 2) { + } elsif (SL::DB::Default->get->payments_changeable == 2) { # on the same day $form->{"changeable_$i"} = (($form->{"gldate_$i"} eq '') || ($form->current_date(\%myconfig) eq $form->{"gldate_$i"})); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index d5bd22946..bc95adb3b 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -35,6 +35,7 @@ use SL::FU; use SL::IS; use SL::PE; use SL::OE; +use SL::DB::Default; use Data::Dumper; use List::Util qw(max sum); @@ -444,10 +445,10 @@ sub form_footer { for my $i (1 .. $form->{paidaccounts}) { $form->{"changeable_$i"} = 1; - if ($::lx_office_conf{features}->{payments_changeable} == 0) { + if (SL::DB::Default->get->payments_changeable == 0) { # never $form->{"changeable_$i"} = ($form->{"acc_trans_id_$i"})? 0 : 1; - } elsif ($::lx_office_conf{features}->{payments_changeable} == 2) { + } elsif (SL::DB::Default->get->payments_changeable == 2) { # on the same day $form->{"changeable_$i"} = (($form->{"gldate_$i"} eq '') || ($form->current_date(\%myconfig) eq $form->{"gldate_$i"})); diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index d69ecac94..8e05d548f 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -93,9 +93,6 @@ parts_image_css = border:0;float:left;max-width:250px;margin-top:20px:margin-rig # Show the picture in the results when you search for parts parts_listing_images = 0 -# Should payments be changeable after posting (0 = never; 1 = every time; 2 = on the same day) -payments_changeable = 0 - [paths] # path to temporary files (must be writeable by the web server) userspath = users diff --git a/locale/de/all b/locale/de/all index b608feb39..8d40cefbd 100644 --- a/locale/de/all +++ b/locale/de/all @@ -406,6 +406,8 @@ $self->{texts} = { 'Cleared Balance' => 'abgeschlossen', 'Clearing Tax Received (No 71)' => 'Verrechnung des Erstattungsbetrages erwünscht (Zeile 71)', 'Click on login name to edit!' => 'Zum Bearbeiten den Benutzernamen anklicken!', + 'Client Configuration' => 'Mandantenkonfiguration', + 'Client Configuration saved!' => 'Mandantenkonfiguration gespeichert!', 'Close' => 'Übernehmen', 'Close Books up to' => 'Die Bücher abschließen bis zum', 'Close Dialog' => 'Schließen', @@ -1369,6 +1371,7 @@ $self->{texts} = { 'Payment terms (database ID)' => 'Zahlungsbedingungen (Datenbank-ID)', 'Payment terms (name)' => 'Zahlungsbedingungen (Name)', 'Payments' => 'Zahlungsausgänge', + 'Payments Changeable' => 'Änderbarkeit von Zahlungen', 'Per. Inv.' => 'Wied. Rech.', 'Period' => 'Zeitraum', 'Period:' => 'Zeitraum:', @@ -1417,6 +1420,7 @@ $self->{texts} = { 'Post' => 'Buchen', 'Post Payment' => 'Zahlung buchen', 'Post payments' => 'Zahlungen buchen', + 'Posting Configuration' => 'Buchungskonfiguration', 'Postscript' => 'Postscript', 'Posustva_coa' => 'USTVA Kennz.', 'Preferences' => 'Einstellungen', @@ -1681,6 +1685,7 @@ $self->{texts} = { 'Shipto is in use and was flagged invalid.' => 'Lieferadresse ist noch in Verwendung, und wurde als ungültig markiert.', 'Shopartikel' => 'Shopartikel', 'Short' => 'Knapp', + 'Should payments be and when should they be changeable after posting?' => 'Sollen Zahlungen nach dem Buchen änderbar sein, und wenn ja, wann?', 'Show' => 'Zeigen', 'Show Filter' => 'Filter zeigen', 'Show Salesman' => 'Verkäufer anzeigen', @@ -2285,6 +2290,7 @@ $self->{texts} = { 'ea' => 'St.', 'emailed to' => 'gemailt an', 'empty' => 'leer', + 'every time' => 'immer', 'executed' => 'ausgeführt', 'failed' => 'fehlgeschlagen', 'female' => 'weiblich', @@ -2343,6 +2349,7 @@ $self->{texts} = { 'number' => 'Nummer', 'oe.pl::search called with unknown type' => 'oe.pl::search mit unbekanntem Typ aufgerufen', 'one-time execution' => 'einmalige Ausführung', + 'on the same day' => 'am selben Tag', 'only OB Transactions' => 'nur EB-Buchungen', 'open' => 'Offen', 'order' => 'Reihenfolge', diff --git a/locale/de_DE/all b/locale/de_DE/all index eb83e18e3..04030cce0 100644 --- a/locale/de_DE/all +++ b/locale/de_DE/all @@ -397,6 +397,8 @@ $self->{texts} = { 'Cleared Balance' => 'abgeschlossen', 'Clearing Tax Received (No 71)' => 'Verrechnung des Erstattungsbetrages erwünscht (Zeile 71)', 'Click on login name to edit!' => 'Zum Bearbeiten den Benutzernamen anklicken!', + 'Client Configuration' => 'Mandantenkonfiguration', + 'Client Configuration saved!' => 'Mandantenkonfiguration gespeichert!', 'Close' => 'Übernehmen', 'Close Books up to' => 'Die Bücher abschließen bis zum', 'Close Dialog' => 'Schließen', @@ -1333,6 +1335,7 @@ $self->{texts} = { 'Payment terms (database ID)' => 'Zahlungsbedingungen (Datenbank-ID)', 'Payment terms (name)' => 'Zahlungsbedingungen (Name)', 'Payments' => 'Zahlungsausgänge', + 'Payments Changeable' => 'Änderbarkeit von Zahlungen', 'Per. Inv.' => 'Wied. Rech.', 'Period' => 'Zeitraum', 'Period:' => 'Zeitraum:', @@ -1381,6 +1384,7 @@ $self->{texts} = { 'Post' => 'Buchen', 'Post Payment' => 'Zahlung buchen', 'Post payments' => 'Zahlungen buchen', + 'Posting Configuration' => 'Buchungskonfiguration', 'Postscript' => 'Postscript', 'Posustva_coa' => 'USTVA Kennz.', 'Preferences' => 'Einstellungen', @@ -1636,6 +1640,7 @@ $self->{texts} = { 'Shipto is in use and was flagged invalid.' => 'Lieferadresse ist noch in Verwendung, und wurde als ungültig markiert.', 'Shopartikel' => 'Shopartikel', 'Short' => 'Knapp', + 'Should payments be and when should they be changeable after posting?' => 'Sollen Zahlungen nach dem Buchen änderbar sein, und wenn ja, wann?', 'Show' => 'Zeigen', 'Show Salesman' => 'Verkäufer anzeigen', 'Show TODO list' => 'Meine Aufgaben', @@ -2209,6 +2214,7 @@ $self->{texts} = { 'eMail?' => 'eMail?', 'ea' => 'St.', 'emailed to' => 'gemailt an', + 'every time' => 'immer', 'executed' => 'ausgeführt', 'female' => 'weiblich', 'follow_up_list' => 'wiedervorlageliste', @@ -2250,6 +2256,7 @@ $self->{texts} = { 'not yet executed' => 'Noch nicht ausgeführt', 'number' => 'Nummer', 'oe.pl::search called with unknown type' => 'oe.pl::search mit unbekanntem Typ aufgerufen', + 'on the same day' => 'am selben Tag', 'only OB Transactions' => 'nur EB-Buchungen', 'open' => 'Offen', 'order' => 'Reihenfolge', diff --git a/locale/en/all b/locale/en/all index bd86b1c23..dfde56cc4 100644 --- a/locale/en/all +++ b/locale/en/all @@ -398,6 +398,8 @@ $self->{texts} = { 'Cleared Balance' => '', 'Clearing Tax Received (No 71)' => '', 'Click on login name to edit!' => '', + 'Client Configuration' => '', + 'Client Configuration saved!' => '', 'Close' => '', 'Close Books up to' => '', 'Close Dialog' => '', @@ -1349,6 +1351,7 @@ $self->{texts} = { 'Payment terms (database ID)' => '', 'Payment terms (name)' => '', 'Payments' => '', + 'Payments Changeable' => '', 'Per. Inv.' => '', 'Period' => '', 'Period:' => '', @@ -1397,6 +1400,7 @@ $self->{texts} = { 'Post' => '', 'Post Payment' => '', 'Post payments' => '', + 'Posting Configuration' => '', 'Postscript' => '', 'Posustva_coa' => '', 'Preferences' => '', @@ -1658,6 +1662,7 @@ $self->{texts} = { 'Shipto is in use and was flagged invalid.' => '', 'Shopartikel' => '', 'Short' => '', + 'Should payments be and when should they be changeable after posting?' => '', 'Show' => '', 'Show Filter' => '', 'Show Salesman' => '', @@ -2238,6 +2243,7 @@ $self->{texts} = { 'ea' => '', 'emailed to' => '', 'empty' => '', + 'every time' => '', 'executed' => '', 'female' => '', 'follow_up_list' => '', @@ -2273,6 +2279,7 @@ $self->{texts} = { 'missing' => '', 'month' => '', 'monthly' => '', + 'never' => '', 'new Window' => '', 'next' => '', 'no' => '', @@ -2288,6 +2295,7 @@ $self->{texts} = { 'not yet executed' => '', 'number' => '', 'oe.pl::search called with unknown type' => '', + 'on the same day' => '', 'only OB Transactions' => '', 'open' => '', 'order' => '', diff --git a/menu.ini b/menu.ini index ca7c972f7..cb0700309 100644 --- a/menu.ini +++ b/menu.ini @@ -824,6 +824,11 @@ action=audit_control module=am.pl action=show_history_search +[System--Client Configuration] +ACCESS=admin +module=controller.pl +action=ClientConfig/edit + [System--Employees] ACCESS=admin module=controller.pl diff --git a/sql/Pg-upgrade2/defaults_posting_config.pl b/sql/Pg-upgrade2/defaults_posting_config.pl new file mode 100644 index 000000000..dd033d43c --- /dev/null +++ b/sql/Pg-upgrade2/defaults_posting_config.pl @@ -0,0 +1,49 @@ +# @tag: defaults_posting_config +# @description: Einstellung, ob und wann Zahlungen änderbar sind, vom Config-File in die DB verlagern. +# @depends: release_2_7_0 +# @charset: utf-8 + +use utf8; +use strict; + +die("This script cannot be run from the command line.") unless ($main::form); + +sub mydberror { + my ($msg) = @_; + die($dbup_locale->text("Database update error:") . + "
$msg
" . $DBI::errstr); +} + +sub do_query { + my ($query, $may_fail) = @_; + + if (!$dbh->do($query)) { + mydberror($query) unless ($may_fail); + $dbh->rollback(); + $dbh->begin_work(); + } +} + +sub do_update { + + # this query will fail if column already exist (new database) + do_query(qq|ALTER TABLE defaults ADD COLUMN payments_changeable integer NOT NULL DEFAULT 0|, 1); + + # check current configuration and set default variables accordingly, so that + # Lx-Office behaviour isn't changed by this update + # if payments_changeable is not set in config set it to 0 + my $payments_changeable = 0; + if ($::lx_office_conf{features}->{payments_changeable} == 1 ) { + $payments_changeable = 1; + } elsif ($::lx_office_conf{features}->{payments_changeable} == 2 ) { + $payments_changeable = 2; + } + + my $update_column = "UPDATE defaults SET payments_changeable = '$payments_changeable';"; + do_query($update_column); + + return 1; +} + +return do_update(); + diff --git a/templates/webpages/client_config/form.html b/templates/webpages/client_config/form.html new file mode 100644 index 000000000..173a98748 --- /dev/null +++ b/templates/webpages/client_config/form.html @@ -0,0 +1,25 @@ +[%- USE T8 %][%- USE L %][% USE LxERP %] + +

[% title | html %]

+ +[% PROCESS 'common/flash.html' %] + +
+ + + + + + + + + + +
[% 'Posting Configuration' | $T8 %]
[% 'Payments Changeable' | $T8 %][% L.select_tag('payments_changeable', SELF.payment_options, value_key => 'value', title_key => 'title', default => SELF.payments_changeable) %][% 'Should payments be and when should they be changeable after posting?' | $T8 %]
+ +
+ +[%- L.hidden_tag('action', 'ClientConfig/dispatch') %] +[%- L.submit_tag('action_save', LxERP.t8('Save')) %] + +
-- 2.20.1