`userid` ASC",
__FILE__, __LINE__);
- // Do we have entries left?
+ // Are there entries left?
if (!SQL_HASZERONUMS($result)) {
// Convert timestamp selections
$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),
// Get the insert id from the table
$couponId = SQL_INSERTID();
+ // Init userid array
+ $adminUserids = array();
+
// Load entry
while (list($userid) = SQL_FETCHROW($result)) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'NUMS=' . SQL_NUMROWS($result) . ',userid=' . $userid);
+
// By default no code is unique
- $isUnique = false;
+ $isUnique = FALSE;
$couponCode = '';
// Look for a unique id
while (!$isUnique) {
/*
- * Add a coupon for this user, first we need to create a
- * table-unique "id". The function generatePassword() can do
- * this job for us but we want to exclude some characters.
+ * Add a coupon for this user, first generate a
+ * "table-unique" id number. generatePassword() can do this
+ * but with some characters excluded.
*/
$couponCode = generatePassword(30, array('-', '+', '_', '/', '.'));
// Is it really unique?
- $isUnique = (countSumTotalData($couponCode, 'user_coupons', 'id', 'coupon_code', true) == 0);
+ $isUnique = (countSumTotalData($couponCode, 'user_coupons', 'id', 'coupon_code', TRUE) == 0);
} // 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,
$content['coupon_default_time_selection'] = createConfigurationTimeSelections('coupon_default_time', 'WDh');
// Load template
- loadTemplate('admin_send_coupon', false, $content);
+ loadTemplate('admin_send_coupon', FALSE, $content);
}
// [EOF]