X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=669c44e70823a690de5235e93278f11be0b13894;hp=18cb275bf1bb2a3999baaa866811ca6a87e20352;hb=12c0f8134129c1fedd9580beb7bb13b2c0e9bd8a;hpb=2b2dd969f3c18751afc583ad1e836ab8e6f73b5d diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 18cb275bf..669c44e70 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -157,7 +157,10 @@ sub send_email { unshift @mimeparts, { 'Type' => ( $options{'content-type'} || 'text/plain' ), 'Charset' => 'UTF-8', - 'Data' => $options{'body'}, + 'Data' => ( $options{'content-type'} =~ /^text\// + ? Encode::encode_utf8( $options{'body'} ) + : $options{'body'} + ), 'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ), 'Disposition' => 'inline', }; @@ -166,7 +169,10 @@ sub send_email { @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' ), 'Charset' => 'UTF-8', ); @@ -256,10 +262,17 @@ sub send_email { } 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')) { @@ -274,7 +287,7 @@ sub send_email { 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, @@ -370,7 +383,7 @@ sub generate_email { 'Encoding' => 'quoted-printable', 'Charset' => 'UTF-8', #'Encoding' => '7bit', - 'Data' => $data, + 'Data' => Encode::encode_utf8($data), 'Disposition' => 'inline', ); @@ -391,7 +404,7 @@ sub generate_email { ' ', ' ', ' ', - @html_data, + ( map Encode::encode_utf8($_), @html_data ), ' ', '', ], @@ -510,6 +523,9 @@ use Locale::SubCountry; 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; $_; } @@ -532,6 +548,27 @@ sub states_hash { @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. @@ -695,6 +732,8 @@ sub generate_ps { 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"; @@ -752,6 +791,8 @@ sub generate_pdf { #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 ". @@ -834,6 +875,7 @@ sub do_print { : $conf->config('lpr', $opt{'agentnum'} ); my $outerr = ''; + local($SIG{CHLD}) = sub {}; run3 $lpr, $data, \$outerr, \$outerr; if ( $? ) { $outerr = ": $outerr" if length($outerr); @@ -923,6 +965,8 @@ sub ocr_image { print $fh $logo_data; close $fh; + local($SIG{CHLD}) = sub {}; + run( [qw(ocroscript recognize), $filename], '>'=>"$filename.hocr" ) or die "ocroscript recognize failed\n";