Admin gets notified when member submits the coupon.
Member will be notified when admin approves the coupon.
// Load the Member Data class
require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMembers.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
+require_once GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+
// Extend the member class
class GlmMembersAdmin_coupon_notification extends GlmDataMembers
*/
public $config;
- /*
+ /**
* Constructor
*
* This constructor performs the work for this model. This model returns
/**
- * Send the member a notice
+ * Send the member a notice.
+ *
+ * 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.
*/
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.
+ // See if there's a primary member contact for this member
+ $notify_to = apply_filters( 'glm-member-db-admin-get-member-primary-email', '', $memberId );
+ if ( !$notify_to ) {
+ return false;
+ }
+
+ $memberInfoData = new GlmDataMemberInfo( $this->wpdb, $this->config );
+ $memberInfo = $memberInfoData->getActiveInfoForMember( $memberId );
+ // get settings
$settings = $this->config['settings'];
$notify_from = $settings['notify_from'];
// Add standard parameters
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
- $viewFile = 'front/coupons/ownerEmail.html';
+ $viewFile = 'admin/coupons/memberEmail.html';
- $couponList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-coupons-list";
- $smarty->templateAssign( 'notify_message', $notify_message);
+ $couponList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-coupons-list&glm_action=list";
$smarty->templateAssign( 'location', 'Member Coupons' );
$smarty->templateAssign( 'name', $coupon['fieldData']['name'] );
$smarty->templateAssign( 'pendingCoupons', $couponList );
// 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';
+ $subject = 'Coupon Approved';
$message = $htmlMessage;
$header[] = 'From:' . $notify_from;
$header[] = 'Reply-To:' . $notify_from;
}
/**
- * Send the admin user a notice
+ * Send the admin user a notice.
+ *
+ * Sending email notice to the Admin user setting form Coupon Management.
*/
public function sendAdminNotice( $memberId, $coupon )
{
// Add standard parameters
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
- $viewFile = 'front/coupons/ownerEmail.html';
+ $viewFile = 'admin/coupons/ownerEmail.html';
$couponList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-coupons-list";
$smarty->templateAssign( 'notify_message', $notify_message);
}
/**
- * Set content type of the email
+ * Set content type of the email.
+ *
+ * Used as filter for the wp_mail_content_type
*/
function set_content_type()
{
if ( $old_coupon_status == 20 && $new_status == 10 ) {
// Update approved timestamp.
$this->updateTimestamp('approved', $this->couponID);
+ if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest']) ) {
+ $notification->sendMemberNotice( $member_id, $coupon);
+ }
} else if ( $lockedToMember && $old_coupon_status == 10 && $new_status == 20 ) {
// Here the status is changing from active to pending. (member edit)
// Send notice to admin user
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
+ </head>
+ <body>
+ <h1 id="title"> Coupon Approval Notification</h1>
+
+ <div style="width: 500px">
+ <p> Your coupon has been approved! </p>
+ </div>
+
+ <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;">Coupon Name:</td>
+ <td style="width:200px;padding:5px;border:1px solid #ccc;">{$name}</td>
+ </tr>
+ </table>
+
+ <div id="emailFooter">
+ <p style="margin-bottom: 0px;">A Coupon has been approved.</p>
+ <p style="margin-top: 0px;">To view it, please go to the <a style="color: rgb(5, 104, 179);" href="{$pendingCoupons}"> coupons </a> page in your admin.</p>
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
+ </head>
+ <body>
+ <h1 id="title"> Coupon Submission Notification</h1>
+
+ {if $notify_message}
+ <div style="width: 500px">
+ <p> {$notify_message} </p>
+ </div>
+ {/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.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.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.timestamp|date_format:"%D"}</td>
+ </tr>
+ </table>
+
+ <div id="emailFooter">
+ <p style="margin-bottom: 0px;">A new Coupon has been added to your Website from your "{$location}" page.</p>
+ <p style="margin-top: 0px;">To approve it, please go to the <a style="color: rgb(5, 104, 179);" href="{$pendingCoupons}"> coupons </a> page in your admin.</p>
+ </div>
+ </body>
+</html>
+++ /dev/null
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
- </head>
- <body>
- <h1 id="title"> Coupon Submission Notification</h1>
-
- {if $notify_message}
- <div style="width: 500px">
- <p> {$notify_message} </p>
- </div>
- {/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.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.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.timestamp|date_format:"%D"}</td>
- </tr>
- </table>
-
- <div id="emailFooter">
- <p style="margin-bottom: 0px;">A new Coupon has been added to your Website from your "{$location}" page.</p>
- <p style="margin-top: 0px;">To approve it, please go to the <a style="color: rgb(5, 104, 179);" href="{$pendingCoupons}"> coupons </a> page in your admin.</p>
- </div>
- </body>
-</html>