From: Ivan Kohler Date: Wed, 28 Jan 2015 10:26:52 +0000 (-0800) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=2e4fa975e054554beac71883436b143267d7aa12;hp=-c Merge branch 'master' of git.freeside.biz:/home/git/freeside --- 2e4fa975e054554beac71883436b143267d7aa12 diff --combined FS/FS/Conf.pm index f9a169672,279a4dfe8..239e304dd --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@@ -773,7 -773,7 +773,7 @@@ sub reason_type_options { 'key' => 'log_sent_mail', 'section' => 'notification', - 'description' => 'Enable logging of template-generated email.', + 'description' => 'Enable logging of all sent email.', 'type' => 'checkbox', }, @@@ -1233,9 -1233,24 +1233,24 @@@ { 'key' => 'invoice_from', 'section' => 'required', - 'description' => 'Return address on email invoices', + 'description' => 'Return address on email invoices (address only, see invoice_from_name)', 'type' => 'text', 'per_agent' => 1, + 'validate' => sub { $_[0] =~ + /^[^@]+\@[[:alnum:]-]+(\.[[:alnum:]-]+)+$/ + ? '' : 'Invalid email address'; + } + }, + + { + 'key' => 'invoice_from_name', + 'section' => 'invoicing', + 'description' => 'Return name on email invoices (set address in invoice_from)', + 'type' => 'text', + 'per_agent' => 1, + 'validate' => sub { (($_[0] =~ /[^[:alnum:][:space:]]/) && ($_[0] !~ /^\".*\"$/)) + ? 'Invalid name. Use quotation marks around names that contain punctuation.' + : '' } }, { diff --combined FS/FS/cust_main.pm index 30dbc043c,e4766f52b..1ed1d4ace --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@@ -2139,8 -2139,8 +2139,8 @@@ Returns all notes (see L $self->custnum }, '', @@@ -4327,7 -4327,10 +4327,10 @@@ sub notify return unless $conf->exists($template); - my $from = $conf->config('invoice_from', $self->agentnum) + my $from = $conf->config('invoice_from_name', $self->agentnum) ? + $conf->config('invoice_from_name', $self->agentnum) . ' <' . + $conf->config('invoice_from', $self->agentnum) . '>' : + $conf->config('invoice_from', $self->agentnum) if $conf->exists('invoice_from', $self->agentnum); $from = $options{from} if exists($options{from}); diff --combined FS/FS/cust_pay.pm index df567a5c1,0020a824d..e44278d92 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@@ -694,7 -694,10 +694,10 @@@ sub send_receipt 'msgtype' => 'receipt', }; $error = $queue->insert( - 'from' => $conf->config('invoice_from', $cust_main->agentnum), + 'from' => $conf->config('invoice_from_name', $cust_main->agentnum ) ? + $conf->config('invoice_from_name', $cust_main->agentnum ) . ' <' . + $conf->config('invoice_from', $cust_main->agentnum ) . '>' : + $conf->config('invoice_from', $cust_main->agentnum ), #invoice_from??? well as good as any 'to' => \@invoicing_list, 'subject' => 'Payment receipt', @@@ -942,11 -945,10 +945,11 @@@ sub _upgrade_data { #class metho #not the most efficient, but hey, it only has to run once - my $where = "WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) ". - " AND usernum IS NULL ". - " AND 0 < ( SELECT COUNT(*) FROM cust_main ". - " WHERE cust_main.custnum = cust_pay.custnum ) "; + my $where = " WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) + AND usernum IS NULL + AND EXISTS ( SELECT 1 FROM cust_main + WHERE cust_main.custnum = cust_pay.custnum ) + "; my $count_sql = "SELECT COUNT(*) FROM cust_pay $where";