X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FBackgroundJob%2FCreatePeriodicInvoices.pm;h=0817ae6c606505ae55ef9809f01e198843246696;hb=ec4aa5bbad60c76fd7b898fcbbdf2de705a055c4;hp=1a2cf81f51e7b0d2169777252c76dbf5266161a0;hpb=f04a7950a3040894b77e09289a71d3931ce898d0;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 1a2cf81f5..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; @@ -22,7 +23,7 @@ sub run { my $self = shift; $self->{db_obj} = shift; - my $configs = SL::DB::Manager::PeriodicInvoicesConfig->get_all(where => [ active => 1 ]); + my $configs = SL::DB::Manager::PeriodicInvoicesConfig->get_all(query => [ active => 1 ]); foreach my $config (@{ $configs }) { my $new_end_date = $config->handle_automatic_extension; @@ -64,9 +65,9 @@ sub run { } sub _log_msg { - # my $message = join('', @_); - # $message .= "\n" unless $message =~ m/\n$/; - # $::lxdebug->message(0, $message); + my $message = join('', @_); + $message .= "\n" unless $message =~ m/\n$/; + $::lxdebug->message(LXDebug::DEBUG1(), $message); } sub _generate_time_period_variables { @@ -75,8 +76,8 @@ sub _generate_time_period_variables { my $period_end_date = $period_start_date->clone->truncate(to => 'month')->add(months => $config->get_period_length)->subtract(days => 1); my @month_names = ('', - 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', - 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'); + $::locale->text('January'), $::locale->text('February'), $::locale->text('March'), $::locale->text('April'), $::locale->text('May'), $::locale->text('June'), + $::locale->text('July'), $::locale->text('August'), $::locale->text('September'), $::locale->text('October'), $::locale->text('November'), $::locale->text('December')); my $vars = { current_quarter => $period_start_date->quarter, previous_quarter => $period_start_date->clone->subtract(months => 3)->quarter, @@ -184,7 +185,7 @@ sub _calculate_dates { sub _send_email { my ($posted_invoices, $printed_invoices) = @_; - read_config 'config/lx_office.conf' => my %config; + my %config = %::lx_office_conf; return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices }; @@ -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 ); @@ -232,15 +233,16 @@ sub _print_invoice { $form->{formname} = $form->{type}; $form->{format} = 'pdf'; $form->{media} = 'printer'; - $form->{OUT} = "| " . $config->printer->printer_command; + $form->{OUT} = $config->printer->printer_command; + $form->{OUT_MODE} = '|-'; $form->prepare_for_printing; $form->throw_on_error(sub { eval { - $form->parse_template(\%::myconfig, $::userspath); + $form->parse_template(\%::myconfig); 1; - } || die $EVAL_ERROR->{error}; + } || die $EVAL_ERROR->getMessage; }); }