/**
* Send the member a notice
*/
- public function sendMemberNotice()
+ public function sendMemberNotice( $memberId, $coupon )
{
+ $member = $this->getEntry( $memberId );
+ // find notify_to
+ // This will be the primary contact email if found
+ // if not found use the member info record email
+ // if nothing in either one then return.
+ $settings = $this->config['settings'];
+ $notify_from = $settings['notify_from'];
+
+ // Setup the Smarty Engine
+ $smarty = new smartyTemplateSupport();
+ $viewPath = GLM_MEMBERS_COUPONS_PLUGIN_PATH . '/views';
+ $smarty->template->setTemplateDir( $viewPath );
+
+ // Add standard parameters
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+ $viewFile = 'front/coupons/ownerEmail.html';
+
+ $couponList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-coupons-list";
+ $smarty->templateAssign( 'notify_message', $notify_message);
+ $smarty->templateAssign( 'location', 'Member Coupons' );
+ $smarty->templateAssign( 'name', $coupon['fieldData']['name'] );
+ $smarty->templateAssign( 'pendingCoupons', $couponList );
+ // Generate output from model data and view
+ $htmlMessage = $smarty->template->fetch( $viewFile );
+
+
+ // 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' ) );
+
+ $subject = 'Coupon Form Submission';
+ $message = $htmlMessage;
+ $header[] = 'From:' . $notify_from;
+ $header[] = 'Reply-To:' . $notify_from;
+
+ wp_mail( $notify_to, $subject, $message, $header );
+
+ // remove the filter to avoid conflicts
+ remove_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
}
/**
*/
public function sendAdminNotice( $memberId, $coupon )
{
- $member = $this->getEntry( $memberId );
+ $member = $this->getEntry( $memberId );
$settings = $this->config['settings'];
$notify_to = $settings['notify_to'];
$notify_from = $settings['notify_from'];
$notify_message = $settings['notify_message'];
// Setup the Smarty Engine
- $smarty = new smartyTemplateSupport();
+ $smarty = new smartyTemplateSupport();
$viewPath = GLM_MEMBERS_COUPONS_PLUGIN_PATH . '/views';
- $smarty->template->setTemplateDir($viewPath);
+ $smarty->template->setTemplateDir( $viewPath );
// Add standard parameters
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
- $viewFile = 'front/coupons/ownerEmail.html';
-
- $smarty->templateAssign('notify_message', $notify_message);
- $smarty->templateAssign('name', $coupon['fieldData']['name']);
- $smarty->templateAssign('start_date', $coupon['fieldData']['start_date']);
- $smarty->templateAssign('end_date', $coupon['fieldData']['end_date']);
- $smarty->templateAssign('expire', $coupon['fieldData']['expire']);
+ $viewFile = 'front/coupons/ownerEmail.html';
+
+ $couponList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-coupons-list";
+ $smarty->templateAssign( 'notify_message', $notify_message);
+ $smarty->templateAssign( 'location', 'Member Coupons' );
+ $smarty->templateAssign( 'member', $member );
+ $smarty->templateAssign( 'name', $coupon['fieldData']['name'] );
+ $smarty->templateAssign( 'start_date', $coupon['fieldData']['start_date'] );
+ $smarty->templateAssign( 'end_date', $coupon['fieldData']['end_date'] );
+ $smarty->templateAssign( 'expire', $coupon['fieldData']['expire'] );
+ $smarty->templateAssign( 'pendingCoupons', $couponList );
// Generate output from model data and view
- $htmlMessage = $smarty->template->fetch($viewFile);
+ $htmlMessage = $smarty->template->fetch( $viewFile );
// change the default wordpress from name when sending mail
add_filter(
'wp_mail_from_name',
- function ($name) {
- $siteName = get_bloginfo('name');
+ function ( $name ) {
+ $siteName = get_bloginfo( 'name' );
return $siteName;
}
);
{/if}
<table cellspacing="0" cellpadding="0" width="500" style="background: lightgrey;border:1px solid #ccc;border-collapse:collapse;">
+ <tr>
+ <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Member Name:</td>
+ <td style="width:200px;padding:5px;border:1px solid #ccc;">{$member.name}</td>
+ </tr>
<tr>
<td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Coupon Name:</td>
<td style="width:200px;padding:5px;border:1px solid #ccc;">{$name}</td>
</tr>
<tr>
<td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Coupon Start Date: </td>
- <td style="width:200px;padding:5px;border:1px solid #ccc;"> {$start_date} </td>
+ <td style="width:200px;padding:5px;border:1px solid #ccc;"> {$start_date.timestamp|date_format:"%D"} </td>
</tr>
<tr>
<td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;" >Coupon End Date:</td>
- <td style="width:200px;padding:5px;border:1px solid #ccc;" >{$end_date}</td>
+ <td style="width:200px;padding:5px;border:1px solid #ccc;" >{$end_date.timestamp|date_format:"%D"}</td>
</tr>
<tr>
<td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;" >Coupon Expire Date:</td>
- <td style="width:200px;padding:5px;border:1px solid #ccc;" >{$expire}</td>
+ <td style="width:200px;padding:5px;border:1px solid #ccc;" >{$expire.timestamp|date_format:"%D"}</td>
</tr>
</table>