return $form->quote_html($_[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;
use SL::IC;
+require "$form->{path}/common.pl";
+
# any custom scripts for this one
if (-f "$form->{path}/custom_io.pl") {
eval { require "$form->{path}/custom_io.pl"; };
$form->{"cc"} = $saved_cc if ($saved_cc);
$form->{"bcc"} = $saved_bcc if ($saved_bcc);
- # format payment dates
- for $i (1 .. $form->{paidaccounts} - 1) {
- $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
+ my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
+ if ($form->{"language_id"}) {
+ ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
+ AM->get_language_details(\%myconfig, $form, $form->{language_id});
+ } else {
+ $output_dateformat = $myconfig{"dateformat"};
+ $output_numberformat = $myconfig{"numberformat"};
+ $output_longdates = 1;
}
($form->{employee}) = split /--/, $form->{employee};
IS->invoice_details(\%myconfig, \%$form, $locale);
}
- # format global dates
- map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
- ("${inv}date", "${due}date", "shippingdate", "deliverydate");
-
- # format item dates
- for my $field (qw(transdate_oe deliverydate_oe)) {
- map {
- $form->{$field}[$_] = $locale->date(\%myconfig, $form->{$field}[$_], 1);
- } 0 .. $#{ $form->{$field} };
- }
-
if ($form->{shipto_id}) {
$form->get_shipto(\%myconfig);
}
$form->{language} = "_" . $form->{language};
}
+ # Format dates.
+ format_dates($output_dateformat, $output_longdates,
+ qw(invdate orddate quodate pldate duedate reqdate transdate
+ shippingdate deliverydate validitydate paymentdate
+ datepaid transdate_oe deliverydate_oe
+ employee_startdate employee_enddate
+ ),
+ grep({ /^datepaid_\d+$/ ||
+ /^transdate_oe_\d+$/ ||
+ /^deliverydate_oe_\d+$/ ||
+ /^reqdate_\d+$/ ||
+ /^deliverydate_\d+$/ ||
+ /^transdate_\d+$/
+ } keys(%{$form})));
+
+ reformat_numbers($output_numberformat, 2,
+ qw(invtotal ordtotal quototal subtotal linetotal
+ listprice sellprice netprice discount
+ tax taxbase),
+ grep({ /^linetotal_\d+$/ ||
+ /^listprice_\d+$/ ||
+ /^sellprice_\d+$/ ||
+ /^netprice_\d+$/ ||
+ /^taxbase_\d+$/ ||
+ /^discount_\d+$/ ||
+ /^tax_\d+$/
+ } keys(%{$form})));
+
+ reformat_numbers($output_numberformat, undef,
+ qw(qty),
+ grep({ /^qty_\d+$/
+ } keys(%{$form})));
+
if ($form->{printer_code} ne "") {
$form->{printer_code} = "_" . $form->{printer_code};
}