$self->{action} = lc $self->{action};
$self->{action} =~ s/( |-|,|\#)/_/g;
- $self->{version} = "2.4.0";
+ $self->{version} = "2.3.9";
$main::lxdebug->leave_sub();
return @columns;
}
-
+#
sub format_amount {
$main::lxdebug->enter_sub(2);
my ($self, $myconfig, $amount, $places, $dash) = @_;
+ my $neg = ($amount =~ s/-//);
- #Workaround for $format_amount calls without $places
- if (!defined $places) {
- (my $dec) = ($amount =~ /\.(\d+)/);
- $places = length $dec;
- }
-
- if ($places =~ /\d/) {
- $amount = $self->round_amount($amount, $places);
- }
-
- # is the amount negative
- my $negative = ($amount < 0);
- my $fillup = "";
-
- if ($amount != 0) {
- if ($myconfig->{numberformat} && ($myconfig->{numberformat} ne '1000.00'))
- {
- my ($whole, $dec) = split /\./, "$amount";
- $whole =~ s/-//;
- $amount = join '', reverse split //, $whole;
- $fillup = "0" x ($places - length($dec));
-
- if ($myconfig->{numberformat} eq '1,000.00') {
- $amount =~ s/\d{3,}?/$&,/g;
- $amount =~ s/,$//;
- $amount = join '', reverse split //, $amount;
- $amount .= "\.$dec" . $fillup if ($places ne '' && $places * 1 != 0);
- }
+ $amount = $self->round_amount($amount, $places) if ($places =~ /\d/);
- if ($myconfig->{numberformat} eq '1.000,00') {
- $amount =~ s/\d{3,}?/$&./g;
- $amount =~ s/\.$//;
- $amount = join '', reverse split //, $amount;
- $amount .= ",$dec" . $fillup if ($places ne '' && $places * 1 != 0);
- }
+ my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars
+ my @p = split /\./, $amount ; # split amount at decimal point
- if ($myconfig->{numberformat} eq '1000,00') {
- $amount = "$whole";
- $amount .= ",$dec" . $fillup if ($places ne '' && $places * 1 != 0);
- }
-
- if ($dash =~ /-/) {
- $amount = ($negative) ? "($amount)" : "$amount";
- } elsif ($dash =~ /DRCR/) {
- $amount = ($negative) ? "$amount DR" : "$amount CR";
- } else {
- $amount = ($negative) ? "-$amount" : "$amount";
- }
- }
- } else {
- if ($dash eq "0" && $places) {
- if ($myconfig->{numberformat} eq '1.000,00') {
- $amount = "0" . "," . "0" x $places;
- } else {
- $amount = "0" . "." . "0" x $places;
- }
- } else {
- $amount = ($dash ne "") ? "$dash" : "0";
- }
- }
+ $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters
+ $amount = $p[0];
+ $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne '');
+
+ $amount = do {
+ ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) :
+ ($dash =~ /DRCR/) ? ($neg ? "$amount DR" : "$amount CR" ) :
+ ($neg ? "-$amount" : "$amount" ) ;
+ };
+
$main::lxdebug->leave_sub(2);
-
return $amount;
}
-
+#
sub parse_amount {
$main::lxdebug->enter_sub(2);
$mail->{to} = qq|$self->{email}|;
$mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|;
$mail->{fileid} = "$fileid.";
+ $myconfig->{signature} =~ s/\\r\\n/\\n/g;
# if we send html or plain text inline
if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) {
$mail->{message} =~ s/\r\n/<br>\n/g;
$myconfig->{signature} =~ s/\\n/<br>\n/g;
- $mail->{message} .= "<br>\n--<br>\n$myconfig->{signature}\n<br>";
+ $mail->{message} .= "<br>\n-- <br>\n$myconfig->{signature}\n<br>";
open(IN, $self->{tmpfile})
or $self->error($self->cleanup . "$self->{tmpfile} : $!");
@{ $mail->{attachments} } = ($self->{tmpfile}) unless ($form->{do_not_attach});
- $myconfig->{signature} =~ s/\\n/\r\n/g;
- $mail->{message} .= "\r\n--\r\n$myconfig->{signature}";
+ $mail->{message} =~ s/\r\n/\n/g;
+ $myconfig->{signature} =~ s/\\n/\n/g;
+ $mail->{message} .= "\n-- \n$myconfig->{signature}";
}
my $query = qq|SELECT s.* FROM shipto s
- WHERE s.id = $self->{shipto_id}|;
+ WHERE s.shipto_id = $self->{shipto_id}|;
my $sth = $dbh->prepare($query);
$sth->execute || $self->dberror($query);
$ref = $sth->fetchrow_hashref(NAME_lc);
}
$self->{"shipto$item"} =~ s/\'/\'\'/g;
}
-
if ($shipto) {
if ($self->{shipto_id}) {
my $query = qq| UPDATE shipto set
shiptophone = '$self->{shiptophone}',
shiptofax = '$self->{shiptofax}',
shiptoemail = '$self->{shiptoemail}'
- WHERE id = $self->{shipto_id}|;
+ WHERE shipto_id = $self->{shipto_id}|;
$dbh->do($query) || $self->dberror($query);
} else {
my $query =
}
$sth->finish;
- # get adr
- $query = qq|SELECT id, adr_description, adr_code
- FROM adr|;
- $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
-
-
- $self->{ADR} = [];
- while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
- push @{ $self->{ADR} }, $ref;
- }
- $sth->finish;
$dbh->disconnect;
$main::lxdebug->leave_sub();
}
my ($type, $country, $NLS_file) = @_;
my $self = {};
- %self = ();
if ($country && -d "locale/$country") {
+ local *IN;
$self->{countrycode} = $country;
- eval { require "locale/$country/$NLS_file"; };
+ if (open(IN, "locale/$country/$NLS_file")) {
+ my $code = join("", <IN>);
+ eval($code);
+ close(IN);
+ }
}
$self->{NLS_file} = $NLS_file;
sub text {
my ($self, $text) = @_;
- return (exists $self{texts}{$text}) ? $self{texts}{$text} : $text;
+ return (exists $self->{texts}{$text}) ? $self->{texts}{$text} : $text;
}
sub findsub {
my ($self, $text) = @_;
- if (exists $self{subs}{$text}) {
- $text = $self{subs}{$text};
+ if (exists $self->{subs}{$text}) {
+ $text = $self->{subs}{$text};
} else {
if ($self->{countrycode} && $self->{NLS_file}) {
Form->error(