Skip to content

Commit

Permalink
Output, use correct from and reply to address when sending statement …
Browse files Browse the repository at this point in the history
…and invoice emails.

Set correct email subject line.
  • Loading branch information
steveblamey committed Dec 13, 2021
1 parent 1e56a77 commit e7eed5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,21 @@ public function printInvoice($status = 'generate')
$sc = new Systemcompany();
$sc->load(COMPANY_ID);
$options['replyto'] = $sc->getInvoiceReplyToEmailAddress();

// If the customer's statement email is not set,
// then use the users employee work email
// or the user email as a last resort.
if (empty($options['replyto'])) {
$user = DataObjectFactory::Factory('user');
$user->load($_SESSION['username']);
$person = DataObjectFactory::Factory('Person');
$person->load($user->person_id);
$options['replyto'] = $person->email->contactmethod->contact;
}

if (empty($options['replyto']) || !is_string($options['replyto'])) {
$options['replyto'] = $user->email;
}

// Set the XSL:FO template to be used
$invoice_layout = 'SalesInvoice';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ public function printStatement($status = 'generate')
if ((strtolower($this->_data['printaction']) == 'printstatement' || $this->_data['print']['printaction'] == 'email') && ! is_null($customer->email_statement())) {
$options['default_print_action'] = 'email';
$options['email'] = $customer->email_statement();
$options['email_subject']='"Account Statement from ' . SYSTEM_COMPANY . '"';
$options['email_subject'] = 'Account Statement from ' . SYSTEM_COMPANY;
$sc = new Systemcompany();
$sc->load(COMPANY_ID);
$options['replyto'] = $sc->getStatementReplyToEmailAddress();
Expand All @@ -1365,10 +1365,10 @@ public function printStatement($status = 'generate')
$user->load($_SESSION['username']);
$person = DataObjectFactory::Factory('Person');
$person->load($user->person_id);
$options['replyto'] = $person->email->contactmethod;
$options['replyto'] = $person->email->contactmethod->contact;
}

if (empty($contact)) {
if (empty($options['replyto']) || !is_string($options['replyto'])) {
$options['replyto'] = $user->email;
}
}
Expand Down

0 comments on commit e7eed5f

Please sign in to comment.