X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=9628ddffda77c78e4c0cf0373b55a877248a3c71;hb=1f8b0477b52069959871280c0899f461f5855b1c;hp=e889f2aef7da2ff46f9718292f84d9027b960ae3;hpb=e503a1d422ed53d99d68db3ebbc6d4dfe11dea7f;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index e889f2aef..9628ddffd 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -54,7 +54,9 @@ use SL::IO; use SL::File; use SL::PriceSource; use SL::Presenter::Part; +use SL::Util qw(trim); +use SL::DB::AuthUser; use SL::DB::Contact; use SL::DB::Currency; use SL::DB::Customer; @@ -172,12 +174,8 @@ sub display_row { ); # serialnr is important for delivery_orders if ($form->{type} eq 'sales_delivery_order') { - for my $i (1 .. $form->{rowcount} - 1) { - next unless $form->{"has_sernumber_$i"}; - splice @row2_sort, 0, 1; - splice @header_sort, 4, 0, "serialnr"; - last; - } + splice @row2_sort, 0, 1; + splice @header_sort, 4, 0, "serialnr"; } my %column_def = ( @@ -1396,6 +1394,8 @@ sub print_form { $form->get_shipto(\%myconfig); } + $form->set_addition_billing_address_print_variables; + $form->{notes} =~ s/^\s+//g; delete $form->{printer_command}; @@ -1574,6 +1574,10 @@ sub print_form { today => DateTime->today, }; + if ($defaults->print_interpolate_variables_in_positions) { + $form->substitute_placeholders_in_template_arrays({ field => 'description', type => 'text' }, { field => 'longdescription', type => 'html' }); + } + $form->parse_template(\%myconfig); $form->{callback} = ""; @@ -2111,7 +2115,11 @@ sub show_sales_purchase_email_dialog { $body_params{fallback_translation_type} = "preset_text_invoice"; } - $::form->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); + my @employees_with_email = grep { + my $user = SL::DB::Manager::AuthUser->find_by(login => $_->login); + $user && !!trim($user->get_config_value('email')); + } @{ SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]) }; + my $email_form = { to => $email, cc => $email_cc, @@ -2123,12 +2131,12 @@ sub show_sales_purchase_email_dialog { my %files = _get_files_for_email_dialog(); my $html = $::form->parse_html_template("common/_send_email_dialog", { - email_form => $email_form, - show_bcc => $::auth->assert('email_bcc', 'may fail'), - FILES => \%files, - is_customer => $::form->{vc} eq 'customer', + email_form => $email_form, + show_bcc => $::auth->assert('email_bcc', 'may fail'), + FILES => \%files, + is_customer => $::form->{vc} eq 'customer', is_invoice_mail => ($record_email && $::form->{type} eq 'invoice'), - ALL_EMPLOYEES => $::form->{all_employees}, + ALL_EMPLOYEES => \@employees_with_email, }); print $::form->ajax_response_header, $html; @@ -2148,7 +2156,18 @@ sub send_sales_purchase_email { $::form->{media} = 'email'; - if (($::form->{attachment_policy} // '') =~ m{^(?:old_file|no_file)$}) { + $::form->{attachment_policy} //= ''; + + # Is an old file version available? + my $attfile; + if ($::form->{attachment_policy} eq 'old_file') { + $attfile = SL::File->get_all(object_id => $id, + object_type => $type, + file_type => 'document', + print_variant => $::form->{formname},); + } + + if ($::form->{attachment_policy} eq 'no_file' || ($::form->{attachment_policy} eq 'old_file' && $attfile)) { $::form->send_email(\%::myconfig, 'pdf'); } else { @@ -2193,3 +2212,35 @@ sub _maybe_attach_zugferd_data { $::form->error($e->message); } } + +sub download_factur_x_xml { + my ($form) = @_; + + my $record = _make_record(); + + die if !$record + || !$record->can('customer') + || !$record->customer + || !$record->can('create_pdf_a_print_options') + || !$record->can('create_zugferd_data') + || !$record->customer->create_zugferd_invoices_for_this_customer; + + my $xml_content = eval { $record->create_zugferd_data }; + + if (my $e = SL::X::ZUGFeRDValidation->caught) { + $::form->error($e->message); + } + + my $attachment_filename = $::form->generate_attachment_filename; + $attachment_filename =~ s{\.[^.]+$}{.xml}; + my %headers = ( + '-type' => 'application/xml', + '-connection' => 'close', + '-attachment' => $attachment_filename, + '-content-length' => length($xml_content), + ); + + print $::request->cgi->header(%headers); + + $::locale->with_raw_io(\*STDOUT, sub { print $xml_content }); +}