From: Moritz Bunkus Date: Fri, 14 Jun 2013 14:05:46 +0000 (+0200) Subject: 'templates' nicht aus %::myconfig, sondern aus Defaults-Tabelle holen X-Git-Tag: release-3.1.0beta1~331^2~3 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2e66dde525c12d064518c316d25a6b41ed727b39;p=kivitendo-erp.git 'templates' nicht aus %::myconfig, sondern aus Defaults-Tabelle holen --- diff --git a/SL/AM.pm b/SL/AM.pm index 441a184de..bc6c8266e 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -43,6 +43,7 @@ use Encode; use List::MoreUtils qw(any); use SL::DBUtils; use SL::DB::AuthUser; +use SL::DB::Default; use SL::DB::Employee; use strict; @@ -994,7 +995,7 @@ sub prepare_template_filename { $filename =~ s|.*/||; } $display_filename = $filename; - $filename = "$myconfig->{templates}/$filename"; + $filename = SL::DB::Default->get->templates . "/$filename"; } $main::lxdebug->leave_sub(); diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index a316c3afa..0817ae6c6 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -8,6 +8,7 @@ use Config::Std; use English qw(-no_match_vars); use SL::DB::AuthUser; +use SL::DB::Default; use SL::DB::Order; use SL::DB::Invoice; use SL::DB::PeriodicInvoice; @@ -202,7 +203,7 @@ sub _send_email { return unless $template; my $email_template = $config{periodic_invoices}->{email_template}; - my $filename = $email_template || ( ($user->get_config_value('templates') || "templates/webpages") . "/periodic_invoices_email.txt" ); + my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/periodic_invoices_email.txt" ); my %params = ( POSTED_INVOICES => $posted_invoices, PRINTED_INVOICES => $printed_invoices ); diff --git a/SL/BackgroundJob/SelfTest.pm b/SL/BackgroundJob/SelfTest.pm index 37a02eb94..aab279610 100644 --- a/SL/BackgroundJob/SelfTest.pm +++ b/SL/BackgroundJob/SelfTest.pm @@ -11,6 +11,7 @@ use Sys::Hostname; use FindBin; use SL::DB::AuthUser; +use SL::DB::Default; use SL::Common; use Rose::Object::MakeMethods::Generic ( @@ -145,7 +146,7 @@ sub _prepare_report { return unless $template; my $email_template = $self->config->{email_template}; - my $filename = $email_template || ( ($user->get_config_value('templates') || "templates/mails") . "/self_test/status_mail.txt" ); + my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/mails") . "/self_test/status_mail.txt" ); my $content_type = $filename =~ m/.html$/ ? 'text/html' : 'text/plain'; diff --git a/SL/CT.pm b/SL/CT.pm index 66b3e25b7..44707f91b 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -42,6 +42,7 @@ use Data::Dumper; use SL::Common; use SL::CVar; use SL::DBUtils; +use SL::DB::Default; use SL::FU; use SL::Notes; use SL::TransNumber; @@ -1080,6 +1081,10 @@ sub parse_excel_file { my ($self, $myconfig, $form) = @_; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + $form->{formname} = 'sales_quotation'; $form->{type} = 'sales_quotation'; $form->{format} = 'excel'; @@ -1122,8 +1127,6 @@ sub parse_excel_file { $form->{notes} =~ s/^\s+//g; - $form->{templates} = $myconfig->{templates}; - delete $form->{printer_command}; $form->get_employee_info($myconfig); diff --git a/SL/DN.pm b/SL/DN.pm index 8eb407b60..2eeed6762 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -36,6 +36,7 @@ package DN; use SL::Common; use SL::DBUtils; +use SL::DB::Default; use SL::GenericTranslations; use SL::IS; use SL::Mailer; @@ -394,7 +395,9 @@ sub set_template_options { my ($self, $myconfig, $form) = @_; - $form->{templates} = "$myconfig->{templates}"; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; $form->{language} = $form->get_template_language($myconfig); $form->{printer_code} = $form->get_printer_code($myconfig); @@ -433,7 +436,7 @@ sub set_template_options { $form->{IN} = undef; for my $filename (@template_files) { - if (-f "$form->{templates}/$filename") { + if (-f ($defaults->templates . "/$filename")) { $form->{IN} = $filename; last; } diff --git a/SL/Form.pm b/SL/Form.pm index d6cba7321..0246f232e 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -53,6 +53,7 @@ use SL::CVar; use SL::DB; use SL::DBConnect; use SL::DBUtils; +use SL::DB::Default; use SL::DO; use SL::IC; use SL::IS; @@ -3368,7 +3369,9 @@ sub restore_vars { sub prepare_for_printing { my ($self) = @_; - $self->{templates} ||= $::myconfig{templates}; + my $defaults = SL::DB::Default->get; + + $self->{templates} ||= $defaults->templates; $self->{formname} ||= $self->{type}; $self->{media} ||= 'email'; @@ -3420,7 +3423,7 @@ sub prepare_for_printing { } my $printer_code = $self->{printer_code} ? '_' . $self->{printer_code} : ''; - my $email_extension = -f "$::myconfig{templates}/$self->{formname}_email${language}.${extension}" ? '_email' : ''; + my $email_extension = -f ($defaults->templates . "/$self->{formname}_email${language}.${extension}") ? '_email' : ''; $self->{IN} = "$self->{formname}${email_extension}${language}${printer_code}.${extension}"; # Format dates. diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index 291eb9f0f..d99afa43c 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -12,6 +12,8 @@ use File::Temp; use List::MoreUtils qw(any); use Unicode::Normalize qw(); +use SL::DB::Default; + sub new { my $type = shift; @@ -516,7 +518,7 @@ sub parse_and_create_pdf { $local_form->{IN} = $template_file_name; $local_form->{tmpdir} = $::lx_office_conf{paths}->{userspath}; $local_form->{tmpfile} = $tex_file_name; - $local_form->{templates} = $::myconfig{templates}; + $local_form->{templates} = SL::DB::Default->get->templates; foreach (keys %params) { croak "The parameter '$_' must not be used." if exists $local_form->{$_}; diff --git a/bin/mozilla/amtemplates.pl b/bin/mozilla/amtemplates.pl index 9f21e22c7..6d7e399c9 100644 --- a/bin/mozilla/amtemplates.pl +++ b/bin/mozilla/amtemplates.pl @@ -33,6 +33,7 @@ use File::Find; +use SL::DB::Default; use SL::AM; use SL::Form; @@ -115,6 +116,9 @@ sub display_template_form { $main::auth->assert('admin'); + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + if ($form->{"formname"} =~ m|\.\.| || $form->{"formname"} =~ m|^/|) { $form->{"formname"} =~ s|.*/||; } @@ -205,13 +209,13 @@ sub display_template_form { my $fname = $File::Find::name; # remove template dir from name - $fname =~ s|^$myconfig{templates}/||; + $fname =~ s|^templates/[^/+]/||; # remove .tex from name $fname =~ s|.tex$||; push(@all_files, $fname); - }, $myconfig{templates}); + }, $defaults->templates); # filter all files already set up (i.e. not already in @values) my @other_files = grep { my $a=$_; not grep {$a eq $_->{value}} @values } @all_files; diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 99b61f31e..69b70e813 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -47,6 +47,7 @@ use SL::CT; use SL::IC; use SL::IO; +use SL::DB::Default; use SL::DB::Language; use SL::DB::Printer; use SL::Helper::Flash; @@ -1224,6 +1225,10 @@ sub print_form { _check_io_auth(); + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + my ($old_form) = @_; my $inv = "inv"; @@ -1447,8 +1452,6 @@ sub print_form { $form->{notes} =~ s/^\s+//g; - $form->{templates} = "$myconfig{templates}"; - delete $form->{printer_command}; $form->{language} = $form->get_template_language(\%myconfig); @@ -1528,7 +1531,7 @@ sub print_form { push @template_files, "$form->{formname}.$extension"; push @template_files, "default.$extension"; @template_files = uniq @template_files; - $form->{IN} = first { -f "$myconfig{templates}/$_" } @template_files; + $form->{IN} = first { -f ($defaults->templates . "/$_") } @template_files; if (!defined $form->{IN}) { $::form->error($::locale->text('Cannot find matching template for this print request. Please contact your template maintainer. I tried these: #1.', join ', ', map { "'$_'"} @template_files)); diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index d455d5aae..89e1b280d 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -37,6 +37,7 @@ use POSIX qw(strftime); +use SL::DB::Default; use SL::DB::Project; use SL::PE; use SL::RP; @@ -220,6 +221,10 @@ sub generate_income_statement { my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + $form->{padding} = "  "; $form->{bold} = ""; $form->{endbold} = ""; @@ -374,8 +379,6 @@ sub generate_income_statement { my @a = qw(company address businessnumber); map { $form->{$_} = $myconfig{$_} } @a; - $form->{templates} = $myconfig{templates}; - $form->{IN} = "income_statement.html"; $form->parse_template; @@ -387,6 +390,9 @@ sub generate_balance_sheet { $::lxdebug->enter_sub; $::auth->assert('report'); + my $defaults = SL::DB::Default->get; + $::form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $::form->{templates} = $defaults->templates; $::form->{decimalplaces} = $::form->{decimalplaces} * 1 || 2; $::form->{padding} = "  "; $::form->{bold} = ""; @@ -412,8 +418,6 @@ sub generate_balance_sheet { # setup company variables for the form map { $::form->{$_} = $::myconfig{$_} } qw(company address businessnumber nativecurr); - $::form->{templates} = $::myconfig{templates}; - $::form->header; print $::form->parse_html_template('rp/balance_sheet', $data); @@ -1195,9 +1199,11 @@ sub print_form { my %myconfig = %main::myconfig; my $locale = $main::locale; - $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1); + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; - $form->{templates} = "$myconfig{templates}"; + $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1); my $suffix = "html"; my $attachment_suffix = "html"; @@ -1631,6 +1637,10 @@ sub generate_bwa { my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + $form->{padding} = "  "; $form->{bold} = ""; $form->{endbold} = ""; @@ -1821,7 +1831,6 @@ sub generate_bwa { # setup variables for the form my @a = qw(company address businessnumber); map { $form->{$_} = $myconfig{$_} } @a; - $form->{templates} = $myconfig{templates}; $form->{IN} = "bwa.html"; diff --git a/bin/mozilla/ustva.pl b/bin/mozilla/ustva.pl index 8d77a314e..cb1c09180 100644 --- a/bin/mozilla/ustva.pl +++ b/bin/mozilla/ustva.pl @@ -38,6 +38,7 @@ require "bin/mozilla/common.pl"; use List::Util qw(first); +use SL::DB::Default; use SL::PE; use SL::RP; use SL::USTVA; @@ -225,14 +226,12 @@ sub help { $::auth->assert('advance_turnover_tax_return'); # parse help documents under doc - my $tmp = $::form->{templates}; $::form->{templates} = 'doc'; $::form->{help} = 'ustva'; $::form->{type} = 'help'; $::form->{format} = 'html'; generate_ustva(); - #$form->{templates} = $tmp; $::lxdebug->leave_sub(); } @@ -543,6 +542,10 @@ sub generate_ustva { $::auth->assert('advance_turnover_tax_return'); + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + # Aufruf von get_config zum Einlesen der Finanzamtdaten aus finanzamt.ini my $ustva = USTVA->new(); @@ -1060,7 +1063,6 @@ sub generate_ustva { . '!'); } - $form->{templates} = $myconfig{templates}; $form->{templates} = "doc" if ( $form->{type} eq 'help' ); if ($form->{format} eq 'generic'){