X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=1aa0248d0be8e17371acea54b77d2b158fa7b35d;hb=e97c628d0f75459a88926c33e4b370aa98c6b680;hp=e45faba125aa4f8fcf250689bd2657d658295797;hpb=4bc7f0aadc85b49bd5bd57412f6de081eb733016;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index e45faba12..1aa0248d0 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -38,6 +38,7 @@ use Carp; use CGI; +use List::MoreUtils qw(uniq); use List::Util qw(min max first); use SL::CVar; @@ -225,6 +226,7 @@ sub display_row { # adjust prices by unit, ignore if pricegroup changed if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) { $form->{"sellprice_$i"} *= AM->convert_unit($form->{"selected_unit_$i"}, $form->{"unit_old_$i"}, $all_units) || 1; + $form->{"lastcost_$i"} *= AM->convert_unit($form->{"selected_unit_$i"}, $form->{"unit_old_$i"}, $all_units) || 1; $form->{"unit_old_$i"} = $form->{"selected_unit_$i"}; } my $this_unit = $form->{"unit_$i"}; @@ -247,7 +249,10 @@ sub display_row { $column_data{"unit"} = AM->unit_select_html($all_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef); # / unit ending +#count the max of decimalplaces of sellprice and lastcost, so the same number of decimalplaces +#is shown for lastcost and sellprice. my $decimalplaces = ($form->{"sellprice_$i"} =~ /\.(\d+)/) ? max 2, length $1 : 2; + $decimalplaces = ($form->{"lastcost_$i"} =~ /\.(\d+)/) ? max $decimalplaces, length $1 : $decimalplaces; my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1; my $discount = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100 / $price_factor, 2); @@ -354,7 +359,7 @@ sub display_row { } else { $real_sellprice = $linetotal; }; - my $real_lastcost = $form->{"lastcost_$i"} * $form->{"qty_$i"} / ( $form->{"marge_price_factor_$i"} || 1 ); + my $real_lastcost = $form->round_amount($form->{"lastcost_$i"} * $form->{"qty_$i"} / $price_factor, 2); my $marge_percent_warn = $myconfig{marge_percent_warn} * 1 || 15; my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; @@ -376,7 +381,7 @@ sub display_row {  %s |, $marge_color, $locale->text('Ertrag'),$form->{"marge_absolut_$i"}, $form->{"marge_percent_$i"}, $locale->text('LP'), $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2), - $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) } + $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces) } if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ || $form->{type} =~ /invoice/ || $form->{type} =~ /^credit_note$/ ) && !$is_delivery_order; $form->{"listprice_$i"} = $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) @@ -962,6 +967,9 @@ sub edit_e_mail { $form->{"email"} = $form->{"cp_email"} if $form->{"cp_email"}; } + $form->{language} = $form->get_template_language(\%myconfig); + $form->{language} = "_" . $form->{language} if $form->{language}; + my $title = $locale->text('E-mail') . " " . $form->get_formname_translation(); $form->{oldmedia} = $form->{media}; @@ -1397,7 +1405,7 @@ sub print_form { $form->get_shipto(\%myconfig); } - my @a = qw(name street zipcode city country contact); + my @a = qw(name department_1 department_2 street zipcode city country contact phone fax email); my $shipto = 1; @@ -1446,7 +1454,7 @@ sub print_form { format_dates($output_dateformat, $output_longdates, qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate - datepaid transdate_oe deliverydate_oe + datepaid transdate_oe deliverydate_oe dodate employee_startdate employee_enddate ), grep({ /^datepaid_\d+$/ || @@ -1501,14 +1509,8 @@ sub print_form { push @template_files, "$form->{formname}$form->{language}$printer_code.$extension"; push @template_files, "$form->{formname}.$extension"; push @template_files, "default.$extension"; - - $form->{IN} = undef; - for my $filename (@template_files) { - if (-f "$myconfig{templates}/$filename") { - $form->{IN} = $filename; - last; - } - } + @template_files = uniq @template_files; + $form->{IN} = first { -f "$myconfig{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)); @@ -1537,22 +1539,31 @@ sub print_form { my %queued = map { s|.*/|| } split / /, $form->{queued}; my $filename; + my $suffix = ($form->{postscript}) ? '.ps' : '.pdf'; if ($filename = $queued{ $form->{formname} }) { $form->{queued} =~ s/\Q$form->{formname} $filename\E//; unlink $::lx_office_conf{paths}->{spool} . "/$filename"; $filename =~ s/\..*$//g; + $filename .= $suffix; + $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT_MODE} = '>'; } else { - $filename = time; - $filename .= $$; + my $temp_fh; + ($temp_fh, $filename) = File::Temp::tempfile( + 'kivitendo-spoolXXXXXX', + SUFFIX => "$suffix", + DIR => $::lx_office_conf{paths}->{spool}, + ); + close $temp_fh; + $form->{OUT} = "$filename"; + # use >> for OUT_MODE because file is already created by File::Temp + $form->{OUT_MODE} = '>>'; + # strip directory so that only filename is stored in table status + ($filename) = $filename =~ /^$::lx_office_conf{paths}->{spool}\/(.*)/; } - $filename .= ($form->{postscript}) ? '.ps' : '.pdf'; - $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; - $form->{OUT_MODE} = '>'; - # add type $form->{queued} .= " $form->{formname} $filename"; - $form->{queued} =~ s/^ //; } my $queued = $form->{queued};