X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FForm.pm;h=ee040b5e70d59e7fae69044c2a71fa4bd07e9efa;hb=f7399fa8ecb63d8cc0f34c7d1adf3930400edda5;hp=99fe818cc87628d2e2734456e94401e8be62d0c2;hpb=c0713b66e59e458d4966b8954ec1c835e2bc0c5b;p=kivitendo-erp.git
diff --git a/SL/Form.pm b/SL/Form.pm
index 99fe818cc..ee040b5e7 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -66,6 +66,7 @@ use SL::IC;
use SL::IS;
use SL::Layout::Dispatcher;
use SL::Locale;
+use SL::Locale::String;
use SL::Mailer;
use SL::Menu;
use SL::MoreCommon qw(uri_encode uri_decode);
@@ -468,7 +469,7 @@ sub header {
# standard css for all
# this should gradually move to the layouts that need it
$layout->use_stylesheet("$_.css") for qw(
- main menu common list_accounts jquery.autocomplete
+ common main menu list_accounts jquery.autocomplete
jquery.multiselect2side
ui-lightness/jquery-ui
jquery-ui.custom
@@ -539,7 +540,7 @@ sub footer {
print $::request->{layout}->post_content;
if (my @inline_scripts = $::request->{layout}->javascripts_inline) {
- print "\n";
+ print "\n";
}
print <leave_sub;
}
+sub prepare_global_vars {
+ my ($self) = @_;
+
+ $self->{AUTH} = $::auth;
+ $self->{INSTANCE_CONF} = $::instance_conf;
+ $self->{LOCALE} = $::locale;
+ $self->{LXCONFIG} = $::lx_office_conf;
+ $self->{LXDEBUG} = $::lxdebug;
+ $self->{MYCONFIG} = \%::myconfig;
+}
+
sub _prepare_html_template {
$main::lxdebug->enter_sub();
@@ -609,15 +621,6 @@ sub _prepare_html_template {
::end_of_request();
}
- if ($self->{"DEBUG"}) {
- $additional_params->{"DEBUG"} = $self->{"DEBUG"};
- }
-
- if ($additional_params->{"DEBUG"}) {
- $additional_params->{"DEBUG"} =
- " DEBUG INFORMATION:
" . $additional_params->{"DEBUG"} . "
";
- }
-
if (%main::myconfig) {
$::myconfig{jsc_dateformat} = apply {
s/d+/\%d/gi;
@@ -810,6 +813,7 @@ sub format_amount {
my $force_places = defined $places && $places >= 0;
$amount = $self->round_amount($amount, abs $places) if $force_places;
+ $neg = 0 if $amount == 0; # don't show negative zero
$amount = sprintf "%.*f", ($force_places ? $places : 10), abs $amount; # 6 is default for %fa
# before the sprintf amount was a number, afterwards it's a string. because of the dynamic nature of perl
@@ -826,7 +830,7 @@ sub format_amount {
if ($places || $p[1]) {
$amount .= $d[0]
. ( $p[1] || '' )
- . (0 x (abs($places || 0) - length ($p[1]||''))); # pad the fraction
+ . (0 x max(abs($places || 0) - length ($p[1]||''), 0)); # pad the fraction
}
$amount = do {
@@ -969,7 +973,9 @@ sub round_amount {
# part. If an overflow occurs then apply that overflow to the part
# before the decimal sign as well using integer arithmetic again.
- my $amount_str = sprintf '%.*f', $places + 10, abs($amount);
+ my $int_amount = int(abs $amount);
+ my $str_places = max(min(10, 16 - length("$int_amount") - $places), $places);
+ my $amount_str = sprintf '%.*f', $places + $str_places, abs($amount);
return $amount unless $amount_str =~ m{^(\d+)\.(\d+)$};
@@ -1301,6 +1307,9 @@ sub generate_attachment_filename {
} elsif ($attachment_filename && $self->{"${prefix}number"}) {
$attachment_filename .= "_" . $self->{"${prefix}number"} . $self->get_extension_for_format();
+ } elsif ($attachment_filename) {
+ $attachment_filename .= $self->get_extension_for_format();
+
} else {
$attachment_filename = "";
}
@@ -1787,6 +1796,10 @@ sub set_payment_options {
$self->{payment_terms} =~ s/<%account_number%>/$self->{account_number}/g;
$self->{payment_terms} =~ s/<%bank%>/$self->{bank}/g;
$self->{payment_terms} =~ s/<%bank_code%>/$self->{bank_code}/g;
+ $self->{payment_terms} =~ s/<\%bic\%>/$self->{bic}/g;
+ $self->{payment_terms} =~ s/<\%iban\%>/$self->{iban}/g;
+ $self->{payment_terms} =~ s/<\%mandate_date_of_signature\%>/$self->{mandate_date_of_signature}/g;
+ $self->{payment_terms} =~ s/<\%mandator_id\%>/$self->{mandator_id}/g;
map { $self->{payment_terms} =~ s/<%${_}%>/$formatted_amounts{$_}/g; } keys %formatted_amounts;
@@ -2585,6 +2598,25 @@ sub all_vc {
$main::lxdebug->leave_sub();
}
+sub mtime_ischanged {
+ my ($self, $table, $option) = @_;
+
+ return unless $self->{id};
+ croak ("wrong call, no valid table defined") unless $table =~ /^(oe|ar|ap|delivery_orders|parts)$/;
+
+ my $query = "SELECT mtime, itime FROM " . $table . " WHERE id = ?";
+ my $ref = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id});
+ $ref->{mtime} ||= $ref->{itime};
+
+ if ($self->{lastmtime} && $self->{lastmtime} ne $ref->{mtime} ) {
+ $self->error(($option eq 'mail') ?
+ t8("The document has been changed by another user. No mail was sent. Please reopen it in another window and copy the changes to the new window") :
+ t8("The document has been changed by another user. Please reopen it in another window and copy the changes to the new window")
+ );
+ ::end_of_request();
+ }
+}
+
sub language_payment {
$main::lxdebug->enter_sub();
@@ -2736,6 +2768,7 @@ sub create_links {
qq|SELECT
a.cp_id, a.invnumber, a.transdate, a.${table}_id, a.datepaid,
a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.notes,
+ a.mtime, a.itime,
a.intnotes, a.department_id, a.amount AS oldinvtotal,
a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type,
a.globalproject_id, ${extra_columns}
@@ -2752,7 +2785,8 @@ sub create_links {
foreach my $key (keys %$ref) {
$self->{$key} = $ref->{$key};
}
-
+ $self->{mtime} ||= $self->{itime};
+ $self->{lastmtime} = $self->{mtime};
my $transdate = "current_date";
if ($self->{transdate}) {
$transdate = $dbh->quote($self->{transdate});
@@ -3474,9 +3508,9 @@ sub calculate_arap {
if ( $selected_tax ) {
if ( $buysell eq 'sell' ) {
- $self->{AR_amounts}{"tax_$i"} = $selected_tax->chart->accno unless $selected_tax->taxkey == 0;
+ $self->{AR_amounts}{"tax_$i"} = $selected_tax->chart->accno if defined $selected_tax->chart;
} else {
- $self->{AP_amounts}{"tax_$i"} = $selected_tax->chart->accno unless $selected_tax->taxkey == 0;
+ $self->{AP_amounts}{"tax_$i"} = $selected_tax->chart->accno if defined $selected_tax->chart;
};
$self->{"taxkey_$i"} = $selected_tax->taxkey;
@@ -3718,6 +3752,17 @@ Used to override the default favicon.
A html page title will be generated from this
+=item mtime_ischanged
+
+Tries to avoid concurrent write operations to records by checking the database mtime with a fetched one.
+
+Can be used / called with any table, that has itime and mtime attributes.
+Valid C
names are: oe, ar, ap, delivery_orders, parts.
+Can be called wit C