]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-send_coupon.php
Bad things are now 'classified' as bad (CSS class 'bad' is being used instead of...
[mailer.git] / inc / modules / admin / what-send_coupon.php
index 9cf143b81f21d6dca7a0a78058c75913b6a7da56..262a4c8c73eaa4021217515f8f3929032fef0435 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -46,10 +46,10 @@ addYouAreHereLink('admin', __FILE__);
 // Is the form sent?
 if (isFormSent()) {
        // Are all required fields set?
-       if (!isPostRequestParameterSet('points')) {
+       if (!isPostRequestElementSet('points')) {
                // Points not entered
                displayMessage('{--ADMIN_SEND_COUPON_POINTS_NOT_ENTERED--}');
-       } elseif (!isPostRequestParameterSet('coupon_description')) {
+       } elseif (!isPostRequestElementSet('coupon_description')) {
                // Description not entered
                displayMessage('{--ADMIN_SEND_COUPON_DESCRIPTION_NOT_ENTERED--}');
        } else {
@@ -63,12 +63,12 @@ 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),
-                                       bigintval(postRequestParameter('points')),
-                                       postRequestParameter('coupon_description')
+                                       bigintval(postRequestElement('points')),
+                                       postRequestElement('coupon_description')
                                ), __FILE__, __LINE__
                        );
 
@@ -95,14 +95,14 @@ 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
                                $content = array(
                                        'coupon_id'      => $couponId,
                                        'userid'         => $userid,
-                                       'points'         => bigintval(postRequestParameter('points')),
+                                       'points'         => bigintval(postRequestElement('points')),
                                        'coupon_code'    => $couponCode,
                                        'coupon_expired' => generateDateTime($expirationTime, '0')
                                );
@@ -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(postRequestElement('points')),
+                               'coupon_description' => postRequestElement('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_code', $content);
-
                // Free result
                SQL_FREERESULT($result);
        }