( @config_items, $self->_orbase_items(@_) );
}
+=item invoice_from_full [ AGENTNUM ]
+
+Returns values of invoice_from and invoice_from_name, appropriately combined
+based on their current values.
+
+=cut
+
+sub invoice_from_full {
+ my ($self, $agentnum) = @_;
+ return $self->config('invoice_from_name', $agentnum ) ?
+ $self->config('invoice_from_name', $agentnum ) . ' <' .
+ $self->config('invoice_from', $agentnum ) . '>' :
+ $self->config('invoice_from', $agentnum );
+}
+
=back
=head1 SUBROUTINES
RT::ConnectToDatabase();
}
- my $from = $conf->config('invoice_from_name') ?
- $conf->config('invoice_from_name') . ' <' .
- $conf->config('invoice_from') . '>' :
- $conf->config('invoice_from');
+ my $from = $conf->invoice_from_full();
my $outbuf = '';;
my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
(
to => $to,
- from => $conf->config('invoice_from_name', $agentnum) ?
- $conf->config('invoice_from_name', $agentnum) . ' <' .
- $conf->config('invoice_from', $agentnum) . '>' :
- $conf->config('invoice_from', $agentnum),
+ from => $conf->invoice_from_full($agentnum),
subject => $subject,
body => $body,
);
my $conf = new FS::Conf;
- if ($conf->config('invoice_from') =~ /\<(.*)\>/) {
- my $realemail = $1;
- $realemail =~ s/^\s*//; # remove leading spaces
- $realemail =~ s/\s*$//; # remove trailing spaces
- my $realname = $conf->config('invoice_from');
- $realname =~ s/\<.*\>//; # remove email address
- $realname =~ s/^\s*//; # remove leading spaces
- $realname =~ s/\s*$//; # remove trailing spaces
- # properly quote names that contain punctuation
- if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) {
- $realname = '"' . $realname . '"';
- }
- $conf->set('invoice_from_name', $realname);
- $conf->set('invoice_from', $realemail);
- }
-
$conf->touch('payment_receipt')
if $conf->exists('payment_receipt_email')
|| $conf->config('payment_receipt_msgnum');
}
}
+ my @agents = qsearch('agent', {});
+
upgrade_overlimit_groups($conf);
- map { upgrade_overlimit_groups($conf,$_->agentnum) } qsearch('agent', {});
+ map { upgrade_overlimit_groups($conf,$_->agentnum) } @agents;
+
+ upgrade_invoice_from($conf);
+ foreach my $agent (@agents) {
+ upgrade_invoice_from($conf,$agent->agentnum);
+ }
my $DIST_CONF = '/usr/local/etc/freeside/default_conf/';#DIST_CONF in Makefile
$conf->set($_, scalar(read_file( "$DIST_CONF/$_" )) )
}
}
+sub upgrade_invoice_from {
+ my ($conf, $agentnum) = @_;
+ if (
+ (!$conf->config('invoice_from_name',$agentnum)) &&
+ ($conf->config('invoice_from',$agentnum) =~ /\<(.*)\>/)
+ ) {
+ my $realemail = $1;
+ $realemail =~ s/^\s*//; # remove leading spaces
+ $realemail =~ s/\s*$//; # remove trailing spaces
+ my $realname = $conf->config('invoice_from',$agentnum);
+ $realname =~ s/\<.*\>//; # remove email address
+ $realname =~ s/^\s*//; # remove leading spaces
+ $realname =~ s/\s*$//; # remove trailing spaces
+ # properly quote names that contain punctuation
+ if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) {
+ $realname = '"' . $realname . '"';
+ }
+ $conf->set('invoice_from_name', $realname, $agentnum);
+ $conf->set('invoice_from', $realemail, $agentnum);
+ }
+}
+
=item upgrade
=cut
# this is where we set the From: address
$from ||= $self->_agent_invoice_from || #XXX should go away
- $conf->config('invoice_from_name', $self->cust_main->agentnum ) ?
- $conf->config('invoice_from_name', $self->cust_main->agentnum ) . ' <' .
- $conf->config('invoice_from', $self->cust_main->agentnum ) . '>' :
- $conf->config('invoice_from', $self->cust_main->agentnum );
+ $conf->invoice_from_full( $self->cust_main->agentnum );
my @invoicing_list = $self->cust_main->invoicing_list_emailonly;
my $cust_main = $self->cust_main;
my $error = send_email(
- 'from' => $conf->config('invoice_from_name', $self->cust_main->agentnum) ?
- $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' .
- $conf->config('invoice_from', $self->cust_main->agentnum) . '>' :
- $conf->config('invoice_from', $self->cust_main->agentnum),
+ 'from' => $conf->invoice_from_full($self->cust_main->agentnum),
#invoice_from??? well as good as any
'to' => $conf->config('deletecredits'),
'subject' => 'FREESIDE NOTIFICATION: Credit deleted',
return unless $conf->exists($template);
- 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)
+ my $from = $conf->invoice_from_full($self->agentnum)
if $conf->exists('invoice_from', $self->agentnum);
$from = $options{from} if exists($options{from});
};
my $error = send_email(
- '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 ),
+ 'from' => $conf->invoice_from_full( $self->agentnum ),
'to' => [ grep { $_ ne 'POST' } $self->invoicing_list ],
'subject' => 'Your payment could not be processed',
'body' => [ $template->fill_in(HASH => $templ_hash) ],
'msgtype' => 'receipt',
};
$error = $queue->insert(
- '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 ),
+ 'from' => $conf->invoice_from_full( $cust_main->agentnum ),
#invoice_from??? well as good as any
'to' => \@invoicing_list,
'subject' => 'Payment receipt',
}
else {
$error = send_email(
- 'from' => $conf->config('invoice_from_name', $self->cust_main->agentnum) ?
- $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' .
- $conf->config('invoice_from', $self->cust_main->agentnum) . '>' :
- $conf->config('invoice_from', $self->cust_main->agentnum),
+ 'from' => $conf->invoice_from_full( $self->cust_main->agentnum ),
'to' => \@invoicing_list,
'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
'body' => [ map "$_\n", $conf->config('cancelmessage') ],
$from_addr = scalar( $conf->config($opt{'from_config'},
$cust_main->agentnum) );
}
- $from_addr ||= $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);
+ $from_addr ||= $conf->invoice_from_full($cust_main->agentnum);
}
# my @cust_msg = ();
# if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
my $body = "Import from gateway ".$gateway->label."\n".$error_text;
send_email(
to => $mail_on_error,
- from => $conf->config('invoice_from_name') ?
- $conf->config('invoice_from_name') . ' <' .
- $conf->config('invoice_from') . '>' :
- $conf->config('invoice_from'),
+ from => $conf->invoice_from_full(),
subject => $subject,
body => $body,
);
# this is where we set the From: address
$from ||= $conf->config('quotation_from', $self->cust_or_prospect->agentnum )
- || ($conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) ?
- $conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) . ' <' .
- $conf->config('invoice_from', $self->cust_or_prospect->agentnum ) . '>' :
- $conf->config('invoice_from', $self->cust_or_prospect->agentnum ));
+ || $conf->invoice_from_full( $self->cust_or_prospect->agentnum );
$self->SUPER::email( {
'from' => $from,
%$opt,
# (maybe use only the raw content, so that we don't have to supply a
# customer for substitutions? ewww.)
my %message = (
- 'from' => $conf->config('invoice_from_name') ?
- $conf->config('invoice_from_name') . ' <' .
- $conf->config('invoice_from') . '>' :
- $conf->config('invoice_from'),
+ 'from' => $conf->invoice_from_full(),
'to' => $to,
'subject' => $self->subject,
'nobody' => 1,