X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=0e10b22122b762a657c421c8a71e5abf8962d1c0;hb=64084bfa6ba2c9167ff4a50683606e57fec62167;hp=c569ef8a53fcefb93e9537052cd3810dd8842103;hpb=588aa1eb2e55c698fecd2dec453e332fb6859af6;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index c569ef8a5..0e10b2212 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -38,7 +38,6 @@ use Carp; use CGI; -use CGI::Ajax; use List::Util qw(min max first); use SL::CVar; @@ -47,6 +46,9 @@ use SL::CT; use SL::IC; use SL::IO; +use SL::DB::Language; +use SL::DB::Printer; + require "bin/mozilla/common.pl"; use strict; @@ -117,7 +119,7 @@ sub display_row { my $numrows = shift; - my ($readonly, $stock_in_out, $stock_in_out_title); + my ($stock_in_out, $stock_in_out_title); my $is_purchase = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl'); my $show_min_order_qty = first { $_ eq $form->{type} } qw(request_quotation purchase_order); @@ -125,8 +127,6 @@ sub display_row { my $is_s_p_order = (first { $_ eq $form->{type} } qw(sales_order purchase_order)); if ($is_delivery_order) { - $readonly = ' readonly' if ($form->{closed}); - if ($form->{type} eq 'sales_delivery_order') { $stock_in_out_title = $locale->text('Release From Stock'); $stock_in_out = 'out'; @@ -278,12 +278,16 @@ sub display_row { } # build in drop down list for pricesgroups + # $sellprice_value setzt den Wert etwas unabhängiger von der Darstellung. + # Hintergrund: Preisgruppen werden hier überprüft und neu berechnet. + # Vorher wurde der ganze cgi->textfield Block zweimal identisch eingebaut, dass passiert + # jetzt nach der Abfrage. + my $sellprice_value; if ($form->{"prices_$i"}) { $column_data{sellprice_pg} = qq||; - $column_data{sellprice} = $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => 'check_right_number_format(this)', -value => - (($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) + $sellprice_value =($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) ? $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces) - : $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces))); + : $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); } else { # for last row and report # set pricegroup drop down list from report menu @@ -296,11 +300,22 @@ sub display_row { } else { $column_data{sellprice_pg} = qq| |; } - $column_data{sellprice} = $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces)); + $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); } - $column_data{discount} = $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"})); + # Falls der Benutzer die Preise nicht anpassen sollte, wird das entsprechende + # Textfield auf readonly gesetzt. Anm. von Sven: Manipulation der Preise ist + # immer noch möglich, konsequenterweise sollten diese NUR aus der Datenbank + # geholt werden. + my $edit_prices = $main::auth->assert('edit_prices', 1); + $column_data{sellprice} = (!$edit_prices) + ? $cgi->textfield(-readonly => "readonly", + -name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value) + : $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value); + $column_data{discount} = (!$edit_prices) + ? $cgi->textfield(-readonly => "readonly", + -name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"})) + : $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"})); $column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2); $column_data{bin} = $form->{"bin_$i"}; @@ -952,7 +967,7 @@ sub edit_e_mail { subject => $subject, print_options => print_options('inline' => 1), HIDDEN => [ map +{ name => $_, value => $form->{$_} }, @hidden_keys ], - SHOW_BCC => $myconfig{role} eq 'admin' }); + SHOW_BCC => $::auth->assert('email_bcc', 'may fail') }); $main::lxdebug->leave_sub(); } @@ -1461,17 +1476,33 @@ sub print_form { $extension = 'xls'; } - my $email_extension = (($form->{media} eq 'email') && (-f "$myconfig{templates}/$form->{formname}_email$form->{language}${printer_code}.${extension}")) ? '_email' : ''; + # search for the template + my @template_files; + push @template_files, "$form->{formname}_email$form->{language}$printer_code.$extension" if $form->{media} eq 'email'; + 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; + } + } - $form->{IN} = "$form->{formname}${email_extension}$form->{language}${printer_code}.${extension}"; + 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)); + } delete $form->{OUT}; if ($form->{media} eq 'printer') { #$form->{OUT} = "| $form->{printer_command} &>/dev/null"; - $form->{OUT} = "| $form->{printer_command} "; + $form->{OUT} = $form->{printer_command}; + $form->{OUT_MODE} = '|-'; $form->{printed} .= " $form->{formname}"; - $form->{printed} =~ s/^ //; + $form->{printed} =~ s/^ //; } my $printed = $form->{printed}; @@ -1498,7 +1529,8 @@ sub print_form { } $filename .= ($form->{postscript}) ? '.ps' : '.pdf'; - $form->{OUT} = ">" . $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT_MODE} = '>'; # add type $form->{queued} .= " $form->{formname} $filename"; @@ -1526,6 +1558,16 @@ sub print_form { } # /saving the history + # prepare meta information for template introspection + $form->{template_meta} = { + formname => $form->{formname}, + language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id}), + format => $form->{format}, + media => $form->{media}, + extension => $extension, + printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id}), + }; + $form->parse_template(\%myconfig); $form->{callback} = "";