Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / admin / what-list_coupon.php
index 2f6f89c79a3c43f91710df52a6dbb862b2bae2db..4d503c8640a575286bb5ab67b774b909bb6eb38f 100644 (file)
@@ -16,8 +16,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
+ * 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 *
  *                                                                      *
  * 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 *
@@ -43,93 +43,96 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 // Add description as navigation point
 addYouAreHereLink('admin', __FILE__);
 
 // Add description as navigation point
 addYouAreHereLink('admin', __FILE__);
 
-if (isGetRequestParameterSet('coupon_id')) {
+if (isGetRequestElementSet('coupon_id')) {
        // List userids for given coupon
        // List userids for given coupon
-       $result = SQL_QUERY_ESC('SELECT
-       u.`coupon_id`,
-       u.`userid`,
-       UNIX_TIMESTAMP(u.`cashed_on`) AS `cashed_on`,
-       UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`,
-       UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`,
-       d.`points`, d.`total_created`, d.`total_cashed`, d.`coupon_description`
+       $result = sqlQueryEscaped('SELECT
+       `u`.`coupon_id`,
+       `u`.`userid`,
+       UNIX_TIMESTAMP(`u`.`cashed_on`) AS `cashed_on`,
+       UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`,
+       UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`,
+       `d`.`points`,
+       `d`.`total_created`,
+       `d`.`total_cashed`,
+       `d`.`coupon_description`
 FROM
 FROM
-       `{?_MYSQL_PREFIX?}_user_coupons` AS u
+       `{?_MYSQL_PREFIX?}_user_coupons` AS `u`
 INNER JOIN
 INNER JOIN
-       `{?_MYSQL_PREFIX?}_coupon_data` AS d
+       `{?_MYSQL_PREFIX?}_coupon_data` AS `d`
 ON
 ON
-       u.`coupon_id`=d.`id`
+       `u`.`coupon_id`=`d`.`id`
 WHERE
 WHERE
-       u.`coupon_id`=%s
+       `u`.`coupon_id`=%s
 ORDER BY
 ORDER BY
-       u.`cashed_on` DESC',
+       `u`.`cashed_on` DESC',
                array(
                array(
-                       bigintval(getRequestParameter('coupon_id'))
+                       bigintval(getRequestElement('coupon_id'))
                ), __FILE__, __LINE__);
 
                ), __FILE__, __LINE__);
 
-       // Do we have entries?
-       if (SQL_NUMROWS($result) > 0) {
+       // Are there entries?
+       if (!ifSqlHasZeroNumRows($result)) {
                // Init variable
                $OUT = '';
 
                // Load all rows
                // Init variable
                $OUT = '';
 
                // Load all rows
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Translate all timestamps
                        $content['cashed_on']      = generateDateTime($content['cashed_on']     , '2');
                        $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
                        $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
 
                        // Add the row template
                        // Translate all timestamps
                        $content['cashed_on']      = generateDateTime($content['cashed_on']     , '2');
                        $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
                        $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
 
                        // Add the row template
-                       $OUT .= loadTemplate('admin_list_coupon_usr_row', true, $content);
+                       $OUT .= loadTemplate('admin_list_coupon_usr_row', TRUE, $content);
                } // END - while
 
                // Load main template
                } // END - while
 
                // Load main template
-               loadTemplate('admin_list_coupon_usr', false, $OUT);
+               loadTemplate('admin_list_coupon_usr', FALSE, $OUT);
        } else {
                // No cashed coupons found
                displayMessage('{--ADMIN_LIST_COUPON_404--}');
        }
 
        // Free result
        } else {
                // No cashed coupons found
                displayMessage('{--ADMIN_LIST_COUPON_404--}');
        }
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 } else {
        // Check if the user has cashed coupons
 } else {
        // Check if the user has cashed coupons
-       $result = SQL_QUERY('SELECT
-       d.`id` AS `coupon_id`,
-       UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`,
-       UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`,
-       d.`points`,
-       d.`total_created`,
-       d.`total_cashed`,
-       d.`coupon_description`
+       $result = sqlQuery('SELECT
+       `d`.`id` AS `coupon_id`,
+       UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`,
+       UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`,
+       `d`.`points`,
+       `d`.`total_created`,
+       `d`.`total_cashed`,
+       `d`.`coupon_description`
 FROM
 FROM
-       `{?_MYSQL_PREFIX?}_coupon_data` AS d
+       `{?_MYSQL_PREFIX?}_coupon_data` AS `d`
 ORDER BY
 ORDER BY
-       d.`id` ASC', __FILE__, __LINE__);
+       `d`.`id` ASC', __FILE__, __LINE__);
 
 
-       // Do we have entries?
-       if (SQL_NUMROWS($result) > 0) {
+       // Are there entries?
+       if (!ifSqlHasZeroNumRows($result)) {
                // Init variable
                $OUT = '';
 
                // Load all rows
                // Init variable
                $OUT = '';
 
                // Load all rows
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Translate all timestamps
                        $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
                        $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
 
                        // Add the row template
                        // Translate all timestamps
                        $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
                        $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
 
                        // Add the row template
-                       $OUT .= loadTemplate('admin_list_coupon_row', true, $content);
+                       $OUT .= loadTemplate('admin_list_coupon_row', TRUE, $content);
                } // END - while
 
                // Load main template
                } // END - while
 
                // Load main template
-               loadTemplate('admin_list_coupon', false, $OUT);
+               loadTemplate('admin_list_coupon', FALSE, $OUT);
        } else {
                // No cashed coupons found
                displayMessage('{--ADMIN_LIST_COUPON_404--}');
        }
 
        // Free result
        } else {
                // No cashed coupons found
                displayMessage('{--ADMIN_LIST_COUPON_404--}');
        }
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 }
 
 // [EOF]
 }
 
 // [EOF]