X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=18cb8907443afcf71f854d6c0df14ad59a88ab39;hb=a25ac4907df1aca0db5fd0017b96e5d0bc5eadf1;hp=67b9e076fa9e6194eab58383e3e156e6f01ee88f;hpb=7d639e01d4b63644343db6b550ec84211e73f167;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 67b9e076f..18cb89074 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -420,4 +420,78 @@ sub H { return $form->quote_html($_[0]); } +sub Q { + return $form->quote($_[0]); +} + +sub format_dates { + $lxdebug->enter_sub(); + + my ($dateformat, $longformat, @indices) = @_; + + $dateformat = $myconfig{"dateformat"} unless ($dateformat); + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $locale->reformat_date(\%myconfig, $form->{$idx}, + $dateformat, $longformat); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $locale->reformat_date(\%myconfig, $form->{$idx}->[$i], + $dateformat, $longformat); + } + } + } + + $lxdebug->leave_sub(); +} + +sub reformat_numbers { + $lxdebug->enter_sub(); + + my ($numberformat, $places, @indices) = @_; + + return $lxdebug->leave_sub() + if (!$numberformat || ($numberformat eq $myconfig{"numberformat"})); + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $form->parse_amount(\%myconfig, $form->{$idx}); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $form->parse_amount(\%myconfig, $form->{$idx}->[$i]); + } + } + } + + my $saved_numberformat = $myconfig{"numberformat"}; + $myconfig{"numberformat"} = $numberformat; + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $form->format_amount(\%myconfig, $form->{$idx}, $places); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $form->format_amount(\%myconfig, $form->{$idx}->[$i], $places); + } + } + } + + $myconfig{"numberformat"} = $saved_numberformat; + + $lxdebug->leave_sub(); +} + 1;