X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fmodules%2Fadmin%2Fwhat-send_coupon.php;h=2d359b36618272f7ed3b5c0cf2de7c33720a4c47;hb=bd13da550348ba1963a434be7ceb9f1675aecadd;hp=b304dbe7bada516e5bf1f2f642d5d2af1ee3c620;hpb=964a3b539e335f6d70e7779630fd3d25fd38398d;p=mailer.git diff --git a/inc/modules/admin/what-send_coupon.php b/inc/modules/admin/what-send_coupon.php index b304dbe7ba..2d359b3661 100644 --- a/inc/modules/admin/what-send_coupon.php +++ b/inc/modules/admin/what-send_coupon.php @@ -63,7 +63,7 @@ if (isFormSent()) { $expirationTime = time() + createEpocheTimeFromSelections('coupon_default_time', postRequestArray()); // Insert coupon data - 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')", + 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), @@ -95,7 +95,7 @@ if (isFormSent()) { } // 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 @@ -108,7 +108,7 @@ if (isFormSent()) { ); // 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); @@ -116,24 +116,27 @@ if (isFormSent()) { // 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')), - 'coupon_description' => postRequestParameter('coupon_description'), - 'coupon_expired' => generateDateTime($expirationTime, '0') - ); - - // Send admin notification - sendAdminNotification('{--ADMIN_COUPON_SUBJECT--}', 'admin_coupon', $content); - // Free result SQL_FREERESULT($result); }