Renamed templates + added some filters for mail order
[mailer.git] / inc / modules / member / what-payout.php
index c0f6f66d53bcd7070748c742f60777bd5b8c7354..91c79fd01f2549210c66b9779283f7cf275d5e6c 100644 (file)
@@ -55,9 +55,13 @@ if ((!isExtensionActive('payout')) && (!isAdmin())) {
 // Translate point into comma
 $payoutPoints = getPayoutPoints(getMemberId());
 
+// Output amount
+displayMessage('{%message,MEMBER_TOTAL_PAYOUT_POINTS=' . $payoutPoints . '%}');
+
+// GET parameter set?
 if (!isGetRequestElementSet('payout')) {
        // Load payout types
-       $result = sqlQueryEscaped("SELECT
+       $result = sqlQueryEscaped('SELECT
        `id`,
        `type`,
        `rate`,
@@ -68,12 +72,11 @@ FROM
 WHERE
        %s >= `min_points`
 ORDER BY
-       `type` ASC",
+       `type` ASC',
                array($payoutPoints), __FILE__, __LINE__);
-       if (!ifSqlHasZeroNums($result)) {
-               // Free memory
-               sqlFreeResult($result);
 
+       // Some entries found?
+       if (!ifSqlHasZeroNums($result)) {
                // Check for his payouts
                $result_payouts = sqlQueryEscaped('SELECT
        `p`.`id`,
@@ -133,11 +136,23 @@ ORDER BY
                outputPayoutList($payoutPoints);
        } else {
                // No payout types setup
-               displayMessage('{--MEMBER_PAYOUT_SETUP_INCOMPLETE--}');
+               displayMessage('{--MEMBER_PAYOUT_SETUP_INCOMPLETE_LOW_POINTS--}');
        }
+
+       // Free memory
+       sqlFreeResult($result);
 } else {
        // Chedk if he can get paid by selected type
-       $result = sqlQueryEscaped("SELECT `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+       $result = sqlQueryEscaped('SELECT
+       `type`,
+       `rate`,
+       `min_points`,
+       `allow_url`
+FROM
+       `{?_MYSQL_PREFIX?}_payout_types`
+WHERE
+       `id`=%s
+LIMIT 1',
                array(bigintval(getRequestElement('payout'))), __FILE__, __LINE__);
 
        if (sqlNumRows($result) == 1) {
@@ -153,7 +168,7 @@ ORDER BY
                if (isPostRequestElementSet('payout')) {
                        $points  = bigintval(postRequestElement('payout')) / $content['rate'];
                        $PAY_MAX = $max / $content['rate'];
-               }
+               } // END - if
 
                // Has enougth points to payout?
                if ($payoutPoints >= $content['min_points']) {