* @access public
* @return void
*/
- public function sendEmailNotification( $notification_id, $account_id, $data = null )
+ public function sendEmailNotification( $notification_id, $account_id, $data = null, $test = false )
{
// Support Class
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
return false;
}
+ $currentAmount = false;
+ if ( $account['invoice_type'] ) {
+ $invTypeData = $BillingSupport->getInvoiceTypeById( $account['invoice_type'] );
+ $currentAmount = $invTypeData['amount'];
+ }
+
// get the Notification type
$notification_type = $this->getNotificationTypeById( $notification_id );
if ( !$notification_type ) {
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
$viewFile = 'admin/notifications/notification.html';
+ $contactData = apply_filters( 'glm-member-db-contacts-get-contact-data-by-refdest', $account['ref_dest'] );
+
$account_data = array(
- 'account' => array(
- 'name' => $account['ref_name'],
- 'email' => $account['email'],
- 'first_name' => $account['billing_fname'],
- 'last_name' => $account['billing_lname'],
- 'addr1' => $account['billing_addr1'],
- 'addr2' => $account['billing_addr2'],
- 'city' => $account['billing_city'],
- 'state' => $account['billing_state'],
- 'zip' => $account['billing_zip'],
- 'phone' => $account['billing_phone'],
- )
+ 'account' => array(
+ 'name' => $account['ref_name'],
+ 'email' => $account['email'],
+ 'first_name' => $account['billing_fname'],
+ 'last_name' => $account['billing_lname'],
+ 'addr1' => $account['billing_addr1'],
+ 'addr2' => $account['billing_addr2'],
+ 'city' => $account['billing_city'],
+ 'state' => $account['billing_state'],
+ 'zip' => $account['billing_zip'],
+ 'phone' => $account['billing_phone'],
+ 'company' => $account['billing_company'],
+ 'position' => $account['billing_position'],
+ 'renewal_date' => isset( $account['renewal_date'] )
+ ? date( 'm/d/Y', strtotime( $account['renewal_date'] ) )
+ : '',
+ 'current_due' => $currentAmount,
+ ),
+ 'contact' => array(
+ 'company' => $contactData['org'],
+ 'fname' => $contactData['business_fname'],
+ 'lname' => $contactData['business_lname'],
+ 'position' => $contactData['title'],
+ 'addr1' => $contactData['business_addr1'],
+ 'addr2' => $contactData['business_addr2'],
+ 'city' => $contactData['business_city'],
+ 'state' => $contactData['business_state']['value'],
+ 'email' => $contactData['business_email'],
+ 'phone' => $contactData['business_phone'],
+ 'office_phone' => $contactData['office_phone'],
+ 'mobile_phone' => $contactData['business_mobile'],
+ 'fax' => $contactData['fax'],
+ ),
);
+ echo '<pre>$account_data: ' . print_r( $account_data, true ) . '</pre>';
// Merge any data passed into this method
$account_data['data'] = $data;
// Generate output from model data and view
$htmlMessage = $smarty->template->fetch( $viewFile );
+ if ( $test ) {
+ echo $htmlMessage;
+ } else {
- // change the default wordpress from name when sending mail
- add_filter(
- 'wp_mail_from_name',
- function ( $name ) {
- $siteName = get_bloginfo( 'name' );
- return $siteName;
+ // change the default wordpress from name when sending mail
+ add_filter(
+ 'wp_mail_from_name',
+ function ( $name ) {
+ $siteName = get_bloginfo( 'name' );
+ return $siteName;
+ }
+ );
+ // Send confirmation email, set the content type to allow html by using this filter
+ add_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
+
+ $message = $htmlMessage;
+ $header[] = 'From:' . $from_header;
+ if ( $replyto ) {
+ $header[] = 'Reply-To:' . $replyto;
}
- );
- // Send confirmation email, set the content type to allow html by using this filter
- add_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
- $message = $htmlMessage;
- $header[] = 'From:' . $from_header;
- if ( $replyto ) {
- $header[] = 'Reply-To:' . $replyto;
- }
+ wp_mail( $to_email, $subject, $message, $header );
- wp_mail( $to_email, $subject, $message, $header );
+ // remove the filter to avoid conflicts
+ remove_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
- // remove the filter to avoid conflicts
- remove_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
+ // Send notification to recordNotification
+ $notice_data = array(
+ 'notification_type' => $notification_id,
+ 'account' => $account_id,
+ 'from_replyto' => $from_header,
+ 'subject' => $subject,
+ 'message' => $message,
+ 'email_sent' => $to_email,
+ );
+ $this->recordNotification( $notice_data );
+
+ }
- // Send notification to recordNotification
- $notice_data = array(
- 'notification_type' => $notification_id,
- 'account' => $account_id,
- 'from_replyto' => $from_header,
- 'subject' => $subject,
- 'message' => $message,
- 'email_sent' => $to_email,
- );
- $this->recordNotification( $notice_data );
}
/**
'data' => false
);
}
-
+ $mergeTagsBilling = array(
+ 'Name of Account', '{$account.name}',
+ 'Billing First Name', '{$account.fname}',
+ 'Billing Last Name', '{$account.lname}',
+ 'Billing Address Line 1', '{$account.addr1}',
+ 'Billing Address Line 2', '{$account.addr2}',
+ 'Billing City', '{$account.city}',
+ 'Billing State', '{$account.state}',
+ 'Billing Zip', '{$account.zip}',
+ 'Billing Email', '{$account.email}',
+ 'Billing Phone', '{$account.phone}',
+ 'Billing Company', '{$account.company}',
+ 'Billing Position', '{$account.position}',
+ );
+ $mergeTagsInvoice = array(
+ 'Invoice Amount', '{$data.amount}',
+ );
+ $mergeTagsPayment = array(
+ 'Payment Amount', '{$data.payment}',
+ );
+ $mergeTagsContact = array(
+ 'Contact First Name', '{$contact.fname}',
+ 'Contact Last Name', '{$contact.lname}',
+ 'Contact Address Line 1', '{$contact.addr1}',
+ 'Contact Address Line 2', '{$contact.addr2}',
+ 'Contact City', '{$contact.city}',
+ 'Contact State', '{$contact.state}',
+ 'Contact Zip', '{$contact.zip}',
+ 'Contact Company', '{$contact.company}',
+ 'Contact Position', '{$contact.position}',
+ 'Contact Email', '{$contact.email}',
+ 'Contact Phone', '{$contact.office_phone}',
+ 'Contact Mobile Phone', '{$contact.mobile_phone}',
+ );
// Compile template data
$templateData = array(
'notification_id' => $id,
'send_date_period' => $this->config['send_date_period'],
'send_date_when' => $this->config['send_date_when'],
'send_action' => $this->config['send_action'],
+ 'mergeTagsBilling' => $mergeTagsBilling,
+ 'mergeTagsInvoice' => $mergeTagsInvoice,
+ 'mergeTagsPayment' => $mergeTagsPayment,
+ 'mergeTagsContact' => $mergeTagsContact,
);
// Return status, suggested view, and data to controller
+<style>
+ .merge-tags table caption {
+ font-weight: bold;
+ }
+</style>
{include file='admin/settings/header.html'}
{include file='admin/settings/subHeader.html'}
</tr>
<tr>
- <td colspan="2">
+ <td colspan="2" class="merge-tags">
<h4>Merge Tags</h4>
<p>The "merge tags" listed below may be used in the E-Mail message content
to include certain information about the Account or Invoice. Be sure to
include the "{literal}{{/literal}" and "{literal}}{/literal}" and "$" characters exactly as show.</p>
- <table>
- <tr>
- <th>{literal}{$account.name}{/literal}</th>
- <td>Name of Account</td>
- </tr>
- <tr>
- <th>{literal}{$account.first_name}{/literal}</th>
- <td>Billing First Name</td>
- </tr>
- <tr>
- <th>{literal}{$account.last_name}{/literal}</th>
- <td>Billing Last Name</td>
- </tr>
- <tr>
- <th>{literal}{$account.addr1}{/literal}</th>
- <td>Billing Address 1</td>
- </tr>
- <tr>
- <th>{literal}{$account.addr2}{/literal}</th>
- <td>Billing Address 2</td>
- </tr>
- <tr>
- <th>{literal}{$account.city}{/literal}</th>
- <td>Billing City</td>
- </tr>
- <tr>
- <th>{literal}{$account.state}{/literal}</th>
- <td>Billing State</td>
- </tr>
- <tr>
- <th>{literal}{$account.zip}{/literal}</th>
- <td>Billing Zip</td>
- </tr>
- <tr>
- <th>{literal}{$account.email}{/literal}</th>
- <td>Billing Email</td>
- </tr>
- <tr>
- <th>{literal}{$account.phone}{/literal}</th>
- <td>Billing Phone</td>
- </tr>
- <tr>
- <td colspan="2">Only available using Immediate Action - Create Invoice</td>
- </tr>
- <tr>
- <th>{literal}{$data.amount}{/literal}</th>
- <td>Invoice Amount</td>
- </tr>
- <tr>
- <td colspan="2">Only available using Immediate Action - Received Payment</td>
- </tr>
- <tr>
- <th>{literal}{$data.payment}{/literal}</th>
- <td>Payment Amount</td>
- </tr>
- </table>
+
+ {html_table loop=$mergeTagsBilling cols=2 table_attr='border=0 width=400' caption='Billing Examples'}
+
+ {html_table loop=$mergeTagsContact cols=2 table_attr='border=0 width=400' caption='Contact Examples'}
+
+ {html_table loop=$mergeTagsInvoice cols=2 table_attr='border=0 width=400' caption='Only available using Immediate Action - Create Invoice'}
+
+ {html_table loop=$mergeTagsPayment cols=2 table_attr='border=0 width=400' caption='Only available using Immediate Action - Received Payment'}
+
+
</td>
</tr>