csv_from_fixed
ocr_image
bytes_substr
+ money_pretty
);
$DEBUG = 0;
unshift @mimeparts, {
'Type' => ( $options{'content-type'} || 'text/plain' ),
- 'Data' => $options{'body'},
+ 'Charset' => 'UTF-8',
+ 'Data' => ( $options{'content-type'} =~ /^text\//
+ ? Encode::encode_utf8( $options{'body'} )
+ : $options{'body'}
+ ),
'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
'Disposition' => 'inline',
};
@mimeargs = (
'Type' => ( $options{'content-type'} || 'text/plain' ),
- 'Data' => $options{'body'},
+ 'Data' => ( $options{'content-type'} =~ /^text\//
+ ? Encode::encode_utf8( $options{'body'} )
+ : $options{'body'}
+ ),
'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
);
$smtp_opt{'ssl'} = 1 if defined($enc) && $enc eq 'tls';
$transport = Email::Sender::Transport::SMTP->new( %smtp_opt );
}
-
+
push @to, $options{bcc} if defined($options{bcc});
+ # fully unpack all addresses found in @to (including Bcc) to make the
+ # envelope list
+ my @env_to;
+ foreach my $dest (@to) {
+ push @env_to, map { $_->address } Email::Address->parse($dest);
+ }
+
local $@; # just in case
eval { sendmail($message, { transport => $transport,
from => $from,
- to => \@to }) };
+ to => \@env_to }) };
my $error = '';
if(ref($@) and $@->isa('Email::Sender::Failure')) {
if ( $conf->exists('log_sent_mail') ) {
my $cust_msg = FS::cust_msg->new({
'env_from' => $options{'from'},
- 'env_to' => join(', ', @to),
+ 'env_to' => join(', ', @env_to),
'header' => $message->header_as_string,
'body' => $message->body_as_string,
'_date' => $time,
'Type' => 'text/plain',
'Encoding' => 'quoted-printable',
#'Encoding' => '7bit',
- 'Data' => $data,
+ 'Data' => Encode::encode_utf8($data),
'Disposition' => 'inline',
);
' </title>',
' </head>',
' <body bgcolor="#ffffff">',
- @html_data,
+ ( map Encode::encode_utf8($_), @html_data ),
' </body>',
'</html>',
],
sub states_hash {
my($country) = @_;
+ #a hash? not expecting an explosion of business from unrecognized countries..
+ return states_hash_nosubcountry($country) if $country eq 'XC';
+
my @states =
# sort
map { s/[\n\r]//g; $_; }
@states;
}
+sub states_hash_nosubcountry {
+ my($country) = @_;
+
+ my @states =
+# sort
+ map { s/[\n\r]//g; $_; }
+ map { $_->state; }
+ qsearch({
+ 'select' => 'state',
+ 'table' => 'cust_main_county',
+ 'hashref' => { 'country' => $country },
+ 'extra_sql' => 'GROUP BY state',
+ });
+
+ #"i see your schwartz is as big as mine!"
+ map { ( $_->[0] => $_->[1] ) }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_ => $_ ] }
+ @states;
+}
+
=item counties STATE COUNTRY
Returns a list of counties for this state and country.
my $papersize = $conf->config('papersize') || 'letter';
+ local($SIG{CHLD}) = sub {};
+
system('dvips', '-q', '-t', $papersize, "$file.dvi", '-o', "$file.ps" ) == 0
or die "dvips failed";
#system('dvipdf', "$file.dvi", "$file.pdf" );
my $papersize = $conf->config('papersize') || 'letter';
+ local($SIG{CHLD}) = sub {};
+
system(
"dvips -q -f $sfile.dvi -t $papersize ".
"| gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$sfile.pdf ".
}
return if -e "$file.dvi" && -s "$file.dvi";
- die "pslatex $file.tex failed; see $file.log for details?\n";
+ die "pslatex $file.tex failed, see $file.log for details?\n";
}
: $conf->config('lpr', $opt{'agentnum'} );
my $outerr = '';
+ local($SIG{CHLD}) = sub {};
run3 $lpr, $data, \$outerr, \$outerr;
if ( $? ) {
$outerr = ": $outerr" if length($outerr);
print $fh $logo_data;
close $fh;
+ local($SIG{CHLD}) = sub {};
+
run( [qw(ocroscript recognize), $filename], '>'=>"$filename.hocr" )
or die "ocroscript recognize failed\n";
return Encode::decode('utf8', $bytes, $chk);
}
+=item money_pretty
+
+Accepts a postive or negative numerical value.
+Returns amount formatted for display,
+including money character.
+
+=cut
+
+sub money_pretty {
+ my $amount = shift;
+ my $money_char = $conf->{'money_char'} || '$';
+ $amount = sprintf("%0.2f",$amount);
+ $amount =~ s/^(-?)/$1$money_char/;
+ return $amount;
+}
+
=back
=head1 BUGS