if (!isPostRequestParameterSet('points')) {
// Points not entered
displayMessage('{--ADMIN_SEND_COUPON_POINTS_NOT_ENTERED--}');
- } elseif (!isPostRequestParameterSet('description')) {
+ } elseif (!isPostRequestParameterSet('coupon_description')) {
// Description not entered
displayMessage('{--ADMIN_SEND_COUPON_DESCRIPTION_NOT_ENTERED--}');
} else {
$expirationTime = time() + createEpocheTimeFromSelections('coupon_default_time', postRequestArray());
// Insert coupon data
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_coupon_data` (`timestamp_expired`, `total_created`, `points`, `coupon_description`) VALUES('{%%pipe,SQL_EPOCHE_TO_TIMESTAMP=%s%%}', %s,%s,'%s')",
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_coupon_data` (`coupon_expired`,`total_created`,`points`,`coupon_description`) VALUES ('{%%pipe,SQL_EPOCHE_TO_TIMESTAMP=%s%%}', %s,%s,'%s')",
array(
$expirationTime,
SQL_NUMROWS($result),
bigintval(postRequestParameter('points')),
- postRequestParameter('description')
+ postRequestParameter('coupon_description')
), __FILE__, __LINE__
);
} // END - while
// The above loop should always set $couponCode, so we can now insert it
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_coupons` (`coupon_id`, `userid`, `coupon_code`) VALUES(%s,%s,'%s')",
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_coupons` (`coupon_id`,`userid`,`coupon_code`) VALUES (%s,%s,'%s')",
array($couponId, $userid, $couponCode), __FILE__, __LINE__);
// Fill array with all required data
'userid' => $userid,
'points' => bigintval(postRequestParameter('points')),
'coupon_code' => $couponCode,
- 'coupon_expires' => generateDateTime($expirationTime, '0')
+ 'coupon_expired' => generateDateTime($expirationTime, '0')
);
// Load member email template
- $mailText = loadEmailTemplate('member_coupon', $content, $userid);
+ $mailText = loadEmailTemplate('member_coupon_code', $content, $userid);
// And deliver it
sendEmail($userid, '{--MEMBER_COUPON_SUBJECT--}', $mailText);
// Rember this user for the admin email
$adminUserids[] = $userid;
} // END - while
+
+ // Prepare content for template
+ $content = array(
+ 'userids' => implode(',', $adminUserids),
+ 'userid_count' => count($adminUserids),
+ 'coupon_id' => $couponId,
+ 'points' => bigintval(postRequestParameter('points')),
+ 'coupon_description' => postRequestParameter('coupon_description'),
+ 'coupon_expired' => generateDateTime($expirationTime, '0')
+ );
+
+ // Send admin notification
+ sendAdminNotification('{--ADMIN_COUPON_SUBJECT--}', 'admin_coupon_code', $content);
+
+ // Coupon has been sent
+ displayMessage('{--ADMIN_SEND_COUPON_DONE--}');
} else {
// No user was found
displayMessage('{--ADMIN_SEND_COUPON_USER_404--}');
}
- // Prepare content for template
- $content = array(
- 'userids' => implode(',', $adminUserids),
- 'userid_count' => count($adminUserids),
- 'coupon_id' => $couponId,
- 'points' => bigintval(postRequestParameter('points')),
- 'description' => postRequestParameter('description'),
- 'coupon_expires' => generateDateTime($expirationTime, '0')
- );
-
- // Send admin notification
- sendAdminNotification('{--ADMIN_COUPON_SUBJECT--}', 'admin_coupon', $content);
-
// Free result
SQL_FREERESULT($result);
}