// If there's no account then return false.
return false;
}
+ // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+ // exit;
$to_email = $account['email'];
if ( !$to_email ) {
// If there's no email then return false.
// get the Notification type
var_dump( $notification_id );
$notification_type = $this->getNotificationTypeById( $notification_id );
- echo '<pre>$notification_type: ' . print_r( $notification_type, true ) . '</pre>';
+ // echo '<pre>$notification_type: ' . print_r( $notification_type, true ) . '</pre>';
if ( !$notification_type ) {
// If there's no notification type then return false.
return false;
}
- $subject = $notification_type['subject'];
+ $subject = $notification_type['subject'];
if ( !$subject ) {
// If there's no subject then return false.
return false;
// Add standard parameters
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
- $viewFile = 'admin/notifications/notification.html';
+ $viewFile = 'admin/notifications/notification.html';
+
+ $account_data = array(
+ 'account' => array(
+ 'name' => $account['ref_name'],
+ 'email' => $account['email'],
+ 'addr1' => $account['billing_addr1'],
+ 'addr2' => $account['billing_addr2'],
+ 'city' => $account['billing_city'],
+ 'state' => $account['billing_state'],
+ 'zip' => $account['billing_zip'],
+ 'phone' => $account['billing_phone'],
+ )
+ );
+ echo '<pre>$notification_type[message]: ' . print_r( $notification_type['message'], true ) . '</pre>';
+ $notification_message = $this->parseSmartyTemplateString(
+ $account_data,
+ wpautop( $notification_type['message'] )
+ );
+ echo '<pre>$account_data: ' . print_r( $account_data, true ) . '</pre>';
+ echo '<pre>$notification_message: ' . print_r( $notification_message, true ) . '</pre>';
+ // exit;
$smarty->templateAssign( 'title', $notification_type['subject'] );
- $smarty->templateAssign( 'html_content', wpautop( $notification_type['message'] ) );
+ $smarty->templateAssign( 'html_content', $notification_message );
// Generate output from model data and view
$htmlMessage = $smarty->template->fetch( $viewFile );
$this->recordNotification( $notice_data );
}
+ public function parseSmartyTemplateString( $data, $template_string )
+ {
+ // Load Smarty Template support
+ $smarty = new smartyTemplateSupport();
+
+ // Add standard parameters
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
+
+ // Add data from model to Smarty template
+ if ( is_array( $data ) && count( $data ) > 0 ) {
+ foreach ( $data as $key => $value ) {
+ echo '<pre>$key: ' . print_r( $key, true ) . '</pre>';
+ $smarty->templateAssign( $key, $value );
+ }
+ }
+
+ return $smarty->template->fetch( 'eval:' . $template_string );
+ }
+
/**
* recordNotification
*
return true;
}
- public function getNotificationByType( $type )
+ /**
+ * getNotificationsByType
+ *
+ * @param mixed $type Type of send_action (10: Create Invoice, 20: Received Payment)
+ *
+ * @access public
+ * @return void
+ */
+ public function getNotificationsByType( $type )
{
echo '<pre>$this->config: ' . print_r( $this->config['send_action_numb'], true ) . '</pre>';
return $this->wpdb->get_results(
}
switch( $option ) {
- case 'test':
+ case 'test': // TODO: remove this case (only for testing notifications)
+ require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
+ $Notifications = new GlmNotifications( $this->wpdb, $this->config );
/**
* test:
*
* After the test it will call wp_die
*/
// echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
- // require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
- // $Notifications = new GlmNotifications( $this->wpdb, $this->config );
// // Test
- // $notices = $Notifications->getNotificationByType( 'Create Invoice' );
+ // $notices = $Notifications->getNotificationsByType( 'Create Invoice' );
// echo '<pre>$notices: ' . print_r( $notices, true ) . '</pre>';
// if ( $notices ) {
// foreach ( $notices as $notice ) {
</td>
</tr>
+ <tr>
+ <td colspan="2">
+ <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.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>
+ </table>
+ </td>
+ </tr>
+
<tr>
<td colspan="2">
<input class="button button-primary" type="submit" value="{if $notification_id}Update{else}Add{/if} Notification Type">